diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp --- a/mlir/lib/Transforms/StripDebugInfo.cpp +++ b/mlir/lib/Transforms/StripDebugInfo.cpp @@ -21,9 +21,20 @@ } // 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 ®ion : 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. diff --git a/mlir/test/Transforms/strip-debuginfo.mlir b/mlir/test/Transforms/strip-debuginfo.mlir --- a/mlir/test/Transforms/strip-debuginfo.mlir +++ b/mlir/test/Transforms/strip-debuginfo.mlir @@ -17,6 +17,13 @@ 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") }