Dehao Chen | 20866ed | 2016-09-19 18:38:14 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -instcombine -sample-profile -sample-profile-file=%S/Inputs/einline.prof -S | FileCheck %s |
Dehao Chen | 41cde0b | 2016-09-18 23:11:37 +0000 | [diff] [blame] | 2 | |
| 3 | ; Checks if both call and invoke can be inlined early if their inlined |
| 4 | ; instances are hot in profile. |
| 5 | |
| 6 | target triple = "x86_64-unknown-linux-gnu" |
| 7 | |
| 8 | @_ZTIi = external constant i8* |
| 9 | |
| 10 | ; Function Attrs: uwtable |
| 11 | define void @_Z3foov() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) !dbg !6 { |
| 12 | %1 = alloca i8* |
| 13 | %2 = alloca i32 |
| 14 | %3 = alloca i32, align 4 |
Dehao Chen | 3a81f84 | 2017-09-14 17:29:56 +0000 | [diff] [blame] | 15 | ; CHECK: call void @no_inline |
| 16 | call void @no_inline(), !dbg !16 |
Dehao Chen | 41cde0b | 2016-09-18 23:11:37 +0000 | [diff] [blame] | 17 | ; CHECK-NOT: call |
| 18 | call void @_ZL3barv(), !dbg !9 |
| 19 | ; CHECK-NOT: invoke |
| 20 | invoke void @_ZL3barv() |
| 21 | to label %4 unwind label %5, !dbg !10 |
| 22 | |
| 23 | ; <label>:4: |
| 24 | ret void |
| 25 | |
| 26 | ; <label>:5: |
| 27 | %6 = landingpad { i8*, i32 } |
| 28 | catch i8* bitcast (i8** @_ZTIi to i8*) |
| 29 | ret void |
| 30 | } |
| 31 | |
| 32 | ; Function Attrs: nounwind uwtable |
Dehao Chen | be707f2 | 2017-09-13 21:49:36 +0000 | [diff] [blame] | 33 | define internal void @_ZL3barv() #0 !dbg !12 { |
Dehao Chen | 41cde0b | 2016-09-18 23:11:37 +0000 | [diff] [blame] | 34 | ret void |
| 35 | } |
| 36 | |
Dehao Chen | 50f2aa1 | 2017-06-21 17:57:43 +0000 | [diff] [blame] | 37 | ; CHECK-LABEL: @recursive |
Dehao Chen | be707f2 | 2017-09-13 21:49:36 +0000 | [diff] [blame] | 38 | define void @recursive() #0 !dbg !13 { |
Dehao Chen | 50f2aa1 | 2017-06-21 17:57:43 +0000 | [diff] [blame] | 39 | ; Recursive calls should not be early-inlined. |
| 40 | ; CHECK-NOT: call void @recursive |
| 41 | ; CHECK: call void @recursive |
| 42 | ; CHECK: call void @recursive |
| 43 | ; CHECK-NOT: call void @recursive |
| 44 | ; CHECK: ret |
| 45 | call void @recursive(), !dbg !14 |
| 46 | call void @recursive(), !dbg !15 |
| 47 | ret void |
| 48 | } |
| 49 | |
Dehao Chen | 3a81f84 | 2017-09-14 17:29:56 +0000 | [diff] [blame] | 50 | ; The callee has mismatch attributes to the caller, it should not be inlined |
| 51 | define void @no_inline() #1 !dbg !17 { |
| 52 | ret void |
| 53 | } |
| 54 | |
Dehao Chen | 41cde0b | 2016-09-18 23:11:37 +0000 | [diff] [blame] | 55 | declare i32 @__gxx_personality_v0(...) |
| 56 | |
Dehao Chen | 3a81f84 | 2017-09-14 17:29:56 +0000 | [diff] [blame] | 57 | attributes #0 = {"target-features"="+sse4.1"} |
| 58 | attributes #1 = {"target-features"="+sse4.2"} |
| 59 | |
Dehao Chen | 41cde0b | 2016-09-18 23:11:37 +0000 | [diff] [blame] | 60 | !llvm.dbg.cu = !{!0} |
| 61 | !llvm.module.flags = !{!3, !4} |
| 62 | |
| 63 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1) |
| 64 | !1 = !DIFile(filename: "a", directory: "b/") |
| 65 | !3 = !{i32 2, !"Dwarf Version", i32 4} |
| 66 | !4 = !{i32 2, !"Debug Info Version", i32 3} |
Justin Bogner | efc3fbf | 2017-02-17 23:57:42 +0000 | [diff] [blame] | 67 | !6 = distinct !DISubprogram(linkageName: "_Z3foov", scope: !1, file: !1, line: 5, scopeLine: 5, unit: !0) |
Dehao Chen | 41cde0b | 2016-09-18 23:11:37 +0000 | [diff] [blame] | 68 | !9 = !DILocation(line: 6, column: 3, scope: !6) |
| 69 | !10 = !DILocation(line: 8, column: 5, scope: !11) |
| 70 | !11 = distinct !DILexicalBlock(scope: !6, file: !1, line: 7, column: 7) |
Justin Bogner | efc3fbf | 2017-02-17 23:57:42 +0000 | [diff] [blame] | 71 | !12 = distinct !DISubprogram(linkageName: "_ZL3barv", scope: !1, file: !1, line: 20, scopeLine: 20, unit: !0) |
Dehao Chen | 50f2aa1 | 2017-06-21 17:57:43 +0000 | [diff] [blame] | 72 | !13 = distinct !DISubprogram(linkageName: "recursive", scope: !1, file: !1, line: 20, scopeLine: 20, unit: !0) |
| 73 | !14 = !DILocation(line: 21, column: 3, scope: !13) |
| 74 | !15 = !DILocation(line: 22, column: 3, scope: !13) |
Dehao Chen | 3a81f84 | 2017-09-14 17:29:56 +0000 | [diff] [blame] | 75 | !16 = !DILocation(line: 7, column: 3, scope: !6) |
| 76 | !17 = distinct !DISubprogram(linkageName: "no_inline", scope: !1, file: !1, line: 20, scopeLine: 20, unit: !0) |