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 |
| 15 | ; CHECK-NOT: call |
| 16 | call void @_ZL3barv(), !dbg !9 |
| 17 | ; CHECK-NOT: invoke |
| 18 | invoke void @_ZL3barv() |
| 19 | to label %4 unwind label %5, !dbg !10 |
| 20 | |
| 21 | ; <label>:4: |
| 22 | ret void |
| 23 | |
| 24 | ; <label>:5: |
| 25 | %6 = landingpad { i8*, i32 } |
| 26 | catch i8* bitcast (i8** @_ZTIi to i8*) |
| 27 | ret void |
| 28 | } |
| 29 | |
| 30 | ; Function Attrs: nounwind uwtable |
Dehao Chen | 554f500 | 2016-11-22 22:50:01 +0000 | [diff] [blame] | 31 | define internal void @_ZL3barv() !dbg !12 { |
Dehao Chen | 41cde0b | 2016-09-18 23:11:37 +0000 | [diff] [blame] | 32 | ret void |
| 33 | } |
| 34 | |
Dehao Chen | 50f2aa1 | 2017-06-21 17:57:43 +0000 | [diff] [blame^] | 35 | ; CHECK-LABEL: @recursive |
| 36 | define void @recursive() !dbg !13 { |
| 37 | ; Recursive calls should not be early-inlined. |
| 38 | ; CHECK-NOT: call void @recursive |
| 39 | ; CHECK: call void @recursive |
| 40 | ; CHECK: call void @recursive |
| 41 | ; CHECK-NOT: call void @recursive |
| 42 | ; CHECK: ret |
| 43 | call void @recursive(), !dbg !14 |
| 44 | call void @recursive(), !dbg !15 |
| 45 | ret void |
| 46 | } |
| 47 | |
Dehao Chen | 41cde0b | 2016-09-18 23:11:37 +0000 | [diff] [blame] | 48 | declare i32 @__gxx_personality_v0(...) |
| 49 | |
| 50 | !llvm.dbg.cu = !{!0} |
| 51 | !llvm.module.flags = !{!3, !4} |
| 52 | |
| 53 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1) |
| 54 | !1 = !DIFile(filename: "a", directory: "b/") |
| 55 | !3 = !{i32 2, !"Dwarf Version", i32 4} |
| 56 | !4 = !{i32 2, !"Debug Info Version", i32 3} |
Justin Bogner | efc3fbf | 2017-02-17 23:57:42 +0000 | [diff] [blame] | 57 | !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] | 58 | !9 = !DILocation(line: 6, column: 3, scope: !6) |
| 59 | !10 = !DILocation(line: 8, column: 5, scope: !11) |
| 60 | !11 = distinct !DILexicalBlock(scope: !6, file: !1, line: 7, column: 7) |
Justin Bogner | efc3fbf | 2017-02-17 23:57:42 +0000 | [diff] [blame] | 61 | !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^] | 62 | !13 = distinct !DISubprogram(linkageName: "recursive", scope: !1, file: !1, line: 20, scopeLine: 20, unit: !0) |
| 63 | !14 = !DILocation(line: 21, column: 3, scope: !13) |
| 64 | !15 = !DILocation(line: 22, column: 3, scope: !13) |