xref: /llvm-project/llvm/test/DebugInfo/X86/dbg_value_direct.ll (revision 10b03e66629aedad79a804e22d23b575077303b3)
1; RUN: llc -filetype=obj -O0 < %s
2; RUN: llc --try-experimental-debuginfo-iterators -filetype=obj -O0 < %s
3; Test that we handle DBG_VALUEs in a register without crashing.
4;
5; Generated from clang with -fsanitize=address:
6; struct A {
7;   A();
8;   A(const A&);
9; };
10;
11; A func(int) {
12;   A a;
13;   return a;
14; }
15
16target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
17target triple = "x86_64-unknown-linux-gnu"
18
19%struct.A = type { i8 }
20
21@__asan_mapping_offset = linkonce_odr constant i64 2147450880
22@__asan_mapping_scale = linkonce_odr constant i64 3
23@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 1, ptr @asan.module_ctor, ptr null }]
24@___asan_gen_ = private unnamed_addr constant [16 x i8] c"1 32 4 5 .addr \00", align 1
25
26; Function Attrs: sanitize_address uwtable
27define void @_Z4funci(ptr noalias sret(%struct.A) %agg.result, i32) #0 "stack-protector-buffer-size"="1" !dbg !4 {
28entry:
29  %MyAlloca = alloca [96 x i8], align 32
30  %1 = ptrtoint ptr %MyAlloca to i64
31  %2 = add i64 %1, 32
32  %3 = inttoptr i64 %2 to ptr
33  %4 = inttoptr i64 %1 to ptr
34  store i64 1102416563, ptr %4
35  %5 = add i64 %1, 8
36  %6 = inttoptr i64 %5 to ptr
37  store i64 ptrtoint (ptr @___asan_gen_ to i64), ptr %6
38  %7 = add i64 %1, 16
39  %8 = inttoptr i64 %7 to ptr
40  store i64 ptrtoint (ptr @_Z4funci to i64), ptr %8
41  %9 = lshr i64 %1, 3
42  %10 = add i64 %9, 2147450880
43  %11 = inttoptr i64 %10 to ptr
44  store i32 -235802127, ptr %11
45  %12 = add i64 %10, 4
46  %13 = inttoptr i64 %12 to ptr
47  store i32 -185273340, ptr %13
48  %14 = add i64 %10, 8
49  %15 = inttoptr i64 %14 to ptr
50  store i32 -202116109, ptr %15
51  %16 = ptrtoint ptr %3 to i64
52  %17 = lshr i64 %16, 3
53  %18 = add i64 %17, 2147450880
54  %19 = inttoptr i64 %18 to ptr
55  %20 = load i8, ptr %19
56  %21 = icmp ne i8 %20, 0
57  call void @llvm.dbg.declare(metadata ptr %3, metadata !23, metadata !28), !dbg !DILocation(scope: !4)
58  br i1 %21, label %22, label %28
59
60; <label>:22                                      ; preds = %entry
61  %23 = and i64 %16, 7
62  %24 = add i64 %23, 3
63  %25 = trunc i64 %24 to i8
64  %26 = icmp sge i8 %25, %20
65  br i1 %26, label %27, label %28
66
67; <label>:27                                      ; preds = %22
68  call void @__asan_report_store4(i64 %16)
69  call void asm sideeffect "", ""()
70  unreachable
71
72; <label>:28                                      ; preds = %22, %entry
73  store i32 %0, ptr %3, align 4
74  call void @llvm.dbg.declare(metadata ptr %agg.result, metadata !24, metadata !DIExpression()), !dbg !25
75  call void @_ZN1AC1Ev(ptr %agg.result), !dbg !25
76  store i64 1172321806, ptr %4, !dbg !26
77  %29 = inttoptr i64 %10 to ptr, !dbg !26
78  store i32 0, ptr %29, !dbg !26
79  %30 = add i64 %10, 4, !dbg !26
80  %31 = inttoptr i64 %30 to ptr, !dbg !26
81  store i32 0, ptr %31, !dbg !26
82  %32 = add i64 %10, 8, !dbg !26
83  %33 = inttoptr i64 %32 to ptr, !dbg !26
84  store i32 0, ptr %33, !dbg !26
85  ret void, !dbg !26
86}
87
88; Function Attrs: nounwind readnone
89declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
90
91declare void @_ZN1AC1Ev(ptr) #2
92
93define internal void @asan.module_ctor()  "stack-protector-buffer-size"="1" {
94  call void @__asan_init_v3()
95  %1 = load volatile i64, ptr @__asan_mapping_offset
96  %2 = load volatile i64, ptr @__asan_mapping_scale
97  ret void
98}
99
100declare void @__asan_init_v3()
101
102declare void @__asan_report_load1(i64)
103
104declare void @__asan_report_load2(i64)
105
106declare void @__asan_report_load4(i64)
107
108declare void @__asan_report_load8(i64)
109
110declare void @__asan_report_load16(i64)
111
112declare void @__asan_report_store1(i64)
113
114declare void @__asan_report_store2(i64)
115
116declare void @__asan_report_store4(i64)
117
118declare void @__asan_report_store8(i64)
119
120declare void @__asan_report_store16(i64)
121
122declare void @__asan_report_load_n(i64, i64)
123
124declare void @__asan_report_store_n(i64, i64)
125
126declare void @__asan_handle_no_return()
127
128declare i64 @__asan_stack_malloc(i64, i64)
129
130declare void @__asan_stack_free(i64, i64, i64)
131
132declare void @__asan_poison_stack_memory(i64, i64)
133
134declare void @__asan_unpoison_stack_memory(i64, i64)
135
136declare void @__asan_before_dynamic_init(i64)
137
138declare void @__asan_after_dynamic_init()
139
140declare void @__asan_register_globals(i64, i64)
141
142declare void @__asan_unregister_globals(i64, i64)
143
144attributes #0 = { sanitize_address uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "ssp-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
145attributes #1 = { nounwind readnone }
146attributes #2 = { "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "ssp-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
147
148!llvm.dbg.cu = !{!0}
149!llvm.module.flags = !{!22, !27}
150
151!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.4 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
152!1 = !DIFile(filename: "crash.cpp", directory: "/tmp")
153!2 = !{}
154!4 = distinct !DISubprogram(name: "func", linkageName: "_Z4funci", line: 6, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 6, file: !1, scope: !5, type: !6, retainedNodes: !2)
155!5 = !DIFile(filename: "crash.cpp", directory: "/tmp")
156!6 = !DISubroutineType(types: !7)
157!7 = !{!8, !21}
158!8 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", line: 1, size: 8, align: 8, file: !1, elements: !9)
159!9 = !{!10, !15}
160!10 = !DISubprogram(name: "A", line: 2, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !1, scope: !8, type: !11)
161!11 = !DISubroutineType(types: !12)
162!12 = !{null, !13}
163!13 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !8)
164!15 = !DISubprogram(name: "A", line: 3, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 3, file: !1, scope: !8, type: !16)
165!16 = !DISubroutineType(types: !17)
166!17 = !{null, !13, !18}
167!18 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !19)
168!19 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
169!21 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
170!22 = !{i32 2, !"Dwarf Version", i32 3}
171!23 = !DILocalVariable(name: "", line: 6, arg: 1, scope: !4, file: !5, type: !21)
172!24 = !DILocalVariable(name: "a", line: 7, scope: !4, file: !5, type: !8)
173!25 = !DILocation(line: 7, scope: !4)
174!26 = !DILocation(line: 8, scope: !4)
175!27 = !{i32 1, !"Debug Info Version", i32 3}
176!28 = !DIExpression(DW_OP_deref)
177