diff options
| author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2015-09-30 19:55:43 +0000 |
|---|---|---|
| committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2015-09-30 19:55:43 +0000 |
| commit | f608111d1b6493ae9f8e8f0c24da57ca1aebb72f (patch) | |
| tree | 8ff46ff99f7f0243649d692783bf9e14eecef0f5 /llvm/lib/Transforms | |
| parent | 57737529feea5229c3d259ed0fe666f61ec42fac (diff) | |
| download | bcm5719-llvm-f608111d1b6493ae9f8e8f0c24da57ca1aebb72f.tar.gz bcm5719-llvm-f608111d1b6493ae9f8e8f0c24da57ca1aebb72f.zip | |
Fix debug info with SafeStack.
llvm-svn: 248933
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/SafeStack.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 14 |
2 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SafeStack.cpp b/llvm/lib/Transforms/Instrumentation/SafeStack.cpp index 8a767617f90..bfc69621456 100644 --- a/llvm/lib/Transforms/Instrumentation/SafeStack.cpp +++ b/llvm/lib/Transforms/Instrumentation/SafeStack.cpp @@ -443,7 +443,7 @@ SafeStack::moveStaticAllocasToUnsafeStack(IRBuilder<> &IRB, Function &F, cast<Instruction>(NewAI)->takeName(AI); // Replace alloc with the new location. - replaceDbgDeclareForAlloca(AI, NewAI, DIB, /*Deref=*/true); + replaceDbgDeclareForAlloca(AI, BasePointer, DIB, /*Deref=*/true, -StaticOffset); AI->replaceAllUsesWith(NewAI); AI->eraseFromParent(); } diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index adee3f6c985..1a74544045c 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1136,7 +1136,7 @@ DbgDeclareInst *llvm::FindAllocaDbgDeclare(Value *V) { } bool llvm::replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress, - DIBuilder &Builder, bool Deref) { + DIBuilder &Builder, bool Deref, int Offset) { DbgDeclareInst *DDI = FindAllocaDbgDeclare(AI); if (!DDI) return false; @@ -1145,13 +1145,21 @@ bool llvm::replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress, auto *DIExpr = DDI->getExpression(); assert(DIVar && "Missing variable"); - if (Deref) { + if (Deref || Offset) { // 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<uint64_t, 4> NewDIExpr; - NewDIExpr.push_back(dwarf::DW_OP_deref); + if (Deref) + NewDIExpr.push_back(dwarf::DW_OP_deref); + if (Offset > 0) { + NewDIExpr.push_back(dwarf::DW_OP_plus); + NewDIExpr.push_back(Offset); + } else if (Offset < 0) { + NewDIExpr.push_back(dwarf::DW_OP_minus); + NewDIExpr.push_back(-Offset); + } if (DIExpr) NewDIExpr.append(DIExpr->elements_begin(), DIExpr->elements_end()); DIExpr = Builder.createExpression(NewDIExpr); |

