summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-07-20 23:49:05 +0000
committerDan Gohman <gohman@apple.com>2010-07-20 23:49:05 +0000
commit333a94765a78e0d7057059c6cb05dba2330eddf0 (patch)
treee506ae6e7d81affd8a4793cb337cfe849f7e4868 /lib/Transforms/Utils
parent539673579ec79b75a95ef9daefc6a8b2fc8552f5 (diff)
downloadllvm-333a94765a78e0d7057059c6cb05dba2330eddf0.tar.gz
llvm-333a94765a78e0d7057059c6cb05dba2330eddf0.tar.bz2
llvm-333a94765a78e0d7057059c6cb05dba2330eddf0.tar.xz
Use DebugLocs instead of MDNodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108967 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/CloneFunction.cpp59
1 files changed, 27 insertions, 32 deletions
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp
index 2aea51abdb..767fc2a840 100644
--- a/lib/Transforms/Utils/CloneFunction.cpp
+++ b/lib/Transforms/Utils/CloneFunction.cpp
@@ -334,25 +334,16 @@ ConstantFoldMappedInstruction(const Instruction *I) {
Ops.size(), TD);
}
-static MDNode *UpdateInlinedAtInfo(MDNode *InsnMD, MDNode *TheCallMD) {
- DILocation ILoc(InsnMD);
- if (!ILoc.Verify()) return InsnMD;
-
- DILocation CallLoc(TheCallMD);
- if (!CallLoc.Verify()) return InsnMD;
-
- DILocation OrigLocation = ILoc.getOrigLocation();
- MDNode *NewLoc = TheCallMD;
- if (OrigLocation.Verify())
- NewLoc = UpdateInlinedAtInfo(OrigLocation, TheCallMD);
-
- Value *MDVs[] = {
- InsnMD->getOperand(0), // Line
- InsnMD->getOperand(1), // Col
- InsnMD->getOperand(2), // Scope
- NewLoc
- };
- return MDNode::get(InsnMD->getContext(), MDVs, 4);
+static DebugLoc
+UpdateInlinedAtInfo(const DebugLoc &InsnDL, const DebugLoc &TheCallDL,
+ LLVMContext &Ctx) {
+ DebugLoc NewLoc = TheCallDL;
+ if (MDNode *IA = InsnDL.getInlinedAt(Ctx))
+ NewLoc = UpdateInlinedAtInfo(DebugLoc::getFromDILocation(IA), TheCallDL,
+ Ctx);
+
+ return DebugLoc::get(InsnDL.getLine(), InsnDL.getCol(),
+ InsnDL.getScope(Ctx), NewLoc.getAsMDNode(Ctx));
}
/// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto,
@@ -408,9 +399,9 @@ void llvm::CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,
//
BasicBlock::iterator I = NewBB->begin();
- MDNode *TheCallMD = NULL;
- if (TheCall && TheCall->hasMetadata())
- TheCallMD = TheCall->getMetadata(LLVMContext::MD_dbg);
+ DebugLoc TheCallDL;
+ if (TheCall)
+ TheCallDL = TheCall->getDebugLoc();
// Handle PHI nodes specially, as we have to remove references to dead
// blocks.
@@ -419,15 +410,17 @@ void llvm::CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,
BasicBlock::const_iterator OldI = BI->begin();
for (; (PN = dyn_cast<PHINode>(I)); ++I, ++OldI) {
if (I->hasMetadata()) {
- if (TheCallMD) {
- if (MDNode *IMD = I->getMetadata(LLVMContext::MD_dbg)) {
- MDNode *NewMD = UpdateInlinedAtInfo(IMD, TheCallMD);
- I->setMetadata(LLVMContext::MD_dbg, NewMD);
+ if (!TheCallDL.isUnknown()) {
+ DebugLoc IDL = I->getDebugLoc();
+ if (!IDL.isUnknown()) {
+ DebugLoc NewDL = UpdateInlinedAtInfo(IDL, TheCallDL,
+ I->getContext());
+ I->setDebugLoc(NewDL);
}
} else {
// The cloned instruction has dbg info but the call instruction
// does not have dbg info. Remove dbg info from cloned instruction.
- I->setMetadata(LLVMContext::MD_dbg, 0);
+ I->setDebugLoc(DebugLoc());
}
}
PHIToResolve.push_back(cast<PHINode>(OldI));
@@ -443,15 +436,17 @@ void llvm::CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,
// Otherwise, remap the rest of the instructions normally.
for (; I != NewBB->end(); ++I) {
if (I->hasMetadata()) {
- if (TheCallMD) {
- if (MDNode *IMD = I->getMetadata(LLVMContext::MD_dbg)) {
- MDNode *NewMD = UpdateInlinedAtInfo(IMD, TheCallMD);
- I->setMetadata(LLVMContext::MD_dbg, NewMD);
+ if (!TheCallDL.isUnknown()) {
+ DebugLoc IDL = I->getDebugLoc();
+ if (!IDL.isUnknown()) {
+ DebugLoc NewDL = UpdateInlinedAtInfo(IDL, TheCallDL,
+ I->getContext());
+ I->setDebugLoc(NewDL);
}
} else {
// The cloned instruction has dbg info but the call instruction
// does not have dbg info. Remove dbg info from cloned instruction.
- I->setMetadata(LLVMContext::MD_dbg, 0);
+ I->setDebugLoc(DebugLoc());
}
}
RemapInstruction(I, VMap);