[CIR] Fix cir.call verifier error for implicitly declared variadic functions (#182626)

Fixes #182175
This commit is contained in:
valium007 2026-02-25 00:15:13 +05:30 committed by GitHub
parent 19e05e62c3
commit 5e9570508f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View File

@ -124,7 +124,7 @@ public:
llvm::ArrayRef<CanQualType> argTypes) {
id.AddBoolean(instanceMethod);
id.AddBoolean(info.getNoReturn());
id.AddBoolean(required.getOpaqueData());
id.AddInteger(required.getOpaqueData());
resultType.Profile(id);
for (const CanQualType &arg : argTypes)
arg.Profile(id);

View File

@ -0,0 +1,21 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=gnu89 -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s
// Regression test for https://github.com/llvm/llvm-project/issues/182175
// A function called with no prior declaration must get a variadic CIR function
// type so that multiple call sites with different argument counts do not
// trigger a verifier error.
char temp[] = "some str";
int foo(const char *);
int bar(void) {
int t = foo(temp);
printf("Hello %d!\n", t);
printf("Works!\n");
return 0;
}
// CHECK: cir.func private @printf(!cir.ptr<!s8i>, ...) -> !s32i
// CHECK: cir.call @printf({{.*}}, {{.*}}) : (!cir.ptr<!s8i>, !s32i) -> !s32i
// CHECK: cir.call @printf({{.*}}) : (!cir.ptr<!s8i>) -> !s32i