[mlir] Make StripDebugInfo strip out block arguments locs

Differential Revision: https://reviews.llvm.org/D103187
This commit is contained in:
thomasraoux 2021-05-26 10:28:45 -07:00
parent f7c5c0d87b
commit e5eff533f7
2 changed files with 20 additions and 2 deletions

View File

@ -21,9 +21,20 @@ struct StripDebugInfo : public StripDebugInfoBase<StripDebugInfo> {
} // end anonymous namespace
void StripDebugInfo::runOnOperation() {
// Strip the debug info from all operations.
auto unknownLoc = UnknownLoc::get(&getContext());
getOperation()->walk([&](Operation *op) { op->setLoc(unknownLoc); });
// Strip the debug info from all operations.
getOperation()->walk([&](Operation *op) {
op->setLoc(unknownLoc);
// Strip block arguments debug info.
for (Region &region : op->getRegions()) {
for (Block &block : region.getBlocks()) {
for (BlockArgument &arg : block.getArguments()) {
arg.setLoc(unknownLoc);
}
}
}
});
}
/// Creates a pass to strip debug information from a function.

View File

@ -17,6 +17,13 @@ func @inline_notation() -> i32 {
affine.if #set0(%2) {
} loc(fused<"myPass">["foo", "foo2"])
"foo.region"() ({
// CHECK: ^bb0(%{{.*}}: i32 loc(unknown), %{{.*}}: i32 loc(unknown)):
^bb0(%a0: i32 loc("argloc"), %z: i32 loc("argloc2")):
%s = addi %a0, %a0 : i32
"foo.yield"(%s) : (i32) -> ()
}) : () -> ()
// CHECK: return %0 : i32 loc(unknown)
return %1 : i32 loc("bar")
}