[flang-commits] [flang] [flang] [cuda] Fix CUDA implicit data transfer entity creation (PR #139414)
via flang-commits
flang-commits at lists.llvm.org
Sat May 10 15:48:26 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Zhen Wang (wangzpgi)
<details>
<summary>Changes</summary>
Fixed an issue in `genCUDAImplicitDataTransfer` where creating an `hlfir::Entity` from a symbol address could fail when the address comes from a `hlfir.declare` operation. Fix is to check if the address comes from a `hlfir.declare` operation. If so, use the base value from the declare op when available. Falling back to the original address otherwise.
---
Full diff: https://github.com/llvm/llvm-project/pull/139414.diff
1 Files Affected:
- (modified) flang/lib/Lower/Bridge.cpp (+7-1)
``````````diff
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 43375e84f21fa..bfe8898ebff3d 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -4778,7 +4778,13 @@ class FirConverter : public Fortran::lower::AbstractConverter {
nbDeviceResidentObject <= 1 &&
"Only one reference to the device resident object is supported");
auto addr = getSymbolAddress(sym);
- hlfir::Entity entity{addr};
+ mlir::Value baseValue;
+ if (auto declareOp = llvm::dyn_cast<hlfir::DeclareOp>(addr.getDefiningOp()))
+ baseValue = declareOp.getBase();
+ else
+ baseValue = addr;
+
+ hlfir::Entity entity{baseValue};
auto [temp, cleanup] =
hlfir::createTempFromMold(loc, builder, entity);
auto needCleanup = fir::getIntIfConstant(cleanup);
``````````
</details>
https://github.com/llvm/llvm-project/pull/139414
More information about the flang-commits
mailing list