[llvm] [RemoveDIs][NFC] Rename DPValue -> DbgVariableRecord (PR #85216)

via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 14 05:41:19 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-globalisel
@llvm/pr-subscribers-llvm-ir
@llvm/pr-subscribers-compiler-rt-sanitizer

@llvm/pr-subscribers-coroutines

Author: Stephen Tozer (SLTozer)

<details>
<summary>Changes</summary>

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 described sed-style as:

  s/DPValue/DbgVariableRecord/
  s/DPVal/DbgVarRec/
  s/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 existing DPValue class. The idea behind this patch is therefore that pure string substitution is correct in all cases as long as these assumptions hold.

---

Patch is 366.00 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/85216.diff


77 Files Affected:

- (modified) llvm/docs/RemoveDIsDebugInfo.md (+5-5) 
- (modified) llvm/include/llvm/CodeGen/FunctionLoweringInfo.h (+1-1) 
- (modified) llvm/include/llvm/IR/BasicBlock.h (+3-3) 
- (modified) llvm/include/llvm/IR/DIBuilder.h (+4-3) 
- (modified) llvm/include/llvm/IR/DebugInfo.h (+22-18) 
- (modified) llvm/include/llvm/IR/DebugInfoMetadata.h (+6-6) 
- (modified) llvm/include/llvm/IR/DebugProgramInstruction.h (+84-73) 
- (modified) llvm/include/llvm/IR/Metadata.h (+13-13) 
- (modified) llvm/include/llvm/Transforms/Utils/Local.h (+4-4) 
- (modified) llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/Utils/SSAUpdater.h (+4-3) 
- (modified) llvm/include/llvm/Transforms/Utils/ValueMapper.h (+21-15) 
- (modified) llvm/lib/AsmParser/LLParser.cpp (+7-7) 
- (modified) llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp (+79-75) 
- (modified) llvm/lib/CodeGen/CodeGenPrepare.cpp (+31-30) 
- (modified) llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp (+9-9) 
- (modified) llvm/lib/CodeGen/SelectOptimize.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/SelectionDAG/FastISel.cpp (+12-12) 
- (modified) llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+25-24) 
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (+6-6) 
- (modified) llvm/lib/IR/AsmWriter.cpp (+27-26) 
- (modified) llvm/lib/IR/BasicBlock.cpp (+13-13) 
- (modified) llvm/lib/IR/DIBuilder.cpp (+21-17) 
- (modified) llvm/lib/IR/DebugInfo.cpp (+64-58) 
- (modified) llvm/lib/IR/DebugInfoMetadata.cpp (+4-4) 
- (modified) llvm/lib/IR/DebugProgramInstruction.cpp (+116-101) 
- (modified) llvm/lib/IR/Instruction.cpp (+5-5) 
- (modified) llvm/lib/IR/LLVMContextImpl.cpp (+2-2) 
- (modified) llvm/lib/IR/LLVMContextImpl.h (+8-8) 
- (modified) llvm/lib/IR/LegacyPassManager.cpp (+3-2) 
- (modified) llvm/lib/IR/Metadata.cpp (+17-14) 
- (modified) llvm/lib/IR/Value.cpp (+4-4) 
- (modified) llvm/lib/IR/Verifier.cpp (+73-71) 
- (modified) llvm/lib/Target/AArch64/AArch64StackTagging.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+43-42) 
- (modified) llvm/lib/Transforms/Coroutines/CoroInternal.h (+2-2) 
- (modified) llvm/lib/Transforms/Coroutines/CoroSplit.cpp (+13-12) 
- (modified) llvm/lib/Transforms/IPO/IROutliner.cpp (+2-2) 
- (modified) llvm/lib/Transforms/IPO/MergeFunctions.cpp (+32-30) 
- (modified) llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineInternal.h (+3-4) 
- (modified) llvm/lib/Transforms/InstCombine/InstructionCombining.cpp (+69-67) 
- (modified) llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp (+4-3) 
- (modified) llvm/lib/Transforms/Scalar/ADCE.cpp (+8-7) 
- (modified) llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp (+3-2) 
- (modified) llvm/lib/Transforms/Scalar/JumpThreading.cpp (+23-23) 
- (modified) llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp (+10-10) 
- (modified) llvm/lib/Transforms/Scalar/SROA.cpp (+24-24) 
- (modified) llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp (+3-2) 
- (modified) llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp (+12-11) 
- (modified) llvm/lib/Transforms/Utils/BasicBlockUtils.cpp (+44-41) 
- (modified) llvm/lib/Transforms/Utils/CloneFunction.cpp (+13-11) 
- (modified) llvm/lib/Transforms/Utils/CodeExtractor.cpp (+15-15) 
- (modified) llvm/lib/Transforms/Utils/InlineFunction.cpp (+12-12) 
- (modified) llvm/lib/Transforms/Utils/LCSSA.cpp (+5-5) 
- (modified) llvm/lib/Transforms/Utils/Local.cpp (+190-179) 
- (modified) llvm/lib/Transforms/Utils/LoopRotationUtils.cpp (+29-24) 
- (modified) llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp (+3-2) 
- (modified) llvm/lib/Transforms/Utils/LoopUtils.cpp (+13-13) 
- (modified) llvm/lib/Transforms/Utils/MemoryOpRemark.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp (+7-7) 
- (modified) llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (+36-34) 
- (modified) llvm/lib/Transforms/Utils/SSAUpdater.cpp (+13-13) 
- (modified) llvm/lib/Transforms/Utils/SimplifyCFG.cpp (+36-33) 
- (modified) llvm/lib/Transforms/Utils/ValueMapper.cpp (+6-6) 
- (modified) llvm/test/DebugInfo/dpvalue-print-nocrash.ll (+1-1) 
- (modified) llvm/test/Transforms/LoopRotate/dbgvalue.ll (+1-1) 
- (modified) llvm/test/tools/llvm-reduce/remove-dp-values.ll (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceDbgRecords.cpp (+6-6) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceDbgRecords.h (+1-1) 
- (modified) llvm/unittests/IR/BasicBlockDbgInfoTest.cpp (+324-319) 
- (modified) llvm/unittests/IR/DebugInfoTest.cpp (+93-89) 
- (modified) llvm/unittests/IR/IRBuilderTest.cpp (+3-3) 
- (modified) llvm/unittests/IR/ValueTest.cpp (+8-6) 
- (modified) llvm/unittests/Transforms/Utils/LocalTest.cpp (+11-12) 


``````````diff
diff --git a/llvm/docs/RemoveDIsDebugInfo.md b/llvm/docs/RemoveDIsDebugInfo.md
index df66c26308a3c6..5ce3a1e4bfbf32 100644
--- a/llvm/docs/RemoveDIsDebugInfo.md
+++ b/llvm/docs/RemoveDIsDebugInfo.md
@@ -43,10 +43,10 @@ This will all happen transparently without needing to think about it!
 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:
 
   https://llvm.org/docs/doxygen/classllvm_1_1DbgRecord.html
-  https://llvm.org/docs/doxygen/classllvm_1_1DPValue.html
+  https://llvm.org/docs/doxygen/classllvm_1_1DbgVariableRecord.html
   https://llvm.org/docs/doxygen/classllvm_1_1DPLabel.html
 
-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.
+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.
 
 ## How do these `DbgRecords` fit into the instruction stream?
 
@@ -74,13 +74,13 @@ Like so:
 
 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.
 
-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.
+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.
 
-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.
+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.
 
 ## Finding debug info records
 
-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.
+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.
 
 ## Examining debug info records at positions
 
diff --git a/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h b/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
index 31af3014afe4e7..45a47d7333e35a 100644
--- a/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
+++ b/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
@@ -191,7 +191,7 @@ class FunctionLoweringInfo {
   /// Collection of dbg.declare instructions handled after argument
   /// lowering and before ISel proper.
   SmallPtrSet<const DbgDeclareInst *, 8> PreprocessedDbgDeclares;
-  SmallPtrSet<const DPValue *, 8> PreprocessedDPVDeclares;
+  SmallPtrSet<const DbgVariableRecord *, 8> PreprocessedDVRDeclares;
 
   /// set - Initialize this FunctionLoweringInfo with the given Function
   /// and its associated MachineFunction.
diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h
index 71c1a8394896b7..1b5843262cdbdd 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -38,7 +38,7 @@ class LLVMContext;
 class Module;
 class PHINode;
 class ValueSymbolTable;
-class DPValue;
+class DbgVariableRecord;
 class DPMarker;
 
 /// LLVM Basic Block Representation
@@ -121,10 +121,10 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
   DPMarker *getNextMarker(Instruction *I);
 
   /// Insert a DbgRecord into a block at the position given by \p I.
-  void insertDbgRecordAfter(DbgRecord *DPV, Instruction *I);
+  void insertDbgRecordAfter(DbgRecord *DVR, Instruction *I);
 
   /// Insert a DbgRecord into a block at the position given by \p Here.
-  void insertDbgRecordBefore(DbgRecord *DPV, InstListType::iterator Here);
+  void insertDbgRecordBefore(DbgRecord *DVR, InstListType::iterator Here);
 
   /// Eject any debug-info trailing at the end of a block. DbgRecords can
   /// transiently be located "off the end" of a block if the blocks terminator
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index 94af17af8160e9..4f0874fea483c9 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -101,9 +101,10 @@ namespace llvm {
     DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
                            BasicBlock *InsertBB, Instruction *InsertBefore);
 
-    /// Internal helper. Track metadata if untracked and insert \p DPV.
-    void insertDPValue(DPValue *DPV, BasicBlock *InsertBB,
-                       Instruction *InsertBefore, bool InsertAtHead = false);
+    /// Internal helper. Track metadata if untracked and insert \p DVR.
+    void insertDbgVariableRecord(DbgVariableRecord *DVR, BasicBlock *InsertBB,
+                                 Instruction *InsertBefore,
+                                 bool InsertAtHead = false);
 
     /// Internal helper with common code used by insertDbg{Value,Addr}Intrinsic.
     Instruction *insertDbgIntrinsic(llvm::Function *Intrinsic, llvm::Value *Val,
diff --git a/llvm/include/llvm/IR/DebugInfo.h b/llvm/include/llvm/IR/DebugInfo.h
index 6673908d3ed355..53cede5409e260 100644
--- a/llvm/include/llvm/IR/DebugInfo.h
+++ b/llvm/include/llvm/IR/DebugInfo.h
@@ -34,23 +34,25 @@ namespace llvm {
 class DbgDeclareInst;
 class DbgValueInst;
 class DbgVariableIntrinsic;
-class DPValue;
+class DbgVariableRecord;
 class Instruction;
 class Module;
 
 /// Finds dbg.declare intrinsics declaring local variables as living in the
 /// memory that 'V' points to.
 TinyPtrVector<DbgDeclareInst *> findDbgDeclares(Value *V);
-/// As above, for DPVDeclares.
-TinyPtrVector<DPValue *> findDPVDeclares(Value *V);
+/// As above, for DVRDeclares.
+TinyPtrVector<DbgVariableRecord *> findDVRDeclares(Value *V);
 
 /// Finds the llvm.dbg.value intrinsics describing a value.
-void findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues,
-                   Value *V, SmallVectorImpl<DPValue *> *DPValues = nullptr);
+void findDbgValues(
+    SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V,
+    SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords = nullptr);
 
 /// Finds the debug info intrinsics describing a value.
-void findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgInsts,
-                  Value *V, SmallVectorImpl<DPValue *> *DPValues = nullptr);
+void findDbgUsers(
+    SmallVectorImpl<DbgVariableIntrinsic *> &DbgInsts, Value *V,
+    SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords = nullptr);
 
 /// Find subprogram that is enclosing this scope.
 DISubprogram *getDISubprogram(const MDNode *Scope);
@@ -58,7 +60,7 @@ DISubprogram *getDISubprogram(const MDNode *Scope);
 /// Produce a DebugLoc to use for each dbg.declare that is promoted to a
 /// dbg.value.
 DebugLoc getDebugValueLoc(DbgVariableIntrinsic *DII);
-DebugLoc getDebugValueLoc(DPValue *DPV);
+DebugLoc getDebugValueLoc(DbgVariableRecord *DVR);
 
 /// Strip debug info in the module if it exists.
 ///
@@ -109,7 +111,8 @@ class DebugInfoFinder {
   void processVariable(const Module &M, const DILocalVariable *DVI);
   /// Process debug info location.
   void processLocation(const Module &M, const DILocation *Loc);
-  /// Process a DbgRecord (e.g, treat a DPValue like a DbgVariableIntrinsic).
+  /// Process a DbgRecord (e.g, treat a DbgVariableRecord like a
+  /// DbgVariableIntrinsic).
   void processDbgRecord(const Module &M, const DbgRecord &DR);
 
   /// Process subprogram.
@@ -193,10 +196,10 @@ inline AssignmentInstRange getAssignmentInsts(const DbgAssignIntrinsic *DAI) {
   return getAssignmentInsts(DAI->getAssignID());
 }
 
-inline AssignmentInstRange getAssignmentInsts(const DPValue *DPV) {
-  assert(DPV->isDbgAssign() &&
-         "Can't get assignment instructions for non-assign DPV!");
-  return getAssignmentInsts(DPV->getAssignID());
+inline AssignmentInstRange getAssignmentInsts(const DbgVariableRecord *DVR) {
+  assert(DVR->isDbgAssign() &&
+         "Can't get assignment instructions for non-assign DVR!");
+  return getAssignmentInsts(DVR->getAssignID());
 }
 
 //
@@ -231,9 +234,10 @@ inline AssignmentMarkerRange getAssignmentMarkers(const Instruction *Inst) {
     return make_range(Value::user_iterator(), Value::user_iterator());
 }
 
-inline SmallVector<DPValue *> getDPVAssignmentMarkers(const Instruction *Inst) {
+inline SmallVector<DbgVariableRecord *>
+getDVRAssignmentMarkers(const Instruction *Inst) {
   if (auto *ID = Inst->getMetadata(LLVMContext::MD_DIAssignID))
-    return cast<DIAssignID>(ID)->getAllDPValueUsers();
+    return cast<DIAssignID>(ID)->getAllDbgVariableRecordUsers();
   return {};
 }
 
@@ -261,7 +265,7 @@ bool calculateFragmentIntersect(
     std::optional<DIExpression::FragmentInfo> &Result);
 bool calculateFragmentIntersect(
     const DataLayout &DL, const Value *Dest, uint64_t SliceOffsetInBits,
-    uint64_t SliceSizeInBits, const DPValue *DPVAssign,
+    uint64_t SliceSizeInBits, const DbgVariableRecord *DVRAssign,
     std::optional<DIExpression::FragmentInfo> &Result);
 
 /// Helper struct for trackAssignments, below. We don't use the similar
@@ -276,8 +280,8 @@ struct VarRecord {
 
   VarRecord(DbgVariableIntrinsic *DVI)
       : Var(DVI->getVariable()), DL(getDebugValueLoc(DVI)) {}
-  VarRecord(DPValue *DPV)
-      : Var(DPV->getVariable()), DL(getDebugValueLoc(DPV)) {}
+  VarRecord(DbgVariableRecord *DVR)
+      : Var(DVR->getVariable()), DL(getDebugValueLoc(DVR)) {}
   VarRecord(DILocalVariable *Var, DILocation *DL) : Var(Var), DL(DL) {}
   friend bool operator<(const VarRecord &LHS, const VarRecord &RHS) {
     return std::tie(LHS.Var, LHS.DL) < std::tie(RHS.Var, RHS.DL);
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 156f6eb49253de..11fa8c5b20235f 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -65,7 +65,7 @@ enum Tag : uint16_t;
 }
 
 class DbgVariableIntrinsic;
-class DPValue;
+class DbgVariableRecord;
 
 extern cl::opt<bool> EnableFSDiscriminator;
 
@@ -323,8 +323,8 @@ class DIAssignID : public MDNode {
   // This node has no operands to replace.
   void replaceOperandWith(unsigned I, Metadata *New) = delete;
 
-  SmallVector<DPValue *> getAllDPValueUsers() {
-    return Context.getReplaceableUses()->getAllDPValueUsers();
+  SmallVector<DbgVariableRecord *> getAllDbgVariableRecordUsers() {
+    return Context.getReplaceableUses()->getAllDbgVariableRecordUsers();
   }
 
   static DIAssignID *getDistinct(LLVMContext &Context) {
@@ -3788,8 +3788,8 @@ class DIArgList : public Metadata, ReplaceableMetadataImpl {
     return MD->getMetadataID() == DIArgListKind;
   }
 
-  SmallVector<DPValue *> getAllDPValueUsers() {
-    return ReplaceableMetadataImpl::getAllDPValueUsers();
+  SmallVector<DbgVariableRecord *> getAllDbgVariableRecordUsers() {
+    return ReplaceableMetadataImpl::getAllDbgVariableRecordUsers();
   }
 
   void handleChangedOperand(void *Ref, Metadata *New);
@@ -3819,7 +3819,7 @@ class DebugVariable {
 
 public:
   DebugVariable(const DbgVariableIntrinsic *DII);
-  DebugVariable(const DPValue *DPV);
+  DebugVariable(const DbgVariableRecord *DVR);
 
   DebugVariable(const DILocalVariable *Var,
                 std::optional<FragmentInfo> FragmentInfo,
diff --git a/llvm/include/llvm/IR/DebugProgramInstruction.h b/llvm/include/llvm/IR/DebugProgramInstruction.h
index 971c22fa9aa22a..1067729ed1226c 100644
--- a/llvm/include/llvm/IR/DebugProgramInstruction.h
+++ b/llvm/include/llvm/IR/DebugProgramInstruction.h
@@ -27,12 +27,13 @@
 //    %bar = void call @ext(%foo)
 //       ; bar->DbgMarker = {
 //       ;   StoredDbgRecords = {
-//       ;     DPValue(metadata i32 %foo, ...)
+//       ;     DbgVariableRecord(metadata i32 %foo, ...)
 //       ;   }
 //       ; }
 //       ;; There is a debug-info record in front of the %bar instruction,
 //       ;; thus it points at a DPMarker object. That DPMarker contains a
-//       ;; DPValue in it's ilist, storing the equivalent information to the
+//       ;; DbgVariableRecord in it's ilist, storing the equivalent information
+//       to the
 //       ;; dbg.value above: the Value, DILocalVariable, etc.
 //
 // This structure separates the two concerns of the position of the debug-info
@@ -66,7 +67,7 @@ class DbgInfoIntrinsic;
 class DbgLabelInst;
 class DIAssignID;
 class DPMarker;
-class DPValue;
+class DbgVariableRecord;
 class raw_ostream;
 
 /// A typed tracking MDNode reference that does not require a definition for its
@@ -219,7 +220,8 @@ inline raw_ostream &operator<<(raw_ostream &OS, const DbgRecord &R) {
 
 /// Records a position in IR for a source label (DILabel). Corresponds to the
 /// llvm.dbg.label intrinsic.
-/// FIXME: Rename DbgLabelRecord when DPValue is renamed to DbgVariableRecord.
+/// FIXME: Rename DbgLabelRecord when DbgVariableRecord is renamed to
+/// DbgVariableRecord.
 class DPLabel : public DbgRecord {
   DbgRecordParamRef<DILabel> Label;
 
@@ -257,7 +259,7 @@ class DPLabel : public DbgRecord {
 ///
 /// This class inherits from DebugValueUser to allow LLVM's metadata facilities
 /// to update our references to metadata beneath our feet.
-class DPValue : public DbgRecord, protected DebugValueUser {
+class DbgVariableRecord : public DbgRecord, protected DebugValueUser {
   friend class DebugValueUser;
 
 public:
@@ -269,9 +271,10 @@ class DPValue : public DbgRecord, protected DebugValueUser {
     End, ///< Marks the end of the concrete types.
     Any, ///< To indicate all LocationTypes in searches.
   };
-  /// Classification of the debug-info record that this DPValue represents.
-  /// Essentially, "is this a dbg.value or dbg.declare?". dbg.declares are not
-  /// currently supported, but it would be trivial to do so.
+  /// Classification of the debug-info record that this DbgVariableRecord
+  /// represents. Essentially, "is this a dbg.value or dbg.declare?".
+  /// dbg.declares are not currently supported, but it would be trivial to do
+  /// so.
   /// FIXME: We could use spare padding bits from DbgRecord for this.
   LocationType Type;
 
@@ -284,63 +287,69 @@ class DPValue : public DbgRecord, protected DebugValueUser {
   DbgRecordParamRef<DIExpression> AddressExpression;
 
 public:
-  /// Create a new DPValue representing the intrinsic \p DVI, for example the
-  /// assignment represented by a dbg.value.
-  DPValue(const DbgVariableIntrinsic *DVI);
-  DPValue(const DPValue &DPV);
-  /// Directly construct a new DPValue representing a dbg.value intrinsic
-  /// assigning \p Location to the DV / Expr / DI variable.
-  DPValue(Metadata *Location, DILocalVariable *DV, DIExpression *Expr,
-          const DILocation *DI, LocationType Type = LocationType::Value);
-  DPValue(Metadata *Value, DILocalVariable *Variable, DIExpression *Expression,
-          DIAssignID *AssignID, Metadata *Address,
-          DIExpression *AddressExpression, const DILocation *DI);
+  /// Create a new DbgVariableRecord representing the intrinsic \p DVI, for
+  /// example the assignment represented by a dbg.value.
+  DbgVariableRecord(const DbgVariableIntrinsic *DVI);
+  DbgVariableRecord(const DbgVariableRecord &DVR);
+  /// Directly construct a new DbgVariableRecord representing a dbg.value
+  /// intrinsic assigning \p Location to the DV / Expr / DI variable.
+  DbgVariableRecord(Metadata *Location, DILocalVariable *DV, DIExpression *Expr,
+                    const DILocation *DI,
+                    LocationType Type = LocationType::Value);
+  DbgVariableRecord(Metadata *Value, DILocalVariable *Variable,
+                    DIExpression *Expression, DIAssignID *AssignID,
+                    Metadata *Address, DIExpression *AddressExpression,
+                    const DILocation *DI);
 
 private:
   /// Private constructor for creating new instances during parsing only. Only
-  /// called through `createUnresolvedDPValue` below, which makes clear that
-  /// this is used for parsing only, and will later return a subclass depending
-  /// on which Type is passed.
-  DPValue(LocationType Type, Metadata *Val, MDNode *Variable,
-          MDNode *Expression, MDNode *AssignID, Metadata *Address,
-          MDNode *AddressExpression, MDNode *DI);
+  /// called through `createUnresolvedDbgVariableRecord` below, which makes
+  /// clear that this is used for parsing only, and will later return a subclass
+  /// depending on which Type is passed.
+  DbgVariableRecord(LocationType Type, Metadata *Val, MDNode *Variable,
+                    MDNode *Expression, MDNode *AssignID, Metadata *Address,
+                    MDNode *AddressExpression, MDNode *DI);
 
 public:
-  /// Used to create DPValues during parsing, where some metadata references may
-  /// still be unresolved. Although for some fields a generic `Metadata*`
-  /// argument is accepted for forward type-references, the verifier and
-  /// accessors will reject incorrect types later on. The function is used for
-  /// all types of DPValues for simplicity while parsing, but asserts if any
-  /// necessary fields are empty or unused fields are not empty, i.e. if the
-  /// #dbg_assign fields are used for a non-dbg-assign type.
-  static DPValue *createUnresolvedDPValue(LocationType Type, Metadata *Val,
-                                          MDNode *Variable, MDNode *Expression,
-                                          MDNode *AssignID, Metadata *Address,
-                                          MDNode *AddressExpression,
-                                          MDNode *DI);
-
-  static DPValue *createDPVAssign(Value *Val, DILocalVariable *Variable,
-                                  DIExpression *Expression,
-                                  DIAssignID *AssignID, Value *Address,
-                                  DIExpression *AddressExpression,
-                                  const DILocation *DI);
-  static DPValue *createLinkedDPVAssign(Instruction *LinkedInstr, Value *Val,
-                                        DILocalVariable *Variable,
-                                        DIExpression *Expression,
-                                        Value *Address,
-                                        DIExpression *AddressExpression,
-                                        const DILocation *DI);
-
-  static DPValue *createDPValue(Value *Location, DILocalVariable *DV,
-                                DIExpression *Expr, const DILocation *DI);
-  static DPValue *createDPValue(Value *Location, DILocalVariable *DV,
-                                DIExpression *Expr, const DILocation *DI,
-                                DPValue &InsertBefore);
-  static DPValue *createDPVDeclare(Value *Address, DILocalVariable *DV,
-                                   DIExpression *Expr, co...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/85216


More information about the llvm-commits mailing list