aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/contrib/llvm-project/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 203fcdfc87d9..250ad19902f0 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/contrib/llvm-project/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,