diff options
author | Robert Lougher <robert.lougher@sony.com> | 2020-11-25 19:52:20 +0000 |
---|---|---|
committer | Robert Lougher <robert.lougher@sony.com> | 2020-11-26 14:30:18 +0000 |
commit | 6464c4a170173a2b476ff4be6e160836032b68fe (patch) | |
tree | b8d3a1d2ecc6db6ac09d05445e84cc033030ab65 /llvm/lib/CodeGen/LiveDebugVariables.cpp | |
parent | 39a5dd164ca8648e24525869c934c9137c4887ef (diff) | |
download | llvm-6464c4a170173a2b476ff4be6e160836032b68fe.zip llvm-6464c4a170173a2b476ff4be6e160836032b68fe.tar.gz llvm-6464c4a170173a2b476ff4be6e160836032b68fe.tar.bz2 |
[LiveDebugVariables] Strip all debug instructions from nodebug functions
A crash/assertion failure in the greedy register allocator was tracked
down to a debug instr 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.
Differential Revision: https://reviews.llvm.org/D92127
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugVariables.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugVariables.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp index f4238bd..2325341 100644 --- a/llvm/lib/CodeGen/LiveDebugVariables.cpp +++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp @@ -1022,10 +1022,10 @@ bool LDVImpl::runOnMachineFunction(MachineFunction &mf) { return Changed; } -static void removeDebugValues(MachineFunction &mf) { +static void removeDebugInstrs(MachineFunction &mf) { for (MachineBasicBlock &MBB : mf) { for (auto MBBI = MBB.begin(), MBBE = MBB.end(); MBBI != MBBE; ) { - if (!MBBI->isDebugValue()) { + if (!MBBI->isDebugInstr()) { ++MBBI; continue; } @@ -1038,7 +1038,7 @@ bool LiveDebugVariables::runOnMachineFunction(MachineFunction &mf) { if (!EnableLDV) return false; if (!mf.getFunction().getSubprogram()) { - removeDebugValues(mf); + removeDebugInstrs(mf); return false; } if (!pImpl) |