Page MenuHomePhabricator

[debugify] Add way to omit debug-location from MIR output
ClosedPublic

Authored by dsanders on Apr 6 2020, 11:19 AM.

Details

Summary

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

Diff Detail

Event Timeline

dsanders created this revision.Apr 6 2020, 11:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2020, 11:19 AM
Herald added a subscriber: hiraditya. · View Herald Transcript

I haven't added a test case for this as D77576 covers it

vsk added a comment.Apr 6 2020, 12:35 PM

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.

In D77575#1964990, @vsk wrote:

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.

vsk accepted this revision.Apr 6 2020, 1:52 PM

Ok, I think this is fine then.

This revision is now accepted and ready to land.Apr 6 2020, 1:52 PM

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.

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.

This revision was automatically updated to reflect the committed changes.
davide added a subscriber: davide.Apr 6 2020, 5:25 PM