diff options
| author | Adrian Prantl <aprantl@apple.com> | 2017-12-08 21:58:18 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2017-12-08 21:58:18 +0000 |
| commit | d13170174c656a6dbf2f4b30b638645d6e0727fd (patch) | |
| tree | 48e17ffc3aa57c3277dd85aa052f4075a22f6cb5 /llvm/lib/Transforms | |
| parent | 195dfd10a679ed4860200e935d1ca292d09bb64b (diff) | |
| download | bcm5719-llvm-d13170174c656a6dbf2f4b30b638645d6e0727fd.tar.gz bcm5719-llvm-d13170174c656a6dbf2f4b30b638645d6e0727fd.zip | |
Generalize llvm::replaceDbgDeclare and actually support the use-case that
is mentioned in the documentation (inserting a deref before the plus_uconst).
llvm-svn: 320203
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 10 |
3 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index dc17aa6cbd5..f626c2c0b16 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -2918,7 +2918,8 @@ void FunctionStackPoisoner::processStaticAllocas() { Value *NewAllocaPtr = IRB.CreateIntToPtr( IRB.CreateAdd(LocalStackBase, ConstantInt::get(IntptrTy, Desc.Offset)), AI->getType()); - replaceDbgDeclareForAlloca(AI, NewAllocaPtr, DIB, DIExpression::NoDeref); + replaceDbgDeclareForAlloca(AI, NewAllocaPtr, DIB, DIExpression::NoDeref, + 0, DIExpression::NoDeref); AI->replaceAllUsesWith(NewAllocaPtr); } diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index c69ff12b6b9..aa595ce5867 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1810,7 +1810,8 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI, // Move any dbg.declares describing the allocas into the entry basic block. DIBuilder DIB(*Caller->getParent()); for (auto &AI : IFI.StaticAllocas) - replaceDbgDeclareForAlloca(AI, AI, DIB, /*Deref=*/false); + replaceDbgDeclareForAlloca(AI, AI, DIB, DIExpression::NoDeref, 0, + DIExpression::NoDeref); } SmallVector<Value*,4> VarArgsToForward; diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 3f7629540be..3ee2d046513 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1304,14 +1304,14 @@ static void findDbgUsers(SmallVectorImpl<DbgInfoIntrinsic *> &DbgUsers, bool llvm::replaceDbgDeclare(Value *Address, Value *NewAddress, Instruction *InsertBefore, DIBuilder &Builder, - bool Deref, int Offset) { + bool DerefBefore, int Offset, bool DerefAfter) { auto DbgAddrs = FindDbgAddrUses(Address); for (DbgInfoIntrinsic *DII : DbgAddrs) { DebugLoc Loc = DII->getDebugLoc(); auto *DIVar = DII->getVariable(); auto *DIExpr = DII->getExpression(); assert(DIVar && "Missing variable"); - DIExpr = DIExpression::prepend(DIExpr, Deref, Offset); + DIExpr = DIExpression::prepend(DIExpr, DerefBefore, Offset, DerefAfter); // Insert llvm.dbg.declare immediately after InsertBefore, and remove old // llvm.dbg.declare. Builder.insertDeclare(NewAddress, DIVar, DIExpr, Loc, InsertBefore); @@ -1323,9 +1323,10 @@ bool llvm::replaceDbgDeclare(Value *Address, Value *NewAddress, } bool llvm::replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress, - DIBuilder &Builder, bool Deref, int Offset) { + DIBuilder &Builder, bool DerefBefore, + int Offset, bool DerefAfter) { return replaceDbgDeclare(AI, NewAllocaAddress, AI->getNextNode(), Builder, - Deref, Offset); + DerefBefore, Offset, DerefAfter); } static void replaceOneDbgValueForAlloca(DbgValueInst *DVI, Value *NewAddress, @@ -1378,6 +1379,7 @@ void llvm::salvageDebugInfo(Instruction &I) { auto applyOffset = [&](DbgValueInst *DVI, uint64_t Offset) { auto *DIExpr = DVI->getExpression(); DIExpr = DIExpression::prepend(DIExpr, DIExpression::NoDeref, Offset, + DIExpression::NoDeref, DIExpression::WithStackValue); DVI->setOperand(0, wrapMD(I.getOperand(0))); DVI->setOperand(2, MetadataAsValue::get(I.getContext(), DIExpr)); |

