aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-01-30 19:37:48 +0000
committerAdrian Prantl <aprantl@apple.com>2015-01-30 19:37:48 +0000
commit3e2659eb92aeefef87dd16ede20efd45fb034fc2 (patch)
treec006ef0d9b52cb9067065b0670436c978efd3f78 /llvm/lib/Transforms/Utils/Local.cpp
parent70fe588c889ea58c9a9d1d369bb3bbf96413e365 (diff)
downloadllvm-3e2659eb92aeefef87dd16ede20efd45fb034fc2.zip
llvm-3e2659eb92aeefef87dd16ede20efd45fb034fc2.tar.gz
llvm-3e2659eb92aeefef87dd16ede20efd45fb034fc2.tar.bz2
Inliner: Use replaceDbgDeclareForAlloca() instead of splicing the
instruction and generalize it to optionally dereference the variable. Follow-up to r227544. llvm-svn: 227604
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index b54c87a..648d605 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1106,10 +1106,11 @@ DbgDeclareInst *llvm::FindAllocaDbgDeclare(Value *V) {
}
bool llvm::replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress,
- DIBuilder &Builder) {
+ DIBuilder &Builder, bool Deref) {
DbgDeclareInst *DDI = FindAllocaDbgDeclare(AI);
if (!DDI)
return false;
+ DebugLoc Loc = DDI->getDebugLoc();
DIVariable DIVar(DDI->getVariable());
DIExpression DIExpr(DDI->getExpression());
assert((!DIVar || DIVar.isVariable()) &&
@@ -1117,21 +1118,24 @@ bool llvm::replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress,
if (!DIVar)
return false;
- // Create a copy of the original DIDescriptor for user variable, prepending
- // "deref" operation to a list of address elements, as new llvm.dbg.declare
- // will take a value storing address of the memory for variable, not
- // alloca itself.
- SmallVector<int64_t, 4> NewDIExpr;
- NewDIExpr.push_back(dwarf::DW_OP_deref);
- if (DIExpr)
- for (unsigned i = 0, n = DIExpr.getNumElements(); i < n; ++i)
- NewDIExpr.push_back(DIExpr.getElement(i));
+ if (Deref) {
+ // Create a copy of the original DIDescriptor for user variable, prepending
+ // "deref" operation to a list of address elements, as new llvm.dbg.declare
+ // will take a value storing address of the memory for variable, not
+ // alloca itself.
+ SmallVector<int64_t, 4> NewDIExpr;
+ NewDIExpr.push_back(dwarf::DW_OP_deref);
+ if (DIExpr)
+ for (unsigned i = 0, n = DIExpr.getNumElements(); i < n; ++i)
+ NewDIExpr.push_back(DIExpr.getElement(i));
+ DIExpr = Builder.createExpression(NewDIExpr);
+ }
// Insert llvm.dbg.declare in the same basic block as the original alloca,
// and remove old llvm.dbg.declare.
BasicBlock *BB = AI->getParent();
- Builder.insertDeclare(NewAllocaAddress, DIVar,
- Builder.createExpression(NewDIExpr), BB);
+ Builder.insertDeclare(NewAllocaAddress, DIVar, DIExpr, BB)
+ ->setDebugLoc(Loc);
DDI->eraseFromParent();
return true;
}