[PATCH] D64971: [SafeStack] Insert the deref after the offset
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 19 12:10:13 PDT 2019
phosek updated this revision to Diff 210877.
phosek retitled this revision from "[SafeStack] Don't re-insert derefs for allocas in debug info" to "[SafeStack] Insert the deref after the offset".
phosek edited the summary of this revision.
phosek added a comment.
I've moved the `deref` after the offset calculation, tested this against our build and it's producing the expected DWARF output.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64971/new/
https://reviews.llvm.org/D64971
Files:
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/SafeStack/X86/debug-loc2.ll
Index: llvm/test/Transforms/SafeStack/X86/debug-loc2.ll
===================================================================
--- llvm/test/Transforms/SafeStack/X86/debug-loc2.ll
+++ llvm/test/Transforms/SafeStack/X86/debug-loc2.ll
@@ -25,7 +25,7 @@
tail call void @llvm.dbg.value(metadata i32* %x1, metadata !10, metadata !24), !dbg !16
; Supported dbg.value: rewritted based on the [[USP]] value.
-; CHECK: call void @llvm.dbg.value(metadata i8* %[[USP]], metadata ![[X1:.*]], metadata !DIExpression(DW_OP_deref, DW_OP_constu, 4, DW_OP_minus))
+; CHECK: call void @llvm.dbg.value(metadata i8* %[[USP]], metadata ![[X1:.*]], metadata !DIExpression(DW_OP_constu, 4, DW_OP_minus, DW_OP_deref))
tail call void @llvm.dbg.value(metadata i32* %x1, metadata !10, metadata !15), !dbg !16
call void @capture(i32* nonnull %x1), !dbg !17
@@ -33,7 +33,7 @@
; CHECK: call void @llvm.random.metadata.use(metadata ![[EMPTY]])
call void @llvm.random.metadata.use(metadata i32* %x2)
-; CHECK: call void @llvm.dbg.value(metadata i8* %[[USP]], metadata ![[X2:.*]], metadata !DIExpression(DW_OP_deref, DW_OP_constu, 8, DW_OP_minus))
+; CHECK: call void @llvm.dbg.value(metadata i8* %[[USP]], metadata ![[X2:.*]], metadata !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref))
call void @llvm.dbg.value(metadata i32* %x2, metadata !12, metadata !15), !dbg !18
call void @capture(i32* nonnull %x2), !dbg !19
ret void, !dbg !20
Index: llvm/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1591,13 +1591,13 @@
DIExpr->getElement(0) != dwarf::DW_OP_deref)
return;
- // Insert the offset immediately after the first deref.
+ // Insert the offset before the reference.
// We could just change the offset argument of dbg.value, but it's unsigned...
if (Offset) {
SmallVector<uint64_t, 4> Ops;
- Ops.push_back(dwarf::DW_OP_deref);
DIExpression::appendOffset(Ops, Offset);
Ops.append(DIExpr->elements_begin() + 1, DIExpr->elements_end());
+ Ops.push_back(dwarf::DW_OP_deref);
DIExpr = Builder.createExpression(Ops);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64971.210877.patch
Type: text/x-patch
Size: 2207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190719/c61af2e5/attachment.bin>
More information about the llvm-commits
mailing list