https://github.com/valium007 updated https://github.com/llvm/llvm-project/pull/182626
>From 668b9c60c4aec5a477ab21c6850d5eb966c73bf3 Mon Sep 17 00:00:00 2001 From: valium007 <[email protected]> Date: Tue, 24 Feb 2026 14:01:57 +0530 Subject: [PATCH] [CIR] Fix cir.call verifier error for implicitly declared variadic functions --- clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h | 2 +- clang/test/CIR/CodeGen/call-no-decl.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 clang/test/CIR/CodeGen/call-no-decl.c diff --git a/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h b/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h index 8f421f723943f..4a06a47f67038 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h +++ b/clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h @@ -117,7 +117,7 @@ class CIRGenFunctionInfo final RequiredArgs required, CanQualType resultType, llvm::ArrayRef<CanQualType> argTypes) { 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 0000000000000..d22c03a88b7d1 --- /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<!s8i>, ...) -> !s32i +// CHECK: cir.call @printf({{.*}}, {{.*}}) : (!cir.ptr<!s8i>, !s32i) -> !s32i +// CHECK: cir.call @printf({{.*}}) : (!cir.ptr<!s8i>) -> !s32i _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
