Skip to content

Commit ffd08c7

Browse files
authored
[RemoveDIs][NFC] Rename DPValue -> DbgVariableRecord (#85216)
This is the major rename patch that prior patches have built towards. The DPValue class is being renamed to DbgVariableRecord, which reflects the updated terminology for the "final" implementation of the RemoveDI feature. This is a pure string substitution + clang-format patch. The only manual component of this patch was determining where to perform these string substitutions: `DPValue` and `DPV` are almost exclusively used for DbgRecords, *except* for: - llvm/lib/target, where 'DP' is used to mean double-precision, and so appears as part of .td files and in variable names. NB: There is a single existing use of `DPValue` here that refers to debug info, which I've manually updated. - llvm/tools/gold, where 'LDPV' is used as a prefix for symbol visibility enums. Outside of these places, I've applied several basic string substitutions, with the intent that they only affect DbgRecord-related identifiers; I've checked them as I went through to verify this, with reasonable confidence that there are no unintended changes that slipped through the cracks. The substitutions applied are all case-sensitive, and are applied in the order shown: ``` DPValue -> DbgVariableRecord DPVal -> DbgVarRec DPV -> DVR ``` Following the previous rename patches, it should be the case that there are no instances of any of these strings that are meant to refer to the general case of DbgRecords, or anything other than the DPValue class. The idea behind this patch is therefore that pure string substitution is correct in all cases as long as these assumptions hold.
1 parent 3cd9dcc commit ffd08c7

File tree

83 files changed

+1899
-1787
lines changed

Some content is hidden

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

83 files changed

+1899
-1787
lines changed

clang/lib/CodeGen/CGStmtOpenMP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4770,9 +4770,9 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
47704770
assert(!Last.isTerminator() && "unexpected terminator");
47714771
if (auto *Marker =
47724772
CGF.Builder.GetInsertBlock()->getTrailingDbgRecords()) {
4773-
for (llvm::DPValue &DPV : llvm::reverse(
4773+
for (llvm::DbgVariableRecord &DVR : llvm::reverse(
47744774
llvm::filterDbgVars(Marker->getDbgRecordRange()))) {
4775-
UpdateExpr(Last.getContext(), &DPV, Offset);
4775+
UpdateExpr(Last.getContext(), &DVR, Offset);
47764776
break;
47774777
}
47784778
}

llvm/docs/RemoveDIsDebugInfo.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ This will all happen transparently without needing to think about it!
6464
We're using a dedicated C++ class called `DbgRecord` to store debug info, with a one-to-one relationship between each instance of a debug intrinsic and each `DbgRecord` object in any LLVM IR program; these `DbgRecord`s are represented in the IR as non-instruction debug records, as described in the [Source Level Debugging](project:SourceLevelDebugging.rst#Debug Records) document. This class has a set of subclasses that store exactly the same information as is stored in debugging intrinsics. Each one also has almost entirely the same set of methods, that behave in the same way:
6565

6666
https://llvm.org/docs/doxygen/classllvm_1_1DbgRecord.html
67-
https://llvm.org/docs/doxygen/classllvm_1_1DPValue.html
67+
https://llvm.org/docs/doxygen/classllvm_1_1DbgVariableRecord.html
6868
https://llvm.org/docs/doxygen/classllvm_1_1DPLabel.html
6969

70-
This allows you to treat a `DPValue` as if it's a `dbg.value`/`dbg.declare`/`dbg.assign` intrinsic most of the time, for example in generic (auto-param) lambdas, and the same for `DPLabel` and `dbg.label`s.
70+
This allows you to treat a `DbgVariableRecord` as if it's a `dbg.value`/`dbg.declare`/`dbg.assign` intrinsic most of the time, for example in generic (auto-param) lambdas, and the same for `DPLabel` and `dbg.label`s.
7171

7272
## How do these `DbgRecords` fit into the instruction stream?
7373

@@ -95,13 +95,13 @@ Like so:
9595

9696
Each instruction has a pointer to a `DPMarker` (which will become optional), that contains a list of `DbgRecord` objects. No debugging records appear in the instruction list at all. `DbgRecord`s have a parent pointer to their owning `DPMarker`, and each `DPMarker` has a pointer back to it's owning instruction.
9797

98-
Not shown are the links from DbgRecord to other parts of the `Value`/`Metadata` hierachy: `DbgRecord` subclasses have tracking pointers to the DIMetadata that they use, and `DPValue` has references to `Value`s that are stored in a `DebugValueUser` base class. This refers to a `ValueAsMetadata` object referring to `Value`s, via the `TrackingMetadata` facility.
98+
Not shown are the links from DbgRecord to other parts of the `Value`/`Metadata` hierachy: `DbgRecord` subclasses have tracking pointers to the DIMetadata that they use, and `DbgVariableRecord` has references to `Value`s that are stored in a `DebugValueUser` base class. This refers to a `ValueAsMetadata` object referring to `Value`s, via the `TrackingMetadata` facility.
9999

100-
The various kinds of debug intrinsic (value, declare, assign, label) are all stored in `DbgRecord` subclasses, with a "RecordKind" field distinguishing `DPLabel`s from `DPValue`s, and a `LocationType` field in the `DPValue` class further disambiguating the various debug variable intrinsics it can represent.
100+
The various kinds of debug intrinsic (value, declare, assign, label) are all stored in `DbgRecord` subclasses, with a "RecordKind" field distinguishing `DPLabel`s from `DbgVariableRecord`s, and a `LocationType` field in the `DbgVariableRecord` class further disambiguating the various debug variable intrinsics it can represent.
101101

102102
## Finding debug info records
103103

104-
Utilities such as `findDbgUsers` and the like now have an optional argument that will return the set of `DPValue` records that refer to a `Value`. You should be able to treat them the same as intrinsics.
104+
Utilities such as `findDbgUsers` and the like now have an optional argument that will return the set of `DbgVariableRecord` records that refer to a `Value`. You should be able to treat them the same as intrinsics.
105105

106106
## Examining debug info records at positions
107107

llvm/include/llvm/CodeGen/FunctionLoweringInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class FunctionLoweringInfo {
191191
/// Collection of dbg.declare instructions handled after argument
192192
/// lowering and before ISel proper.
193193
SmallPtrSet<const DbgDeclareInst *, 8> PreprocessedDbgDeclares;
194-
SmallPtrSet<const DPValue *, 8> PreprocessedDPVDeclares;
194+
SmallPtrSet<const DbgVariableRecord *, 8> PreprocessedDVRDeclares;
195195

196196
/// set - Initialize this FunctionLoweringInfo with the given Function
197197
/// and its associated MachineFunction.

llvm/include/llvm/IR/BasicBlock.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class LLVMContext;
3838
class Module;
3939
class PHINode;
4040
class ValueSymbolTable;
41-
class DPValue;
41+
class DbgVariableRecord;
4242
class DPMarker;
4343

4444
/// LLVM Basic Block Representation
@@ -121,10 +121,10 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
121121
DPMarker *getNextMarker(Instruction *I);
122122

123123
/// Insert a DbgRecord into a block at the position given by \p I.
124-
void insertDbgRecordAfter(DbgRecord *DPV, Instruction *I);
124+
void insertDbgRecordAfter(DbgRecord *DR, Instruction *I);
125125

126126
/// Insert a DbgRecord into a block at the position given by \p Here.
127-
void insertDbgRecordBefore(DbgRecord *DPV, InstListType::iterator Here);
127+
void insertDbgRecordBefore(DbgRecord *DR, InstListType::iterator Here);
128128

129129
/// Eject any debug-info trailing at the end of a block. DbgRecords can
130130
/// transiently be located "off the end" of a block if the blocks terminator

llvm/include/llvm/IR/DIBuilder.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ namespace llvm {
101101
DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
102102
BasicBlock *InsertBB, Instruction *InsertBefore);
103103

104-
/// Internal helper. Track metadata if untracked and insert \p DPV.
105-
void insertDPValue(DPValue *DPV, BasicBlock *InsertBB,
106-
Instruction *InsertBefore, bool InsertAtHead = false);
104+
/// Internal helper. Track metadata if untracked and insert \p DVR.
105+
void insertDbgVariableRecord(DbgVariableRecord *DVR, BasicBlock *InsertBB,
106+
Instruction *InsertBefore,
107+
bool InsertAtHead = false);
107108

108109
/// Internal helper with common code used by insertDbg{Value,Addr}Intrinsic.
109110
Instruction *insertDbgIntrinsic(llvm::Function *Intrinsic, llvm::Value *Val,

llvm/include/llvm/IR/DebugInfo.h

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,33 @@ namespace llvm {
3434
class DbgDeclareInst;
3535
class DbgValueInst;
3636
class DbgVariableIntrinsic;
37-
class DPValue;
37+
class DbgVariableRecord;
3838
class Instruction;
3939
class Module;
4040

4141
/// Finds dbg.declare intrinsics declaring local variables as living in the
4242
/// memory that 'V' points to.
4343
TinyPtrVector<DbgDeclareInst *> findDbgDeclares(Value *V);
44-
/// As above, for DPVDeclares.
45-
TinyPtrVector<DPValue *> findDPVDeclares(Value *V);
44+
/// As above, for DVRDeclares.
45+
TinyPtrVector<DbgVariableRecord *> findDVRDeclares(Value *V);
4646

4747
/// Finds the llvm.dbg.value intrinsics describing a value.
48-
void findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues,
49-
Value *V, SmallVectorImpl<DPValue *> *DPValues = nullptr);
48+
void findDbgValues(
49+
SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V,
50+
SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords = nullptr);
5051

5152
/// Finds the debug info intrinsics describing a value.
52-
void findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgInsts,
53-
Value *V, SmallVectorImpl<DPValue *> *DPValues = nullptr);
53+
void findDbgUsers(
54+
SmallVectorImpl<DbgVariableIntrinsic *> &DbgInsts, Value *V,
55+
SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords = nullptr);
5456

5557
/// Find subprogram that is enclosing this scope.
5658
DISubprogram *getDISubprogram(const MDNode *Scope);
5759

5860
/// Produce a DebugLoc to use for each dbg.declare that is promoted to a
5961
/// dbg.value.
6062
DebugLoc getDebugValueLoc(DbgVariableIntrinsic *DII);
61-
DebugLoc getDebugValueLoc(DPValue *DPV);
63+
DebugLoc getDebugValueLoc(DbgVariableRecord *DVR);
6264

6365
/// Strip debug info in the module if it exists.
6466
///
@@ -109,7 +111,8 @@ class DebugInfoFinder {
109111
void processVariable(const Module &M, const DILocalVariable *DVI);
110112
/// Process debug info location.
111113
void processLocation(const Module &M, const DILocation *Loc);
112-
/// Process a DbgRecord (e.g, treat a DPValue like a DbgVariableIntrinsic).
114+
/// Process a DbgRecord (e.g, treat a DbgVariableRecord like a
115+
/// DbgVariableIntrinsic).
113116
void processDbgRecord(const Module &M, const DbgRecord &DR);
114117

115118
/// Process subprogram.
@@ -193,10 +196,10 @@ inline AssignmentInstRange getAssignmentInsts(const DbgAssignIntrinsic *DAI) {
193196
return getAssignmentInsts(DAI->getAssignID());
194197
}
195198

196-
inline AssignmentInstRange getAssignmentInsts(const DPValue *DPV) {
197-
assert(DPV->isDbgAssign() &&
198-
"Can't get assignment instructions for non-assign DPV!");
199-
return getAssignmentInsts(DPV->getAssignID());
199+
inline AssignmentInstRange getAssignmentInsts(const DbgVariableRecord *DVR) {
200+
assert(DVR->isDbgAssign() &&
201+
"Can't get assignment instructions for non-assign DVR!");
202+
return getAssignmentInsts(DVR->getAssignID());
200203
}
201204

202205
//
@@ -231,9 +234,10 @@ inline AssignmentMarkerRange getAssignmentMarkers(const Instruction *Inst) {
231234
return make_range(Value::user_iterator(), Value::user_iterator());
232235
}
233236

234-
inline SmallVector<DPValue *> getDPVAssignmentMarkers(const Instruction *Inst) {
237+
inline SmallVector<DbgVariableRecord *>
238+
getDVRAssignmentMarkers(const Instruction *Inst) {
235239
if (auto *ID = Inst->getMetadata(LLVMContext::MD_DIAssignID))
236-
return cast<DIAssignID>(ID)->getAllDPValueUsers();
240+
return cast<DIAssignID>(ID)->getAllDbgVariableRecordUsers();
237241
return {};
238242
}
239243

@@ -261,7 +265,7 @@ bool calculateFragmentIntersect(
261265
std::optional<DIExpression::FragmentInfo> &Result);
262266
bool calculateFragmentIntersect(
263267
const DataLayout &DL, const Value *Dest, uint64_t SliceOffsetInBits,
264-
uint64_t SliceSizeInBits, const DPValue *DPVAssign,
268+
uint64_t SliceSizeInBits, const DbgVariableRecord *DVRAssign,
265269
std::optional<DIExpression::FragmentInfo> &Result);
266270

267271
/// Helper struct for trackAssignments, below. We don't use the similar
@@ -276,8 +280,8 @@ struct VarRecord {
276280

277281
VarRecord(DbgVariableIntrinsic *DVI)
278282
: Var(DVI->getVariable()), DL(getDebugValueLoc(DVI)) {}
279-
VarRecord(DPValue *DPV)
280-
: Var(DPV->getVariable()), DL(getDebugValueLoc(DPV)) {}
283+
VarRecord(DbgVariableRecord *DVR)
284+
: Var(DVR->getVariable()), DL(getDebugValueLoc(DVR)) {}
281285
VarRecord(DILocalVariable *Var, DILocation *DL) : Var(Var), DL(DL) {}
282286
friend bool operator<(const VarRecord &LHS, const VarRecord &RHS) {
283287
return std::tie(LHS.Var, LHS.DL) < std::tie(RHS.Var, RHS.DL);

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ enum Tag : uint16_t;
6565
}
6666

6767
class DbgVariableIntrinsic;
68-
class DPValue;
68+
class DbgVariableRecord;
6969

7070
extern cl::opt<bool> EnableFSDiscriminator;
7171

@@ -323,8 +323,8 @@ class DIAssignID : public MDNode {
323323
// This node has no operands to replace.
324324
void replaceOperandWith(unsigned I, Metadata *New) = delete;
325325

326-
SmallVector<DPValue *> getAllDPValueUsers() {
327-
return Context.getReplaceableUses()->getAllDPValueUsers();
326+
SmallVector<DbgVariableRecord *> getAllDbgVariableRecordUsers() {
327+
return Context.getReplaceableUses()->getAllDbgVariableRecordUsers();
328328
}
329329

330330
static DIAssignID *getDistinct(LLVMContext &Context) {
@@ -3840,8 +3840,8 @@ class DIArgList : public Metadata, ReplaceableMetadataImpl {
38403840
return MD->getMetadataID() == DIArgListKind;
38413841
}
38423842

3843-
SmallVector<DPValue *> getAllDPValueUsers() {
3844-
return ReplaceableMetadataImpl::getAllDPValueUsers();
3843+
SmallVector<DbgVariableRecord *> getAllDbgVariableRecordUsers() {
3844+
return ReplaceableMetadataImpl::getAllDbgVariableRecordUsers();
38453845
}
38463846

38473847
void handleChangedOperand(void *Ref, Metadata *New);
@@ -3871,7 +3871,7 @@ class DebugVariable {
38713871

38723872
public:
38733873
DebugVariable(const DbgVariableIntrinsic *DII);
3874-
DebugVariable(const DPValue *DPV);
3874+
DebugVariable(const DbgVariableRecord *DVR);
38753875

38763876
DebugVariable(const DILocalVariable *Var,
38773877
std::optional<FragmentInfo> FragmentInfo,

0 commit comments

Comments
 (0)