Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions flang/lib/Optimizer/Transforms/CUFDeviceGlobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ static void processAddrOfOp(fir::AddrOfOp addrOfOp,
addrOfOp.getSymbol().getRootReference().getValue())) {
// TO DO: limit candidates to non-scalars. Scalars appear to have been
// folded in already.
if (globalOp.getConstant()) {
if (recurseInGlobal)
globalOp.walk([&](fir::AddrOfOp op) {
processAddrOfOp(op, symbolTable, candidates, recurseInGlobal);
});
candidates.insert(globalOp);
}
if (recurseInGlobal)
globalOp.walk([&](fir::AddrOfOp op) {
processAddrOfOp(op, symbolTable, candidates, recurseInGlobal);
});
candidates.insert(globalOp);
}
}

Expand Down
21 changes: 21 additions & 0 deletions flang/test/Fir/CUDA/cuda-implicit-device-global.f90
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,24 @@ // Test that global used in device function are flagged with the correct
// CHECK-DAG: fir.global linkonce_odr @_QM__mod1E.c.__builtin_c_devptr
// CHECK-DAG: fir.global linkonce_odr @_QM__mod1E.dt.__builtin_c_devptr
// CHECK-DAG: fir.global linkonce_odr @_QM__mod1E.n.__builtin_c_devptr

// -----

// Variables with initialization are promoted to non constant global.
//
// attributes(global) subroutine kernel4()
// integer :: a = 4
// end subroutine

func.func @_QPkernel4() attributes {cuf.proc_attr = #cuf.cuda_proc<global>} {
%0 = fir.address_of(@_QFkernel4Ea) : !fir.ref<i32>
return
}
fir.global internal @_QFkernel4Ea : i32 {
%c4_i32 = arith.constant 4 : i32
fir.has_value %c4_i32 : i32
}

// CHECK-LABEL: fir.global internal @_QFkernel4Ea : i32
// CHECK-LABEL: gpu.module @cuda_device_mod
// CHECK: fir.global internal @_QFkernel4Ea : i32
Loading