Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions llvm/lib/Transforms/Utils/Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2117,19 +2117,22 @@ bool llvm::replaceDbgDeclare(Value *Address, Value *NewAddress,
DIBuilder &Builder, uint8_t DIExprFlags,
int Offset) {
SmallVector<DbgDeclareInst *, 1> DbgDeclares;
findDbgDeclares(DbgDeclares, Address);
for (DbgVariableIntrinsic *DII : DbgDeclares) {
const DebugLoc &Loc = DII->getDebugLoc();
SmallVector<DPValue *, 1> DPValues;
findDbgDeclares(DbgDeclares, Address, &DPValues);

auto ReplaceOne = [&](auto *DII) {
auto *DIVar = DII->getVariable();
auto *DIExpr = DII->getExpression();
assert(DIVar && "Missing variable");
DIExpr = DIExpression::prepend(DIExpr, DIExprFlags, Offset);
// Insert llvm.dbg.declare immediately before DII, and remove old
// llvm.dbg.declare.
Builder.insertDeclare(NewAddress, DIVar, DIExpr, Loc, DII);
DII->eraseFromParent();
}
return !DbgDeclares.empty();
DII->setExpression(DIExpr);
DII->replaceVariableLocationOp(Address, NewAddress);
};

for_each(DbgDeclares, ReplaceOne);
for_each(DPValues, ReplaceOne);

return !DbgDeclares.empty() || !DPValues.empty();
}

static void updateOneDbgValueForAlloca(const DebugLoc &Loc,
Expand Down
1 change: 1 addition & 0 deletions llvm/test/DebugInfo/Generic/block-asan.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: opt -S -passes=asan %s | FileCheck %s
; RUN: opt --try-experimental-debuginfo-iterators -S -passes=asan %s | FileCheck %s

; The IR of this testcase is generated from the following C code:
; void bar (int);
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/DebugInfo/X86/asan_debug_info.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
; RUN: llc -O0 -filetype=obj - -o - | \
; RUN: llvm-dwarfdump - | FileCheck %s

; RUN: opt --try-experimental-debuginfo-iterators < %s -passes=asan -asan-use-after-return=never -S | \
; RUN: llc -O0 -filetype=obj - -o - | \
; RUN: llvm-dwarfdump - | FileCheck %s

; For this test case, ASan used to produce IR which resulted in the following
; DWARF (at -O0):
;
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/Transforms/SafeStack/ARM/debug.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
; RUN: opt -safe-stack -safestack-use-pointer-address < %s -S | FileCheck %s
; RUN: opt -passes=safe-stack -safestack-use-pointer-address < %s -S | FileCheck %s
; RUN: opt --try-experimental-debuginfo-iterators -passes=safe-stack -safestack-use-pointer-address < %s -S | FileCheck %s

target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv7-pc-linux-android"

Expand Down