llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clangir

Author: Andy Kaylor (andykaylor)

<details>
<summary>Changes</summary>

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.

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


1 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h (+10-2) 


``````````diff
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 {

``````````

</details>


https://github.com/llvm/llvm-project/pull/140322
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to