This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][InstrRef] Avoid a debug-info-affects-codegen scenario in MCP
ClosedPublic

Authored by jmorse on Aug 24 2021, 10:07 AM.

Details

Summary

The machine-copy-propagation pass collects all debug uses of instructions and then tries to propagate copies through them -- this includes DBG_PHIs, which can refer to COPYs in rare circumstances where tail duplication simplifies control flow. Such DBG_PHIs should also have copies propagated through them: update the helper utility to do so. I've added a DBG_PHI to an ARM test that tests this behaviour, i.e. that copies get propagated in debug instructions.

In addition, this patch also correctly sets the "debug-use" flag on DBG_PHIs when they're read from MIR files, which was previously being omitted. This is covered by the test, as copy propagation won't happen if there's a non-debug-use of the $r4.

Finally, call setIsDebug when DBG_PHIs are created in LiveDebugVariables. I, uh, don't know of a way to test for this, because "debug-use" doesn't seem to be printed by the MIR printer. Ouch.

Diff Detail

Event Timeline

jmorse created this revision.Aug 24 2021, 10:07 AM
jmorse requested review of this revision.Aug 24 2021, 10:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2021, 10:07 AM

Thanks, looks good to me!

Finally, call setIsDebug when DBG_PHIs are created in LiveDebugVariables. I, uh, don't know of a way to test for this, because "debug-use" doesn't seem to be printed by the MIR printer. Ouch.

unittest ?

StephenTozer added inline comments.Oct 14 2021, 4:17 AM
llvm/include/llvm/CodeGen/MachineRegisterInfo.h
847
jmorse updated this revision to Diff 379943.Oct 15 2021, 2:42 AM

Rebase, fix comment, remove setIsDebug now that a different approach is used for that after D110105.

On the unit test front, I think D110105 avoids this problem now, any register operand added to a debug instruction will now get the isDebug flag set on it.

This revision was not accepted when it landed; it landed in state Needs Review.Oct 18 2021, 3:53 AM
This revision was automatically updated to reflect the committed changes.