Skip to content

Commit abe0475

Browse files
committed
Remove the obsolete offset parameter from @llvm.dbg.value
There is no situation where this rarely-used argument cannot be substituted with a DIExpression and removing it allows us to simplify the DWARF backend. Note that this patch does not yet remove any of the newly dead code. rdar://problem/33580047 Differential Revision: https://reviews.llvm.org/D35951 llvm-svn: 309426
1 parent e109655 commit abe0475

File tree

173 files changed

+713
-680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+713
-680
lines changed

llvm/docs/LangRef.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4018,7 +4018,7 @@ function is using two metadata arguments:
40184018

40194019
.. code-block:: llvm
40204020

4021-
call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
4021+
call void @llvm.dbg.value(metadata !24, metadata !25, metadata !26)
40224022

40234023
Metadata can be attached to an instruction. Here metadata ``!21`` is attached
40244024
to the ``add`` instruction using the ``!dbg`` identifier:

llvm/docs/SourceLevelDebugging.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,13 @@ description of the variable. The third argument is a `complex expression
207207

208208
.. code-block:: llvm
209209
210-
void @llvm.dbg.value(metadata, i64, metadata, metadata)
210+
void @llvm.dbg.value(metadata, metadata, metadata)
211211
212212
This intrinsic provides information when a user source variable is set to a new
213-
value. The first argument is the new value (wrapped as metadata). The second
214-
argument is the offset in the user source variable where the new value is
215-
written. The third argument is a `local variable
216-
<LangRef.html#dilocalvariable>`_ containing a description of the variable. The
217-
fourth argument is a `complex expression <LangRef.html#diexpression>`_.
213+
value. The first argument is the new value (wrapped as metadata). The third
214+
argument is a `local variable <LangRef.html#dilocalvariable>`_ containing a
215+
description of the variable. The fourth argument is a `complex expression
216+
<LangRef.html#diexpression>`_.
218217

219218
Object lifetimes and scoping
220219
============================

llvm/include/llvm/IR/DIBuilder.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,25 +729,23 @@ namespace llvm {
729729

730730
/// Insert a new llvm.dbg.value intrinsic call.
731731
/// \param Val llvm::Value of the variable
732-
/// \param Offset Offset
733732
/// \param VarInfo Variable's debug info descriptor.
734733
/// \param Expr A complex location expression.
735734
/// \param DL Debug info location.
736735
/// \param InsertAtEnd Location for the new intrinsic.
737-
Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
736+
Instruction *insertDbgValueIntrinsic(llvm::Value *Val,
738737
DILocalVariable *VarInfo,
739738
DIExpression *Expr,
740739
const DILocation *DL,
741740
BasicBlock *InsertAtEnd);
742741

743742
/// Insert a new llvm.dbg.value intrinsic call.
744743
/// \param Val llvm::Value of the variable
745-
/// \param Offset Offset
746744
/// \param VarInfo Variable's debug info descriptor.
747745
/// \param Expr A complex location expression.
748746
/// \param DL Debug info location.
749747
/// \param InsertBefore Location for the new intrinsic.
750-
Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
748+
Instruction *insertDbgValueIntrinsic(llvm::Value *Val,
751749
DILocalVariable *VarInfo,
752750
DIExpression *Expr,
753751
const DILocation *DL,

llvm/include/llvm/IR/IntrinsicInst.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,6 @@ namespace llvm {
122122
return getVariableLocation(/* AllowNullOp = */ false);
123123
}
124124

125-
uint64_t getOffset() const {
126-
return cast<ConstantInt>(
127-
const_cast<Value*>(getArgOperand(1)))->getZExtValue();
128-
}
129-
130125
DILocalVariable *getVariable() const {
131126
return cast<DILocalVariable>(getRawVariable());
132127
}
@@ -136,11 +131,11 @@ namespace llvm {
136131
}
137132

138133
Metadata *getRawVariable() const {
139-
return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
134+
return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
140135
}
141136

142137
Metadata *getRawExpression() const {
143-
return cast<MetadataAsValue>(getArgOperand(3))->getMetadata();
138+
return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
144139
}
145140

146141
// Methods for support type inquiry through isa, cast, and dyn_cast:

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
579579
llvm_metadata_ty,
580580
llvm_metadata_ty]>;
581581
def int_dbg_value : Intrinsic<[],
582-
[llvm_metadata_ty, llvm_i64_ty,
582+
[llvm_metadata_ty,
583583
llvm_metadata_ty,
584584
llvm_metadata_ty]>;
585585
}

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -682,23 +682,18 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
682682
if (!V) {
683683
// Currently the optimizer can produce this; insert an undef to
684684
// help debugging. Probably the optimizer should not do this.
685-
MIRBuilder.buildIndirectDbgValue(0, DI.getOffset(), DI.getVariable(),
685+
MIRBuilder.buildIndirectDbgValue(0, 0, DI.getVariable(),
686686
DI.getExpression());
687687
} else if (const auto *CI = dyn_cast<Constant>(V)) {
688-
MIRBuilder.buildConstDbgValue(*CI, DI.getOffset(), DI.getVariable(),
688+
MIRBuilder.buildConstDbgValue(*CI, 0, DI.getVariable(),
689689
DI.getExpression());
690690
} else {
691691
unsigned Reg = getOrCreateVReg(*V);
692692
// FIXME: This does not handle register-indirect values at offset 0. The
693693
// direct/indirect thing shouldn't really be handled by something as
694694
// implicit as reg+noreg vs reg+imm in the first palce, but it seems
695695
// pretty baked in right now.
696-
if (DI.getOffset() != 0)
697-
MIRBuilder.buildIndirectDbgValue(Reg, DI.getOffset(), DI.getVariable(),
698-
DI.getExpression());
699-
else
700-
MIRBuilder.buildDirectDbgValue(Reg, DI.getVariable(),
701-
DI.getExpression());
696+
MIRBuilder.buildDirectDbgValue(Reg, DI.getVariable(), DI.getExpression());
702697
}
703698
return true;
704699
}

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,33 +1214,33 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
12141214
// help debugging. Probably the optimizer should not do this.
12151215
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
12161216
.addReg(0U)
1217-
.addImm(DI->getOffset())
1217+
.addImm(0U)
12181218
.addMetadata(DI->getVariable())
12191219
.addMetadata(DI->getExpression());
12201220
} else if (const auto *CI = dyn_cast<ConstantInt>(V)) {
12211221
if (CI->getBitWidth() > 64)
12221222
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
12231223
.addCImm(CI)
1224-
.addImm(DI->getOffset())
1224+
.addImm(0U)
12251225
.addMetadata(DI->getVariable())
12261226
.addMetadata(DI->getExpression());
12271227
else
12281228
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
12291229
.addImm(CI->getZExtValue())
1230-
.addImm(DI->getOffset())
1230+
.addImm(0U)
12311231
.addMetadata(DI->getVariable())
12321232
.addMetadata(DI->getExpression());
12331233
} else if (const auto *CF = dyn_cast<ConstantFP>(V)) {
12341234
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
12351235
.addFPImm(CF)
1236-
.addImm(DI->getOffset())
1236+
.addImm(0U)
12371237
.addMetadata(DI->getVariable())
12381238
.addMetadata(DI->getExpression());
12391239
} else if (unsigned Reg = lookUpRegForValue(V)) {
12401240
// FIXME: This does not handle register-indirect values at offset 0.
1241-
bool IsIndirect = DI->getOffset() != 0;
1242-
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, IsIndirect, Reg,
1243-
DI->getOffset(), DI->getVariable(), DI->getExpression());
1241+
bool IsIndirect = false;
1242+
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, IsIndirect, Reg, 0,
1243+
DI->getVariable(), DI->getExpression());
12441244
} else {
12451245
// We can't yet handle anything else here because it would require
12461246
// generating code, thus altering codegen because of debug info.

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ void SelectionDAGBuilder::resolveDanglingDebugInfo(const Value *V,
10041004
DIExpression *Expr = DI->getExpression();
10051005
assert(Variable->isValidLocationForIntrinsic(dl) &&
10061006
"Expected inlined-at fields to agree");
1007-
uint64_t Offset = DI->getOffset();
1007+
uint64_t Offset = 0;
10081008
SDDbgValue *SDV;
10091009
if (Val.getNode()) {
10101010
if (!EmitFuncArgumentDbgValue(V, Variable, Expr, dl, Offset, false,
@@ -5139,7 +5139,7 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
51395139

51405140
DILocalVariable *Variable = DI.getVariable();
51415141
DIExpression *Expression = DI.getExpression();
5142-
uint64_t Offset = DI.getOffset();
5142+
uint64_t Offset = 0;
51435143
const Value *V = DI.getValue();
51445144
if (!V)
51455145
return nullptr;

llvm/lib/IR/AutoUpgrade.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,14 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
420420
}
421421
break;
422422
}
423+
case 'd': {
424+
if (Name == "dbg.value" && F->arg_size() == 4) {
425+
rename(F);
426+
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::dbg_value);
427+
return true;
428+
}
429+
break;
430+
}
423431
case 'i':
424432
case 'l': {
425433
bool IsLifetimeStart = Name.startswith("lifetime.start");
@@ -2055,6 +2063,20 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
20552063
NewCall = Builder.CreateCall(NewFn, {CI->getArgOperand(0)});
20562064
break;
20572065

2066+
case Intrinsic::dbg_value:
2067+
// Upgrade from the old version that had an extra offset argument.
2068+
assert(CI->getNumArgOperands() == 4);
2069+
// Drop nonzero offsets instead of attempting to upgrade them.
2070+
if (auto *Offset = dyn_cast_or_null<Constant>(CI->getArgOperand(1)))
2071+
if (Offset->isZeroValue()) {
2072+
NewCall = Builder.CreateCall(
2073+
NewFn,
2074+
{CI->getArgOperand(0), CI->getArgOperand(2), CI->getArgOperand(3)});
2075+
break;
2076+
}
2077+
CI->eraseFromParent();
2078+
return;
2079+
20582080
case Intrinsic::x86_xop_vfrcz_ss:
20592081
case Intrinsic::x86_xop_vfrcz_sd:
20602082
NewCall = Builder.CreateCall(NewFn, {CI->getArgOperand(1)});

llvm/lib/IR/DIBuilder.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
823823
return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertAtEnd), DL);
824824
}
825825

826-
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
826+
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V,
827827
DILocalVariable *VarInfo,
828828
DIExpression *Expr,
829829
const DILocation *DL,
@@ -840,13 +840,12 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
840840
trackIfUnresolved(VarInfo);
841841
trackIfUnresolved(Expr);
842842
Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
843-
ConstantInt::get(Type::getInt64Ty(VMContext), Offset),
844843
MetadataAsValue::get(VMContext, VarInfo),
845844
MetadataAsValue::get(VMContext, Expr)};
846845
return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertBefore), DL);
847846
}
848847

849-
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
848+
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V,
850849
DILocalVariable *VarInfo,
851850
DIExpression *Expr,
852851
const DILocation *DL,
@@ -863,7 +862,6 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
863862
trackIfUnresolved(VarInfo);
864863
trackIfUnresolved(Expr);
865864
Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
866-
ConstantInt::get(Type::getInt64Ty(VMContext), Offset),
867865
MetadataAsValue::get(VMContext, VarInfo),
868866
MetadataAsValue::get(VMContext, Expr)};
869867

0 commit comments

Comments
 (0)