In lieu of a proper pass that strips debug info, add a way
to omit debug-locations from the MIR output so that
instructions with MMO's continue to match CHECK's when
mir-debugify is used
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Why not generalize this to something like -mir-print-debug-info, which, when set to false, makes the MIR printer stop printing DBG_ meta instructions as well? Then you might not need D77438.
My preference is to have a debug info stripping pass which you can include in your pipeline so that there's none left for the printer to print but I haven't done that yet. The change in D77438 is still needed for other reasons though. It's a bug but DEBUG_VALUE affects CodeGen quite a bit as it causes hasOneUse() to return false when it would otherwise return true. Most of the backends are using hasOneUse when they probably meant hasOneNonDbgUse() but it's also not a simple replacement as you still need to do something about the DEBUG_VALUE. D77438 allows backends to make progress on location preservation without dealing with their DEBUG_VALUE bugs at the same time.
In lieu of a proper pass that strips debug info
What is it that you need? Something like llvm::stripDebugInfo() (from DebugInfo.cpp) but for MIR? That should be very easy to adapt.
Yes, it's essentially stripDebugInfo() for MIR along with a pass wrapper that just calls it. The reason for wrapping it in a pass is that you can then go on to something akin to -verify-machineinstrs but with a pipeline like mir-debugify,<pass1>,strip-mir-debug,mir-debugify,<pass2>,strip-mir-debug. At that point Pass2's ability to test for location loss isn't dependent on Pass1's ability to preserve the locations from the first mir-debugify.