1 ; RUN: llc -mtriple=x86_64-linux-gnueabi -disable-debug-info-print < %s | FileCheck %s
2 ; RUN: opt -passes=strip -S < %s | llc -mtriple=x86_64-linux-gnueabi -disable-debug-info-print | FileCheck %s
4 ; This test checks if the code is generated correctly with and without debug info.
6 ; This LL file was generated by running 'clang -g -gcodeview' on the
8 ; 1: extern "C" volatile int x;
9 ; 2: extern "C" void capture(int *p);
10 ; 3: static __forceinline inline void will_be_inlined() {
14 ; 7: extern "C" void f(int param) {
17 ; 10: will_be_inlined();
21 ; 14: will_be_inlined();
28 ; Function Attrs: nounwind uwtable
29 define void @f(i32 %param) #0 !dbg !4 {
31 %v.i1 = alloca i32, align 4
32 call void @llvm.dbg.declare(metadata ptr %v.i1, metadata !15, metadata !16), !dbg !17
33 %v.i = alloca i32, align 4
34 call void @llvm.dbg.declare(metadata ptr %v.i, metadata !15, metadata !16), !dbg !21
35 %param.addr = alloca i32, align 4
36 %a = alloca i32, align 4
37 %b = alloca i32, align 4
38 store i32 %param, ptr %param.addr, align 4
39 call void @llvm.dbg.declare(metadata ptr %param.addr, metadata !24, metadata !16), !dbg !25
40 %0 = load i32, ptr %param.addr, align 4, !dbg !26
41 %tobool = icmp ne i32 %0, 0, !dbg !26
42 br i1 %tobool, label %if.then, label %if.else, !dbg !27
44 ;CHECK: movl [[REG:.*]], 20(%rsp)
45 ;CHECK: je [[LABEL:.*]]
47 if.then: ; preds = %entry
48 call void @llvm.dbg.declare(metadata ptr %a, metadata !28, metadata !16), !dbg !29
49 store i32 42, ptr %a, align 4, !dbg !29
50 store i32 3, ptr %v.i, align 4, !dbg !21
51 call void @capture(ptr %v.i) #3, !dbg !30
52 call void @capture(ptr %a), !dbg !31
53 br label %if.end, !dbg !32
55 ;CHECK: movl $3, 12(%rsp)
57 if.else: ; preds = %entry
58 call void @llvm.dbg.declare(metadata ptr %b, metadata !33, metadata !16), !dbg !34
59 store i32 42, ptr %b, align 4, !dbg !34
60 store i32 3, ptr %v.i1, align 4, !dbg !17
61 call void @capture(ptr %v.i1) #3, !dbg !35
62 call void @capture(ptr %b), !dbg !36
66 ;CHECK: movl $3, 16(%rsp)
68 if.end: ; preds = %if.else, %if.then
72 ; Function Attrs: nounwind readnone
73 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
75 declare void @capture(ptr) #2
77 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "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" "unsafe-fp-math"="false" "use-soft-float"="false" }
78 attributes #1 = { nounwind readnone }
79 attributes #2 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "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" "unsafe-fp-math"="false" "use-soft-float"="false" }
80 attributes #3 = { nounwind }
83 !llvm.module.flags = !{!11, !12, !13}
86 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
87 !1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
89 !4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 7, type: !5, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
90 !5 = !DISubroutineType(types: !6)
92 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
93 !8 = distinct !DISubprogram(name: "will_be_inlined", linkageName: "\01?will_be_inlined@@YAXXZ", scope: !1, file: !1, line: 3, type: !9, isLocal: true, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
94 !9 = !DISubroutineType(types: !10)
96 !11 = !{i32 2, !"CodeView", i32 1}
97 !12 = !{i32 2, !"Debug Info Version", i32 3}
98 !13 = !{i32 1, !"PIC Level", i32 2}
99 !14 = !{!"clang version 3.9.0 "}
100 !15 = !DILocalVariable(name: "v", scope: !8, file: !1, line: 4, type: !7)
101 !16 = !DIExpression()
102 !17 = !DILocation(line: 4, column: 7, scope: !8, inlinedAt: !18)
103 !18 = distinct !DILocation(line: 14, column: 5, scope: !19)
104 !19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 12, column: 10)
105 !20 = distinct !DILexicalBlock(scope: !4, file: !1, line: 8, column: 7)
106 !21 = !DILocation(line: 4, column: 7, scope: !8, inlinedAt: !22)
107 !22 = distinct !DILocation(line: 10, column: 5, scope: !23)
108 !23 = distinct !DILexicalBlock(scope: !20, file: !1, line: 8, column: 14)
109 !24 = !DILocalVariable(name: "param", arg: 1, scope: !4, file: !1, line: 7, type: !7)
110 !25 = !DILocation(line: 7, column: 23, scope: !4)
111 !26 = !DILocation(line: 8, column: 7, scope: !20)
112 !27 = !DILocation(line: 8, column: 7, scope: !4)
113 !28 = !DILocalVariable(name: "a", scope: !23, file: !1, line: 9, type: !7)
114 !29 = !DILocation(line: 9, column: 9, scope: !23)
115 !30 = !DILocation(line: 5, column: 3, scope: !8, inlinedAt: !22)
116 !31 = !DILocation(line: 11, column: 5, scope: !23)
117 !32 = !DILocation(line: 12, column: 3, scope: !23)
118 !33 = !DILocalVariable(name: "b", scope: !19, file: !1, line: 13, type: !7)
119 !34 = !DILocation(line: 13, column: 9, scope: !19)
120 !35 = !DILocation(line: 5, column: 3, scope: !8, inlinedAt: !18)
121 !36 = !DILocation(line: 15, column: 5, scope: !19)
122 !37 = !DILocation(line: 17, column: 1, scope: !4)