[flang-commits] [flang] [flang][cuda] Return early if no cuf.shared_type_descs attribute is set (PR #231222)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Mon Oct 12 09:47:02 PDT 2026
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/231222
Avoid to look at parent operations if not needed.
>From bba8ea689466a02fc8cc6bb6e02832c5482dac0d Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Mon, 12 Oct 2026 09:44:05 -0700
Subject: [PATCH] [flang][cuda] Return early if no cuf.shared_type_descs
attribute is set
---
flang/lib/Optimizer/CodeGen/CodeGen.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
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)
More information about the flang-commits
mailing list