8000 [CIR] Fix problem with phantom function arguments (#140322) · llvm/llvm-project@f7ef8dc · GitHub
[go: up one dir, main page]

Skip to content

Commit f7ef8dc

Browse files
authored
[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.
1 parent 5c15427 commit f7ef8dc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,16 @@ class CIRGenFunctionInfo final
112112

113113
// NOLINTNEXTLINE(readability-identifier-naming)
114114
void Profile(llvm::FoldingSetNodeID &id) {
115-
id.AddBoolean(required.getOpaqueData());
116-
getReturnType().Profile(id);
115+
// It's unfortunate that we are looping over the arguments twice (here and
116+
// in the static Profile function we call from here), but if the Profile
117+
// functions get out of sync, we can end up with incorrect function
118+
// signatures, and we don't have the argument types in the format that the
119+
// static Profile function requires.
120+
llvm::SmallVector<CanQualType, 16> argTypes;
121+
for (const ArgInfo &argInfo : arguments())
122+
argTypes.push_back(argInfo.type);
123+
124+
Profile(id, required, getReturnType(), argTypes);
117125
}
118126

119127
llvm::ArrayRef<ArgInfo> arguments() const {

0 commit comments

Comments
 (0)
0