[flang-commits] [flang] [flang][cuda] Return early if no cuf.shared_type_descs attribute is set (PR #231222)

via flang-commits flang-commits at lists.llvm.org
Mon Oct 12 09:47:40 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-codegen

Author: Valentin Clement (バレンタイン クレメン) (clementval)

<details>
<summary>Changes</summary>

Avoid to look at parent operations if not needed. 

---
Full diff: https://github.com/llvm/llvm-project/pull/231222.diff


1 Files Affected:

- (modified) flang/lib/Optimizer/CodeGen/CodeGen.cpp (+4-4) 


``````````diff
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 3eec423b5669b..b59996a9491e4 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -245,6 +245,10 @@ static mlir::Value
 loadSharedTypeDescriptor(mlir::gpu::GPUModuleOp gpuMod,
                          mlir::ConversionPatternRewriter &rewriter,
                          mlir::Location loc, llvm::StringRef name) {
+  auto typeDescs =
+      gpuMod->getAttrOfType<mlir::DictionaryAttr>(cudaSharedTypeDescsAttrName);
+  if (!typeDescs)
+    return {};
   if (mlir::Block *block = rewriter.getInsertionBlock()) {
     mlir::Operation *parent = block->getParentOp();
     if (mlir::isa<fir::GlobalOp, mlir::LLVM::GlobalOp>(parent) ||
@@ -252,10 +256,6 @@ loadSharedTypeDescriptor(mlir::gpu::GPUModuleOp gpuMod,
         parent->getParentOfType<mlir::LLVM::GlobalOp>())
       return {};
   }
-  auto typeDescs =
-      gpuMod->getAttrOfType<mlir::DictionaryAttr>(cudaSharedTypeDescsAttrName);
-  if (!typeDescs)
-    return {};
   auto ptrSym = typeDescs.getAs<mlir::FlatSymbolRefAttr>(
       fir::NameUniquer::replaceSpecialSymbols(name.str()));
   if (!ptrSym)

``````````

</details>


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


More information about the flang-commits mailing list