xref: /llvm-project/llvm/test/DebugInfo/X86/nodebug_with_debug_loc.ll (revision 5a288fa32e0c91b211e39f3e370255916902f898)
1
2; RUN: llc -mtriple=i386-linux-gnu -filetype=obj -relocation-model=pic %s -o /dev/null
3
4; Derived from the test case in PR20367, there's nothing really positive to
5; test here (hence no FileCheck, etc). All that was wrong is that the debug info
6; intrinsics (introduced by inlining) in 'f1' were causing codegen to crash, but
7; since 'f1' is a nodebug function, there's no positive outcome to confirm, just
8; that debug info doesn't get in the way/cause a crash.
9
10; The test case isn't particularly well reduced/tidy, but as simple as I could
11; get the C++ source. I assume the complexity is mostly just about producing a
12; certain amount of register pressure, so it might be able to be simplified/made
13; more uniform.
14
15; Generated from:
16; $ clang-tot -cc1 -triple i386 -emit-obj -g -O3 repro.cpp
17; void sink(const ptr);
18; int source();
19; void f3(int);
20;
21; extern bool b;
22;
23; struct string {
24;   unsigned *mem;
25; };
26;
27; extern string &str;
28;
29; inline __attribute__((always_inline)) void s2(string *lhs) { sink(lhs->mem); }
30; inline __attribute__((always_inline)) void f() {
31;   string str2;
32;   s2(&str2);
33;   sink(&str2);
34; }
35; void __attribute__((nodebug)) f1() {
36;   for (int iter = 0; iter != 2; ++iter) {
37;     f();
38;     sink(str.mem);
39;     if (b) return;
40;   }
41; }
42
43%struct.string = type { ptr }
44
45@str = external constant ptr
46@b = external global i8
47
48; Function Attrs: nounwind
49define void @_Z2f1v() #0 {
50entry:
51  %str2.i = alloca %struct.string, align 4
52  %0 = load ptr, ptr @str, align 4
53  br label %for.body
54
55for.body:                                         ; preds = %for.body, %entry
56  %iter.02 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
57  call void @llvm.lifetime.start(i64 4, ptr %str2.i), !dbg !26
58  call void @llvm.dbg.value(metadata ptr %str2.i, metadata !16, metadata !DIExpression(DW_OP_deref)) #3, !dbg !26
59  call void @llvm.dbg.value(metadata ptr %str2.i, metadata !27, metadata !DIExpression(DW_OP_deref)) #3, !dbg !29
60  call void @_Z4sinkPKv(ptr undef) #3, !dbg !29
61  call void @_Z4sinkPKv(ptr %str2.i) #3, !dbg !30
62  call void @llvm.lifetime.end(i64 4, ptr %str2.i), !dbg !31
63  %1 = load ptr, ptr %0, align 4, !tbaa !32
64  call void @_Z4sinkPKv(ptr %1) #3
65  %2 = load i8, ptr @b, align 1, !tbaa !37, !range !39
66  %tobool = icmp ne i8 %2, 0
67  %inc = add nsw i32 %iter.02, 1
68  %cmp = icmp eq i32 %inc, 2
69  %or.cond = or i1 %tobool, %cmp
70  br i1 %or.cond, label %for.end, label %for.body
71
72for.end:                                          ; preds = %for.body
73  ret void
74}
75
76declare void @_Z4sinkPKv(ptr) #1
77
78; Function Attrs: nounwind readnone
79declare void @llvm.dbg.value(metadata, metadata, metadata) #2
80
81; Function Attrs: nounwind
82declare void @llvm.lifetime.start(i64, ptr nocapture) #3
83
84; Function Attrs: nounwind
85declare void @llvm.lifetime.end(i64, ptr nocapture) #3
86
87attributes #0 = { nounwind "less-precise-fpmad"="false" "frame-pointer"="none" "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" }
88attributes #1 = { "less-precise-fpmad"="false" "frame-pointer"="none" "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" }
89attributes #2 = { nounwind readnone }
90attributes #3 = { nounwind }
91
92!llvm.dbg.cu = !{!0}
93!llvm.module.flags = !{!23, !24}
94!llvm.ident = !{!25}
95
96!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2)
97!1 = !DIFile(filename: "<stdin>", directory: "/tmp/dbginfo")
98!2 = !{}
99!3 = !{!4}
100!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "string", line: 7, size: 32, align: 32, file: !5, elements: !6, identifier: "_ZTS6string")
101!5 = !DIFile(filename: "repro.cpp", directory: "/tmp/dbginfo")
102!6 = !{!7}
103!7 = !DIDerivedType(tag: DW_TAG_member, name: "mem", line: 8, size: 32, align: 32, file: !5, scope: !4, baseType: !8)
104!8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 32, align: 32, baseType: !9)
105!9 = !DIBasicType(tag: DW_TAG_base_type, name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
106!11 = distinct !DISubprogram(name: "f", linkageName: "_Z1fv", line: 14, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 14, file: !5, scope: !12, type: !13, retainedNodes: !15)
107!12 = !DIFile(filename: "repro.cpp", directory: "/tmp/dbginfo")
108!13 = !DISubroutineType(types: !14)
109!14 = !{null}
110!15 = !{!16}
111!16 = !DILocalVariable(name: "str2", line: 15, scope: !11, file: !12, type: !4)
112!17 = distinct !DISubprogram(name: "s2", linkageName: "_Z2s2P6string", line: 13, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 13, file: !5, scope: !12, type: !18, retainedNodes: !21)
113!18 = !DISubroutineType(types: !19)
114!19 = !{null, !20}
115!20 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 32, align: 32, baseType: !4)
116!21 = !{!22}
117!22 = !DILocalVariable(name: "lhs", line: 13, arg: 1, scope: !17, file: !12, type: !20)
118!23 = !{i32 2, !"Dwarf Version", i32 4}
119!24 = !{i32 2, !"Debug Info Version", i32 3}
120!25 = !{!"clang version 3.5.0 "}
121!26 = !DILocation(line: 15, scope: !11)
122!27 = !DILocalVariable(name: "lhs", line: 13, arg: 1, scope: !17, file: !12, type: !20)
123!28 = !DILocation(line: 16, scope: !11)
124!29 = !DILocation(line: 13, scope: !17, inlinedAt: !28)
125!30 = !DILocation(line: 17, scope: !11)
126!31 = !DILocation(line: 18, scope: !11)
127!32 = !{!33, !34, i64 0}
128!33 = !{!"struct", !34, i64 0}
129!34 = !{!"any pointer", !35, i64 0}
130!35 = !{!"omnipotent char", !36, i64 0}
131!36 = !{!"Simple C/C++ TBAA"}
132!37 = !{!38, !38, i64 0}
133!38 = !{!"bool", !35, i64 0}
134!39 = !{i8 0, i8 2}
135