aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorStephen Tozer <Stephen.Tozer@Sony.com>2021-05-26 15:27:57 +0100
committerStephen Tozer <Stephen.Tozer@Sony.com>2021-05-26 17:34:05 +0100
commita0bd6105d80698c53ceaa64bbe6e3b7e7bbf99ee (patch)
tree82e43cc0f0d6d7e7c02cd9e7b9fa352ae9749702 /llvm/lib/Transforms/Utils/Local.cpp
parent969eefd98e0f8e485148be61190cc2ef62fb1eca (diff)
downloadllvm-a0bd6105d80698c53ceaa64bbe6e3b7e7bbf99ee.zip
llvm-a0bd6105d80698c53ceaa64bbe6e3b7e7bbf99ee.tar.gz
llvm-a0bd6105d80698c53ceaa64bbe6e3b7e7bbf99ee.tar.bz2
[DebugInfo] Limit the number of values that may be referenced by a dbg.value
Following the addition of salvaging dbg.values using DIArgLists to reference multiple values, a case has been found where excessively large DIArgLists are produced as a result of this salvaging, resulting in large enough performance costs to effectively freeze the compiler. This patch introduces an upper bound of 16 to the number of values that may be salvaged into a dbg.value, to limit the impact of these extreme cases to performance. Differential Revision: https://reviews.llvm.org/D103162
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 38ecb75..eeaf43a 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1724,6 +1724,9 @@ void llvm::salvageDebugInfo(Instruction &I) {
void llvm::salvageDebugInfoForDbgValues(
Instruction &I, ArrayRef<DbgVariableIntrinsic *> DbgUsers) {
+ // This is an arbitrary chosen limit on the maximum number of values we can
+ // salvage up to in a DIArgList, used for performance reasons.
+ const unsigned MaxDebugArgs = 16;
bool Salvaged = false;
for (auto *DII : DbgUsers) {
@@ -1748,11 +1751,15 @@ void llvm::salvageDebugInfoForDbgValues(
DII->replaceVariableLocationOp(&I, I.getOperand(0));
if (AdditionalValues.empty()) {
DII->setExpression(SalvagedExpr);
- } else if (isa<DbgValueInst>(DII)) {
+ } else if (isa<DbgValueInst>(DII) &&
+ DII->getNumVariableLocationOps() + AdditionalValues.size() <=
+ MaxDebugArgs) {
DII->addVariableLocationOps(AdditionalValues, SalvagedExpr);
} else {
// Do not salvage using DIArgList for dbg.addr/dbg.declare, as it is
// currently only valid for stack value expressions.
+ // Also do not salvage if the resulting DIArgList would contain an
+ // unreasonably large number of values.
Value *Undef = UndefValue::get(I.getOperand(0)->getType());
DII->replaceVariableLocationOp(I.getOperand(0), Undef);
}