[llvm] [RemoveDIs][DebugInfo] Handle DPVAssign in most transforms (PR #78986)
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 23 07:46:31 PST 2024
https://github.com/SLTozer updated https://github.com/llvm/llvm-project/pull/78986
>From 06a4856358792129325beeb04073610c674ebf06 Mon Sep 17 00:00:00 2001
From: Stephen Tozer <Stephen.Tozer at Sony.com>
Date: Wed, 3 Jan 2024 16:48:29 +0000
Subject: [PATCH 1/2] Update trivial DPAssign cases
---
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | 6 +-
.../InstCombine/InstCombineCalls.cpp | 10 +-
llvm/lib/Transforms/Scalar/ADCE.cpp | 5 +
.../Scalar/DeadStoreElimination.cpp | 35 +++---
llvm/lib/Transforms/Utils/CodeExtractor.cpp | 4 +
llvm/lib/Transforms/Utils/InlineFunction.cpp | 18 ++-
llvm/lib/Transforms/Utils/Local.cpp | 33 +++--
.../Utils/PromoteMemoryToRegister.cpp | 116 ++++++++++++------
llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 19 ++-
llvm/lib/Transforms/Utils/ValueMapper.cpp | 12 +-
.../Transforms/Vectorize/SLPVectorizer.cpp | 4 +-
.../assignment-tracking/adce/no-delete.ll | 2 +
.../dse/dse-after-memcpyopt-merge.ll | 1 +
.../assignment-tracking/dse/shorten-offset.ll | 1 +
.../assignment-tracking/dse/shorten.ll | 1 +
.../Generic/assignment-tracking/inline/id.ll | 4 +-
.../inline/inline-stores.ll | 2 +
.../inline/shared-alloca.ll | 2 +
.../inline/use-before-def.ll | 2 +
.../do-not-remove-redundant-dbg.ll | 2 +
.../assignment-tracking/instcombine/memset.ll | 2 +
.../instcombine/sink-store.ll | 1 +
.../assignment-tracking/instcombine/sink.ll | 2 +
.../instcombine/store-new-type.ll | 1 +
.../instcombine/storemerge.ll | 1 +
.../Generic/assignment-tracking/licm/merge.ll | 1 +
.../assignment-tracking/licm/multi-exit.ll | 1 +
.../loop-deletion/dead-loop.ll | 2 +
.../assignment-tracking/mem2reg/phi.ll | 2 +
.../mem2reg/single-block-alloca.ll | 2 +
.../mem2reg/single-store-alloca.ll | 2 +
.../mem2reg/store-to-part-of-alloca.ll | 1 +
.../memcpyopt/merge-stores.ll | 1 +
.../mldst-motion/diamond.ll | 2 +
.../parse-and-verify/instruction-type.ll | 2 +
.../parse-and-verify/verify.ll | 2 +
.../remove-redundant-fwd-scan-linked.ll | 2 +
.../assignment-tracking/salvage-value.ll | 2 +
.../simplifycfg/empty-block.ll | 2 +
.../simplifycfg/speculated-store.ll | 2 +
.../slp-vectorizer/merge-scalars.ll | 2 +
.../HotColdSplit/invalid-dbg-assign.ll | 1 +
42 files changed, 227 insertions(+), 88 deletions(-)
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index db09337215c10f3..e69c718f0ae3ac3 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -963,7 +963,7 @@ static void cacheDIVar(FrameDataInfo &FrameData,
if (DIVarCache.contains(V))
continue;
- auto CacheIt = [&DIVarCache, V](auto Container) {
+ auto CacheIt = [&DIVarCache, V](const auto &Container) {
auto *I = llvm::find_if(Container, [](auto *DDI) {
return DDI->getExpression()->getNumElements() == 0;
});
@@ -1868,7 +1868,7 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
// alias.
if (F->getSubprogram()) {
auto *CurDef = Def;
- while (DIs.empty() && isa<LoadInst>(CurDef)) {
+ while (DIs.empty() && DPVs.empty() && isa<LoadInst>(CurDef)) {
auto *LdInst = cast<LoadInst>(CurDef);
// Only consider ptr to ptr same type load.
if (LdInst->getPointerOperandType() != LdInst->getType())
@@ -2966,7 +2966,7 @@ void coro::salvageDebugInfo(
Function *F = DPV.getFunction();
// Follow the pointer arithmetic all the way to the incoming
// function argument and convert into a DIExpression.
- bool SkipOutermostLoad = DPV.getType() == DPValue::LocationType::Declare;
+ bool SkipOutermostLoad = DPV.isDbgDeclare();
Value *OriginalStorage = DPV.getVariableLocationOp(0);
auto SalvagedInfo = ::salvageDebugInfoImpl(
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 64fbd5543a9e203..a647be2d26c7613 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -282,10 +282,12 @@ Instruction *InstCombinerImpl::SimplifyAnyMemSet(AnyMemSetInst *MI) {
Constant *FillVal = ConstantInt::get(ITy, Fill);
StoreInst *S = Builder.CreateStore(FillVal, Dest, MI->isVolatile());
S->copyMetadata(*MI, LLVMContext::MD_DIAssignID);
- for (auto *DAI : at::getAssignmentMarkers(S)) {
- if (llvm::is_contained(DAI->location_ops(), FillC))
- DAI->replaceVariableLocationOp(FillC, FillVal);
- }
+ auto replaceOpForAssignmentMarkers = [FillC, FillVal](auto *DbgAssign) {
+ if (llvm::is_contained(DbgAssign->location_ops(), FillC))
+ DbgAssign->replaceVariableLocationOp(FillC, FillVal);
+ };
+ for_each(at::getAssignmentMarkers(S), replaceOpForAssignmentMarkers);
+ for_each(at::getDPVAssignmentMarkers(S), replaceOpForAssignmentMarkers);
S->setAlignment(Alignment);
if (isa<AtomicMemSetInst>(MI))
diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp
index 9af275a9f4e204a..90b544c8922623d 100644
--- a/llvm/lib/Transforms/Scalar/ADCE.cpp
+++ b/llvm/lib/Transforms/Scalar/ADCE.cpp
@@ -549,6 +549,11 @@ ADCEChanged AggressiveDeadCodeElimination::removeDeadInstructions() {
// like the rest of this loop does. Extending support to assignment tracking
// is future work.
for (DPValue &DPV : make_early_inc_range(I.getDbgValueRange())) {
+ // Avoid removing a DPV that is linked to instructions because it holds
+ // information about an existing store.
+ if (DPV.isDbgAssign())
+ if (!at::getAssignmentInsts(&DPV).empty())
+ continue;
if (AliveScopes.count(DPV.getDebugLoc()->getScope()))
continue;
I.dropOneDbgValue(&DPV);
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 008dcc53fd44fce..11a91bfbe5baffa 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -488,27 +488,27 @@ static void shortenAssignment(Instruction *Inst, Value *OriginalDest,
uint64_t DeadSliceSizeInBits = OldSizeInBits - NewSizeInBits;
uint64_t DeadSliceOffsetInBits =
OldOffsetInBits + (IsOverwriteEnd ? NewSizeInBits : 0);
- auto SetDeadFragExpr = [](DbgAssignIntrinsic *DAI,
+ auto SetDeadFragExpr = [](auto *Assign,
DIExpression::FragmentInfo DeadFragment) {
// createFragmentExpression expects an offset relative to the existing
// fragment offset if there is one.
uint64_t RelativeOffset = DeadFragment.OffsetInBits -
- DAI->getExpression()
+ Assign->getExpression()
->getFragmentInfo()
.value_or(DIExpression::FragmentInfo(0, 0))
.OffsetInBits;
if (auto NewExpr = DIExpression::createFragmentExpression(
- DAI->getExpression(), RelativeOffset, DeadFragment.SizeInBits)) {
- DAI->setExpression(*NewExpr);
+ Assign->getExpression(), RelativeOffset, DeadFragment.SizeInBits)) {
+ Assign->setExpression(*NewExpr);
return;
}
// Failed to create a fragment expression for this so discard the value,
// making this a kill location.
auto *Expr = *DIExpression::createFragmentExpression(
- DIExpression::get(DAI->getContext(), std::nullopt),
+ DIExpression::get(Assign->getContext(), std::nullopt),
DeadFragment.OffsetInBits, DeadFragment.SizeInBits);
- DAI->setExpression(Expr);
- DAI->setKillLocation();
+ Assign->setExpression(Expr);
+ Assign->setKillLocation();
};
// A DIAssignID to use so that the inserted dbg.assign intrinsics do not
@@ -526,32 +526,35 @@ static void shortenAssignment(Instruction *Inst, Value *OriginalDest,
// returned by getAssignmentMarkers so save a copy of the markers to iterate
// over.
auto LinkedRange = at::getAssignmentMarkers(Inst);
+ SmallVector<DPValue *> LinkedDPVAssigns = at::getDPVAssignmentMarkers(Inst);
SmallVector<DbgAssignIntrinsic *> Linked(LinkedRange.begin(),
LinkedRange.end());
- for (auto *DAI : Linked) {
+ auto InsertAssignForOverlap = [&](auto *Assign) {
std::optional<DIExpression::FragmentInfo> NewFragment;
if (!at::calculateFragmentIntersect(DL, OriginalDest, DeadSliceOffsetInBits,
- DeadSliceSizeInBits, DAI,
+ DeadSliceSizeInBits, Assign,
NewFragment) ||
!NewFragment) {
// We couldn't calculate the intersecting fragment for some reason. Be
// cautious and unlink the whole assignment from the store.
- DAI->setKillAddress();
- DAI->setAssignId(GetDeadLink());
- continue;
+ Assign->setKillAddress();
+ Assign->setAssignId(GetDeadLink());
+ return;
}
// No intersect.
if (NewFragment->SizeInBits == 0)
- continue;
+ return;
// Fragments overlap: insert a new dbg.assign for this dead part.
- auto *NewAssign = cast<DbgAssignIntrinsic>(DAI->clone());
- NewAssign->insertAfter(DAI);
+ auto *NewAssign = static_cast<decltype(Assign)>(Assign->clone());
+ NewAssign->insertAfter(Assign);
NewAssign->setAssignId(GetDeadLink());
if (NewFragment)
SetDeadFragExpr(NewAssign, *NewFragment);
NewAssign->setKillAddress();
- }
+ };
+ for_each(Linked, InsertAssignForOverlap);
+ for_each(LinkedDPVAssigns, InsertAssignForOverlap);
}
static bool tryToShorten(Instruction *DeadI, int64_t &DeadStart,
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index c6a2a264582972c..eee60969af9f68a 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -1594,6 +1594,10 @@ static void fixupDebugInfoPostExtraction(Function &OldFunc, Function &NewFunc,
DPVsToDelete.push_back(&DPV);
continue;
}
+ if (DPV.isDbgAssign() && IsInvalidLocation(DPV.getAddress())) {
+ DPVsToDelete.push_back(&DPV);
+ continue;
+ }
if (!DPV.getDebugLoc().getInlinedAt())
DPV.setVariable(GetUpdatedDIVariable(DPV.getVariable()));
DPV.setDebugLoc(DebugLoc::replaceInlinedAtSubprogram(DPV.getDebugLoc(),
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 39d5f6e53c1de48..d4d4bf5ebdf36e1 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1789,13 +1789,15 @@ static at::StorageToVarsMap collectEscapedLocals(const DataLayout &DL,
continue;
// Find all local variables associated with the backing storage.
- for (auto *DAI : at::getAssignmentMarkers(Base)) {
+ auto CollectAssignsForStorage = [&](auto *DbgAssign) {
// Skip variables from inlined functions - they are not local variables.
- if (DAI->getDebugLoc().getInlinedAt())
- continue;
- LLVM_DEBUG(errs() << " > DEF : " << *DAI << "\n");
- EscapedLocals[Base].insert(at::VarRecord(DAI));
- }
+ if (DbgAssign->getDebugLoc().getInlinedAt())
+ return;
+ LLVM_DEBUG(errs() << " > DEF : " << *DbgAssign << "\n");
+ EscapedLocals[Base].insert(at::VarRecord(DbgAssign));
+ };
+ for_each(at::getAssignmentMarkers(Base), CollectAssignsForStorage);
+ for_each(at::getDPVAssignmentMarkers(Base), CollectAssignsForStorage);
}
return EscapedLocals;
}
@@ -1827,6 +1829,10 @@ static void fixupAssignments(Function::iterator Start, Function::iterator End) {
// attachment or use, replace it with a new version.
for (auto BBI = Start; BBI != End; ++BBI) {
for (Instruction &I : *BBI) {
+ for (DPValue &DPV : I.getDbgValueRange()) {
+ if (DPV.isDbgAssign())
+ DPV.setAssignId(GetNewID(DPV.getAssignID()));
+ }
if (auto *ID = I.getMetadata(LLVMContext::MD_DIAssignID))
I.setMetadata(LLVMContext::MD_DIAssignID, GetNewID(ID));
else if (auto *DAI = dyn_cast<DbgAssignIntrinsic>(&I))
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 2a1ac85ee55bf51..459e3d980592833 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1753,7 +1753,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
void llvm::ConvertDebugDeclareToDebugValue(DPValue *DPV, StoreInst *SI,
DIBuilder &Builder) {
- assert(DPV->isAddressOfVariable());
+ assert(DPV->isAddressOfVariable() || DPV->isDbgAssign());
auto *DIVar = DPV->getVariable();
assert(DIVar && "Missing variable");
auto *DIExpr = DPV->getExpression();
@@ -2189,14 +2189,13 @@ void llvm::salvageDebugInfo(Instruction &I) {
salvageDebugInfoForDbgValues(I, DbgUsers, DPUsers);
}
-/// Salvage the address component of \p DAI.
-static void salvageDbgAssignAddress(DbgAssignIntrinsic *DAI) {
- Instruction *I = dyn_cast<Instruction>(DAI->getAddress());
+template <typename T> static void salvageDbgAssignAddress(T *Assign) {
+ Instruction *I = dyn_cast<Instruction>(Assign->getAddress());
// Only instructions can be salvaged at the moment.
if (!I)
return;
- assert(!DAI->getAddressExpression()->getFragmentInfo().has_value() &&
+ assert(!Assign->getAddressExpression()->getFragmentInfo().has_value() &&
"address-expression shouldn't have fragment info");
// The address component of a dbg.assign cannot be variadic.
@@ -2210,16 +2209,16 @@ static void salvageDbgAssignAddress(DbgAssignIntrinsic *DAI) {
return;
DIExpression *SalvagedExpr = DIExpression::appendOpsToArg(
- DAI->getAddressExpression(), Ops, 0, /*StackValue=*/false);
+ Assign->getAddressExpression(), Ops, 0, /*StackValue=*/false);
assert(!SalvagedExpr->getFragmentInfo().has_value() &&
"address-expression shouldn't have fragment info");
// Salvage succeeds if no additional values are required.
if (AdditionalValues.empty()) {
- DAI->setAddress(NewV);
- DAI->setAddressExpression(SalvagedExpr);
+ Assign->setAddress(NewV);
+ Assign->setAddressExpression(SalvagedExpr);
} else {
- DAI->setKillAddress();
+ Assign->setKillAddress();
}
}
@@ -2293,10 +2292,19 @@ void llvm::salvageDebugInfoForDbgValues(
}
// Duplicate of above block for DPValues.
for (auto *DPV : DPUsers) {
+ if (DPV->isDbgAssign()) {
+ if (DPV->getAddress() == &I) {
+ salvageDbgAssignAddress(DPV);
+ Salvaged = true;
+ }
+ if (DPV->getValue() != &I)
+ continue;
+ }
+
// Do not add DW_OP_stack_value for DbgDeclare and DbgAddr, because they
// are implicitly pointing out the value as a DWARF memory location
// description.
- bool StackValue = DPV->getType() == DPValue::LocationType::Value;
+ bool StackValue = DPV->getType() != DPValue::LocationType::Declare;
auto DPVLocation = DPV->location_ops();
assert(
is_contained(DPVLocation, &I) &&
@@ -2330,7 +2338,7 @@ void llvm::salvageDebugInfoForDbgValues(
SalvagedExpr->getNumElements() <= MaxExpressionSize;
if (AdditionalValues.empty() && IsValidSalvageExpr) {
DPV->setExpression(SalvagedExpr);
- } else if (DPV->getType() == DPValue::LocationType::Value &&
+ } else if (DPV->getType() != DPValue::LocationType::Declare &&
IsValidSalvageExpr &&
DPV->getNumVariableLocationOps() + AdditionalValues.size() <=
MaxDebugArgs) {
@@ -2340,8 +2348,7 @@ void llvm::salvageDebugInfoForDbgValues(
// 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());
- DPV->replaceVariableLocationOp(I.getOperand(0), Undef);
+ DPV->setKillLocation();
}
LLVM_DEBUG(dbgs() << "SALVAGE: " << DPV << '\n');
Salvaged = true;
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index 717b6d301c8c90f..88b05aab8db4dfb 100644
--- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -101,12 +101,30 @@ bool llvm::isAllocaPromotable(const AllocaInst *AI) {
namespace {
+static DPValue *createDebugValue(DIBuilder &DIB, Value *NewValue,
+ DILocalVariable *Variable,
+ DIExpression *Expression, const DILocation *DI,
+ DPValue *InsertBefore) {
+ (void)DIB;
+ return DPValue::createDPValue(NewValue, Variable, Expression, DI,
+ *InsertBefore);
+}
+static DbgValueInst *createDebugValue(DIBuilder &DIB, Value *NewValue,
+ DILocalVariable *Variable,
+ DIExpression *Expression,
+ const DILocation *DI,
+ Instruction *InsertBefore) {
+ return static_cast<DbgValueInst *>(DIB.insertDbgValueIntrinsic(
+ NewValue, Variable, Expression, DI, InsertBefore));
+}
+
/// Helper for updating assignment tracking debug info when promoting allocas.
class AssignmentTrackingInfo {
/// DbgAssignIntrinsics linked to the alloca with at most one per variable
/// fragment. (i.e. not be a comprehensive set if there are multiple
/// dbg.assigns for one variable fragment).
SmallVector<DbgVariableIntrinsic *> DbgAssigns;
+ SmallVector<DPValue *> DPVAssigns;
public:
void init(AllocaInst *AI) {
@@ -115,16 +133,21 @@ class AssignmentTrackingInfo {
if (Vars.insert(DebugVariable(DAI)).second)
DbgAssigns.push_back(DAI);
}
+ for (DPValue *DPV : at::getDPVAssignmentMarkers(AI)) {
+ if (Vars.insert(DebugVariable(DPV)).second)
+ DPVAssigns.push_back(DPV);
+ }
}
/// Update assignment tracking debug info given for the to-be-deleted store
/// \p ToDelete that stores to this alloca.
- void updateForDeletedStore(
- StoreInst *ToDelete, DIBuilder &DIB,
- SmallSet<DbgAssignIntrinsic *, 8> *DbgAssignsToDelete) const {
+ void
+ updateForDeletedStore(StoreInst *ToDelete, DIBuilder &DIB,
+ SmallSet<DbgAssignIntrinsic *, 8> *DbgAssignsToDelete,
+ SmallSet<DPValue *, 8> *DPVAssignsToDelete) const {
// There's nothing to do if the alloca doesn't have any variables using
// assignment tracking.
- if (DbgAssigns.empty())
+ if (DbgAssigns.empty() && DPVAssigns.empty())
return;
// Insert a dbg.value where the linked dbg.assign is and remember to delete
@@ -134,13 +157,17 @@ class AssignmentTrackingInfo {
// dbg.assign for each variable fragment for the untracked store handling
// (after this loop).
SmallSet<DebugVariableAggregate, 2> VarHasDbgAssignForStore;
- for (DbgAssignIntrinsic *DAI : at::getAssignmentMarkers(ToDelete)) {
- VarHasDbgAssignForStore.insert(DebugVariableAggregate(DAI));
- DbgAssignsToDelete->insert(DAI);
- DIB.insertDbgValueIntrinsic(DAI->getValue(), DAI->getVariable(),
- DAI->getExpression(), DAI->getDebugLoc(),
- DAI);
- }
+ auto InsertValueForAssign = [&](auto *DbgAssign, auto *&AssignList) {
+ VarHasDbgAssignForStore.insert(DebugVariableAggregate(DbgAssign));
+ AssignList->insert(DbgAssign);
+ createDebugValue(DIB, DbgAssign->getValue(), DbgAssign->getVariable(),
+ DbgAssign->getExpression(), DbgAssign->getDebugLoc(),
+ DbgAssign);
+ };
+ for (auto *Assign : at::getAssignmentMarkers(ToDelete))
+ InsertValueForAssign(Assign, DbgAssignsToDelete);
+ for (auto *Assign : at::getDPVAssignmentMarkers(ToDelete))
+ InsertValueForAssign(Assign, DPVAssignsToDelete);
// It's possible for variables using assignment tracking to have no
// dbg.assign linked to this store. These are variables in DbgAssigns that
@@ -150,11 +177,13 @@ class AssignmentTrackingInfo {
// cannot be represented using assignment tracking (non-const offset or
// size) or one that is trackable but has had its DIAssignID attachment
// dropped accidentally.
- for (auto *DAI : DbgAssigns) {
- if (VarHasDbgAssignForStore.contains(DebugVariableAggregate(DAI)))
- continue;
- ConvertDebugDeclareToDebugValue(DAI, ToDelete, DIB);
- }
+ auto ConvertUnlinkedAssignToValue = [&](auto *Assign) {
+ if (VarHasDbgAssignForStore.contains(DebugVariableAggregate(Assign)))
+ return;
+ ConvertDebugDeclareToDebugValue(Assign, ToDelete, DIB);
+ };
+ for_each(DbgAssigns, ConvertUnlinkedAssignToValue);
+ for_each(DPVAssigns, ConvertUnlinkedAssignToValue);
}
/// Update assignment tracking debug info given for the newly inserted PHI \p
@@ -165,10 +194,15 @@ class AssignmentTrackingInfo {
// debug-phi.
for (auto *DAI : DbgAssigns)
ConvertDebugDeclareToDebugValue(DAI, NewPhi, DIB);
+ for (auto *DPV : DPVAssigns)
+ ConvertDebugDeclareToDebugValue(DPV, NewPhi, DIB);
}
- void clear() { DbgAssigns.clear(); }
- bool empty() { return DbgAssigns.empty(); }
+ void clear() {
+ DbgAssigns.clear();
+ DPVAssigns.clear();
+ }
+ bool empty() { return DbgAssigns.empty() && DPVAssigns.empty(); }
};
struct AllocaInfo {
@@ -229,11 +263,15 @@ struct AllocaInfo {
}
}
DbgUserVec AllDbgUsers;
- findDbgUsers(AllDbgUsers, AI, &DPUsers);
+ SmallVector<DPValue *> AllDPUsers;
+ findDbgUsers(AllDbgUsers, AI, &AllDPUsers);
std::copy_if(AllDbgUsers.begin(), AllDbgUsers.end(),
std::back_inserter(DbgUsers), [](DbgVariableIntrinsic *DII) {
return !isa<DbgAssignIntrinsic>(DII);
});
+ std::copy_if(AllDPUsers.begin(), AllDPUsers.end(),
+ std::back_inserter(DPUsers),
+ [](DPValue *DPV) { return !DPV->isDbgAssign(); });
AssignmentTracking.init(AI);
}
};
@@ -341,6 +379,7 @@ struct PromoteMem2Reg {
/// A set of dbg.assigns to delete because they've been demoted to
/// dbg.values. Call cleanUpDbgAssigns to delete them.
SmallSet<DbgAssignIntrinsic *, 8> DbgAssignsToDelete;
+ SmallSet<DPValue *, 8> DPVAssignsToDelete;
/// The set of basic blocks the renamer has already visited.
SmallPtrSet<BasicBlock *, 16> Visited;
@@ -390,6 +429,9 @@ struct PromoteMem2Reg {
for (auto *DAI : DbgAssignsToDelete)
DAI->eraseFromParent();
DbgAssignsToDelete.clear();
+ for (auto *DPV : DPVAssignsToDelete)
+ DPV->eraseFromParent();
+ DPVAssignsToDelete.clear();
}
};
@@ -462,10 +504,12 @@ static void removeIntrinsicUsers(AllocaInst *AI) {
/// false there were some loads which were not dominated by the single store
/// and thus must be phi-ed with undef. We fall back to the standard alloca
/// promotion algorithm in that case.
-static bool rewriteSingleStoreAlloca(
- AllocaInst *AI, AllocaInfo &Info, LargeBlockInfo &LBI, const DataLayout &DL,
- DominatorTree &DT, AssumptionCache *AC,
- SmallSet<DbgAssignIntrinsic *, 8> *DbgAssignsToDelete) {
+static bool
+rewriteSingleStoreAlloca(AllocaInst *AI, AllocaInfo &Info, LargeBlockInfo &LBI,
+ const DataLayout &DL, DominatorTree &DT,
+ AssumptionCache *AC,
+ SmallSet<DbgAssignIntrinsic *, 8> *DbgAssignsToDelete,
+ SmallSet<DPValue *, 8> *DPVAssignsToDelete) {
StoreInst *OnlyStore = Info.OnlyStore;
bool StoringGlobalVal = !isa<Instruction>(OnlyStore->getOperand(0));
BasicBlock *StoreBB = OnlyStore->getParent();
@@ -525,8 +569,8 @@ static bool rewriteSingleStoreAlloca(
DIBuilder DIB(*AI->getModule(), /*AllowUnresolved*/ false);
// Update assignment tracking info for the store we're going to delete.
- Info.AssignmentTracking.updateForDeletedStore(Info.OnlyStore, DIB,
- DbgAssignsToDelete);
+ Info.AssignmentTracking.updateForDeletedStore(
+ Info.OnlyStore, DIB, DbgAssignsToDelete, DPVAssignsToDelete);
// Record debuginfo for the store and remove the declaration's
// debuginfo.
@@ -570,10 +614,12 @@ static bool rewriteSingleStoreAlloca(
/// use(t);
/// *A = 42;
/// }
-static bool promoteSingleBlockAlloca(
- AllocaInst *AI, const AllocaInfo &Info, LargeBlockInfo &LBI,
- const DataLayout &DL, DominatorTree &DT, AssumptionCache *AC,
- SmallSet<DbgAssignIntrinsic *, 8> *DbgAssignsToDelete) {
+static bool
+promoteSingleBlockAlloca(AllocaInst *AI, const AllocaInfo &Info,
+ LargeBlockInfo &LBI, const DataLayout &DL,
+ DominatorTree &DT, AssumptionCache *AC,
+ SmallSet<DbgAssignIntrinsic *, 8> *DbgAssignsToDelete,
+ SmallSet<DPValue *, 8> *DPVAssignsToDelete) {
// The trickiest case to handle is when we have large blocks. Because of this,
// this code is optimized assuming that large blocks happen. This does not
// significantly pessimize the small block case. This uses LargeBlockInfo to
@@ -637,8 +683,8 @@ static bool promoteSingleBlockAlloca(
while (!AI->use_empty()) {
StoreInst *SI = cast<StoreInst>(AI->user_back());
// Update assignment tracking info for the store we're going to delete.
- Info.AssignmentTracking.updateForDeletedStore(SI, DIB, DbgAssignsToDelete);
-
+ Info.AssignmentTracking.updateForDeletedStore(SI, DIB, DbgAssignsToDelete,
+ DPVAssignsToDelete);
// Record debuginfo for the store before removing it.
auto DbgUpdateForStore = [&](auto &Container) {
for (auto *DbgItem : Container) {
@@ -710,7 +756,7 @@ void PromoteMem2Reg::run() {
// it that are directly dominated by the definition with the value stored.
if (Info.DefiningBlocks.size() == 1) {
if (rewriteSingleStoreAlloca(AI, Info, LBI, SQ.DL, DT, AC,
- &DbgAssignsToDelete)) {
+ &DbgAssignsToDelete, &DPVAssignsToDelete)) {
// The alloca has been processed, move on.
RemoveFromAllocasList(AllocaNum);
++NumSingleStore;
@@ -722,7 +768,7 @@ void PromoteMem2Reg::run() {
// linear sweep over the block to eliminate it.
if (Info.OnlyUsedInOneBlock &&
promoteSingleBlockAlloca(AI, Info, LBI, SQ.DL, DT, AC,
- &DbgAssignsToDelete)) {
+ &DbgAssignsToDelete, &DPVAssignsToDelete)) {
// The alloca has been processed, move on.
RemoveFromAllocasList(AllocaNum);
continue;
@@ -1128,8 +1174,8 @@ void PromoteMem2Reg::RenamePass(BasicBlock *BB, BasicBlock *Pred,
// Record debuginfo for the store before removing it.
IncomingLocs[AllocaNo] = SI->getDebugLoc();
- AllocaATInfo[AllocaNo].updateForDeletedStore(SI, DIB,
- &DbgAssignsToDelete);
+ AllocaATInfo[AllocaNo].updateForDeletedStore(SI, DIB, &DbgAssignsToDelete,
+ &DPVAssignsToDelete);
auto ConvertDbgDeclares = [&](auto &Container) {
for (auto *DbgItem : Container)
if (DbgItem->isAddressOfVariable())
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index f3994b6cc39fefb..13eae549b2ce41b 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1770,6 +1770,11 @@ bool SimplifyCFGOpt::hoistSuccIdenticalTerminatorToSwitchOrIf(
Locs.push_back(I1->getDebugLoc());
for (auto *OtherSuccTI : OtherSuccTIs)
Locs.push_back(OtherSuccTI->getDebugLoc());
+ // Also clone DPValues from the existing terminator, and all others (to
+ // duplicate existing hoisting behaviour).
+ NT->cloneDebugInfoFrom(I1);
+ for (Instruction *OtherSuccTI : OtherSuccTIs)
+ NT->cloneDebugInfoFrom(OtherSuccTI);
NT->setDebugLoc(DILocation::getMergedLocations(Locs));
// PHIs created below will adopt NT's merged DebugLoc.
@@ -3101,10 +3106,12 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI,
// %merge = select %cond, %two, %one
// store %merge, %x.dest, !DIAssignID !2
// dbg.assign %merge, "x", ..., !2
- for (auto *DAI : at::getAssignmentMarkers(SpeculatedStore)) {
- if (llvm::is_contained(DAI->location_ops(), OrigV))
- DAI->replaceVariableLocationOp(OrigV, S);
- }
+ auto replaceVariable = [OrigV, S](auto *DbgAssign) {
+ if (llvm::is_contained(DbgAssign->location_ops(), OrigV))
+ DbgAssign->replaceVariableLocationOp(OrigV, S);
+ };
+ for_each(at::getAssignmentMarkers(SpeculatedStore), replaceVariable);
+ for_each(at::getDPVAssignmentMarkers(SpeculatedStore), replaceVariable);
}
// Metadata can be dependent on the condition we are hoisting above.
@@ -3133,7 +3140,9 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI,
// instructions, in the same way that dbg.value intrinsics are dropped at the
// end of this block.
for (auto &It : make_range(ThenBB->begin(), ThenBB->end()))
- It.dropDbgValues();
+ for (DPValue &DPV : make_early_inc_range(It.getDbgValueRange()))
+ if (!DPV.isDbgAssign())
+ It.dropOneDbgValue(&DPV);
BB->splice(BI->getIterator(), ThenBB, ThenBB->begin(),
std::prev(ThenBB->end()));
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index 71d0f09e47713b3..380541ffdd49d6e 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -544,6 +544,16 @@ void Mapper::remapDPValue(DPValue &V) {
V.setVariable(cast<DILocalVariable>(MappedVar));
V.setDebugLoc(DebugLoc(cast<DILocation>(MappedDILoc)));
+ bool IgnoreMissingLocals = Flags & RF_IgnoreMissingLocals;
+
+ if (V.isDbgAssign()) {
+ auto *NewAddr = mapValue(V.getAddress());
+ if (!IgnoreMissingLocals && !NewAddr)
+ V.setKillAddress();
+ else if (NewAddr)
+ V.setAddress(NewAddr);
+ }
+
// Find Value operands and remap those.
SmallVector<Value *, 4> Vals, NewVals;
for (Value *Val : V.location_ops())
@@ -555,8 +565,6 @@ void Mapper::remapDPValue(DPValue &V) {
if (Vals == NewVals)
return;
- bool IgnoreMissingLocals = Flags & RF_IgnoreMissingLocals;
-
// Otherwise, do some replacement.
if (!IgnoreMissingLocals &&
llvm::any_of(NewVals, [&](Value *V) { return V == nullptr; })) {
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 482970bbf306120..809d740aae3e097 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -12988,8 +12988,8 @@ void BoUpSLP::scheduleBlock(BlockScheduling *BS) {
for (ScheduleData *BundleMember = Picked; BundleMember;
BundleMember = BundleMember->NextInBundle) {
Instruction *PickedInst = BundleMember->Inst;
- if (PickedInst->getNextNode() != LastScheduledInst)
- PickedInst->moveBefore(LastScheduledInst);
+ if (PickedInst->getNextNonDebugInstruction() != LastScheduledInst)
+ PickedInst->moveAfter(LastScheduledInst->getPrevNode());
LastScheduledInst = PickedInst;
}
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/adce/no-delete.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/adce/no-delete.ll
index 8fce6ab629666fa..93931c6f68e3407 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/adce/no-delete.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/adce/no-delete.ll
@@ -1,5 +1,7 @@
; RUN: opt %s -passes=adce -S -o - \
; RUN: | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators %s -passes=adce -S -o - \
+; RUN: | FileCheck %s
;; $ cat test.c
;; void fun(int local) {}
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/dse/dse-after-memcpyopt-merge.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/dse/dse-after-memcpyopt-merge.ll
index f1704f4bcc98bf4..5c92b1aa2b36fe6 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/dse/dse-after-memcpyopt-merge.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/dse/dse-after-memcpyopt-merge.ll
@@ -1,4 +1,5 @@
; RUN: opt %s -S -passes=dse -o - | FileCheck %s --implicit-check-not="call void @llvm.dbg"
+; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=dse -o - | FileCheck %s --implicit-check-not="call void @llvm.dbg"
;; Observed in the wild, but test is created by running memcpyopt on
;; assignment-tracking/memcpyopt/merge-stores.ll then manually inserting
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/dse/shorten-offset.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/dse/shorten-offset.ll
index b6dc56acf7636f2..c7420dfa31775c4 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/dse/shorten-offset.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/dse/shorten-offset.ll
@@ -1,4 +1,5 @@
; RUN: opt %s -S -passes=dse -o - | FileCheck %s --implicit-check-not="call void @llvm.dbg"
+; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=dse -o - | FileCheck %s --implicit-check-not="call void @llvm.dbg"
;; Based on the test shorten.ll with some adjustments.
;;
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/dse/shorten.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/dse/shorten.ll
index 37d22f4df576a2e..a2cf5923d680f95 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/dse/shorten.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/dse/shorten.ll
@@ -1,4 +1,5 @@
; RUN: opt %s -S -passes=dse -o - | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=dse -o - | FileCheck %s
;; $ cat test.cpp
;; void esc(int*);
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/inline/id.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/inline/id.ll
index 51d9511ec17b91c..7260ec54360d140 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/inline/id.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/inline/id.ll
@@ -1,5 +1,5 @@
-; RUN: opt %s -S -passes=inline -o - \
-; RUN: | FileCheck %s
+; RUN: opt %s -S -passes=inline -o - | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=inline -o - | FileCheck %s
;; Check that all DIAssignID metadata that are inlined are replaced with new
;; versions. Otherwise two inlined instances of an assignment will be considered
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/inline/inline-stores.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/inline/inline-stores.ll
index 4d4a62947177cf0..1b004011af839e1 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/inline/inline-stores.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/inline/inline-stores.ll
@@ -1,5 +1,7 @@
; RUN: opt -passes=inline %s -S -o - \
; RUN: | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -passes=inline %s -S -o - \
+; RUN: | FileCheck %s
;; $ cat test.cpp
;; __attribute__((always_inline))
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/inline/shared-alloca.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/inline/shared-alloca.ll
index e77a3a58bdad2e9..33bc2f196872f0b 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/inline/shared-alloca.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/inline/shared-alloca.ll
@@ -1,5 +1,7 @@
; RUN: opt -S %s -passes=inline -o - \
; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
+; RUN: opt --try-experimental-debuginfo-iterators -S %s -passes=inline -o - \
+; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
;; The dbg.assign linked to the large alloca describes a variable sitting at
;; offset 0, size 64. Check:
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/inline/use-before-def.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/inline/use-before-def.ll
index 84f00d5dd7a69a4..ff7e5b18a9439ca 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/inline/use-before-def.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/inline/use-before-def.ll
@@ -1,5 +1,7 @@
; RUN: opt -passes=inline %s -S -o - \
; RUN: | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -passes=inline %s -S -o - \
+; RUN: | FileCheck %s
;; Hand modified from:
;; $ cat test.c
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/do-not-remove-redundant-dbg.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/do-not-remove-redundant-dbg.ll
index f14a6e63b63f0a4..9763064dac2b054 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/do-not-remove-redundant-dbg.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/do-not-remove-redundant-dbg.ll
@@ -1,5 +1,7 @@
; RUN: opt -passes=instcombine -S %s -o - \
; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
+; RUN: opt --try-experimental-debuginfo-iterators -passes=instcombine -S %s -o - \
+; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
;; Based on the test remove-redundant-dbg.ll.
;;
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/memset.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/memset.ll
index b3a529597e20af9..3e343ceb3d1bd32 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/memset.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/memset.ll
@@ -1,5 +1,7 @@
; RUN: opt %s -S -passes=instcombine -o - \
; RUN: | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=instcombine -o - \
+; RUN: | FileCheck %s
;; $ cat test.cpp
;; void esc(int*);
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/sink-store.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/sink-store.ll
index 697df132b086dc1..668e9567e4fe4fd 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/sink-store.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/sink-store.ll
@@ -1,4 +1,5 @@
; RUN: opt %s -S -passes=instcombine | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=instcombine | FileCheck %s
;; Check that instcombine merges the DIAssignID metadata when merging two
;; stores into a successor. Filecheck directives inline.
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/sink.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/sink.ll
index cdbf876fdfaf918..f233e9ff704bb26 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/sink.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/sink.ll
@@ -1,5 +1,7 @@
; RUN: opt %s -S -passes=instcombine -o - \
; RUN: | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=instcombine -o - \
+; RUN: | FileCheck %s
;; Check that when instcombine sinks an instruction used by a dbg.assign, the
;; usual debug intrinsic updating doesn't take place (i.e. do not
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/store-new-type.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/store-new-type.ll
index cbd35af94c51230..cf427323dc2e574 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/store-new-type.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/store-new-type.ll
@@ -1,4 +1,5 @@
; RUN: opt %s -passes=instcombine -S | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators %s -passes=instcombine -S | FileCheck %s
;; Based on test/Transforms/InstCombine/shufflevec-bitcast.ll in which the
;; store of <4 x i4> is replaced with a store of type <2 x i8>. Debug info
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/storemerge.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/storemerge.ll
index ce0c88775e5bdd2..c0ef6750d785f3f 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/storemerge.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/instcombine/storemerge.ll
@@ -1,4 +1,5 @@
; RUN: opt %s -S -passes=instcombine -o - | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=instcombine -o - | FileCheck %s
;; $ cat test.cpp
;; class a {
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/licm/merge.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/licm/merge.ll
index e4db307b14ebe37..187194dd9326181 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/licm/merge.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/licm/merge.ll
@@ -1,4 +1,5 @@
; RUN: opt -passes=licm %s -S | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -passes=licm %s -S | FileCheck %s
;; Ensure that we correctly merge the DIAssignID's from the sunk stores, add it
;; to the new new store instruction, and update the dbg.assign intrinsics using
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/licm/multi-exit.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/licm/multi-exit.ll
index 9f8723bd1ddedfc..5684f4d42a8a5e8 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/licm/multi-exit.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/licm/multi-exit.ll
@@ -1,4 +1,5 @@
; RUN: opt %s -S -passes=licm -o - | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=licm -o - | FileCheck %s
;; $ cat test.c
;; int b, c, d;
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/loop-deletion/dead-loop.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/loop-deletion/dead-loop.ll
index 0e3a700246279bd..afd5b1837053584 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/loop-deletion/dead-loop.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/loop-deletion/dead-loop.ll
@@ -1,5 +1,7 @@
; RUN: opt %s -passes=loop-deletion -S -o - \
; RUN: | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators %s -passes=loop-deletion -S -o - \
+; RUN: | FileCheck %s
;; $ cat test.cpp:
;; void esc(int*);
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/phi.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/phi.ll
index d7c1299788703e8..8a72377c6375f37 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/phi.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/phi.ll
@@ -1,5 +1,7 @@
; RUN: opt -passes=mem2reg -S %s -o - \
; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
+; RUN: opt --try-experimental-debuginfo-iterators -passes=mem2reg -S %s -o - \
+; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
;; Test assignment tracking debug info when mem2reg promotes an alloca with
;; stores requiring insertion of a phi. Check the output when the stores are
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/single-block-alloca.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/single-block-alloca.ll
index 26e61cd50e45179..e3cbe89dceecb47 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/single-block-alloca.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/single-block-alloca.ll
@@ -1,5 +1,7 @@
; RUN: opt -passes=mem2reg -S %s -o - \
; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
+; RUN: opt --try-experimental-debuginfo-iterators -passes=mem2reg -S %s -o - \
+; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
;; Test assignment tracking debug info when mem2reg promotes a single-block
;; alloca. Check the output when the stores are tagged and also untagged (test
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/single-store-alloca.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/single-store-alloca.ll
index ea8f0b8a10e8cba..1753ca5644e3e1a 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/single-store-alloca.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/single-store-alloca.ll
@@ -1,5 +1,7 @@
; RUN: opt -passes=mem2reg -S %s -o - \
; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
+; RUN: opt --try-experimental-debuginfo-iterators -passes=mem2reg -S %s -o - \
+; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
;; Test assignment tracking debug info when mem2reg promotes a single-store
;; alloca. Additionally, check that all the dbg.assigns linked to the alloca
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/store-to-part-of-alloca.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/store-to-part-of-alloca.ll
index 5cf673cde262963..7242c4eafafce7d 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/store-to-part-of-alloca.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/store-to-part-of-alloca.ll
@@ -1,4 +1,5 @@
; RUN: opt -passes=mem2reg -S %s -o - | FileCheck %s --implicit-check-not="call void @llvm.dbg"
+; RUN: opt --try-experimental-debuginfo-iterators -passes=mem2reg -S %s -o - | FileCheck %s --implicit-check-not="call void @llvm.dbg"
; CHECK: llvm.dbg.value(metadata i64 0, metadata ![[#]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32))
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/memcpyopt/merge-stores.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/memcpyopt/merge-stores.ll
index ed4f1dd1b628df8..b62f1966d961e57 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/memcpyopt/merge-stores.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/memcpyopt/merge-stores.ll
@@ -1,4 +1,5 @@
; RUN: opt %s -S -passes=memcpyopt -o - | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=memcpyopt -o - | FileCheck %s
;; $ cat test.cpp
;; struct v {
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/mldst-motion/diamond.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/mldst-motion/diamond.ll
index ae86e747fc389b5..395c5b581c84c26 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/mldst-motion/diamond.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/mldst-motion/diamond.ll
@@ -1,5 +1,7 @@
; RUN: opt -passes=mldst-motion -S %s -o - \
; RUN: | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -passes=mldst-motion -S %s -o - \
+; RUN: | FileCheck %s
;; $ cat test.cpp
;; int cond;
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/instruction-type.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/instruction-type.ll
index 2ca9f0d431afdb0..95cba59a987e99f 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/instruction-type.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/instruction-type.ll
@@ -1,5 +1,7 @@
; RUN: opt -S %s -passes=verify 2>&1 \
; RUN: | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -S %s -passes=verify 2>&1 \
+; RUN: | FileCheck %s
;; NOTE: Expect opt to return zero because the badly formed debug info
;; is going to be stripped.
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/verify.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/verify.ll
index 0a4b7c255dc7180..55ad1814463fb89 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/verify.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/verify.ll
@@ -1,5 +1,7 @@
; RUN: opt %s -S -passes=verify 2>&1 \
; RUN: | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=verify 2>&1 \
+; RUN: | FileCheck %s
;; Check that badly formed assignment tracking metadata is caught either
;; while parsing or by the verifier.
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/remove-redundant-fwd-scan-linked.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/remove-redundant-fwd-scan-linked.ll
index 0d9c6021a5302c2..d2cc9d9180fc4f5 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/remove-redundant-fwd-scan-linked.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/remove-redundant-fwd-scan-linked.ll
@@ -1,5 +1,7 @@
; RUN: opt -passes=redundant-dbg-inst-elim -S %s -o - \
; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
+; RUN: opt --try-experimental-debuginfo-iterators -passes=redundant-dbg-inst-elim -S %s -o - \
+; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
;; $ cat -n reduce.c
;; 1 void ext();
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/salvage-value.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/salvage-value.ll
index ba591b1aa5425d4..3c1ef0791945ffb 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/salvage-value.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/salvage-value.ll
@@ -1,5 +1,7 @@
; RUN: opt %s -S -o - -passes=instcombine \
; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
+; RUN: opt --try-experimental-debuginfo-iterators %s -S -o - -passes=instcombine \
+; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
;; Hand-written (the debug info doesn't necessarily make sense and isn't fully
;; formed). Test salvaging a dbg.assign value and address. Checks and comments
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/simplifycfg/empty-block.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/simplifycfg/empty-block.ll
index e4a22dc1d7026ea..338625eb27f76e6 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/simplifycfg/empty-block.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/simplifycfg/empty-block.ll
@@ -1,5 +1,7 @@
; RUN: opt -S %s -passes=simplifycfg -o - \
; RUN: | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -S %s -passes=simplifycfg -o - \
+; RUN: | FileCheck %s
;; $ cat test.cpp
;; class a {};
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/simplifycfg/speculated-store.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/simplifycfg/speculated-store.ll
index fd0110d16912ce1..7b1a80540c48a69 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/simplifycfg/speculated-store.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/simplifycfg/speculated-store.ll
@@ -1,5 +1,7 @@
; RUN: opt -passes=simplifycfg %s -S \
; RUN: | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -passes=simplifycfg %s -S \
+; RUN: | FileCheck %s
;; Ensure that we correctly update the value component of dbg.assign intrinsics
;; after merging a conditional block with a store its the predecessor. The
diff --git a/llvm/test/DebugInfo/Generic/assignment-tracking/slp-vectorizer/merge-scalars.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/slp-vectorizer/merge-scalars.ll
index d675300395acf9c..ab1e1e966139b62 100644
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/slp-vectorizer/merge-scalars.ll
+++ b/llvm/test/DebugInfo/Generic/assignment-tracking/slp-vectorizer/merge-scalars.ll
@@ -1,6 +1,8 @@
; REQUIRES: x86-registered-target
; RUN: opt -passes=slp-vectorizer -S -o - %s \
; RUN: | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -passes=slp-vectorizer -S -o - %s \
+; RUN: | FileCheck %s
;; $ cat test.cpp
;; float get();
diff --git a/llvm/test/Transforms/HotColdSplit/invalid-dbg-assign.ll b/llvm/test/Transforms/HotColdSplit/invalid-dbg-assign.ll
index 3163fc7071e978a..74a096019c66473 100644
--- a/llvm/test/Transforms/HotColdSplit/invalid-dbg-assign.ll
+++ b/llvm/test/Transforms/HotColdSplit/invalid-dbg-assign.ll
@@ -1,4 +1,5 @@
; RUN: opt -passes=hotcoldsplit -hotcoldsplit-threshold=-1 -S %s | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -passes=hotcoldsplit -hotcoldsplit-threshold=-1 -S %s | FileCheck %s
declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
; CHECK: define void @foo
>From 62ac1a3f3bbc01d0220238666a0ade667c2964e9 Mon Sep 17 00:00:00 2001
From: Stephen Tozer <Stephen.Tozer at Sony.com>
Date: Tue, 23 Jan 2024 15:46:19 +0000
Subject: [PATCH 2/2] Remove outdated comment
---
llvm/lib/Transforms/Utils/CodeExtractor.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index eee60969af9f68a..278111883459b37 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -1589,7 +1589,6 @@ static void fixupDebugInfoPostExtraction(Function &OldFunc, Function &NewFunc,
for (auto &DPV : I.getDbgValueRange()) {
// Apply the two updates that dbg.values get: invalid operands, and
// variable metadata fixup.
- // FIXME: support dbg.assign form of DPValues.
if (any_of(DPV.location_ops(), IsInvalidLocation)) {
DPVsToDelete.push_back(&DPV);
continue;
More information about the llvm-commits
mailing list