xref: /aosp_15_r20/external/llvm/test/Transforms/SafeStack/debug-loc2.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Test llvm.dbg.value for the local variables moved onto the unsafe stack.
4*9880d681SAndroid Build Coastguard Worker; SafeStack rewrites them relative to the unsafe stack pointer (base address of
5*9880d681SAndroid Build Coastguard Worker; the unsafe stack frame).
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
8*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-unknown-linux-gnu"
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Worker; Function Attrs: noinline safestack uwtable
11*9880d681SAndroid Build Coastguard Workerdefine void @f() #0 !dbg !6 {
12*9880d681SAndroid Build Coastguard Workerentry:
13*9880d681SAndroid Build Coastguard Worker; CHECK:   %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
14*9880d681SAndroid Build Coastguard Worker  %x1 = alloca i32, align 4
15*9880d681SAndroid Build Coastguard Worker  %x2 = alloca i32, align 4
16*9880d681SAndroid Build Coastguard Worker  %0 = bitcast i32* %x1 to i8*, !dbg !13
17*9880d681SAndroid Build Coastguard Worker  %1 = bitcast i32* %x2 to i8*, !dbg !14
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; Unhandled dbg.value: expression does not start with OP_DW_deref
20*9880d681SAndroid Build Coastguard Worker; CHECK: call void @llvm.dbg.value(metadata ![[EMPTY:.*]], i64 0, metadata !{{.*}}, metadata !{{.*}})
21*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.value(metadata i32* %x1, i64 0, metadata !10, metadata !23), !dbg !16
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Worker; Unhandled dbg.value: expression does not start with OP_DW_deref
24*9880d681SAndroid Build Coastguard Worker; CHECK: call void @llvm.dbg.value(metadata ![[EMPTY]], i64 0, metadata !{{.*}}, metadata !{{.*}})
25*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.value(metadata i32* %x1, i64 0, metadata !10, metadata !24), !dbg !16
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Worker; Supported dbg.value: rewritted based on the [[USP]] value.
28*9880d681SAndroid Build Coastguard Worker; CHECK: call void @llvm.dbg.value(metadata i8* %[[USP]], i64 0, metadata ![[X1:.*]], metadata ![[X1_EXPR:.*]])
29*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.value(metadata i32* %x1, i64 0, metadata !10, metadata !15), !dbg !16
30*9880d681SAndroid Build Coastguard Worker  call void @capture(i32* nonnull %x1), !dbg !17
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker; An extra non-dbg.value metadata use of %x2. Replaced with an empty metadata.
33*9880d681SAndroid Build Coastguard Worker; CHECK: call void @llvm.random.metadata.use(metadata ![[EMPTY]])
34*9880d681SAndroid Build Coastguard Worker  call void @llvm.random.metadata.use(metadata i32* %x2)
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker; CHECK: call void @llvm.dbg.value(metadata i8* %[[USP]], i64 0, metadata ![[X2:.*]], metadata ![[X2_EXPR:.*]])
37*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.value(metadata i32* %x2, i64 0, metadata !12, metadata !15), !dbg !18
38*9880d681SAndroid Build Coastguard Worker  call void @capture(i32* nonnull %x2), !dbg !19
39*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !20
40*9880d681SAndroid Build Coastguard Worker}
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Worker; Function Attrs: argmemonly nounwind
43*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.lifetime.start(i64, i8* nocapture) #1
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Workerdeclare void @capture(i32*) #2
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Worker; Function Attrs: argmemonly nounwind
48*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.lifetime.end(i64, i8* nocapture) #1
49*9880d681SAndroid Build Coastguard Worker
50*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone
51*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.value(metadata, i64, metadata, metadata) #3
52*9880d681SAndroid Build Coastguard Worker
53*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.random.metadata.use(metadata)
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Workerattributes #0 = { noinline safestack uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
56*9880d681SAndroid Build Coastguard Workerattributes #1 = { argmemonly nounwind }
57*9880d681SAndroid Build Coastguard Workerattributes #2 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
58*9880d681SAndroid Build Coastguard Workerattributes #3 = { nounwind readnone }
59*9880d681SAndroid Build Coastguard Workerattributes #4 = { nounwind }
60*9880d681SAndroid Build Coastguard Worker
61*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0}
62*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!3, !4}
63*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!5}
64*9880d681SAndroid Build Coastguard Worker
65*9880d681SAndroid Build Coastguard Worker!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)
66*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "../llvm/2.cc", directory: "/code/build-llvm")
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ![[EMPTY]] = !{}
69*9880d681SAndroid Build Coastguard Worker!2 = !{}
70*9880d681SAndroid Build Coastguard Worker!3 = !{i32 2, !"Dwarf Version", i32 4}
71*9880d681SAndroid Build Coastguard Worker!4 = !{i32 2, !"Debug Info Version", i32 3}
72*9880d681SAndroid Build Coastguard Worker!5 = !{!"clang version 3.9.0 (trunk 271022) (llvm/trunk 271027)"}
73*9880d681SAndroid Build Coastguard Worker!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, variables: !9)
74*9880d681SAndroid Build Coastguard Worker!7 = !DISubroutineType(types: !8)
75*9880d681SAndroid Build Coastguard Worker!8 = !{null}
76*9880d681SAndroid Build Coastguard Worker!9 = !{!10, !12}
77*9880d681SAndroid Build Coastguard Worker
78*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ![[X1]] = !DILocalVariable(name: "x1",
79*9880d681SAndroid Build Coastguard Worker!10 = !DILocalVariable(name: "x1", scope: !6, file: !1, line: 5, type: !11)
80*9880d681SAndroid Build Coastguard Worker!11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
81*9880d681SAndroid Build Coastguard Worker
82*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ![[X2]] = !DILocalVariable(name: "x2",
83*9880d681SAndroid Build Coastguard Worker!12 = !DILocalVariable(name: "x2", scope: !6, file: !1, line: 6, type: !11)
84*9880d681SAndroid Build Coastguard Worker!13 = !DILocation(line: 5, column: 3, scope: !6)
85*9880d681SAndroid Build Coastguard Worker!14 = !DILocation(line: 6, column: 3, scope: !6)
86*9880d681SAndroid Build Coastguard Worker
87*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ![[X1_EXPR]] = !DIExpression(DW_OP_deref, DW_OP_minus, 4)
88*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ![[X2_EXPR]] = !DIExpression(DW_OP_deref, DW_OP_minus, 8)
89*9880d681SAndroid Build Coastguard Worker!15 = !DIExpression(DW_OP_deref)
90*9880d681SAndroid Build Coastguard Worker!16 = !DILocation(line: 5, column: 7, scope: !6)
91*9880d681SAndroid Build Coastguard Worker!17 = !DILocation(line: 8, column: 3, scope: !6)
92*9880d681SAndroid Build Coastguard Worker!18 = !DILocation(line: 6, column: 7, scope: !6)
93*9880d681SAndroid Build Coastguard Worker!19 = !DILocation(line: 9, column: 3, scope: !6)
94*9880d681SAndroid Build Coastguard Worker!20 = !DILocation(line: 10, column: 1, scope: !6)
95*9880d681SAndroid Build Coastguard Worker!21 = !DILocation(line: 10, column: 1, scope: !22)
96*9880d681SAndroid Build Coastguard Worker!22 = !DILexicalBlockFile(scope: !6, file: !1, discriminator: 1)
97*9880d681SAndroid Build Coastguard Worker!23 = !DIExpression()
98*9880d681SAndroid Build Coastguard Worker!24 = !DIExpression(DW_OP_minus, 42)
99