aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveDebugVariables.cpp
diff options
context:
space:
mode:
authorStephen Tozer <Stephen.Tozer@Sony.com>2021-04-28 10:32:08 +0100
committerStephen Tozer <Stephen.Tozer@Sony.com>2021-04-28 10:39:02 +0100
commitb622df3c93983c4512aa54f2c706716bdf865a90 (patch)
tree192db6f4b3fa633a3218a75208293674e98b0aa8 /llvm/lib/CodeGen/LiveDebugVariables.cpp
parent789549bea441f1347458505307db322aea3ac289 (diff)
downloadllvm-b622df3c93983c4512aa54f2c706716bdf865a90.zip
llvm-b622df3c93983c4512aa54f2c706716bdf865a90.tar.gz
llvm-b622df3c93983c4512aa54f2c706716bdf865a90.tar.bz2
[DebugInfo] Drop DBG_VALUE_LISTs with an excessive number of debug operands
This patch fixes a crash in LiveDebugVariables for inputs where a DBG_VALUE_LIST had 64 or more debug operands. This was triggering an assert, which was added under the assumption that only bad CodeGen would result in such a limit being hit, but relatively simple source files that result in these incredibly long debug values have been found, so this assert has been changed to a condition that drops the debug value if it is not met. Differential Revision: https://reviews.llvm.org/D101373
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugVariables.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveDebugVariables.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index ce898cd..9de33d6 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -119,17 +119,33 @@ public:
DIExpression::replaceArg(Expression, OpIdx, DuplicatingIdx);
}
}
- // A debug value referencing 64+ unique machine locations is very likely
- // to be the result of a bug earlier in the pipeline. If by some means this
- // limit is validly reached, then we can add a byte to the size of
- // LocNoCount.
- assert(LocNoVec.size() < 64 &&
- "debug value containing 64+ unique machine locations is not "
- "supported by Live Debug Variables");
- LocNoCount = LocNoVec.size();
- if (LocNoCount > 0) {
- LocNos.reset(new unsigned[LocNoCount]());
- std::copy(LocNoVec.begin(), LocNoVec.end(), loc_nos_begin());
+ // FIXME: Debug values referencing 64+ unique machine locations are rare and
+ // currently unsupported for performance reasons. If we can verify that
+ // performance is acceptable for such debug values, we can increase the
+ // bit-width of LocNoCount to 14 to enable up to 16384 unique machine
+ // locations. We will also need to verify that this does not cause issues
+ // with LiveDebugVariables' use of IntervalMap.
+ if (LocNoVec.size() < 64) {
+ LocNoCount = LocNoVec.size();
+ if (LocNoCount > 0) {
+ LocNos = std::make_unique<unsigned[]>(LocNoCount);
+ std::copy(LocNoVec.begin(), LocNoVec.end(), loc_nos_begin());
+ }
+ } else {
+ LLVM_DEBUG(dbgs() << "Found debug value with 64+ unique machine "
+ "locations, dropping...\n");
+ LocNoCount = 1;
+ // Turn this into an undef debug value list; right now, the simplest form
+ // of this is an expression with one arg, and an undef debug operand.
+ Expression =
+ DIExpression::get(Expr.getContext(), {dwarf::DW_OP_LLVM_arg, 0,
+ dwarf::DW_OP_stack_value});
+ if (auto FragmentInfoOpt = Expr.getFragmentInfo())
+ Expression = *DIExpression::createFragmentExpression(
+ Expression, FragmentInfoOpt->OffsetInBits,
+ FragmentInfoOpt->SizeInBits);
+ LocNos = std::make_unique<unsigned[]>(LocNoCount);
+ LocNos[0] = UndefLocNo;
}
}