https://github.com/aobolensk updated https://github.com/llvm/llvm-project/pull/236040
>From 3549c52ff8cf0e2f3fff236bb8ec8990bf44bab1 Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy <[email protected]> Date: Tue, 27 Oct 2026 10:03:21 +0100 Subject: [PATCH] [CIR] Return the callee operand for indirect calls in getCallableForCallee An empty callable made MarkDeclareTarget assert under -fopenmp --- clang/include/clang/CIR/Dialect/IR/CIROps.td | 4 ++++ .../test/CIR/Transforms/omp-mark-declare-target.cir | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index bd762aae3e1d7e..1b80bdd2907bf5 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -4751,11 +4751,15 @@ class CIR_CallOpBase<string mnemonic, list<Trait> extra_traits = []> /// Return the callee of this operation mlir::CallInterfaceCallable getCallableForCallee() { + if (isIndirect()) + return getIndirectCall(); return (*this)->getAttrOfType<mlir::SymbolRefAttr>("callee"); } /// Set the callee for this operation. void setCalleeFromCallable(::mlir::CallInterfaceCallable callee) { + if (isIndirect()) + return setOperand(0, mlir::cast<mlir::Value>(callee)); (*this)->setAttr(getCalleeAttrName(), mlir::cast<mlir::SymbolRefAttr>(callee)); } diff --git a/clang/test/CIR/Transforms/omp-mark-declare-target.cir b/clang/test/CIR/Transforms/omp-mark-declare-target.cir index daa082683d03a3..bdbbcb042c1932 100644 --- a/clang/test/CIR/Transforms/omp-mark-declare-target.cir +++ b/clang/test/CIR/Transforms/omp-mark-declare-target.cir @@ -23,6 +23,19 @@ module { cir.return } + // CHECK-LABEL: cir.func private @after_indirect + // CHECK-SAME: omp.declare_target = #omp.declaretarget<device_type = host, capture_clause = to + cir.func private @after_indirect() { + cir.return + } + + // CHECK-LABEL: cir.func @indirect_caller + cir.func @indirect_caller(%arg0: !cir.ptr<!cir.func<()>>) attributes {omp.declare_target = #omp.declaretarget<device_type = host, capture_clause = to>} { + cir.call %arg0() : (!cir.ptr<!cir.func<()>>) -> () + cir.call @after_indirect() : () -> () + cir.return + } + // Called from within an omp.target region; should be marked as nohost. // CHECK-LABEL: cir.func private @device_helper // CHECK-SAME: omp.declare_target = #omp.declaretarget<device_type = nohost, capture_clause = to _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
