[llvm] 83f7f86 - [NFC][Assignment Tracking] Add is/setKillAddress
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 12 01:46:37 PST 2023
Author: OCHyams
Date: 2023-01-12T09:46:01Z
New Revision: 83f7f86e7d4d122f0e8e1f7f497a2c8705ae2483
URL: https://github.com/llvm/llvm-project/commit/83f7f86e7d4d122f0e8e1f7f497a2c8705ae2483
DIFF: https://github.com/llvm/llvm-project/commit/83f7f86e7d4d122f0e8e1f7f497a2c8705ae2483.diff
LOG: [NFC][Assignment Tracking] Add is/setKillAddress
Unlike D140903 this patch folds in treating an empty metadata address component
of a dbg.assign the same as undef because it was already being treated that way
in the AssignmentTrackingAnalysis pass.
Reviewed By: scott.linder
Differential Revision: https://reviews.llvm.org/D141125
Added:
Modified:
llvm/include/llvm/IR/IntrinsicInst.h
llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
llvm/lib/IR/IntrinsicInst.cpp
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/lib/Transforms/Utils/Local.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/IntrinsicInst.h b/llvm/include/llvm/IR/IntrinsicInst.h
index 3928b02134535..2f5b4cfc05e17 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -440,6 +440,13 @@ class DbgAssignIntrinsic : public DbgValueInst {
}
void setAssignId(DIAssignID *New);
void setAddress(Value *V);
+ /// Kill the address component.
+ void setKillAddress();
+ /// Check whether this kills the address component. This doesn't take into
+ /// account the position of the intrinsic, therefore a returned value of false
+ /// does not guarentee the address is a valid location for the variable at the
+ /// intrinsic's position in IR.
+ bool isKillAddress() const;
void setValue(Value *V);
/// \name Casting methods
/// @{
diff --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
index f553da4ae5e7c..bf421a4054c01 100644
--- a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
+++ b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
@@ -1263,7 +1263,11 @@ void AssignmentTrackingLowering::emitDbgValue(
const auto *DAI = cast<DbgAssignIntrinsic>(Source);
// Check the address hasn't been dropped (e.g. the debug uses may not have
// been replaced before deleting a Value).
- if (Value *Val = DAI->getAddress()) {
+ if (DAI->isKillAddress()) {
+ // The address isn't valid so treat this as a non-memory def.
+ Kind = LocKind::Val;
+ } else {
+ Value *Val = DAI->getAddress();
DIExpression *Expr = DAI->getAddressExpression();
assert(!Expr->getFragmentInfo() &&
"fragment info should be stored in value-expression only");
@@ -1279,9 +1283,6 @@ void AssignmentTrackingLowering::emitDbgValue(
walkToAllocaAndPrependOffsetDeref(Layout, Val, Expr);
Emit(Val, Expr);
return;
- } else {
- // The address isn't valid so treat this as a non-memory def.
- Kind = LocKind::Val;
}
}
@@ -1483,11 +1484,10 @@ void AssignmentTrackingLowering::processDbgAssign(DbgAssignIntrinsic &DAI,
// that an assignment happened here, and we know that specific assignment
// was the last one to take place in memory for this variable.
LocKind Kind;
- if (isa<UndefValue>(DAI.getAddress())) {
- // Address may be undef to indicate that although the store does take
- // place, this part of the original store has been elided.
+ if (DAI.isKillAddress()) {
LLVM_DEBUG(
- dbgs() << "Val, Stack matches Debug program but address is undef\n";);
+ dbgs()
+ << "Val, Stack matches Debug program but address is killed\n";);
Kind = LocKind::Val;
} else {
LLVM_DEBUG(dbgs() << "Mem, Stack matches Debug program\n";);
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 6fd59d8070ae4..b258e7bd31541 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -212,6 +212,17 @@ void DbgAssignIntrinsic::setAddress(Value *V) {
MetadataAsValue::get(getContext(), ValueAsMetadata::get(V)));
}
+void DbgAssignIntrinsic::setKillAddress() {
+ if (isKillAddress())
+ return;
+ setAddress(UndefValue::get(getAddress()->getType()));
+}
+
+bool DbgAssignIntrinsic::isKillAddress() const {
+ Value *Addr = getAddress();
+ return !Addr || isa<UndefValue>(Addr);
+}
+
void DbgAssignIntrinsic::setValue(Value *V) {
setOperand(OpValue,
MetadataAsValue::get(getContext(), ValueAsMetadata::get(V)));
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 777fd5dc64242..9c0b4d6731459 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -520,7 +520,7 @@ static void shortenAssignment(Instruction *Inst, uint64_t OldOffsetInBits,
LinkToNothing = DIAssignID::getDistinct(Inst->getContext());
NewAssign->setAssignId(LinkToNothing);
NewAssign->setExpression(CreateDeadFragExpr());
- NewAssign->setAddress(UndefValue::get(DAI->getAddress()->getType()));
+ NewAssign->setKillAddress();
}
}
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index cd9ee04f852b0..d5d0232d7c1e8 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1842,7 +1842,7 @@ static void salvageDbgAssignAddress(DbgAssignIntrinsic *DAI) {
DAI->setAddress(NewV);
DAI->setAddressExpression(SalvagedExpr);
} else {
- DAI->setAddress(UndefValue::get(I->getType()));
+ DAI->setKillAddress();
}
}
More information about the llvm-commits
mailing list