This is an archive of the discontinued LLVM Phabricator instance.

[RDA] Fix DBG_VALUE issues
ClosedPublic

Authored by samparker on Aug 10 2020, 9:02 AM.

Details

Summary

We skip debug instructions in RDA so we cannot attempt to look them up in our instruction map without causing a crash. But some of the methods select the last instruction in the block and this instruction may be a debug instruction... So, use getLastNonDebugInstr instead of calling back on a MachineBasicBlock.
MachineBasicBlock iterators have also been updated to use instructionsWithoutDebug so we can avoid the manual checks for debug instructions.
There's no test attached here... trying to make a sensible reproducer has been a real pain...

Diff Detail

Event Timeline

samparker created this revision.Aug 10 2020, 9:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2020, 9:02 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
samparker requested review of this revision.Aug 10 2020, 9:02 AM
nikic accepted this revision.Aug 10 2020, 10:03 AM

This LGTM, with some thoughts on how this could be improved in a followup.

llvm/lib/CodeGen/ReachingDefAnalysis.cpp
501

The general approach in this function looks a bit dubious to me. Instead of passing in the last instruction to getReachingDef(), we should add a function that gets the reaching def at the end of the block. This can be found by inspecting the last element in the reaching def vector, rather than scanning the whole vector, and has the advantage that it will automatically include reaching defs from the last instruction. From a cursory look, I suspect that the current implementation has a discrepancy in handling of aliased registers for the last instruction, because reg units are not inspected for it.

This revision is now accepted and ready to land.Aug 10 2020, 10:03 AM
This revision was landed with ongoing or failed builds.Aug 11 2020, 1:03 AM
This revision was automatically updated to reflect the committed changes.
samparker added inline comments.Aug 11 2020, 1:25 AM
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
501

Thanks, sounds good.