IR: Give 'DI' prefix to debug info metadata
Finish off PR23080 by renaming the debug info IR constructs from `MD*`
to `DI*`. The last of the `DIDescriptor` classes were deleted in
r235356, and the last of the related typedefs removed in r235413, so
this has all baked for about a week.
Note: If you have out-of-tree code (like a frontend), I recommend that
you get everything compiling and tests passing with the *previous*
commit before updating to this one. It'll be easier to keep track of
what code is using the `DIDescriptor` hierarchy and what you've already
updated, and I think you're extremely unlikely to insert bugs. YMMV of
course.
Back to *this* commit: I did this using the rename-md-di-nodes.sh
upgrade script I've attached to PR23080 (both code and testcases) and
filtered through clang-format-diff.py. I edited the tests for
test/Assembler/invalid-generic-debug-node-*.ll by hand since the columns
were off-by-three. It should work on your out-of-tree testcases (and
code, if you've followed the advice in the previous paragraph).
Some of the tests are in badly named files now (e.g.,
test/Assembler/invalid-mdcompositetype-missing-tag.ll should be
'dicompositetype'); I'll come back and move the files in a follow-up
commit.
llvm-svn: 236120
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 15b0106..85a6da3 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -784,7 +784,7 @@
Record.clear();
}
-static void WriteMDLocation(const MDLocation *N, const ValueEnumerator &VE,
+static void WriteDILocation(const DILocation *N, const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
@@ -798,11 +798,11 @@
Record.clear();
}
-static void WriteGenericDebugNode(const GenericDebugNode *N,
- const ValueEnumerator &VE,
- BitstreamWriter &Stream,
- SmallVectorImpl<uint64_t> &Record,
- unsigned Abbrev) {
+static void WriteGenericDINode(const GenericDINode *N,
+ const ValueEnumerator &VE,
+ BitstreamWriter &Stream,
+ SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev) {
Record.push_back(N->isDistinct());
Record.push_back(N->getTag());
Record.push_back(0); // Per-tag version field; unused for now.
@@ -819,7 +819,7 @@
return I < 0 ? ~(U << 1) : U << 1;
}
-static void WriteMDSubrange(const MDSubrange *N, const ValueEnumerator &,
+static void WriteDISubrange(const DISubrange *N, const ValueEnumerator &,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
@@ -831,7 +831,7 @@
Record.clear();
}
-static void WriteMDEnumerator(const MDEnumerator *N, const ValueEnumerator &VE,
+static void WriteDIEnumerator(const DIEnumerator *N, const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
@@ -843,7 +843,7 @@
Record.clear();
}
-static void WriteMDBasicType(const MDBasicType *N, const ValueEnumerator &VE,
+static void WriteDIBasicType(const DIBasicType *N, const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
@@ -858,7 +858,7 @@
Record.clear();
}
-static void WriteMDDerivedType(const MDDerivedType *N,
+static void WriteDIDerivedType(const DIDerivedType *N,
const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
@@ -880,7 +880,7 @@
Record.clear();
}
-static void WriteMDCompositeType(const MDCompositeType *N,
+static void WriteDICompositeType(const DICompositeType *N,
const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
@@ -906,7 +906,7 @@
Record.clear();
}
-static void WriteMDSubroutineType(const MDSubroutineType *N,
+static void WriteDISubroutineType(const DISubroutineType *N,
const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
@@ -919,7 +919,7 @@
Record.clear();
}
-static void WriteMDFile(const MDFile *N, const ValueEnumerator &VE,
+static void WriteDIFile(const DIFile *N, const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) {
Record.push_back(N->isDistinct());
@@ -930,7 +930,7 @@
Record.clear();
}
-static void WriteMDCompileUnit(const MDCompileUnit *N,
+static void WriteDICompileUnit(const DICompileUnit *N,
const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
@@ -954,11 +954,10 @@
Record.clear();
}
-static void WriteMDSubprogram(const MDSubprogram *N,
- const ValueEnumerator &VE,
- BitstreamWriter &Stream,
- SmallVectorImpl<uint64_t> &Record,
- unsigned Abbrev) {
+static void WriteDISubprogram(const DISubprogram *N, const ValueEnumerator &VE,
+ BitstreamWriter &Stream,
+ SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev) {
Record.push_back(N->isDistinct());
Record.push_back(VE.getMetadataOrNullID(N->getScope()));
Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
@@ -983,11 +982,11 @@
Record.clear();
}
-static void WriteMDLexicalBlock(const MDLexicalBlock *N,
- const ValueEnumerator &VE,
- BitstreamWriter &Stream,
- SmallVectorImpl<uint64_t> &Record,
- unsigned Abbrev) {
+static void WriteDILexicalBlock(const DILexicalBlock *N,
+ const ValueEnumerator &VE,
+ BitstreamWriter &Stream,
+ SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev) {
Record.push_back(N->isDistinct());
Record.push_back(VE.getMetadataOrNullID(N->getScope()));
Record.push_back(VE.getMetadataOrNullID(N->getFile()));
@@ -998,7 +997,7 @@
Record.clear();
}
-static void WriteMDLexicalBlockFile(const MDLexicalBlockFile *N,
+static void WriteDILexicalBlockFile(const DILexicalBlockFile *N,
const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
@@ -1012,7 +1011,7 @@
Record.clear();
}
-static void WriteMDNamespace(const MDNamespace *N, const ValueEnumerator &VE,
+static void WriteDINamespace(const DINamespace *N, const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
@@ -1026,7 +1025,7 @@
Record.clear();
}
-static void WriteMDTemplateTypeParameter(const MDTemplateTypeParameter *N,
+static void WriteDITemplateTypeParameter(const DITemplateTypeParameter *N,
const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
@@ -1039,7 +1038,7 @@
Record.clear();
}
-static void WriteMDTemplateValueParameter(const MDTemplateValueParameter *N,
+static void WriteDITemplateValueParameter(const DITemplateValueParameter *N,
const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
@@ -1054,7 +1053,7 @@
Record.clear();
}
-static void WriteMDGlobalVariable(const MDGlobalVariable *N,
+static void WriteDIGlobalVariable(const DIGlobalVariable *N,
const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
@@ -1075,7 +1074,7 @@
Record.clear();
}
-static void WriteMDLocalVariable(const MDLocalVariable *N,
+static void WriteDILocalVariable(const DILocalVariable *N,
const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
@@ -1094,7 +1093,7 @@
Record.clear();
}
-static void WriteMDExpression(const MDExpression *N, const ValueEnumerator &,
+static void WriteDIExpression(const DIExpression *N, const ValueEnumerator &,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
@@ -1107,11 +1106,11 @@
Record.clear();
}
-static void WriteMDObjCProperty(const MDObjCProperty *N,
- const ValueEnumerator &VE,
- BitstreamWriter &Stream,
- SmallVectorImpl<uint64_t> &Record,
- unsigned Abbrev) {
+static void WriteDIObjCProperty(const DIObjCProperty *N,
+ const ValueEnumerator &VE,
+ BitstreamWriter &Stream,
+ SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev) {
Record.push_back(N->isDistinct());
Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
Record.push_back(VE.getMetadataOrNullID(N->getFile()));
@@ -1125,7 +1124,7 @@
Record.clear();
}
-static void WriteMDImportedEntity(const MDImportedEntity *N,
+static void WriteDIImportedEntity(const DIImportedEntity *N,
const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
@@ -1164,7 +1163,7 @@
#define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
#include "llvm/IR/Metadata.def"
- if (VE.hasMDLocation()) {
+ if (VE.hasDILocation()) {
// Abbrev for METADATA_LOCATION.
//
// Assume the column is usually under 128, and always output the inlined-at
@@ -1176,10 +1175,10 @@
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
- MDLocationAbbrev = Stream.EmitAbbrev(Abbv);
+ DILocationAbbrev = Stream.EmitAbbrev(Abbv);
}
- if (VE.hasGenericDebugNode()) {
+ if (VE.hasGenericDINode()) {
// Abbrev for METADATA_GENERIC_DEBUG.
//
// Assume the column is usually under 128, and always output the inlined-at
@@ -1192,7 +1191,7 @@
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
- GenericDebugNodeAbbrev = Stream.EmitAbbrev(Abbv);
+ GenericDINodeAbbrev = Stream.EmitAbbrev(Abbv);
}
unsigned NameAbbrev = 0;
@@ -2105,7 +2104,7 @@
bool NeedsMetadataAttachment = F.hasMetadata();
- MDLocation *LastDL = nullptr;
+ DILocation *LastDL = nullptr;
// Finally, emit all the instructions, in order.
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
@@ -2120,7 +2119,7 @@
NeedsMetadataAttachment |= I->hasMetadataOtherThanDebugLoc();
// If the instruction has a debug location, emit it.
- MDLocation *DL = I->getDebugLoc();
+ DILocation *DL = I->getDebugLoc();
if (!DL)
continue;
diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
index 652851f..6c517f5 100644
--- a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
+++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
@@ -285,7 +285,7 @@
ValueEnumerator::ValueEnumerator(const Module &M,
bool ShouldPreserveUseListOrder)
- : HasMDString(false), HasMDLocation(false), HasGenericDebugNode(false),
+ : HasMDString(false), HasDILocation(false), HasGenericDINode(false),
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {
if (ShouldPreserveUseListOrder)
UseListOrders = predictUseListOrder(M);
@@ -382,7 +382,7 @@
// Don't enumerate the location directly -- it has a special record
// type -- but enumerate its operands.
- if (MDLocation *L = I.getDebugLoc())
+ if (DILocation *L = I.getDebugLoc())
EnumerateMDNodeOperands(L);
}
}
@@ -548,8 +548,8 @@
EnumerateValue(C->getValue());
HasMDString |= isa<MDString>(MD);
- HasMDLocation |= isa<MDLocation>(MD);
- HasGenericDebugNode |= isa<GenericDebugNode>(MD);
+ HasDILocation |= isa<DILocation>(MD);
+ HasGenericDINode |= isa<GenericDINode>(MD);
// Replace the dummy ID inserted above with the correct one. MDValueMap may
// have changed by inserting operands, so we need a fresh lookup here.
diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.h b/llvm/lib/Bitcode/Writer/ValueEnumerator.h
index ba245a3..92d166e 100644
--- a/llvm/lib/Bitcode/Writer/ValueEnumerator.h
+++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.h
@@ -65,8 +65,8 @@
typedef DenseMap<const Metadata *, unsigned> MetadataMapType;
MetadataMapType MDValueMap;
bool HasMDString;
- bool HasMDLocation;
- bool HasGenericDebugNode;
+ bool HasDILocation;
+ bool HasGenericDINode;
bool ShouldPreserveUseListOrder;
typedef DenseMap<AttributeSet, unsigned> AttributeGroupMapType;
@@ -121,8 +121,8 @@
}
bool hasMDString() const { return HasMDString; }
- bool hasMDLocation() const { return HasMDLocation; }
- bool hasGenericDebugNode() const { return HasGenericDebugNode; }
+ bool hasDILocation() const { return HasDILocation; }
+ bool hasGenericDINode() const { return HasGenericDINode; }
bool shouldPreserveUseListOrder() const { return ShouldPreserveUseListOrder; }