This is an archive of the discontinued LLVM Phabricator instance.

[LiveDebugVariables] Strip all debug instructions from nodebug functions
ClosedPublic

Authored by rob.lougher on Nov 25 2020, 1:00 PM.

Details

Summary

A crash/assertion failure in the greedy register allocator was tracked down to a debug instruction being passed to LiveIntervals::getInstructionIndex. Normally this should not occur as debug instructions are collected and removed by LiveDebugVariables before RA, and reinserted afterwards. However, when a function has no debug info, LiveDebugVariables simply strips any debug values that are present as they're not needed (this situation will occur when a function with debug info is inlined into a nodebug function). The problem is, it only removes DBG_VALUE instructions, leaving DBG_LABELs (the cause of the crash).

This patch updates the LiveDebugVariables nodebug path to remove all debug instructions. The test case verifies that DBG_VALUE/DBG_LABEL instructions are present, and that they are stripped.

When -experimental-debug-variable-locations is enabled, certain variable locations are represented by DBG_INSTR_REF instead of DBG_VALUE. The test case verifies that a DBG_INSTR_REF is emitted by the option, and that it is also stripped.

Diff Detail

Event Timeline

rob.lougher created this revision.Nov 25 2020, 1:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 25 2020, 1:00 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
rob.lougher requested review of this revision.Nov 25 2020, 1:00 PM
dblaikie accepted this revision.Nov 25 2020, 1:51 PM

Seems good to me!

This revision is now accepted and ready to land.Nov 25 2020, 1:51 PM
jmorse accepted this revision.Nov 26 2020, 4:03 AM
jmorse added subscribers: debug-info, jmorse.

LGTM too

This revision was landed with ongoing or failed builds.Nov 26 2020, 6:32 AM
This revision was automatically updated to reflect the committed changes.