[llvm] r366865 - [SafeStack] Insert the deref before remaining elements
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 23 17:16:23 PDT 2019
Author: phosek
Date: Tue Jul 23 17:16:23 2019
New Revision: 366865
URL: http://llvm.org/viewvc/llvm-project?rev=366865&view=rev
Log:
[SafeStack] Insert the deref before remaining elements
This is a follow up to D64971. While we need to insert the deref after
the offset, it needs to come before the remaining elements in the
original expression since the deref needs to happen before the LLVM
fragment if present.
Differential Revision: https://reviews.llvm.org/D65172
Modified:
llvm/trunk/lib/Transforms/Utils/Local.cpp
llvm/trunk/test/Transforms/SafeStack/X86/debug-loc2.ll
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=366865&r1=366864&r2=366865&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Tue Jul 23 17:16:23 2019
@@ -1599,13 +1599,8 @@ static void replaceOneDbgValueForAlloca(
// Insert the offset before the first deref.
// We could just change the offset argument of dbg.value, but it's unsigned...
- if (Offset) {
- SmallVector<uint64_t, 4> Ops;
- DIExpression::appendOffset(Ops, Offset);
- Ops.append(DIExpr->elements_begin() + 1, DIExpr->elements_end());
- Ops.push_back(dwarf::DW_OP_deref);
- DIExpr = Builder.createExpression(Ops);
- }
+ if (Offset)
+ DIExpr = DIExpression::prepend(DIExpr, 0, Offset);
Builder.insertDbgValueIntrinsic(NewAddress, DIVar, DIExpr, Loc, DVI);
DVI->eraseFromParent();
Modified: llvm/trunk/test/Transforms/SafeStack/X86/debug-loc2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SafeStack/X86/debug-loc2.ll?rev=366865&r1=366864&r2=366865&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SafeStack/X86/debug-loc2.ll (original)
+++ llvm/trunk/test/Transforms/SafeStack/X86/debug-loc2.ll Tue Jul 23 17:16:23 2019
@@ -25,6 +25,10 @@ entry:
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_constu, 4, DW_OP_minus, DW_OP_deref, DW_OP_LLVM_fragment, 0, 4))
+ tail call void @llvm.dbg.value(metadata i32* %x1, metadata !10, metadata !25), !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_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
@@ -94,3 +98,4 @@ attributes #4 = { nounwind }
!22 = !DILexicalBlockFile(scope: !6, file: !1, discriminator: 1)
!23 = !DIExpression()
!24 = !DIExpression(DW_OP_constu, 42, DW_OP_minus)
+!25 = !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 4)
More information about the llvm-commits
mailing list