Skip to content

Add arrangeCXXMethodCall to the CodeGenABITypes interface. #111597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

hjyamauchi
Copy link
Contributor

In MSVC, the calling conventions for free functions and C++ instance methods could be different, it makes sense to have this variant there.

Copy link

github-actions bot commented Oct 8, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@hjyamauchi hjyamauchi force-pushed the arrangecxxmethodcall branch from 7be9488 to 4744991 Compare October 8, 2024 22:38
@hjyamauchi hjyamauchi requested a review from rjmccall October 8, 2024 22:38
@hjyamauchi hjyamauchi marked this pull request as ready for review October 8, 2024 22:52
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen IR generation bugs: mangling, exceptions, etc. labels Oct 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 8, 2024

@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Hiroshi Yamauchi (hjyamauchi)

Changes

In MSVC, the calling conventions for free functions and C++ instance methods could be different, it makes sense to have this variant there.


Full diff: https://github.com/llvm/llvm-project/pull/111597.diff

2 Files Affected:

  • (modified) clang/include/clang/CodeGen/CodeGenABITypes.h (+6)
  • (modified) clang/lib/CodeGen/CodeGenABITypes.cpp (+8)
diff --git a/clang/include/clang/CodeGen/CodeGenABITypes.h b/clang/include/clang/CodeGen/CodeGenABITypes.h
index 9cbc5a8a2a3f41..3d29c45cf0cf1b 100644
--- a/clang/include/clang/CodeGen/CodeGenABITypes.h
+++ b/clang/include/clang/CodeGen/CodeGenABITypes.h
@@ -75,6 +75,12 @@ const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule &CGM,
                                            const FunctionProtoType *FTP,
                                            const CXXMethodDecl *MD);
 
+const CGFunctionInfo &arrangeCXXMethodCall(CodeGenModule &CGM,
+                                           CanQualType returnType,
+                                           ArrayRef<CanQualType> argTypes,
+                                           FunctionType::ExtInfo info,
+                                           RequiredArgs args);
+
 const CGFunctionInfo &arrangeFreeFunctionCall(CodeGenModule &CGM,
                                               CanQualType returnType,
                                               ArrayRef<CanQualType> argTypes,
diff --git a/clang/lib/CodeGen/CodeGenABITypes.cpp b/clang/lib/CodeGen/CodeGenABITypes.cpp
index a6073e1188d6fa..972bc4137c6053 100644
--- a/clang/lib/CodeGen/CodeGenABITypes.cpp
+++ b/clang/lib/CodeGen/CodeGenABITypes.cpp
@@ -59,6 +59,14 @@ CodeGen::arrangeCXXMethodType(CodeGenModule &CGM,
   return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
 }
 
+const CGFunctionInfo &
+CodeGen::arrangeCXXMethodCall(CodeGenModule &CGM, CanQualType returnType,
+                              ArrayRef<CanQualType> argTypes,
+                              FunctionType::ExtInfo info, RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(
+      returnType, FnInfoOpts::IsInstanceMethod, argTypes, info, {}, args);
+}
+
 const CGFunctionInfo &
 CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM,
                                  CanQualType returnType,

CanQualType returnType,
ArrayRef<CanQualType> argTypes,
FunctionType::ExtInfo info,
RequiredArgs args);
Copy link
Contributor

@rjmccall rjmccall Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. The internal function for this now takes an array of ExtParameterInfos. As long as we're introducing new API, could you go ahead and add that parameter to these functions? You'll need to either add overloads or give it a default argument (an empty array is an acceptable default).

You just need to modify the functions that don't take a FunctionProtoType.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjmccall Updated. Do you mean like the latest revision?

@hjyamauchi hjyamauchi force-pushed the arrangecxxmethodcall branch 2 times, most recently from 1c7101f to 98f58ce Compare October 10, 2024 21:46
Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that looks good.

@hjyamauchi hjyamauchi force-pushed the arrangecxxmethodcall branch from 98f58ce to 1ccc7c1 Compare October 11, 2024 18:55
Also add ExtParameterInfos to the argument list of
arrangeFreeFunctionCall.
@hjyamauchi hjyamauchi force-pushed the arrangecxxmethodcall branch from 1ccc7c1 to ae4cdf4 Compare October 15, 2024 23:43
@hjyamauchi hjyamauchi merged commit 1de15c1 into llvm:main Oct 16, 2024
8 checks passed
hjyamauchi added a commit to hjyamauchi/llvm-project that referenced this pull request Oct 28, 2024
Also add ExtParameterInfos to the argument list of
arrangeFreeFunctionCall.

Cherrypick llvm#111597
hjyamauchi added a commit to hjyamauchi/llvm-project that referenced this pull request Oct 29, 2024
Also add ExtParameterInfos to the argument list of
arrangeFreeFunctionCall.

Cherrypick PR llvm#111597
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants