Skip to content

Commit ac6ce80

Browse files
committed
walk the module
1 parent 195f88e commit ac6ce80

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

mlir/lib/Conversion/Normalize/Normalize.cpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ struct NormalizePass : public impl::NormalizeBase<NormalizePass> {
3838
private:
3939
// Random constant for hashing, so the state isn't zero.
4040
const uint64_t magicHashConstant = 0x6acaa36bef8325c5ULL;
41-
void
42-
collectOutputOperations(Block &block,
43-
SmallVector<Operation *, 16> &outputs) const noexcept;
4441
bool isOutput(Operation &op) const noexcept;
4542
void reorderOperations(const SmallVector<Operation *, 16> &outputs);
4643
void reorderOperation(Operation *used, Operation *user,
@@ -69,16 +66,14 @@ void NormalizePass::runOnOperation() {
6966

7067
ModuleOp module = getOperation();
7168

72-
for (auto &op : module.getOps()) {
73-
SmallVector<Operation *, 16> outputs;
69+
SmallVector<Operation *, 16> outputs;
70+
module.walk([&](Operation *op) {
71+
if (isOutput(*op))
72+
outputs.push_back(op);
73+
});
7474

75-
for (auto &region : op.getRegions())
76-
for (auto &block : region)
77-
collectOutputOperations(block, outputs);
78-
79-
reorderOperations(outputs);
80-
renameOperations(outputs);
81-
}
75+
reorderOperations(outputs);
76+
renameOperations(outputs);
8277
}
8378

8479
void NormalizePass::renameOperations(
@@ -384,13 +379,6 @@ void NormalizePass::reorderOperation(
384379
}
385380
}
386381

387-
void NormalizePass::collectOutputOperations(
388-
Block &block, SmallVector<Operation *, 16> &outputs) const noexcept {
389-
for (auto &innerOp : block)
390-
if (isOutput(innerOp))
391-
outputs.emplace_back(&innerOp);
392-
}
393-
394382
/// The following Operations are termed as output:
395383
/// - Terminator operations are outputs
396384
/// - Any operation that implements MemoryEffectOpInterface and reports at

0 commit comments

Comments
 (0)