rename getMDKind -> getMDKindID, make it autoinsert if an MD Kind
doesn't exist already, eliminate registerMDKind. Tidy up a bunch
of random stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92225 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp
index 9e182ef..24a5b0d 100644
--- a/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -351,9 +351,9 @@
if (MMI) {
MetadataContext &TheMetadata =
DI->getParent()->getContext().getMetadata();
- unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
- MDNode *Dbg = TheMetadata.getMD(MDDbgKind, DI);
- MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg);
+ unsigned MDDbgKind = TheMetadata.getMDKindID("dbg");
+ if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, DI))
+ MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg);
}
return true;
}
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 8fe7c45..266cb64 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -4383,9 +4383,9 @@
if (MMI) {
MetadataContext &TheMetadata =
DI.getParent()->getContext().getMetadata();
- unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
- MDNode *Dbg = TheMetadata.getMD(MDDbgKind, &DI);
- MMI->setVariableDbgInfo(Variable, FI, Dbg);
+ unsigned MDDbgKind = TheMetadata.getMDKindID("dbg");
+ if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, &DI))
+ MMI->setVariableDbgInfo(Variable, FI, Dbg);
}
return 0;
}
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 667be90..7efd480 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -362,27 +362,25 @@
/// SetDebugLoc - Update MF's and SDB's DebugLocs if debug information is
/// attached with this instruction.
-static void SetDebugLoc(unsigned MDDbgKind,
- MetadataContext &TheMetadata,
- Instruction *I,
- SelectionDAGBuilder *SDB,
- FastISel *FastIS,
- MachineFunction *MF) {
- if (!isa<DbgInfoIntrinsic>(I))
- if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, I)) {
- DILocation DILoc(Dbg);
- DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo());
+static void SetDebugLoc(unsigned MDDbgKind, MetadataContext &TheMetadata,
+ Instruction *I, SelectionDAGBuilder *SDB,
+ FastISel *FastIS, MachineFunction *MF) {
+ if (isa<DbgInfoIntrinsic>(I)) return;
+
+ if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, I)) {
+ DILocation DILoc(Dbg);
+ DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo());
- SDB->setCurDebugLoc(Loc);
+ SDB->setCurDebugLoc(Loc);
- if (FastIS)
- FastIS->setCurDebugLoc(Loc);
+ if (FastIS)
+ FastIS->setCurDebugLoc(Loc);
- // If the function doesn't have a default debug location yet, set
- // it. This is kind of a hack.
- if (MF->getDefaultDebugLoc().isUnknown())
- MF->setDefaultDebugLoc(Loc);
- }
+ // If the function doesn't have a default debug location yet, set
+ // it. This is kind of a hack.
+ if (MF->getDefaultDebugLoc().isUnknown())
+ MF->setDefaultDebugLoc(Loc);
+ }
}
/// ResetDebugLoc - Set MF's and SDB's DebugLocs to Unknown.
@@ -398,14 +396,13 @@
BasicBlock::iterator End,
bool &HadTailCall) {
SDB->setCurrentBasicBlock(BB);
- MetadataContext &TheMetadata = LLVMBB->getParent()->getContext().getMetadata();
- unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
+ MetadataContext &TheMetadata =LLVMBB->getParent()->getContext().getMetadata();
+ unsigned MDDbgKind = TheMetadata.getMDKindID("dbg");
// Lower all of the non-terminator instructions. If a call is emitted
// as a tail call, cease emitting nodes for this block.
for (BasicBlock::iterator I = Begin; I != End && !SDB->HasTailCall; ++I) {
- if (MDDbgKind)
- SetDebugLoc(MDDbgKind, TheMetadata, I, SDB, 0, MF);
+ SetDebugLoc(MDDbgKind, TheMetadata, I, SDB, 0, MF);
if (!isa<TerminatorInst>(I)) {
SDB->visit(*I);
@@ -681,7 +678,7 @@
);
MetadataContext &TheMetadata = Fn.getContext().getMetadata();
- unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
+ unsigned MDDbgKind = TheMetadata.getMDKindID("dbg");
// Iterate over all basic blocks in the function.
for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) {
@@ -779,8 +776,7 @@
break;
}
- if (MDDbgKind)
- SetDebugLoc(MDDbgKind, TheMetadata, BI, SDB, FastIS, &MF);
+ SetDebugLoc(MDDbgKind, TheMetadata, BI, SDB, FastIS, &MF);
// First try normal tablegen-generated "fast" selection.
if (FastIS->SelectInstruction(BI)) {