https://github.com/Fznamznon updated https://github.com/llvm/llvm-project/pull/237275
>From d8d0321eab60a6002ceeda9521d06e9d4d95bc21 Mon Sep 17 00:00:00 2001 From: Mariya Podchishchaeva <[email protected]> Date: Fri, 30 Oct 2026 11:09:52 -0500 Subject: [PATCH 1/4] [CIR] Return function pointer from `getCallableForCallee` Currently any indirect call will cause an assertion failure if openmp is enabled together with CIR. This is because one of omp dialect-specific passes (MarkDeclareTarget) will dyn_cast a pointer returned from `getCallableForCallee`. The patch follows the same approach as FIR: if there is no function, return first argument. --- clang/include/clang/CIR/Dialect/IR/CIROps.td | 5 ++++- clang/test/CIR/CodeGenOpenMP/indirect-call.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 clang/test/CIR/CodeGenOpenMP/indirect-call.c diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index bd762aae3e1d7e..b5af71f0fb51e8 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -4751,7 +4751,10 @@ class CIR_CallOpBase<string mnemonic, list<Trait> extra_traits = []> /// Return the callee of this operation mlir::CallInterfaceCallable getCallableForCallee() { - return (*this)->getAttrOfType<mlir::SymbolRefAttr>("callee"); + if (auto calling = + (*this)->getAttrOfType<mlir::SymbolRefAttr>(getCalleeAttrName())) + return calling; + return getOperand(0); } /// Set the callee for this operation. diff --git a/clang/test/CIR/CodeGenOpenMP/indirect-call.c b/clang/test/CIR/CodeGenOpenMP/indirect-call.c new file mode 100644 index 00000000000000..7ee5513e0c0d8f --- /dev/null +++ b/clang/test/CIR/CodeGenOpenMP/indirect-call.c @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fclangir -emit-llvm %s -o - | FileCheck %s +int call(int (*fp)(int)) { return fp(1); } +// CHECK: call i32 %{{.*}}(i32 noundef 1) >From 4c42d83496729aa1c87274243ea57834610c78de Mon Sep 17 00:00:00 2001 From: Mariya Podchishchaeva <[email protected]> Date: Fri, 6 Nov 2026 07:09:39 -0600 Subject: [PATCH 2/4] Move test --- clang/test/CIR/CodeGenOpenMP/non-openmp-code.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/test/CIR/CodeGenOpenMP/non-openmp-code.cpp b/clang/test/CIR/CodeGenOpenMP/non-openmp-code.cpp index b34ffaec20ec2e..975d447acb7e67 100644 --- a/clang/test/CIR/CodeGenOpenMP/non-openmp-code.cpp +++ b/clang/test/CIR/CodeGenOpenMP/non-openmp-code.cpp @@ -74,3 +74,6 @@ void complex_ops(float _Complex *c, float _Complex v) { // OGCG: store float %{{.*}}, ptr %{{.*}} // OGCG: %[[REAL:.*]] = load float, ptr %{{.*}} // OGCG: %[[INC:.*]] = fadd float %[[REAL]], 1.000000e+00 + +int call(int (*fp)(int)) { return fp(1); } +// LLVMCIR: call{{.*}}i32 %{{.*}}(i32 noundef 1) >From 1e45df408fa1edbeb15d7092f20027621f4373d9 Mon Sep 17 00:00:00 2001 From: Mariya Podchishchaeva <[email protected]> Date: Fri, 6 Nov 2026 07:10:13 -0600 Subject: [PATCH 3/4] Remove old one --- clang/test/CIR/CodeGenOpenMP/indirect-call.c | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 clang/test/CIR/CodeGenOpenMP/indirect-call.c diff --git a/clang/test/CIR/CodeGenOpenMP/indirect-call.c b/clang/test/CIR/CodeGenOpenMP/indirect-call.c deleted file mode 100644 index 7ee5513e0c0d8f..00000000000000 --- a/clang/test/CIR/CodeGenOpenMP/indirect-call.c +++ /dev/null @@ -1,3 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -fclangir -emit-llvm %s -o - | FileCheck %s -int call(int (*fp)(int)) { return fp(1); } -// CHECK: call i32 %{{.*}}(i32 noundef 1) >From 063ab1a3341601d4b9c7ae8b3c9d717496b898cc Mon Sep 17 00:00:00 2001 From: Mariya Podchishchaeva <[email protected]> Date: Mon, 9 Nov 2026 08:14:22 -0600 Subject: [PATCH 4/4] Check OGCG output too --- clang/test/CIR/CodeGenOpenMP/non-openmp-code.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/CIR/CodeGenOpenMP/non-openmp-code.cpp b/clang/test/CIR/CodeGenOpenMP/non-openmp-code.cpp index 975d447acb7e67..84a6cb7bd4e5e8 100644 --- a/clang/test/CIR/CodeGenOpenMP/non-openmp-code.cpp +++ b/clang/test/CIR/CodeGenOpenMP/non-openmp-code.cpp @@ -76,4 +76,4 @@ void complex_ops(float _Complex *c, float _Complex v) { // OGCG: %[[INC:.*]] = fadd float %[[REAL]], 1.000000e+00 int call(int (*fp)(int)) { return fp(1); } -// LLVMCIR: call{{.*}}i32 %{{.*}}(i32 noundef 1) +// LLVM: call{{.*}}i32 %{{.*}}(i32 noundef 1) _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
