155 lines · plain
1; RUN: opt -passes='cgscc(inline)' -S < %s | FileCheck %s2;3; A hand-edited version of inline-debug-info.ll to test inlining of a4; 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 location12; has the source location of line 14.13; CHECK: ![[INL:[0-9]+]] = distinct !DILocation(line: 14, scope: {{.*}})14; CHECK: ![[MD]] = !DILocation(line: 9, scope: {{.*}}, inlinedAt: ![[INL]])15 16; ModuleID = 'test.cpp'17target 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"18target triple = "x86_64-apple-darwin12.0.0"19 20@_ZTIi = external constant ptr21@global_var = external global i3222 23; copy of above function with multiple returns24define i32 @_Z4testi(i32 %k) !dbg !4 {25entry:26 %retval = alloca i32, align 427 %k.addr = alloca i32, align 428 %k2 = alloca i32, align 429 store i32 %k, ptr %k.addr, align 430 call void @llvm.dbg.declare(metadata ptr %k.addr, metadata !13, metadata !DIExpression()), !dbg !1431 call void @llvm.dbg.declare(metadata ptr %k2, metadata !15, metadata !DIExpression()), !dbg !1632 %0 = load i32, ptr %k.addr, align 4, !dbg !1633 %call = call i32 @_Z8test_exti(i32 %0), !dbg !1634 store i32 %call, ptr %k2, align 4, !dbg !1635 %1 = load i32, ptr %k2, align 4, !dbg !1736 %cmp = icmp sgt i32 %1, 100, !dbg !1737 br i1 %cmp, label %if.then, label %if.end, !dbg !1738 39if.then: ; preds = %entry40 %2 = load i32, ptr %k2, align 4, !dbg !1841 store i32 %2, ptr %retval, !dbg !1842 br label %return, !dbg !1843 44if.end: ; preds = %entry45 store i32 0, ptr %retval, !dbg !1946 %3 = load i32, ptr %retval, !dbg !20 ; hand-edited47 ret i32 %3, !dbg !20 ; hand-edited48 49return: ; preds = %if.end, %if.then50 %4 = load i32, ptr %retval, !dbg !2051 ret i32 %4, !dbg !2052}53 54 55; Function Attrs: nounwind readnone56declare void @llvm.dbg.declare(metadata, metadata, metadata) #157 58declare i32 @_Z8test_exti(i32)59 60define i32 @_Z5test2v() personality ptr @__gxx_personality_v0 !dbg !10 {61entry:62 %exn.slot = alloca ptr63 %ehselector.slot = alloca i3264 %e = alloca i32, align 465 %0 = load i32, ptr @global_var, align 4, !dbg !2166 %call = invoke i32 @_Z4testi(i32 %0)67 to label %invoke.cont unwind label %lpad, !dbg !2168 69invoke.cont: ; preds = %entry70 br label %try.cont, !dbg !2371 72lpad: ; preds = %entry73 %1 = landingpad { ptr, i32 }74 catch ptr @_ZTIi, !dbg !2175 %2 = extractvalue { ptr, i32 } %1, 0, !dbg !2176 store ptr %2, ptr %exn.slot, !dbg !2177 %3 = extractvalue { ptr, i32 } %1, 1, !dbg !2178 store i32 %3, ptr %ehselector.slot, !dbg !2179 br label %catch.dispatch, !dbg !2180 81catch.dispatch: ; preds = %lpad82 %sel = load i32, ptr %ehselector.slot, !dbg !2383 %4 = call i32 @llvm.eh.typeid.for(ptr @_ZTIi) #2, !dbg !2384 %matches = icmp eq i32 %sel, %4, !dbg !2385 br i1 %matches, label %catch, label %eh.resume, !dbg !2386 87catch: ; preds = %catch.dispatch88 call void @llvm.dbg.declare(metadata ptr %e, metadata !24, metadata !DIExpression()), !dbg !2589 %exn = load ptr, ptr %exn.slot, !dbg !2390 %5 = call ptr @__cxa_begin_catch(ptr %exn) #2, !dbg !2391 %6 = load i32, ptr %5, align 4, !dbg !2392 store i32 %6, ptr %e, align 4, !dbg !2393 store i32 0, ptr @global_var, align 4, !dbg !2694 call void @__cxa_end_catch() #2, !dbg !2895 br label %try.cont, !dbg !2896 97try.cont: ; preds = %catch, %invoke.cont98 store i32 1, ptr @global_var, align 4, !dbg !2999 ret i32 0, !dbg !30100 101eh.resume: ; preds = %catch.dispatch102 %exn1 = load ptr, ptr %exn.slot, !dbg !23103 %sel2 = load i32, ptr %ehselector.slot, !dbg !23104 %lpad.val = insertvalue { ptr, i32 } undef, ptr %exn1, 0, !dbg !23105 %lpad.val3 = insertvalue { ptr, i32 } %lpad.val, i32 %sel2, 1, !dbg !23106 resume { ptr, i32 } %lpad.val3, !dbg !23107}108 109declare i32 @__gxx_personality_v0(...)110 111; Function Attrs: nounwind readnone112declare i32 @llvm.eh.typeid.for(ptr) #1113 114declare ptr @__cxa_begin_catch(ptr)115 116declare void @__cxa_end_catch()117 118attributes #1 = { nounwind readnone }119attributes #2 = { nounwind }120 121!llvm.dbg.cu = !{!0}122!llvm.module.flags = !{!31}123 124!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.3 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)125!1 = !DIFile(filename: "<unknown>", directory: "")126!2 = !{}127!4 = distinct !DISubprogram(name: "test", linkageName: "_Z4testi", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 4, file: !5, scope: !6, type: !7, retainedNodes: !2)128!5 = !DIFile(filename: "test.cpp", directory: "")129!6 = !DIFile(filename: "test.cpp", directory: "")130!7 = !DISubroutineType(types: !8)131!8 = !{!9, !9}132!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)133!10 = distinct !DISubprogram(name: "test2", linkageName: "_Z5test2v", line: 11, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 11, file: !5, scope: !6, type: !11, retainedNodes: !2)134!11 = !DISubroutineType(types: !12)135!12 = !{!9}136!13 = !DILocalVariable(name: "k", line: 4, arg: 1, scope: !4, file: !6, type: !9)137!14 = !DILocation(line: 4, scope: !4)138!15 = !DILocalVariable(name: "k2", line: 5, scope: !4, file: !6, type: !9)139!16 = !DILocation(line: 5, scope: !4)140!17 = !DILocation(line: 6, scope: !4)141!18 = !DILocation(line: 7, scope: !4)142!19 = !DILocation(line: 8, scope: !4)143!20 = !DILocation(line: 9, scope: !4)144!21 = !DILocation(line: 14, scope: !22)145!22 = distinct !DILexicalBlock(line: 13, column: 0, file: !5, scope: !10)146!23 = !DILocation(line: 15, scope: !22)147!24 = !DILocalVariable(name: "e", line: 16, scope: !10, file: !6, type: !9)148!25 = !DILocation(line: 16, scope: !10)149!26 = !DILocation(line: 17, scope: !27)150!27 = distinct !DILexicalBlock(line: 16, column: 0, file: !5, scope: !10)151!28 = !DILocation(line: 18, scope: !27)152!29 = !DILocation(line: 19, scope: !10)153!30 = !DILocation(line: 20, scope: !10)154!31 = !{i32 1, !"Debug Info Version", i32 3}155