[llvm] [IR] Remove unused debug intrinsic methods (NFC) (PR #231075)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 11 23:20:54 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
DbgVariableIntrinsic::replaceVariableLocationOp(unsigned, Value *),
DbgVariableIntrinsic::setKillLocation, and
DbgVariableIntrinsic::setRawLocation: The last callers were removed on
July 18, 2025 in commit c9d8b68676dbf51996a76475313088f750697343.
DbgVariableIntrinsic::addVariableLocationOps,
DbgAssignIntrinsic::setAddressExpression, and
DbgAssignIntrinsic::setKillAddress: The last callers were removed on
July 18, 2025 in commit 2a1869b9815c1f59af9eae91a3ef7e7d78e8f4f2,
leaving DbgAssignIntrinsic::isKillAddress unused as well.
DbgVariableIntrinsic::setVariable and DbgLabelInst::setLabel: The last
callers were removed on June 17, 2025 in commit
9eb0020555fc643582b2802abb8c1bc92059c248.
DbgVariableIntrinsic::isAddressOfVariable: The last caller was removed
on July 21, 2025 in commit c9ceb9b75fd547c7d2e79837075370f4c8db8faa.
Assisted-by: Antigravity
---
Full diff: https://github.com/llvm/llvm-project/pull/231075.diff
2 Files Affected:
- (modified) llvm/include/llvm/IR/IntrinsicInst.h (-50)
- (modified) llvm/lib/IR/IntrinsicInst.cpp (-46)
``````````diff
diff --git a/llvm/include/llvm/IR/IntrinsicInst.h b/llvm/include/llvm/IR/IntrinsicInst.h
index 7d0bb92114e84..5768e959e8872 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -324,16 +324,6 @@ class DbgVariableIntrinsic : public DbgInfoIntrinsic {
LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue,
bool AllowEmpty = false);
- LLVM_ABI void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue);
- /// Adding a new location operand will always result in this intrinsic using
- /// an ArgList, and must always be accompanied by a new expression that uses
- /// the new operand.
- LLVM_ABI void addVariableLocationOps(ArrayRef<Value *> NewValues,
- DIExpression *NewExpr);
-
- void setVariable(DILocalVariable *NewVar) {
- setArgOperand(1, MetadataAsValue::get(NewVar->getContext(), NewVar));
- }
void setExpression(DIExpression *NewExpr) {
setArgOperand(2, MetadataAsValue::get(NewExpr->getContext(), NewExpr));
@@ -345,13 +335,6 @@ class DbgVariableIntrinsic : public DbgInfoIntrinsic {
bool hasArgList() const { return getWrappedLocation().hasArgList(); }
- /// Does this describe the address of a local variable. True for dbg.declare,
- /// but not dbg.value, which describes its value, or dbg.assign, which
- /// describes a combination of the variable's value and address.
- bool isAddressOfVariable() const {
- return getIntrinsicID() == Intrinsic::dbg_declare;
- }
-
/// Determine if this describes the value of a local variable. It is true for
/// dbg.value, but false for dbg.declare, which describes its address, and
/// false for dbg.assign, which describes a combination of the variable's
@@ -360,18 +343,6 @@ class DbgVariableIntrinsic : public DbgInfoIntrinsic {
return getIntrinsicID() == Intrinsic::dbg_value;
}
- void setKillLocation() {
- // TODO: When/if we remove duplicate values from DIArgLists, we don't need
- // this set anymore.
- SmallPtrSet<Value *, 4> RemovedValues;
- for (Value *OldValue : location_ops()) {
- if (!RemovedValues.insert(OldValue).second)
- continue;
- Value *Poison = PoisonValue::get(OldValue->getType());
- replaceVariableLocationOp(OldValue, Poison);
- }
- }
-
bool isKillLocation() const {
return getWrappedLocation().isKillLocation(getExpression());
}
@@ -400,13 +371,6 @@ class DbgVariableIntrinsic : public DbgInfoIntrinsic {
return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
}
- /// Use of this should generally be avoided; instead,
- /// replaceVariableLocationOp and addVariableLocationOps should be used where
- /// possible to avoid creating invalid state.
- void setRawLocation(Metadata *Location) {
- return setArgOperand(0, MetadataAsValue::get(getContext(), Location));
- }
-
/// Get the size (in bits) of the variable, or fragment of the variable that
/// is described.
LLVM_ABI std::optional<uint64_t> getFragmentSizeInBits() const;
@@ -522,19 +486,8 @@ class DbgAssignIntrinsic : public DbgValueInst {
DIExpression *getAddressExpression() const {
return cast<DIExpression>(getRawAddressExpression());
}
- void setAddressExpression(DIExpression *NewExpr) {
- setArgOperand(OpAddressExpr,
- MetadataAsValue::get(NewExpr->getContext(), NewExpr));
- }
LLVM_ABI void setAssignId(DIAssignID *New);
LLVM_ABI void setAddress(Value *V);
- /// Kill the address component.
- LLVM_ABI 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.
- LLVM_ABI bool isKillAddress() const;
LLVM_ABI void setValue(Value *V);
/// \name Casting methods
/// @{
@@ -551,9 +504,6 @@ class DbgAssignIntrinsic : public DbgValueInst {
class DbgLabelInst : public DbgInfoIntrinsic {
public:
DILabel *getLabel() const { return cast<DILabel>(getRawLabel()); }
- void setLabel(DILabel *NewLabel) {
- setArgOperand(0, MetadataAsValue::get(getContext(), NewLabel));
- }
Metadata *getRawLabel() const {
return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 684aaf1a8f2d3..4c4c460758f55 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -160,41 +160,6 @@ void DbgVariableIntrinsic::replaceVariableLocationOp(Value *OldValue,
setArgOperand(
0, MetadataAsValue::get(getContext(), DIArgList::get(getContext(), MDs)));
}
-void DbgVariableIntrinsic::replaceVariableLocationOp(unsigned OpIdx,
- Value *NewValue) {
- assert(OpIdx < getNumVariableLocationOps() && "Invalid Operand Index");
- if (!hasArgList()) {
- Value *NewOperand = isa<MetadataAsValue>(NewValue)
- ? NewValue
- : MetadataAsValue::get(
- getContext(), ValueAsMetadata::get(NewValue));
- return setArgOperand(0, NewOperand);
- }
- SmallVector<ValueAsMetadata *, 4> MDs;
- ValueAsMetadata *NewOperand = getAsMetadata(NewValue);
- for (unsigned Idx = 0; Idx < getNumVariableLocationOps(); ++Idx)
- MDs.push_back(Idx == OpIdx ? NewOperand
- : getAsMetadata(getVariableLocationOp(Idx)));
- setArgOperand(
- 0, MetadataAsValue::get(getContext(), DIArgList::get(getContext(), MDs)));
-}
-
-void DbgVariableIntrinsic::addVariableLocationOps(ArrayRef<Value *> NewValues,
- DIExpression *NewExpr) {
- assert(NewExpr->hasAllLocationOps(getNumVariableLocationOps() +
- NewValues.size()) &&
- "NewExpr for debug variable intrinsic does not reference every "
- "location operand.");
- assert(!is_contained(NewValues, nullptr) && "New values must be non-null");
- setArgOperand(2, MetadataAsValue::get(getContext(), NewExpr));
- SmallVector<ValueAsMetadata *, 4> MDs;
- for (auto *VMD : location_ops())
- MDs.push_back(getAsMetadata(VMD));
- for (auto *VMD : NewValues)
- MDs.push_back(getAsMetadata(VMD));
- setArgOperand(
- 0, MetadataAsValue::get(getContext(), DIArgList::get(getContext(), MDs)));
-}
std::optional<uint64_t> DbgVariableIntrinsic::getFragmentSizeInBits() const {
if (auto Fragment = getExpression()->getFragmentInfo())
@@ -221,17 +186,6 @@ void DbgAssignIntrinsic::setAddress(Value *V) {
MetadataAsValue::get(getContext(), ValueAsMetadata::get(V)));
}
-void DbgAssignIntrinsic::setKillAddress() {
- if (isKillAddress())
- return;
- setAddress(PoisonValue::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)));
``````````
</details>
https://github.com/llvm/llvm-project/pull/231075
More information about the llvm-commits
mailing list