1; RUN: llc -verify-machineinstrs -filetype=obj -mtriple=aarch64-- \ 2; RUN: -enable-machine-outliner < %s | llvm-dwarfdump - | FileCheck %s 3 4; Ensure that the MachineOutliner produces valid DWARF when it creates outlined 5; functions. Check that the outlined function has a subprogram, and that the 6; expected DWARF attributes are present. 7 8; The outlined function appears after bar. Skip past the functions we don't 9; care about. 10; CHECK: DW_TAG_compile_unit 11; CHECK-DAG: DW_AT_name ("foo") 12; CHECK-DAG: DW_AT_name ("p") 13 14; Check the high address of bar. This is one past the end of bar. It should be 15; the beginning of the outlined function. 16; CHECK: DW_AT_high_pc ([[ONE_PAST_BAR:0x[a-f0-9]+]]) 17; CHECK-NEXT: DW_AT_frame_base (DW_OP_reg29 W29) 18; CHECK-NEXT: DW_AT_name ("bar") 19 20; Check the outlined function's DWARF. 21; CHECK-DAG: DW_TAG_subprogram 22; CHECK-NEXT: DW_AT_low_pc ([[ONE_PAST_BAR]]) 23; CHECK-NEXT: DW_AT_high_pc (0x{{[0-9a-f]+}}) 24; CHECK-NEXT: DW_AT_frame_base (DW_OP_reg29 W29) 25; CHECK-NEXT: DW_AT_MIPS_linkage_name ("[[NAME:OUTLINED_FUNCTION_[0-9]+]]") 26; CHECK-NEXT: DW_AT_name ("[[NAME]]") 27; CHECK-NEXT: DW_AT_artificial (0x01) 28; CHECK-NEXT: DW_AT_external (0x01) 29 30define void @foo() #0 !dbg !8 { 31entry: 32 %p = alloca i32*, align 8 33 call void @llvm.dbg.declare(metadata i32** %p, metadata !11, metadata !DIExpression()), !dbg !14 34 %0 = load i32*, i32** %p, align 8, !dbg !15 35 %incdec.ptr = getelementptr inbounds i32, i32* %0, i32 1, !dbg !15 36 store i32* %incdec.ptr, i32** %p, align 8, !dbg !15 37 call void @foo(), !dbg !16 38 ret void, !dbg !17 39} 40 41declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 42 43define void @bar() #0 !dbg !18 { 44entry: 45 %p = alloca i32*, align 8 46 call void @llvm.dbg.declare(metadata i32** %p, metadata !19, metadata !DIExpression()), !dbg !20 47 %0 = load i32*, i32** %p, align 8, !dbg !21 48 %incdec.ptr = getelementptr inbounds i32, i32* %0, i32 1, !dbg !21 49 store i32* %incdec.ptr, i32** %p, align 8, !dbg !21 50 call void @foo(), !dbg !22 51 ret void, !dbg !23 52} 53 54attributes #0 = { nounwind ssp uwtable "frame-pointer"="all" } 55attributes #1 = { nounwind readnone speculatable } 56 57!llvm.dbg.cu = !{!0} 58!llvm.module.flags = !{!3, !4, !5, !6} 59!llvm.ident = !{!7} 60 61!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 62!1 = !DIFile(filename: "something.c", directory: "somewhere") 63!2 = !{} 64!3 = !{i32 2, !"Dwarf Version", i32 2} 65!4 = !{i32 2, !"Debug Info Version", i32 3} 66!5 = !{i32 1, !"wchar_size", i32 4} 67!6 = !{i32 7, !"PIC Level", i32 2} 68!7 = !{!"clang"} 69!8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 70!9 = !DISubroutineType(types: !10) 71!10 = !{null} 72!11 = !DILocalVariable(name: "p", scope: !8, file: !1, line: 2, type: !12) 73!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) 74!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 75!14 = !DILocation(line: 2, column: 8, scope: !8) 76!15 = !DILocation(line: 3, column: 4, scope: !8) 77!16 = !DILocation(line: 4, column: 3, scope: !8) 78!17 = !DILocation(line: 5, column: 1, scope: !8) 79!18 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 7, type: !9, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 80!19 = !DILocalVariable(name: "p", scope: !18, file: !1, line: 9, type: !12) 81!20 = !DILocation(line: 9, column: 8, scope: !18) 82!21 = !DILocation(line: 10, column: 4, scope: !18) 83!22 = !DILocation(line: 11, column: 3, scope: !18) 84!23 = !DILocation(line: 12, column: 1, scope: !18) 85 86