================ @@ -3566,8 +3568,12 @@ getDeclareTargetRefPtrSuffix(LLVM::GlobalOp globalOp, return suffix; } -static bool isDeclareTargetLink(mlir::Value value) { - if (auto addressOfOp = value.getDefiningOp<LLVM::AddressOfOp>()) { +static bool isDeclareTargetLink(Value value) { + Operation *op = value.getDefiningOp(); + if (auto addrCast = llvm::dyn_cast_if_present<LLVM::AddrSpaceCastOp>(op)) + op = addrCast->getOperand(0).getDefiningOp(); + + if (auto addressOfOp = llvm::dyn_cast_if_present<LLVM::AddressOfOp>(op)) { auto modOp = addressOfOp->getParentOfType<mlir::ModuleOp>(); Operation *gOp = modOp.lookupSymbol(addressOfOp.getGlobalName()); ---------------- skatrak wrote:
Nit: The logic to initialize `gOp` can be shared between `isDeclareTargetLink` and `isDeclareTargetTo`, which should help keep things consistent in the future. ```c++ static bool isDeclareTargetLink(Value value) { omp::DeclareTargetInterface declareTargetGlobal = findDeclareTargetGlobal(value); return declareTargetGlobal && declareTargetGlobal.getDeclareTargetCaptureClause() == omp::DeclareTargetCaptureClause::link; } ``` `getRefPtrIfDeclareTarget` might also benefit from that helper function. https://github.com/llvm/llvm-project/pull/119589 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits