|
| 1 | +; RUN: opt < %s -always-inline -S | FileCheck %s |
| 2 | + |
| 3 | +; Original input generated from clang -emit-llvm -S -c -mllvm -disable-llvm-optzns |
| 4 | +; |
| 5 | +; #define CALLS1 f2(); f2(); |
| 6 | +; #define CALLS2 f4(); f4(); |
| 7 | +; void f1(); |
| 8 | +; inline __attribute__((always_inline)) void f2() { |
| 9 | +; f1(); |
| 10 | +; } |
| 11 | +; inline __attribute__((always_inline)) void f3() { |
| 12 | +; CALLS1 |
| 13 | +; } |
| 14 | +; inline __attribute__((always_inline)) void f4() { |
| 15 | +; f3(); |
| 16 | +; } |
| 17 | +; void f() { |
| 18 | +; CALLS2 |
| 19 | +; } |
| 20 | + |
| 21 | +; There should be unique locations for all 4 of these instructions, correctly |
| 22 | +; describing the inlining that has occurred, even in the face of duplicate call |
| 23 | +; site locations. |
| 24 | + |
| 25 | +; The nomenclature used for the tags here is <function name>[cs<number>] where |
| 26 | +; 'cs' is an abbreviation for 'call site' and the number indicates which call |
| 27 | +; site from within the named function this is. (so, given the above inlining, we |
| 28 | +; should have 4 calls to 'f1', two from the first call to f4 and two from the |
| 29 | +; second call to f4) |
| 30 | + |
| 31 | +; CHECK: call void @_Z2f1v(), !dbg [[fcs1_f4_f3cs1_f2:![0-9]+]] |
| 32 | +; CHECK: call void @_Z2f1v(), !dbg [[fcs1_f4_f3cs2_f2:![0-9]+]] |
| 33 | +; CHECK: call void @_Z2f1v(), !dbg [[fcs2_f4_f3cs1_f2:![0-9]+]] |
| 34 | +; CHECK: call void @_Z2f1v(), !dbg [[fcs2_f4_f3cs2_f2:![0-9]+]] |
| 35 | + |
| 36 | +; CHECK-DAG: [[F:![0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [f] |
| 37 | +; CHECK-DAG: [[F2:![0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [f2] |
| 38 | +; CHECK-DAG: [[F3:![0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [f3] |
| 39 | +; CHECK-DAG: [[F4:![0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [f4] |
| 40 | + |
| 41 | +; CHECK: [[fcs1_f4_f3cs1_f2]] = {{.*}}, scope: [[F2]], inlinedAt: [[fcs1_f4_f3cs1:![0-9]+]]) |
| 42 | +; CHECK: [[fcs1_f4_f3cs1]] = {{.*}}, scope: [[F3]], inlinedAt: [[fcs1_f4:![0-9]+]]) |
| 43 | +; CHECK: [[fcs1_f4]] = {{.*}}, scope: [[F4]], inlinedAt: [[fcs1:![0-9]+]]) |
| 44 | +; CHECK: [[fcs1]] = {{.*}}, scope: [[F]]) |
| 45 | +; CHECK: [[fcs1_f4_f3cs2_f2]] = {{.*}}, scope: [[F2]], inlinedAt: [[fcs1_f4_f3cs2:![0-9]+]]) |
| 46 | +; CHECK: [[fcs1_f4_f3cs2]] = {{.*}}, scope: [[F3]], inlinedAt: [[fcs1_f4]]) |
| 47 | + |
| 48 | +; CHECK: [[fcs2_f4_f3cs1_f2]] = {{.*}}, scope: [[F2]], inlinedAt: [[fcs2_f4_f3cs1:![0-9]+]]) |
| 49 | +; CHECK: [[fcs2_f4_f3cs1]] = {{.*}}, scope: [[F3]], inlinedAt: [[fcs2_f4:![0-9]+]]) |
| 50 | +; CHECK: [[fcs2_f4]] = {{.*}}, scope: [[F4]], inlinedAt: [[fcs2:![0-9]+]]) |
| 51 | +; CHECK: [[fcs2]] = {{.*}}, scope: [[F]]) |
| 52 | +; CHECK: [[fcs2_f4_f3cs2_f2]] = {{.*}}, scope: [[F2]], inlinedAt: [[fcs2_f4_f3cs2:![0-9]+]]) |
| 53 | +; CHECK: [[fcs2_f4_f3cs2]] = {{.*}}, scope: [[F3]], inlinedAt: [[fcs2_f4]]) |
| 54 | + |
| 55 | +$_Z2f4v = comdat any |
| 56 | + |
| 57 | +$_Z2f3v = comdat any |
| 58 | + |
| 59 | +$_Z2f2v = comdat any |
| 60 | + |
| 61 | +; Function Attrs: uwtable |
| 62 | +define void @_Z1fv() #0 { |
| 63 | +entry: |
| 64 | + call void @_Z2f4v(), !dbg !13 |
| 65 | + call void @_Z2f4v(), !dbg !13 |
| 66 | + ret void, !dbg !14 |
| 67 | +} |
| 68 | + |
| 69 | +; Function Attrs: alwaysinline inlinehint uwtable |
| 70 | +define linkonce_odr void @_Z2f4v() #1 comdat { |
| 71 | +entry: |
| 72 | + call void @_Z2f3v(), !dbg !15 |
| 73 | + ret void, !dbg !16 |
| 74 | +} |
| 75 | + |
| 76 | +; Function Attrs: alwaysinline inlinehint uwtable |
| 77 | +define linkonce_odr void @_Z2f3v() #1 comdat { |
| 78 | +entry: |
| 79 | + call void @_Z2f2v(), !dbg !17 |
| 80 | + call void @_Z2f2v(), !dbg !17 |
| 81 | + ret void, !dbg !18 |
| 82 | +} |
| 83 | + |
| 84 | +; Function Attrs: alwaysinline inlinehint uwtable |
| 85 | +define linkonce_odr void @_Z2f2v() #1 comdat { |
| 86 | +entry: |
| 87 | + call void @_Z2f1v(), !dbg !19 |
| 88 | + ret void, !dbg !20 |
| 89 | +} |
| 90 | + |
| 91 | +declare void @_Z2f1v() #2 |
| 92 | + |
| 93 | +attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 94 | +attributes #1 = { alwaysinline inlinehint uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 95 | +attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 96 | + |
| 97 | +!llvm.dbg.cu = !{!0} |
| 98 | +!llvm.module.flags = !{!10, !11} |
| 99 | +!llvm.ident = !{!12} |
| 100 | + |
| 101 | +!0 = !{!"0x11\004\00clang version 3.7.0 (trunk 226474) (llvm/trunk 226478)\000\00\000\00\002", !1, !2, !2, !3, !2, !2} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/debug-info-duplicate-calls.cpp] [DW_LANG_C_plus_plus] |
| 102 | +!1 = !{!"debug-info-duplicate-calls.cpp", !"/tmp/dbginfo"} |
| 103 | +!2 = !{} |
| 104 | +!3 = !{!4, !7, !8, !9} |
| 105 | +!4 = !{!"0x2e\00f\00f\00\0013\000\001\000\000\00256\000\0013", !1, !5, !6, null, void ()* @_Z1fv, null, null, !2} ; [ DW_TAG_subprogram ] [line 13] [def] [f] |
| 106 | +!5 = !{!"0x29", !1} ; [ DW_TAG_file_type ] [/tmp/dbginfo/debug-info-duplicate-calls.cpp] |
| 107 | +!6 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !2, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] |
| 108 | +!7 = !{!"0x2e\00f4\00f4\00\0010\000\001\000\000\00256\000\0010", !1, !5, !6, null, void ()* @_Z2f4v, null, null, !2} ; [ DW_TAG_subprogram ] [line 10] [def] [f4] |
| 109 | +!8 = !{!"0x2e\00f3\00f3\00\007\000\001\000\000\00256\000\007", !1, !5, !6, null, void ()* @_Z2f3v, null, null, !2} ; [ DW_TAG_subprogram ] [line 7] [def] [f3] |
| 110 | +!9 = !{!"0x2e\00f2\00f2\00\004\000\001\000\000\00256\000\004", !1, !5, !6, null, void ()* @_Z2f2v, null, null, !2} ; [ DW_TAG_subprogram ] [line 4] [def] [f2] |
| 111 | +!10 = !{i32 2, !"Dwarf Version", i32 4} |
| 112 | +!11 = !{i32 2, !"Debug Info Version", i32 2} |
| 113 | +!12 = !{!"clang version 3.7.0 (trunk 226474) (llvm/trunk 226478)"} |
| 114 | +!13 = !MDLocation(line: 14, column: 3, scope: !4) |
| 115 | +!14 = !MDLocation(line: 15, column: 1, scope: !4) |
| 116 | +!15 = !MDLocation(line: 11, column: 3, scope: !7) |
| 117 | +!16 = !MDLocation(line: 12, column: 1, scope: !7) |
| 118 | +!17 = !MDLocation(line: 8, column: 3, scope: !8) |
| 119 | +!18 = !MDLocation(line: 9, column: 1, scope: !8) |
| 120 | +!19 = !MDLocation(line: 5, column: 3, scope: !9) |
| 121 | +!20 = !MDLocation(line: 6, column: 1, scope: !9) |
0 commit comments