Skip to content

Commit 71783fe

Browse files
committed
[Flang][OpenMP][MLIR] Fix regression by #146653 by adding address space cast to getRefPtrIfDeclareTarget
The patch introduced changes to add address spaces to a wider array of MLIR/LLVM values, however, it was missing an address space cast that exists in our downstream implementation that's required for declare target to work correctly.
1 parent adaa409 commit 71783fe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,11 +3535,13 @@ static llvm::Value *
35353535
getRefPtrIfDeclareTarget(mlir::Value value,
35363536
LLVM::ModuleTranslation &moduleTranslation) {
35373537
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
3538+
Operation *op = value.getDefiningOp();
3539+
if (auto addrCast = llvm::dyn_cast_if_present<LLVM::AddrSpaceCastOp>(op))
3540+
op = addrCast->getOperand(0).getDefiningOp();
35383541

35393542
// An easier way to do this may just be to keep track of any pointer
35403543
// references and their mapping to their respective operation
3541-
if (auto addressOfOp =
3542-
llvm::dyn_cast_if_present<LLVM::AddressOfOp>(value.getDefiningOp())) {
3544+
if (auto addressOfOp = llvm::dyn_cast_if_present<LLVM::AddressOfOp>(op)) {
35433545
if (auto gOp = llvm::dyn_cast_or_null<LLVM::GlobalOp>(
35443546
addressOfOp->getParentOfType<mlir::ModuleOp>().lookupSymbol(
35453547
addressOfOp.getGlobalName()))) {

0 commit comments

Comments
 (0)