Skip to content

Commit cd70987

Browse files
committed
change how dominfo is computed
1 parent 03b89b1 commit cd70987

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ class LegalizeDataValuesInRegion
164164
func::FuncOp funcOp = getOperation();
165165
bool replaceHostVsDevice = this->hostToDevice.getValue();
166166

167-
// Get dominance info for the function
167+
// Initialize dominance info
168168
DominanceInfo domInfo(funcOp);
169169
PostDominanceInfo postDomInfo(funcOp);
170+
bool computedDomInfo = false;
170171

171172
funcOp.walk([&](Operation *op) {
172173
if (!isa<ACC_COMPUTE_CONSTRUCT_AND_LOOP_OPS>(*op) &&
@@ -190,9 +191,19 @@ class LegalizeDataValuesInRegion
190191
} else if (auto hostDataOp = dyn_cast<acc::HostDataOp>(*op)) {
191192
collectAndReplaceInRegion(hostDataOp, replaceHostVsDevice);
192193
} else if (auto declareEnterOp = dyn_cast<acc::DeclareEnterOp>(*op)) {
194+
if (!computedDomInfo) {
195+
domInfo = DominanceInfo(funcOp);
196+
postDomInfo = PostDominanceInfo(funcOp);
197+
computedDomInfo = true;
198+
}
193199
collectAndReplaceInRegion(declareEnterOp, replaceHostVsDevice, &domInfo,
194200
&postDomInfo);
195201
} else if (auto enterDataOp = dyn_cast<acc::EnterDataOp>(*op)) {
202+
if (!computedDomInfo) {
203+
domInfo = DominanceInfo(funcOp);
204+
postDomInfo = PostDominanceInfo(funcOp);
205+
computedDomInfo = true;
206+
}
196207
collectAndReplaceInRegion(enterDataOp, replaceHostVsDevice, &domInfo,
197208
&postDomInfo);
198209
} else {

0 commit comments

Comments
 (0)