Skip to content

Commit 0d63a3d

Browse files
[mlir][acc] Update LegalizeDataValues pass to allow MappableType (llvm#125134)
With the addition of new type interface MappableType, the LegalizeDataValues should not make the assumption it can obtain a pointer to the data (aka acc::getVarPtr() is now not guaranteed to get a value - acc::getVar() must be used instead). Thus update the pass to ensure it handles any var used in its data clause operations.
1 parent 7a0c6cf commit 0d63a3d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

mlir/lib/Dialect/OpenACC/Transforms/LegalizeDataValues.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ static bool insideAccComputeRegion(mlir::Operation *op) {
3636
return false;
3737
}
3838

39-
static void collectPtrs(mlir::ValueRange operands,
39+
static void collectVars(mlir::ValueRange operands,
4040
llvm::SmallVector<std::pair<Value, Value>> &values,
4141
bool hostToDevice) {
4242
for (auto operand : operands) {
43-
Value varPtr = acc::getVarPtr(operand.getDefiningOp());
44-
Value accPtr = acc::getAccPtr(operand.getDefiningOp());
45-
if (varPtr && accPtr) {
43+
Value var = acc::getVar(operand.getDefiningOp());
44+
Value accVar = acc::getAccVar(operand.getDefiningOp());
45+
if (var && accVar) {
4646
if (hostToDevice)
47-
values.push_back({varPtr, accPtr});
47+
values.push_back({var, accVar});
4848
else
49-
values.push_back({accPtr, varPtr});
49+
values.push_back({accVar, var});
5050
}
5151
}
5252
}
@@ -75,16 +75,16 @@ static void collectAndReplaceInRegion(Op &op, bool hostToDevice) {
7575
llvm::SmallVector<std::pair<Value, Value>> values;
7676

7777
if constexpr (std::is_same_v<Op, acc::LoopOp>) {
78-
collectPtrs(op.getReductionOperands(), values, hostToDevice);
79-
collectPtrs(op.getPrivateOperands(), values, hostToDevice);
78+
collectVars(op.getReductionOperands(), values, hostToDevice);
79+
collectVars(op.getPrivateOperands(), values, hostToDevice);
8080
} else {
81-
collectPtrs(op.getDataClauseOperands(), values, hostToDevice);
81+
collectVars(op.getDataClauseOperands(), values, hostToDevice);
8282
if constexpr (!std::is_same_v<Op, acc::KernelsOp> &&
8383
!std::is_same_v<Op, acc::DataOp> &&
8484
!std::is_same_v<Op, acc::DeclareOp>) {
85-
collectPtrs(op.getReductionOperands(), values, hostToDevice);
86-
collectPtrs(op.getPrivateOperands(), values, hostToDevice);
87-
collectPtrs(op.getFirstprivateOperands(), values, hostToDevice);
85+
collectVars(op.getReductionOperands(), values, hostToDevice);
86+
collectVars(op.getPrivateOperands(), values, hostToDevice);
87+
collectVars(op.getFirstprivateOperands(), values, hostToDevice);
8888
}
8989
}
9090

0 commit comments

Comments
 (0)