Debian Codegraph @

llvm/test/Transforms/SafeStack/X86/debug-loc2.ll

raw
1 ; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
2 ; RUN: opt -passes=safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
3
4 ; Test llvm.dbg.value for the local variables moved onto the unsafe stack.
5 ; SafeStack rewrites them relative to the unsafe stack pointer (base address of
6 ; the unsafe stack frame).
7
8 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
9 target triple = "x86_64-unknown-linux-gnu"
10
11 ; Function Attrs: noinline safestack uwtable
12 define void @f() #0 !dbg !6 {
13 entry:
14 ; CHECK: %[[USP:.*]] = load ptr, ptr @__safestack_unsafe_stack_ptr
15 %x1 = alloca i32, align 4
16 %x2 = alloca i32, align 4
17
18 ; Unhandled dbg.value: expression does not start with OP_DW_deref
19 ; CHECK: #dbg_value(ptr poison, !{{.*}}, !{{.*}})
20 tail call void @llvm.dbg.value(metadata ptr %x1, metadata !10, metadata !23), !dbg !16
21
22 ; Unhandled dbg.value: expression does not start with OP_DW_deref
23 ; CHECK: #dbg_value(ptr poison, !{{.*}}, !{{.*}})
24 tail call void @llvm.dbg.value(metadata ptr %x1, metadata !10, metadata !24), !dbg !16
25
26 ; Supported dbg.value: rewritted based on the [[USP]] value.
27 ; CHECK: #dbg_value(ptr %[[USP]], ![[X1:.*]], !DIExpression(DW_OP_constu, 4, DW_OP_minus, DW_OP_deref, DW_OP_LLVM_fragment, 0, 4),
28 tail call void @llvm.dbg.value(metadata ptr %x1, metadata !10, metadata !25), !dbg !16
29
30 ; Supported dbg.value: rewritted based on the [[USP]] value.
31 ; CHECK: #dbg_value(ptr %[[USP]], ![[X1:.*]], !DIExpression(DW_OP_constu, 4, DW_OP_minus, DW_OP_deref),
32 tail call void @llvm.dbg.value(metadata ptr %x1, metadata !10, metadata !15), !dbg !16
33 call void @capture(ptr nonnull %x1), !dbg !17
34
35 ; An extra non-dbg.value metadata use of %x2. Replaced with poison.
36 ; CHECK: call void @llvm.random.metadata.use(metadata ptr poison
37 call void @llvm.random.metadata.use(metadata ptr %x2)
38
39 ; CHECK: #dbg_value(ptr %[[USP]], ![[X2:.*]], !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref),
40 call void @llvm.dbg.value(metadata ptr %x2, metadata !12, metadata !15), !dbg !18
41 call void @capture(ptr nonnull %x2), !dbg !19
42 ret void, !dbg !20
43 }
44
45 ; Function Attrs: argmemonly nounwind
46 declare void @llvm.lifetime.start.p0(ptr nocapture) #1
47
48 declare void @capture(ptr)
49
50 ; Function Attrs: argmemonly nounwind
51 declare void @llvm.lifetime.end.p0(ptr nocapture) #1
52
53 ; Function Attrs: nounwind readnone
54 declare void @llvm.dbg.value(metadata, metadata, metadata) #3
55
56 declare void @llvm.random.metadata.use(metadata)
57
58 attributes #0 = { noinline safestack uwtable }
59 attributes #1 = { argmemonly nounwind }
60 attributes #3 = { nounwind readnone }
61 attributes #4 = { nounwind }
62
63 !llvm.dbg.cu = !{!0}
64 !llvm.module.flags = !{!3, !4}
65 !llvm.ident = !{!5}
66
67 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 271022) (llvm/trunk 271027)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
68 !1 = !DIFile(filename: "../llvm/2.cc", directory: "/code/build-llvm")
69
70 !2 = !{}
71 !3 = !{i32 2, !"Dwarf Version", i32 4}
72 !4 = !{i32 2, !"Debug Info Version", i32 3}
73 !5 = !{!"clang version 3.9.0 (trunk 271022) (llvm/trunk 271027)"}
74 !6 = distinct !DISubprogram(name: "f", linkageName: "_Z1fv", scope: !1, file: !1, line: 4, type: !7, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !9)
75 !7 = !DISubroutineType(types: !8)
76 !8 = !{null}
77 !9 = !{!10, !12}
78
79 ; CHECK-DAG: ![[X1]] = !DILocalVariable(name: "x1",
80 !10 = !DILocalVariable(name: "x1", scope: !6, file: !1, line: 5, type: !11)
81 !11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
82
83 ; CHECK-DAG: ![[X2]] = !DILocalVariable(name: "x2",
84 !12 = !DILocalVariable(name: "x2", scope: !6, file: !1, line: 6, type: !11)
85 !13 = !DILocation(line: 5, column: 3, scope: !6)
86 !14 = !DILocation(line: 6, column: 3, scope: !6)
87
88 !15 = !DIExpression(DW_OP_deref)
89 !16 = !DILocation(line: 5, column: 7, scope: !6)
90 !17 = !DILocation(line: 8, column: 3, scope: !6)
91 !18 = !DILocation(line: 6, column: 7, scope: !6)
92 !19 = !DILocation(line: 9, column: 3, scope: !6)
93 !20 = !DILocation(line: 10, column: 1, scope: !6)
94 !21 = !DILocation(line: 10, column: 1, scope: !22)
95 !22 = !DILexicalBlockFile(scope: !6, file: !1, discriminator: 1)
96 !23 = !DIExpression()
97 !24 = !DIExpression(DW_OP_constu, 42, DW_OP_minus)
98 !25 = !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 4)