Author: Andy Kaylor
Date: 2025-05-16T18:01:12-07:00
New Revision: f7ef8dcbad9d5ac6cf2a8917d5ce03564fdfd0d8

URL: 
https://github.com/llvm/llvm-project/commit/f7ef8dcbad9d5ac6cf2a8917d5ce03564fdfd0d8
DIFF: 
https://github.com/llvm/llvm-project/commit/f7ef8dcbad9d5ac6cf2a8917d5ce03564fdfd0d8.diff

LOG: [CIR] Fix problem with phantom function arguments (#140322)

There was a problem introduced today where sometimes the CIR for
functions with no arguments would be generated with phantom arguments.
This was causing intermittent test failures.

The problem appears to have been that we were using two different
Profile implementations to generate the FoldingSetNodeID for
CIRGenFunctionInfo so occaissionally when we tried to look for a
pre-existing entry for a function with no arguments it would incorrectly
match a CIRGenFunctionInfo entry that had arguments.

To prevent this from happening again, I rewrote one of the two Profile
functions to call the other.

Added: 
    

Modified: 
    clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h 
b/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h
index 1e06599575fbd..b74460b09a44e 100644
--- a/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h
+++ b/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h
@@ -112,8 +112,16 @@ class CIRGenFunctionInfo final
 
   // NOLINTNEXTLINE(readability-identifier-naming)
   void Profile(llvm::FoldingSetNodeID &id) {
-    id.AddBoolean(required.getOpaqueData());
-    getReturnType().Profile(id);
+    // It's unfortunate that we are looping over the arguments twice (here and
+    // in the static Profile function we call from here), but if the Profile
+    // functions get out of sync, we can end up with incorrect function
+    // signatures, and we don't have the argument types in the format that the
+    // static Profile function requires.
+    llvm::SmallVector<CanQualType, 16> argTypes;
+    for (const ArgInfo &argInfo : arguments())
+      argTypes.push_back(argInfo.type);
+
+    Profile(id, required, getReturnType(), argTypes);
   }
 
   llvm::ArrayRef<ArgInfo> arguments() const {


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to