[llvm] [RemoveDIs][DebugInfo] Add support for DPValues to LoopStrengthReduce (PR #78706)
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 22 10:09:47 PST 2024
https://github.com/SLTozer updated https://github.com/llvm/llvm-project/pull/78706
>From 0e47c96dd5659ac1a9baefadbd0da14224c354aa Mon Sep 17 00:00:00 2001
From: Stephen Tozer <Stephen.Tozer at Sony.com>
Date: Thu, 11 Jan 2024 20:32:34 +0000
Subject: [PATCH 1/3] LSR change
---
.../Transforms/Scalar/LoopStrengthReduce.cpp | 240 ++++++++++--------
1 file changed, 136 insertions(+), 104 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index e496f79a8f8ce0a..bdf64744db06201 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -6366,10 +6366,12 @@ struct SCEVDbgValueBuilder {
/// and DIExpression.
struct DVIRecoveryRec {
DVIRecoveryRec(DbgValueInst *DbgValue)
- : DVI(DbgValue), Expr(DbgValue->getExpression()),
+ : DbgRef(DbgValue), Expr(DbgValue->getExpression()),
HadLocationArgList(false) {}
+ DVIRecoveryRec(DPValue *DPV)
+ : DbgRef(DPV), Expr(DPV->getExpression()), HadLocationArgList(false) {}
- DbgValueInst *DVI;
+ PointerUnion<DbgValueInst *, DPValue *> DbgRef;
DIExpression *Expr;
bool HadLocationArgList;
SmallVector<WeakVH, 2> LocationOps;
@@ -6401,17 +6403,19 @@ static unsigned numLLVMArgOps(SmallVectorImpl<uint64_t> &Expr) {
/// Overwrites DVI with the location and Ops as the DIExpression. This will
/// create an invalid expression if Ops has any dwarf::DW_OP_llvm_arg operands,
/// because a DIArglist is not created for the first argument of the dbg.value.
-static void updateDVIWithLocation(DbgValueInst &DVI, Value *Location,
+template <typename T>
+static void updateDVIWithLocation(T &DbgVal, Value *Location,
SmallVectorImpl<uint64_t> &Ops) {
- assert(
- numLLVMArgOps(Ops) == 0 &&
- "Expected expression that does not contain any DW_OP_llvm_arg operands.");
- DVI.setRawLocation(ValueAsMetadata::get(Location));
- DVI.setExpression(DIExpression::get(DVI.getContext(), Ops));
+ assert(numLLVMArgOps(Ops) == 0 && "Expected expression that does not "
+ "contain any DW_OP_llvm_arg operands.");
+ DbgVal.setRawLocation(ValueAsMetadata::get(Location));
+ DbgVal.setExpression(DIExpression::get(DbgVal.getContext(), Ops));
+ DbgVal.setExpression(DIExpression::get(DbgVal.getContext(), Ops));
}
/// Overwrite DVI with locations placed into a DIArglist.
-static void updateDVIWithLocations(DbgValueInst &DVI,
+template <typename T>
+static void updateDVIWithLocations(T &DbgVal,
SmallVectorImpl<Value *> &Locations,
SmallVectorImpl<uint64_t> &Ops) {
assert(numLLVMArgOps(Ops) != 0 &&
@@ -6421,8 +6425,8 @@ static void updateDVIWithLocations(DbgValueInst &DVI,
for (Value *V : Locations)
MetadataLocs.push_back(ValueAsMetadata::get(V));
auto ValArrayRef = llvm::ArrayRef<llvm::ValueAsMetadata *>(MetadataLocs);
- DVI.setRawLocation(llvm::DIArgList::get(DVI.getContext(), ValArrayRef));
- DVI.setExpression(DIExpression::get(DVI.getContext(), Ops));
+ DbgVal.setRawLocation(llvm::DIArgList::get(DbgVal.getContext(), ValArrayRef));
+ DbgVal.setExpression(DIExpression::get(DbgVal.getContext(), Ops));
}
/// Write the new expression and new location ops for the dbg.value. If possible
@@ -6433,30 +6437,37 @@ static void updateDVIWithLocations(DbgValueInst &DVI,
static void UpdateDbgValueInst(DVIRecoveryRec &DVIRec,
SmallVectorImpl<Value *> &NewLocationOps,
SmallVectorImpl<uint64_t> &NewExpr) {
- unsigned NumLLVMArgs = numLLVMArgOps(NewExpr);
- if (NumLLVMArgs == 0) {
- // Location assumed to be on the stack.
- updateDVIWithLocation(*DVIRec.DVI, NewLocationOps[0], NewExpr);
- } else if (NumLLVMArgs == 1 && NewExpr[0] == dwarf::DW_OP_LLVM_arg) {
- // There is only a single DW_OP_llvm_arg at the start of the expression,
- // so it can be omitted along with DIArglist.
- assert(NewExpr[1] == 0 &&
- "Lone LLVM_arg in a DIExpression should refer to location-op 0.");
- llvm::SmallVector<uint64_t, 6> ShortenedOps(llvm::drop_begin(NewExpr, 2));
- updateDVIWithLocation(*DVIRec.DVI, NewLocationOps[0], ShortenedOps);
- } else {
- // Multiple DW_OP_llvm_arg, so DIArgList is strictly necessary.
- updateDVIWithLocations(*DVIRec.DVI, NewLocationOps, NewExpr);
- }
+ auto UpdateDbgValueInstImpl = [&](auto *DbgVal) {
+ unsigned NumLLVMArgs = numLLVMArgOps(NewExpr);
+ if (NumLLVMArgs == 0) {
+ // Location assumed to be on the stack.
+ updateDVIWithLocation(*DbgVal, NewLocationOps[0], NewExpr);
+ } else if (NumLLVMArgs == 1 && NewExpr[0] == dwarf::DW_OP_LLVM_arg) {
+ // There is only a single DW_OP_llvm_arg at the start of the expression,
+ // so it can be omitted along with DIArglist.
+ assert(NewExpr[1] == 0 &&
+ "Lone LLVM_arg in a DIExpression should refer to location-op 0.");
+ llvm::SmallVector<uint64_t, 6> ShortenedOps(llvm::drop_begin(NewExpr, 2));
+ updateDVIWithLocation(*DbgVal, NewLocationOps[0], ShortenedOps);
+ } else {
+ // Multiple DW_OP_llvm_arg, so DIArgList is strictly necessary.
+ updateDVIWithLocations(*DbgVal, NewLocationOps, NewExpr);
+ }
- // If the DIExpression was previously empty then add the stack terminator.
- // Non-empty expressions have only had elements inserted into them and so the
- // terminator should already be present e.g. stack_value or fragment.
- DIExpression *SalvageExpr = DVIRec.DVI->getExpression();
- if (!DVIRec.Expr->isComplex() && SalvageExpr->isComplex()) {
- SalvageExpr = DIExpression::append(SalvageExpr, {dwarf::DW_OP_stack_value});
- DVIRec.DVI->setExpression(SalvageExpr);
- }
+ // If the DIExpression was previously empty then add the stack terminator.
+ // Non-empty expressions have only had elements inserted into them and so
+ // the terminator should already be present e.g. stack_value or fragment.
+ DIExpression *SalvageExpr = DbgVal->getExpression();
+ if (!DVIRec.Expr->isComplex() && SalvageExpr->isComplex()) {
+ SalvageExpr =
+ DIExpression::append(SalvageExpr, {dwarf::DW_OP_stack_value});
+ DbgVal->setExpression(SalvageExpr);
+ }
+ };
+ if (isa<DbgValueInst *>(DVIRec.DbgRef))
+ UpdateDbgValueInstImpl(cast<DbgValueInst *>(DVIRec.DbgRef));
+ else
+ UpdateDbgValueInstImpl(cast<DPValue *>(DVIRec.DbgRef));
}
/// Cached location ops may be erased during LSR, in which case a poison is
@@ -6470,40 +6481,49 @@ static Value *getValueOrPoison(WeakVH &VH, LLVMContext &C) {
/// Restore the DVI's pre-LSR arguments. Substitute undef for any erased values.
static void restorePreTransformState(DVIRecoveryRec &DVIRec) {
- LLVM_DEBUG(dbgs() << "scev-salvage: restore dbg.value to pre-LSR state\n"
- << "scev-salvage: post-LSR: " << *DVIRec.DVI << '\n');
- assert(DVIRec.Expr && "Expected an expression");
- DVIRec.DVI->setExpression(DVIRec.Expr);
-
- // Even a single location-op may be inside a DIArgList and referenced with
- // DW_OP_LLVM_arg, which is valid only with a DIArgList.
- if (!DVIRec.HadLocationArgList) {
- assert(DVIRec.LocationOps.size() == 1 &&
- "Unexpected number of location ops.");
- // LSR's unsuccessful salvage attempt may have added DIArgList, which in
- // this case was not present before, so force the location back to a single
- // uncontained Value.
- Value *CachedValue =
- getValueOrPoison(DVIRec.LocationOps[0], DVIRec.DVI->getContext());
- DVIRec.DVI->setRawLocation(ValueAsMetadata::get(CachedValue));
- } else {
- SmallVector<ValueAsMetadata *, 3> MetadataLocs;
- for (WeakVH VH : DVIRec.LocationOps) {
- Value *CachedValue = getValueOrPoison(VH, DVIRec.DVI->getContext());
- MetadataLocs.push_back(ValueAsMetadata::get(CachedValue));
+ auto RestorePreTransformStateImpl = [&](auto *DbgVal) {
+ LLVM_DEBUG(dbgs() << "scev-salvage: restore dbg.value to pre-LSR state\n"
+ << "scev-salvage: post-LSR: " << *DbgVal << '\n');
+ assert(DVIRec.Expr && "Expected an expression");
+ DbgVal->setExpression(DVIRec.Expr);
+
+ // Even a single location-op may be inside a DIArgList and referenced with
+ // DW_OP_LLVM_arg, which is valid only with a DIArgList.
+ if (!DVIRec.HadLocationArgList) {
+ assert(DVIRec.LocationOps.size() == 1 &&
+ "Unexpected number of location ops.");
+ // LSR's unsuccessful salvage attempt may have added DIArgList, which in
+ // this case was not present before, so force the location back to a
+ // single uncontained Value.
+ Value *CachedValue =
+ getValueOrPoison(DVIRec.LocationOps[0], DbgVal->getContext());
+ DbgVal->setRawLocation(ValueAsMetadata::get(CachedValue));
+ } else {
+ SmallVector<ValueAsMetadata *, 3> MetadataLocs;
+ for (WeakVH VH : DVIRec.LocationOps) {
+ Value *CachedValue = getValueOrPoison(VH, DbgVal->getContext());
+ MetadataLocs.push_back(ValueAsMetadata::get(CachedValue));
+ }
+ auto ValArrayRef = llvm::ArrayRef<llvm::ValueAsMetadata *>(MetadataLocs);
+ DbgVal->setRawLocation(
+ llvm::DIArgList::get(DbgVal->getContext(), ValArrayRef));
}
- auto ValArrayRef = llvm::ArrayRef<llvm::ValueAsMetadata *>(MetadataLocs);
- DVIRec.DVI->setRawLocation(
- llvm::DIArgList::get(DVIRec.DVI->getContext(), ValArrayRef));
- }
- LLVM_DEBUG(dbgs() << "scev-salvage: pre-LSR: " << *DVIRec.DVI << '\n');
+ LLVM_DEBUG(dbgs() << "scev-salvage: pre-LSR: " << *DbgVal << '\n');
+ };
+ if (isa<DbgValueInst *>(DVIRec.DbgRef))
+ RestorePreTransformStateImpl(cast<DbgValueInst *>(DVIRec.DbgRef));
+ else
+ RestorePreTransformStateImpl(cast<DPValue *>(DVIRec.DbgRef));
}
static bool SalvageDVI(llvm::Loop *L, ScalarEvolution &SE,
llvm::PHINode *LSRInductionVar, DVIRecoveryRec &DVIRec,
const SCEV *SCEVInductionVar,
SCEVDbgValueBuilder IterCountExpr) {
- if (!DVIRec.DVI->isKillLocation())
+
+ if (isa<DbgValueInst *>(DVIRec.DbgRef)
+ ? !cast<DbgValueInst *>(DVIRec.DbgRef)->isKillLocation()
+ : !cast<DPValue *>(DVIRec.DbgRef)->isKillLocation())
return false;
// LSR may have caused several changes to the dbg.value in the failed salvage
@@ -6596,16 +6616,20 @@ static bool SalvageDVI(llvm::Loop *L, ScalarEvolution &SE,
}
UpdateDbgValueInst(DVIRec, NewLocationOps, NewExpr);
- LLVM_DEBUG(dbgs() << "scev-salvage: Updated DVI: " << *DVIRec.DVI << "\n");
+ if (isa<DbgValueInst *>(DVIRec.DbgRef))
+ LLVM_DEBUG(dbgs() << "scev-salvage: Updated DVI: "
+ << *cast<DbgValueInst *>(DVIRec.DbgRef) << "\n");
+ else
+ LLVM_DEBUG(dbgs() << "scev-salvage: Updated DVI: "
+ << *cast<DPValue *>(DVIRec.DbgRef) << "\n");
return true;
}
/// Obtain an expression for the iteration count, then attempt to salvage the
/// dbg.value intrinsics.
-static void
-DbgRewriteSalvageableDVIs(llvm::Loop *L, ScalarEvolution &SE,
- llvm::PHINode *LSRInductionVar,
- SmallVector<std::unique_ptr<DVIRecoveryRec>, 2> &DVIToUpdate) {
+static void DbgRewriteSalvageableDVIs(
+ llvm::Loop *L, ScalarEvolution &SE, llvm::PHINode *LSRInductionVar,
+ SmallVector<std::unique_ptr<DVIRecoveryRec>, 2> &DVIToUpdate) {
if (DVIToUpdate.empty())
return;
@@ -6647,48 +6671,56 @@ static void DbgGatherSalvagableDVI(
SmallSet<AssertingVH<DbgValueInst>, 2> &DVIHandles) {
for (const auto &B : L->getBlocks()) {
for (auto &I : *B) {
- auto DVI = dyn_cast<DbgValueInst>(&I);
- if (!DVI)
- continue;
- // Ensure that if any location op is undef that the dbg.vlue is not
- // cached.
- if (DVI->isKillLocation())
- continue;
-
- // Check that the location op SCEVs are suitable for translation to
- // DIExpression.
- const auto &HasTranslatableLocationOps =
- [&](const DbgValueInst *DVI) -> bool {
- for (const auto LocOp : DVI->location_ops()) {
- if (!LocOp)
- return false;
-
- if (!SE.isSCEVable(LocOp->getType()))
- return false;
-
- const SCEV *S = SE.getSCEV(LocOp);
- if (SE.containsUndefs(S))
- return false;
+ auto ProcessDbgValue = [&](auto *DbgVal) -> bool {
+ // Ensure that if any location op is undef that the dbg.vlue is not
+ // cached.
+ if (DbgVal->isKillLocation())
+ return false;
+
+ // Check that the location op SCEVs are suitable for translation to
+ // DIExpression.
+ const auto &HasTranslatableLocationOps =
+ [&](const auto *DbgVal) -> bool {
+ for (const auto LocOp : DbgVal->location_ops()) {
+ if (!LocOp)
+ return false;
+
+ if (!SE.isSCEVable(LocOp->getType()))
+ return false;
+
+ const SCEV *S = SE.getSCEV(LocOp);
+ if (SE.containsUndefs(S))
+ return false;
+ }
+ return true;
+ };
+
+ if (!HasTranslatableLocationOps(DbgVal))
+ return false;
+
+ std::unique_ptr<DVIRecoveryRec> NewRec =
+ std::make_unique<DVIRecoveryRec>(DbgVal);
+ // Each location Op may need a SCEVDbgValueBuilder in order to recover
+ // it. Pre-allocating a vector will enable quick lookups of the builder
+ // later during the salvage.
+ NewRec->RecoveryExprs.resize(DbgVal->getNumVariableLocationOps());
+ for (const auto LocOp : DbgVal->location_ops()) {
+ NewRec->SCEVs.push_back(SE.getSCEV(LocOp));
+ NewRec->LocationOps.push_back(LocOp);
+ NewRec->HadLocationArgList = DbgVal->hasArgList();
}
+ SalvageableDVISCEVs.push_back(std::move(NewRec));
return true;
};
-
- if (!HasTranslatableLocationOps(DVI))
- continue;
-
- std::unique_ptr<DVIRecoveryRec> NewRec =
- std::make_unique<DVIRecoveryRec>(DVI);
- // Each location Op may need a SCEVDbgValueBuilder in order to recover it.
- // Pre-allocating a vector will enable quick lookups of the builder later
- // during the salvage.
- NewRec->RecoveryExprs.resize(DVI->getNumVariableLocationOps());
- for (const auto LocOp : DVI->location_ops()) {
- NewRec->SCEVs.push_back(SE.getSCEV(LocOp));
- NewRec->LocationOps.push_back(LocOp);
- NewRec->HadLocationArgList = DVI->hasArgList();
+ for (auto &DPV : I.getDbgValueRange()) {
+ if (DPV.isDbgValue() || DPV.isDbgAssign())
+ ProcessDbgValue(&DPV);
}
- SalvageableDVISCEVs.push_back(std::move(NewRec));
- DVIHandles.insert(DVI);
+ auto DVI = dyn_cast<DbgValueInst>(&I);
+ if (!DVI)
+ continue;
+ if (ProcessDbgValue(DVI))
+ DVIHandles.insert(DVI);
}
}
}
>From f95586bb73d642b0cf8ed1f4d52fb0514ef2bfd3 Mon Sep 17 00:00:00 2001
From: Stephen Tozer <Stephen.Tozer at Sony.com>
Date: Mon, 22 Jan 2024 18:02:34 +0000
Subject: [PATCH 2/3] LSR DPV Tests
---
llvm/test/Transforms/LoopStrengthReduce/X86/lsr-cond-dbg.ll | 1 +
llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-0.ll | 1 +
llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-1.ll | 1 +
llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-2.ll | 1 +
.../Transforms/LoopStrengthReduce/debuginfo-scev-salvage-0.ll | 1 +
.../Transforms/LoopStrengthReduce/debuginfo-scev-salvage-1.ll | 1 +
.../Transforms/LoopStrengthReduce/debuginfo-scev-salvage-2.ll | 1 +
.../Transforms/LoopStrengthReduce/debuginfo-scev-salvage-3.ll | 1 +
.../Transforms/LoopStrengthReduce/debuginfo-scev-salvage-4.ll | 1 +
.../Transforms/LoopStrengthReduce/debuginfo-scev-salvage-5.ll | 1 +
llvm/test/Transforms/LoopStrengthReduce/optimizemax_debugloc.ll | 1 +
llvm/test/Transforms/LoopStrengthReduce/pr12018.ll | 1 +
llvm/test/Transforms/LoopStrengthReduce/pr51329.ll | 1 +
llvm/test/Transforms/LoopStrengthReduce/pr51656.ll | 1 +
llvm/test/Transforms/LoopStrengthReduce/pr52161.ll | 1 +
15 files changed, 15 insertions(+)
diff --git a/llvm/test/Transforms/LoopStrengthReduce/X86/lsr-cond-dbg.ll b/llvm/test/Transforms/LoopStrengthReduce/X86/lsr-cond-dbg.ll
index 7be45db67a0f907..01c7950ab702db7 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/X86/lsr-cond-dbg.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/X86/lsr-cond-dbg.ll
@@ -1,4 +1,5 @@
; RUN: opt -S -loop-reduce < %s | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -S -loop-reduce < %s | FileCheck %s
; During Loop Strength Reduce, if the terminating condition for the loop is not
; immediately adjacent to the terminating branch and it has more than one use,
diff --git a/llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-0.ll b/llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-0.ll
index 5e983524e408d32..204ea5d320f53d7 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-0.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-0.ll
@@ -1,4 +1,5 @@
; RUN: opt -loop-reduce -S %s | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -loop-reduce -S %s | FileCheck %s
;; Test that LSR preserves debug-info for induction variables and scev-based
;; salvaging produces short DIExpressions that use a constant offset from the
diff --git a/llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-1.ll b/llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-1.ll
index 7aa6d97d935dd85..8b857e1bb6845f5 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-1.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-1.ll
@@ -1,4 +1,5 @@
; RUN: opt < %s -loop-reduce -S | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators < %s -loop-reduce -S | FileCheck %s
;
; Test that LSR avoids crashing on very large integer inputs. It should
; discard the variable location by creating an undef dbg.value.
diff --git a/llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-2.ll b/llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-2.ll
index 8bbcc4d3b3a557a..ec9c48628179a43 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-2.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-2.ll
@@ -1,4 +1,5 @@
; RUN: opt < %s -loop-reduce -S | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators < %s -loop-reduce -S | FileCheck %s
; Test that LSR does not produce invalid debug info when a debug value is
; salvaged during LSR by adding additional location operands, then becomes
diff --git a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-0.ll b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-0.ll
index 176701723234221..836f52542217346 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-0.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-0.ll
@@ -1,4 +1,5 @@
; RUN: opt -S -loop-reduce %s -o - | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -S -loop-reduce %s -o - | FileCheck %s
; REQUIRES: x86-registered-target
;; Ensure that we retain debuginfo for the induction variable and dependant
diff --git a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-1.ll b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-1.ll
index 57ec5b221423365..d20b99283fbbca7 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-1.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-1.ll
@@ -1,4 +1,5 @@
; RUN: opt -S -loop-reduce %s -o - | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -S -loop-reduce %s -o - | FileCheck %s
; REQUIRES: x86-registered-target
;; Ensure that we retain debuginfo for the induction variable and dependant
diff --git a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-2.ll b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-2.ll
index ececeb7cc575e9f..789f47c87d174f9 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-2.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-2.ll
@@ -1,4 +1,5 @@
; RUN: opt -S -loop-reduce %s -o - | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -S -loop-reduce %s -o - | FileCheck %s
; REQUIRES: x86-registered-target
;; Ensure that we retain debuginfo for the induction variable and dependant
diff --git a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-3.ll b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-3.ll
index 5fe00e7d1cafcab..1c5dff9481693f4 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-3.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-3.ll
@@ -1,4 +1,5 @@
; RUN: opt -S -loop-reduce %s -o - | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -S -loop-reduce %s -o - | FileCheck %s
; REQUIRES: x86-registered-target
;; Ensure that we retain debuginfo for the induction variable and dependant
diff --git a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-4.ll b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-4.ll
index a3dd7a74edbf7a1..6456ed43aee64e6 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-4.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-4.ll
@@ -1,4 +1,5 @@
; RUN: opt -S -loop-reduce %s -o - | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -S -loop-reduce %s -o - | FileCheck %s
; REQUIRES: x86-registered-target
;; Ensure that we retain debuginfo for the induction variable and dependant
diff --git a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-5.ll b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-5.ll
index 5656acf8f60e892..b06757ccf915802 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-5.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-5.ll
@@ -1,4 +1,5 @@
; RUN: opt -S -loop-reduce %s | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -S -loop-reduce %s | FileCheck %s
; REQUIRES: x86-registered-target
;; Ensure that SCEV-based salvaging in Loop Strength Reduction can salvage
diff --git a/llvm/test/Transforms/LoopStrengthReduce/optimizemax_debugloc.ll b/llvm/test/Transforms/LoopStrengthReduce/optimizemax_debugloc.ll
index d2d5550c3d68f1f..60ea02c1d2a7bf2 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/optimizemax_debugloc.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/optimizemax_debugloc.ll
@@ -1,4 +1,5 @@
; RUN: opt < %s -loop-reduce -S 2>&1 | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators < %s -loop-reduce -S 2>&1 | FileCheck %s
;; This test case checks that whether the new icmp instruction preserves
;; the debug location of the original instruction for %exitcond
; CHECK: icmp uge i32 %indvar.next, %n, !dbg ![[DBGLOC:[0-9]+]]
diff --git a/llvm/test/Transforms/LoopStrengthReduce/pr12018.ll b/llvm/test/Transforms/LoopStrengthReduce/pr12018.ll
index 78fef12d287501e..62b2fb7fca8d9a3 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/pr12018.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/pr12018.ll
@@ -1,4 +1,5 @@
; RUN: opt < %s -loop-reduce
+; RUN: opt --try-experimental-debuginfo-iterators < %s -loop-reduce
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"
diff --git a/llvm/test/Transforms/LoopStrengthReduce/pr51329.ll b/llvm/test/Transforms/LoopStrengthReduce/pr51329.ll
index ffdb785b8ef8f60..52a8f1921dae9f1 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/pr51329.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/pr51329.ll
@@ -1,4 +1,5 @@
; RUN: opt -S -loop-reduce %s | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -S -loop-reduce %s | FileCheck %s
;
; Test that LSR SCEV-based salvaging does not crash when translating SCEVs
; that contain integers with binary representations greater than 64-bits.
diff --git a/llvm/test/Transforms/LoopStrengthReduce/pr51656.ll b/llvm/test/Transforms/LoopStrengthReduce/pr51656.ll
index da9ce16b6d860cd..1d5886c01c7377f 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/pr51656.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/pr51656.ll
@@ -1,4 +1,5 @@
; RUN: opt -loop-reduce -S %s | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -loop-reduce -S %s | FileCheck %s
;; This test ensures that no attempt is made to translate long SCEVs into
;; DIExpressions. Attempting the translation can use excessive resources and
diff --git a/llvm/test/Transforms/LoopStrengthReduce/pr52161.ll b/llvm/test/Transforms/LoopStrengthReduce/pr52161.ll
index 47b8fda174982dd..1a679392a060090 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/pr52161.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/pr52161.ll
@@ -1,4 +1,5 @@
; RUN: opt -S -loop-reduce %s | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -S -loop-reduce %s | FileCheck %s
;; Ensure that scev-based salvaging in LSR does not select an IV containing
;; an 'undef' element.
>From 3ec7d83fad1d5ac024e073dac6399f870aadb548 Mon Sep 17 00:00:00 2001
From: Stephen Tozer <Stephen.Tozer at Sony.com>
Date: Mon, 22 Jan 2024 18:09:36 +0000
Subject: [PATCH 3/3] Address nit: don't shadow lambda var
---
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index bdf64744db06201..9346da4384f9e5b 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -6680,8 +6680,8 @@ static void DbgGatherSalvagableDVI(
// Check that the location op SCEVs are suitable for translation to
// DIExpression.
const auto &HasTranslatableLocationOps =
- [&](const auto *DbgVal) -> bool {
- for (const auto LocOp : DbgVal->location_ops()) {
+ [&](const auto *DbgValToTranslate) -> bool {
+ for (const auto LocOp : DbgValToTranslate->location_ops()) {
if (!LocOp)
return false;
More information about the llvm-commits
mailing list