[flang-commits] [flang] [flang][OpenMP][CUDA] Set allocator_idx on privatized allocatable device array descriptors (PR #186945)

Zhen Wang via flang-commits flang-commits at lists.llvm.org
Tue Mar 17 09:41:39 PDT 2026


================
@@ -435,9 +436,13 @@ fir::IfOp PopulateInitAndCleanupRegionsHelper::handleNullAllocatable() {
   // right rank. This returns an empty value if the types don't match.
   mlir::Value shape = generateZeroShapeForRank(builder, loc, moldArg);
 
-  mlir::Value nullBox =
-      fir::EmboxOp::create(builder, loc, valType, addr, shape,
-                           /*slice=*/mlir::Value{}, lenParams);
+  auto nullBox = fir::EmboxOp::create(builder, loc, valType, addr, shape,
+                                      /*slice=*/mlir::Value{}, lenParams);
+  if (sym) {
+    unsigned idx = Fortran::lower::getAllocatorIdx(sym->GetUltimate());
+    if (idx != kDefaultAllocator)
+      nullBox.setAllocatorIdx(idx);
----------------
wangzpgi wrote:

I am leaning toward keep it under conditional guard (if (idx != kDefaultAllocator)), so that we don't need to update unrelated tests. What do you think?

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


More information about the flang-commits mailing list