aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorStephen Tozer <stephen.tozer@sony.com>2021-09-21 15:11:22 +0100
committerStephen Tozer <stephen.tozer@sony.com>2021-10-15 17:34:21 +0100
commitf5ed223b0fd0d45ff18013e38756546210e03a34 (patch)
tree95d3169a56b2d6d7823c7ddc7184f8d87c35ad3e /llvm/lib/Transforms/Utils/Local.cpp
parentb24788abd8df02169ecbf6afa91836819c8a35fe (diff)
downloadllvm-f5ed223b0fd0d45ff18013e38756546210e03a34.zip
llvm-f5ed223b0fd0d45ff18013e38756546210e03a34.tar.gz
llvm-f5ed223b0fd0d45ff18013e38756546210e03a34.tar.bz2
[DebugInfo] Limit the size of DIExpressions that we will salvage up to
Fixes: https://bugs.llvm.org/show_bug.cgi?id=51841 This patch places an arbitrary limit on the size of DIExpressions that we will produce via salvaging, for performance reasons. This helps to fix a performance issue observed in the bug above, in which debug values would be salvaged hundreds of times, producing expressions with over 1000 elements and causing the compiler to hang. Limiting the size of debug values that we will produce to 128 largely fixes this issue. Reviewed By: dblaikie, jmorse Differential Revision: https://reviews.llvm.org/D110332
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 7533f4f..122977c 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1733,9 +1733,11 @@ 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.
+ // These are arbitrary chosen limits on the maximum number of values and the
+ // maximum size of a debug expression we can salvage up to, used for
+ // performance reasons.
const unsigned MaxDebugArgs = 16;
+ const unsigned MaxExpressionSize = 128;
bool Salvaged = false;
for (auto *DII : DbgUsers) {
@@ -1772,9 +1774,10 @@ void llvm::salvageDebugInfoForDbgValues(
break;
DII->replaceVariableLocationOp(&I, Op0);
- if (AdditionalValues.empty()) {
+ bool IsValidSalvageExpr = SalvagedExpr->getNumElements() <= MaxExpressionSize;
+ if (AdditionalValues.empty() && IsValidSalvageExpr) {
DII->setExpression(SalvagedExpr);
- } else if (isa<DbgValueInst>(DII) &&
+ } else if (isa<DbgValueInst>(DII) && IsValidSalvageExpr &&
DII->getNumVariableLocationOps() + AdditionalValues.size() <=
MaxDebugArgs) {
DII->addVariableLocationOps(AdditionalValues, SalvagedExpr);