df2ef6c5046d0a3592c8affc8d2908aa19b9d5ef
[oota-llvm.git] / test / DebugInfo / X86 / nodebug_with_debug_loc.ll
1 ; REQUIRES: object-emission
2
3 ; RUN: llc -mtriple=i386-linux-gnu -filetype=obj -relocation-model=pic %s -o /dev/null
4
5 ; Derived from the test case in PR20367, there's nothing really positive to
6 ; test here (hence no FileCheck, etc). All that was wrong is that the debug info
7 ; intrinsics (introduced by inlining) in 'f1' were causing codegen to crash, but
8 ; since 'f1' is a nodebug function, there's no positive outcome to confirm, just
9 ; that debug info doesn't get in the way/cause a crash.
10
11 ; The test case isn't particularly well reduced/tidy, but as simple as I could
12 ; get the C++ source. I assume the complexity is mostly just about producing a
13 ; certain amount of register pressure, so it might be able to be simplified/made
14 ; more uniform.
15
16 ; Generated from:
17 ; $ clang-tot -cc1 -triple i386 -emit-obj -g -O3 repro.cpp
18 ; void sink(const void *);
19 ; int source();
20 ; void f3(int);
21
22 ; extern bool b;
23
24 ; struct string {
25 ;   unsigned *mem;
26 ; };
27
28 ; extern string &str;
29
30 ; inline __attribute__((always_inline)) void s2(string *lhs) { sink(lhs->mem); }
31 ; inline __attribute__((always_inline)) void f() {
32 ;   string str2;
33 ;   s2(&str2);
34 ;   sink(&str2);
35 ; }
36 ; void __attribute__((nodebug)) f1() {
37 ;   for (int iter = 0; iter != 2; ++iter) {
38 ;     f();
39 ;     sink(str.mem);
40 ;     if (b) return;
41 ;   }
42 ; }
43
44 %struct.string = type { i32* }
45
46 @str = external constant %struct.string*
47 @b = external global i8
48
49 ; Function Attrs: nounwind
50 define void @_Z2f1v() #0 {
51 entry:
52   %str2.i = alloca %struct.string, align 4
53   %0 = bitcast %struct.string* %str2.i to i8*, !dbg !26
54   %1 = load %struct.string** @str, align 4
55   %mem = getelementptr inbounds %struct.string* %1, i32 0, i32 0
56   br label %for.body
57
58 for.body:                                         ; preds = %for.body, %entry
59   %iter.02 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
60   call void @llvm.lifetime.start(i64 4, i8* %0), !dbg !26
61   call void @llvm.dbg.value(metadata %struct.string* %str2.i, i64 0, metadata !16, metadata !{!"0x102"}) #3, !dbg !26
62   call void @llvm.dbg.value(metadata %struct.string* %str2.i, i64 0, metadata !27, metadata !{!"0x102"}) #3, !dbg !29
63   call void @_Z4sinkPKv(i8* undef) #3, !dbg !29
64   call void @_Z4sinkPKv(i8* %0) #3, !dbg !30
65   call void @llvm.lifetime.end(i64 4, i8* %0), !dbg !31
66   %2 = load i32** %mem, align 4, !tbaa !32
67   %3 = bitcast i32* %2 to i8*
68   call void @_Z4sinkPKv(i8* %3) #3
69   %4 = load i8* @b, align 1, !tbaa !37, !range !39
70   %tobool = icmp ne i8 %4, 0
71   %inc = add nsw i32 %iter.02, 1
72   %cmp = icmp eq i32 %inc, 2
73   %or.cond = or i1 %tobool, %cmp
74   br i1 %or.cond, label %for.end, label %for.body
75
76 for.end:                                          ; preds = %for.body
77   ret void
78 }
79
80 declare void @_Z4sinkPKv(i8*) #1
81
82 ; Function Attrs: nounwind readnone
83 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
84
85 ; Function Attrs: nounwind
86 declare void @llvm.lifetime.start(i64, i8* nocapture) #3
87
88 ; Function Attrs: nounwind
89 declare void @llvm.lifetime.end(i64, i8* nocapture) #3
90
91 attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
92 attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
93 attributes #2 = { nounwind readnone }
94 attributes #3 = { nounwind }
95
96 !llvm.dbg.cu = !{!0}
97 !llvm.module.flags = !{!23, !24}
98 !llvm.ident = !{!25}
99
100 !0 = !{!"0x11\004\00clang version 3.5.0 \001\00\000\00\001", !1, !2, !3, !10, !2, !2} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/<stdin>] [DW_LANG_C_plus_plus]
101 !1 = !{!"<stdin>", !"/tmp/dbginfo"}
102 !2 = !{}
103 !3 = !{!4}
104 !4 = !{!"0x13\00string\007\0032\0032\000\000\000", !5, null, null, !6, null, null, !"_ZTS6string"} ; [ DW_TAG_structure_type ] [string] [line 7, size 32, align 32, offset 0] [def] [from ]
105 !5 = !{!"repro.cpp", !"/tmp/dbginfo"}
106 !6 = !{!7}
107 !7 = !{!"0xd\00mem\008\0032\0032\000\000", !5, !"_ZTS6string", !8} ; [ DW_TAG_member ] [mem] [line 8, size 32, align 32, offset 0] [from ]
108 !8 = !{!"0xf\00\000\0032\0032\000\000", null, null, !9} ; [ DW_TAG_pointer_type ] [line 0, size 32, align 32, offset 0] [from unsigned int]
109 !9 = !{!"0x24\00unsigned int\000\0032\0032\000\000\007", null, null} ; [ DW_TAG_base_type ] [unsigned int] [line 0, size 32, align 32, offset 0, enc DW_ATE_unsigned]
110 !10 = !{!11, !17}
111 !11 = !{!"0x2e\00f\00f\00_Z1fv\0014\000\001\000\006\00256\001\0014", !5, !12, !13, null, null, null, null, !15} ; [ DW_TAG_subprogram ] [line 14] [def] [f]
112 !12 = !{!"0x29", !5}         ; [ DW_TAG_file_type ] [/tmp/dbginfo/repro.cpp]
113 !13 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !14, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
114 !14 = !{null}
115 !15 = !{!16}
116 !16 = !{!"0x100\00str2\0015\000", !11, !12, !"_ZTS6string"} ; [ DW_TAG_auto_variable ] [str2] [line 15]
117 !17 = !{!"0x2e\00s2\00s2\00_Z2s2P6string\0013\000\001\000\006\00256\001\0013", !5, !12, !18, null, null, null, null, !21} ; [ DW_TAG_subprogram ] [line 13] [def] [s2]
118 !18 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !19, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
119 !19 = !{null, !20}
120 !20 = !{!"0xf\00\000\0032\0032\000\000", null, null, !"_ZTS6string"} ; [ DW_TAG_pointer_type ] [line 0, size 32, align 32, offset 0] [from _ZTS6string]
121 !21 = !{!22}
122 !22 = !{!"0x101\00lhs\0016777229\000", !17, !12, !20} ; [ DW_TAG_arg_variable ] [lhs] [line 13]
123 !23 = !{i32 2, !"Dwarf Version", i32 4}
124 !24 = !{i32 2, !"Debug Info Version", i32 2}
125 !25 = !{!"clang version 3.5.0 "}
126 !26 = !{i32 15, i32 0, !11, null}
127 !27 = !{!"0x101\00lhs\0016777229\000", !17, !12, !20, !28} ; [ DW_TAG_arg_variable ] [lhs] [line 13]
128 !28 = !{i32 16, i32 0, !11, null}
129 !29 = !{i32 13, i32 0, !17, !28}
130 !30 = !{i32 17, i32 0, !11, null}
131 !31 = !{i32 18, i32 0, !11, null}
132 !32 = !{!33, !34, i64 0}
133 !33 = !{!"_ZTS6string", !34, i64 0}
134 !34 = !{!"any pointer", !35, i64 0}
135 !35 = !{!"omnipotent char", !36, i64 0}
136 !36 = !{!"Simple C/C++ TBAA"}
137 !37 = !{!38, !38, i64 0}
138 !38 = !{!"bool", !35, i64 0}
139 !39 = !{i8 0, i8 2}