| Adrian Prantl | 0941638 | 2013-04-30 17:08:16 +0000 | [diff] [blame] | 1 | ; RUN: opt -inline -S < %s | FileCheck %s |
| 2 | ; |
| 3 | ; A hand-edited version of inline-debug-info.ll to test inlining of a |
| 4 | ; function with multiple returns. |
| 5 | ; |
| 6 | ; Make sure the branch instructions created during inlining has a debug location, |
| 7 | ; so the range of the inlined function is correct. |
| 8 | ; CHECK: br label %_Z4testi.exit, !dbg ![[MD:[0-9]+]] |
| 9 | ; CHECK: br label %_Z4testi.exit, !dbg ![[MD]] |
| 10 | ; CHECK: br label %invoke.cont, !dbg ![[MD]] |
| 11 | ; The branch instruction has the source location of line 9 and its inlined location |
| 12 | ; has the source location of line 14. |
| Duncan P. N. Exon Smith | 9885469 | 2015-01-14 22:27:36 +0000 | [diff] [blame^] | 13 | ; CHECK: ![[INL:[0-9]+]] = !MDLocation(line: 14, scope: {{.*}}) |
| 14 | ; CHECK: ![[MD]] = !MDLocation(line: 9, scope: {{.*}}, inlinedAt: ![[INL]]) |
| Adrian Prantl | 0941638 | 2013-04-30 17:08:16 +0000 | [diff] [blame] | 15 | |
| 16 | ; ModuleID = 'test.cpp' |
| 17 | target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" |
| 18 | target triple = "x86_64-apple-darwin12.0.0" |
| 19 | |
| 20 | @_ZTIi = external constant i8* |
| 21 | @global_var = external global i32 |
| 22 | |
| 23 | ; copy of above function with multiple returns |
| 24 | define i32 @_Z4testi(i32 %k) { |
| 25 | entry: |
| 26 | %retval = alloca i32, align 4 |
| 27 | %k.addr = alloca i32, align 4 |
| 28 | %k2 = alloca i32, align 4 |
| 29 | store i32 %k, i32* %k.addr, align 4 |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 30 | call void @llvm.dbg.declare(metadata i32* %k.addr, metadata !13, metadata !{!"0x102"}), !dbg !14 |
| 31 | call void @llvm.dbg.declare(metadata i32* %k2, metadata !15, metadata !{!"0x102"}), !dbg !16 |
| Adrian Prantl | 0941638 | 2013-04-30 17:08:16 +0000 | [diff] [blame] | 32 | %0 = load i32* %k.addr, align 4, !dbg !16 |
| 33 | %call = call i32 @_Z8test_exti(i32 %0), !dbg !16 |
| 34 | store i32 %call, i32* %k2, align 4, !dbg !16 |
| 35 | %1 = load i32* %k2, align 4, !dbg !17 |
| 36 | %cmp = icmp sgt i32 %1, 100, !dbg !17 |
| 37 | br i1 %cmp, label %if.then, label %if.end, !dbg !17 |
| 38 | |
| 39 | if.then: ; preds = %entry |
| 40 | %2 = load i32* %k2, align 4, !dbg !18 |
| 41 | store i32 %2, i32* %retval, !dbg !18 |
| 42 | br label %return, !dbg !18 |
| 43 | |
| 44 | if.end: ; preds = %entry |
| 45 | store i32 0, i32* %retval, !dbg !19 |
| 46 | %3 = load i32* %retval, !dbg !20 ; hand-edited |
| 47 | ret i32 %3, !dbg !20 ; hand-edited |
| 48 | |
| 49 | return: ; preds = %if.end, %if.then |
| 50 | %4 = load i32* %retval, !dbg !20 |
| 51 | ret i32 %4, !dbg !20 |
| 52 | } |
| 53 | |
| 54 | |
| 55 | ; Function Attrs: nounwind readnone |
| Adrian Prantl | 87b7eb9 | 2014-10-01 18:55:02 +0000 | [diff] [blame] | 56 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
| Adrian Prantl | 0941638 | 2013-04-30 17:08:16 +0000 | [diff] [blame] | 57 | |
| 58 | declare i32 @_Z8test_exti(i32) |
| 59 | |
| 60 | define i32 @_Z5test2v() { |
| 61 | entry: |
| 62 | %exn.slot = alloca i8* |
| 63 | %ehselector.slot = alloca i32 |
| 64 | %e = alloca i32, align 4 |
| 65 | %0 = load i32* @global_var, align 4, !dbg !21 |
| 66 | %call = invoke i32 @_Z4testi(i32 %0) |
| 67 | to label %invoke.cont unwind label %lpad, !dbg !21 |
| 68 | |
| 69 | invoke.cont: ; preds = %entry |
| 70 | br label %try.cont, !dbg !23 |
| 71 | |
| 72 | lpad: ; preds = %entry |
| 73 | %1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) |
| 74 | catch i8* bitcast (i8** @_ZTIi to i8*), !dbg !21 |
| 75 | %2 = extractvalue { i8*, i32 } %1, 0, !dbg !21 |
| 76 | store i8* %2, i8** %exn.slot, !dbg !21 |
| 77 | %3 = extractvalue { i8*, i32 } %1, 1, !dbg !21 |
| 78 | store i32 %3, i32* %ehselector.slot, !dbg !21 |
| 79 | br label %catch.dispatch, !dbg !21 |
| 80 | |
| 81 | catch.dispatch: ; preds = %lpad |
| 82 | %sel = load i32* %ehselector.slot, !dbg !23 |
| 83 | %4 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2, !dbg !23 |
| 84 | %matches = icmp eq i32 %sel, %4, !dbg !23 |
| 85 | br i1 %matches, label %catch, label %eh.resume, !dbg !23 |
| 86 | |
| 87 | catch: ; preds = %catch.dispatch |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 88 | call void @llvm.dbg.declare(metadata i32* %e, metadata !24, metadata !{!"0x102"}), !dbg !25 |
| Adrian Prantl | 0941638 | 2013-04-30 17:08:16 +0000 | [diff] [blame] | 89 | %exn = load i8** %exn.slot, !dbg !23 |
| 90 | %5 = call i8* @__cxa_begin_catch(i8* %exn) #2, !dbg !23 |
| 91 | %6 = bitcast i8* %5 to i32*, !dbg !23 |
| 92 | %7 = load i32* %6, align 4, !dbg !23 |
| 93 | store i32 %7, i32* %e, align 4, !dbg !23 |
| 94 | store i32 0, i32* @global_var, align 4, !dbg !26 |
| 95 | call void @__cxa_end_catch() #2, !dbg !28 |
| 96 | br label %try.cont, !dbg !28 |
| 97 | |
| 98 | try.cont: ; preds = %catch, %invoke.cont |
| 99 | store i32 1, i32* @global_var, align 4, !dbg !29 |
| 100 | ret i32 0, !dbg !30 |
| 101 | |
| 102 | eh.resume: ; preds = %catch.dispatch |
| 103 | %exn1 = load i8** %exn.slot, !dbg !23 |
| 104 | %sel2 = load i32* %ehselector.slot, !dbg !23 |
| 105 | %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn1, 0, !dbg !23 |
| 106 | %lpad.val3 = insertvalue { i8*, i32 } %lpad.val, i32 %sel2, 1, !dbg !23 |
| 107 | resume { i8*, i32 } %lpad.val3, !dbg !23 |
| 108 | } |
| 109 | |
| 110 | declare i32 @__gxx_personality_v0(...) |
| 111 | |
| 112 | ; Function Attrs: nounwind readnone |
| 113 | declare i32 @llvm.eh.typeid.for(i8*) #1 |
| 114 | |
| 115 | declare i8* @__cxa_begin_catch(i8*) |
| 116 | |
| 117 | declare void @__cxa_end_catch() |
| 118 | |
| 119 | attributes #1 = { nounwind readnone } |
| 120 | attributes #2 = { nounwind } |
| 121 | |
| 122 | !llvm.dbg.cu = !{!0} |
| Manman Ren | 409558f | 2013-11-22 21:49:45 +0000 | [diff] [blame] | 123 | !llvm.module.flags = !{!31} |
| Adrian Prantl | 0941638 | 2013-04-30 17:08:16 +0000 | [diff] [blame] | 124 | |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 125 | !0 = !{!"0x11\004\00clang version 3.3 \000\00\000\00\000", !1, !2, !2, !3, !2, !2} ; [ DW_TAG_compile_unit ] [<unknown>] [DW_LANG_C_plus_plus] |
| 126 | !1 = !{!"<unknown>", !""} |
| 127 | !2 = !{i32 0} |
| 128 | !3 = !{!4, !10} |
| 129 | !4 = !{!"0x2e\00test\00test\00_Z4testi\004\000\001\000\006\00256\000\004", !5, !6, !7, null, i32 (i32)* @_Z4testi, null, null, !2} ; [ DW_TAG_subprogram ] [line 4] [def] [test] |
| 130 | !5 = !{!"test.cpp", !""} |
| 131 | !6 = !{!"0x29", !5} ; [ DW_TAG_file_type ] [test.cpp] |
| 132 | !7 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !8, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] |
| 133 | !8 = !{!9, !9} |
| 134 | !9 = !{!"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] |
| 135 | !10 = !{!"0x2e\00test2\00test2\00_Z5test2v\0011\000\001\000\006\00256\000\0011", !5, !6, !11, null, i32 ()* @_Z5test2v, null, null, !2} ; [ DW_TAG_subprogram ] [line 11] [def] [test2] |
| 136 | !11 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !12, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] |
| 137 | !12 = !{!9} |
| 138 | !13 = !{!"0x101\00k\0016777220\000", !4, !6, !9} ; [ DW_TAG_arg_variable ] [k] [line 4] |
| Duncan P. N. Exon Smith | 9885469 | 2015-01-14 22:27:36 +0000 | [diff] [blame^] | 139 | !14 = !MDLocation(line: 4, scope: !4) |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 140 | !15 = !{!"0x100\00k2\005\000", !4, !6, !9} ; [ DW_TAG_auto_variable ] [k2] [line 5] |
| Duncan P. N. Exon Smith | 9885469 | 2015-01-14 22:27:36 +0000 | [diff] [blame^] | 141 | !16 = !MDLocation(line: 5, scope: !4) |
| 142 | !17 = !MDLocation(line: 6, scope: !4) |
| 143 | !18 = !MDLocation(line: 7, scope: !4) |
| 144 | !19 = !MDLocation(line: 8, scope: !4) |
| 145 | !20 = !MDLocation(line: 9, scope: !4) |
| 146 | !21 = !MDLocation(line: 14, scope: !22) |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 147 | !22 = !{!"0xb\0013\000\000", !5, !10} ; [ DW_TAG_lexical_block ] [test.cpp] |
| Duncan P. N. Exon Smith | 9885469 | 2015-01-14 22:27:36 +0000 | [diff] [blame^] | 148 | !23 = !MDLocation(line: 15, scope: !22) |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 149 | !24 = !{!"0x100\00e\0016\000", !10, !6, !9} ; [ DW_TAG_auto_variable ] [e] [line 16] |
| Duncan P. N. Exon Smith | 9885469 | 2015-01-14 22:27:36 +0000 | [diff] [blame^] | 150 | !25 = !MDLocation(line: 16, scope: !10) |
| 151 | !26 = !MDLocation(line: 17, scope: !27) |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 152 | !27 = !{!"0xb\0016\000\001", !5, !10} ; [ DW_TAG_lexical_block ] [test.cpp] |
| Duncan P. N. Exon Smith | 9885469 | 2015-01-14 22:27:36 +0000 | [diff] [blame^] | 153 | !28 = !MDLocation(line: 18, scope: !27) |
| 154 | !29 = !MDLocation(line: 19, scope: !10) |
| 155 | !30 = !MDLocation(line: 20, scope: !10) |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 156 | !31 = !{i32 1, !"Debug Info Version", i32 2} |