diff --git a/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h b/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h index 8adfd565ad4c..00b107296d9f 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h +++ b/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h @@ -124,7 +124,7 @@ public: llvm::ArrayRef 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); diff --git a/clang/test/CIR/CodeGen/call-no-decl.c b/clang/test/CIR/CodeGen/call-no-decl.c new file mode 100644 index 000000000000..d22c03a88b7d --- /dev/null +++ b/clang/test/CIR/CodeGen/call-no-decl.c @@ -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, ...) -> !s32i +// CHECK: cir.call @printf({{.*}}, {{.*}}) : (!cir.ptr, !s32i) -> !s32i +// CHECK: cir.call @printf({{.*}}) : (!cir.ptr) -> !s32i