summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SafeStack.cpp8
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp1
-rw-r--r--llvm/lib/IR/DebugInfoMetadata.cpp11
-rw-r--r--llvm/lib/Target/X86/X86OptimizeLEAs.cpp1
-rw-r--r--llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp3
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp3
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp10
7 files changed, 25 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/SafeStack.cpp b/llvm/lib/CodeGen/SafeStack.cpp
index e68f6e10a2a..51233be521b 100644
--- a/llvm/lib/CodeGen/SafeStack.cpp
+++ b/llvm/lib/CodeGen/SafeStack.cpp
@@ -558,7 +558,7 @@ Value *SafeStack::moveStaticAllocasToUnsafeStack(
// Replace alloc with the new location.
replaceDbgDeclare(Arg, BasePointer, BasePointer->getNextNode(), DIB,
- /*Deref=*/false, -Offset);
+ DIExpression::NoDeref, -Offset, DIExpression::NoDeref);
Arg->replaceAllUsesWith(NewArg);
IRB.SetInsertPoint(cast<Instruction>(NewArg)->getNextNode());
IRB.CreateMemCpy(Off, Arg, Size, Arg->getParamAlignment());
@@ -573,7 +573,8 @@ Value *SafeStack::moveStaticAllocasToUnsafeStack(
if (Size == 0)
Size = 1; // Don't create zero-sized stack objects.
- replaceDbgDeclareForAlloca(AI, BasePointer, DIB, /*Deref=*/false, -Offset);
+ replaceDbgDeclareForAlloca(AI, BasePointer, DIB, DIExpression::NoDeref,
+ -Offset, DIExpression::NoDeref);
replaceDbgValueForAlloca(AI, BasePointer, DIB, -Offset);
// Replace uses of the alloca with the new location.
@@ -663,7 +664,8 @@ void SafeStack::moveDynamicAllocasToUnsafeStack(
if (AI->hasName() && isa<Instruction>(NewAI))
NewAI->takeName(AI);
- replaceDbgDeclareForAlloca(AI, NewAI, DIB, /*Deref=*/false);
+ replaceDbgDeclareForAlloca(AI, NewAI, DIB, DIExpression::NoDeref, 0,
+ DIExpression::NoDeref);
AI->replaceAllUsesWith(NewAI);
AI->eraseFromParent();
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index bcc972e0b4f..e45c632c93b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -7130,6 +7130,7 @@ void SelectionDAG::salvageDebugInfo(SDNode &N) {
// DW_OP_stack_value.
auto *DIExpr = DV->getExpression();
DIExpr = DIExpression::prepend(DIExpr, DIExpression::NoDeref, Offset,
+ DIExpression::NoDeref,
DIExpression::WithStackValue);
SDDbgValue *Clone =
getDbgValue(DV->getVariable(), DIExpr, N0.getNode(), N0.getResNo(),
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 940c4d1f366..75ddd47b259 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -750,12 +750,17 @@ bool DIExpression::extractIfOffset(int64_t &Offset) const {
return false;
}
-DIExpression *DIExpression::prepend(const DIExpression *Expr, bool Deref,
- int64_t Offset, bool StackValue) {
+DIExpression *DIExpression::prepend(const DIExpression *Expr, bool DerefBefore,
+ int64_t Offset, bool DerefAfter,
+ bool StackValue) {
SmallVector<uint64_t, 8> Ops;
+ if (DerefBefore)
+ Ops.push_back(dwarf::DW_OP_deref);
+
appendOffset(Ops, Offset);
- if (Deref)
+ if (DerefAfter)
Ops.push_back(dwarf::DW_OP_deref);
+
if (Expr)
for (auto Op : Expr->expr_ops()) {
// A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment.
diff --git a/llvm/lib/Target/X86/X86OptimizeLEAs.cpp b/llvm/lib/Target/X86/X86OptimizeLEAs.cpp
index cc136866c47..0b77014f2b6 100644
--- a/llvm/lib/Target/X86/X86OptimizeLEAs.cpp
+++ b/llvm/lib/Target/X86/X86OptimizeLEAs.cpp
@@ -568,6 +568,7 @@ MachineInstr *OptimizeLEAPass::replaceDebugValue(MachineInstr &MI,
if (AddrDispShift != 0)
Expr = DIExpression::prepend(Expr, DIExpression::NoDeref, AddrDispShift,
+ DIExpression::NoDeref,
DIExpression::WithStackValue);
// Replace DBG_VALUE instruction with modified version.
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));
OpenPOWER on IntegriCloud