[llvm-branch-commits] [flang] [llvm] [mlir] [Flang][OpenMP][MLIR] Initial declare target to for variables implementation (PR #119589)

Sergio Afonso via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Nov 24 04:37:41 PST 2025


================
@@ -3665,62 +3678,59 @@ getDeclareTargetRefPtrSuffix(LLVM::GlobalOp globalOp,
   return suffix;
 }
 
-static bool isDeclareTargetLink(mlir::Value value) {
-  if (auto addressOfOp = value.getDefiningOp<LLVM::AddressOfOp>()) {
-    auto modOp = addressOfOp->getParentOfType<mlir::ModuleOp>();
-    Operation *gOp = modOp.lookupSymbol(addressOfOp.getGlobalName());
-    if (auto declareTargetGlobal =
-            llvm::dyn_cast<mlir::omp::DeclareTargetInterface>(gOp))
+static bool isDeclareTargetLink(Value value) {
+  if (Operation *gOp = getGlobalOpFromValue(value)) {
+    if (auto declareTargetGlobal = dyn_cast<omp::DeclareTargetInterface>(gOp))
----------------
skatrak wrote:

Nit: This change would reduce nesting, but feel free to ignore if you prefer to leave it as is. The same could be done in `isDeclareTargetTo`.
```suggestion
  if (auto declareTargetGlobal = dyn_cast_if_present<omp::DeclareTargetInterface>(getGlobalOpFromValue(value))) {
```

https://github.com/llvm/llvm-project/pull/119589


More information about the llvm-branch-commits mailing list