Home | History | Annotate | Download | only in X86
      1 ; Ensure that we can correctly emit a compile unit for outlined functions and
      2 ; that we correctly emit DISubprograms for those functions.
      3 ; Also make sure that the DISubprograms reference the generated unit.
      4 ; make sure that if there are two outlined functions in the program, 
      5 ; RUN: llc %s -verify-machineinstrs -enable-machine-outliner -mtriple=x86_64-apple-darwin -o /dev/null -print-after=machine-outliner
      6 define void @f6() #0 !dbg !8 {
      7 entry:
      8   %dog = alloca i32, align 4
      9   %cat = alloca i32, align 4
     10   %pangolin = alloca i32, align 4
     11   call void @llvm.dbg.declare(metadata i32* %dog, metadata !11, metadata !DIExpression()), !dbg !13
     12   store i32 16, i32* %dog, align 4, !dbg !13
     13   call void @llvm.dbg.declare(metadata i32* %cat, metadata !14, metadata !DIExpression()), !dbg !15
     14   store i32 32, i32* %cat, align 4, !dbg !15
     15   call void @llvm.dbg.declare(metadata i32* %pangolin, metadata !16, metadata !DIExpression()), !dbg !17
     16   store i32 48, i32* %pangolin, align 4, !dbg !17
     17   ret void, !dbg !18
     18 }
     19 
     20 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
     21 
     22 define void @f5() #0 !dbg !19 {
     23 entry:
     24   %dog = alloca i32, align 4
     25   %cat = alloca i32, align 4
     26   %pangolin = alloca i32, align 4
     27   call void @llvm.dbg.declare(metadata i32* %dog, metadata !20, metadata !DIExpression()), !dbg !21
     28   store i32 16, i32* %dog, align 4, !dbg !21
     29   call void @llvm.dbg.declare(metadata i32* %cat, metadata !22, metadata !DIExpression()), !dbg !23
     30   store i32 32, i32* %cat, align 4, !dbg !23
     31   call void @llvm.dbg.declare(metadata i32* %pangolin, metadata !24, metadata !DIExpression()), !dbg !25
     32   store i32 48, i32* %pangolin, align 4, !dbg !25
     33   ret void, !dbg !26
     34 }
     35 
     36 define void @f4() #0 !dbg !27 {
     37 entry:
     38   %dog = alloca i32, align 4
     39   %cat = alloca i32, align 4
     40   %pangolin = alloca i32, align 4
     41   call void @llvm.dbg.declare(metadata i32* %dog, metadata !28, metadata !DIExpression()), !dbg !29
     42   store i32 16, i32* %dog, align 4, !dbg !29
     43   call void @llvm.dbg.declare(metadata i32* %cat, metadata !30, metadata !DIExpression()), !dbg !31
     44   store i32 32, i32* %cat, align 4, !dbg !31
     45   call void @llvm.dbg.declare(metadata i32* %pangolin, metadata !32, metadata !DIExpression()), !dbg !33
     46   store i32 48, i32* %pangolin, align 4, !dbg !33
     47   ret void, !dbg !34
     48 }
     49 
     50 define i32 @f1() #0 !dbg !35 {
     51 entry:
     52   %dog = alloca i32, align 4
     53   %cat = alloca i32, align 4
     54   %pangolin = alloca i32, align 4
     55   call void @llvm.dbg.declare(metadata i32* %dog, metadata !38, metadata !DIExpression()), !dbg !39
     56   store i32 1, i32* %dog, align 4, !dbg !39
     57   call void @llvm.dbg.declare(metadata i32* %cat, metadata !40, metadata !DIExpression()), !dbg !41
     58   store i32 2, i32* %cat, align 4, !dbg !41
     59   call void @llvm.dbg.declare(metadata i32* %pangolin, metadata !42, metadata !DIExpression()), !dbg !43
     60   store i32 3, i32* %pangolin, align 4, !dbg !43
     61   store i32 16, i32* %dog, align 4, !dbg !44
     62   %0 = load i32, i32* %dog, align 4, !dbg !45
     63   ret i32 %0, !dbg !46
     64 }
     65 
     66 define i32 @f2() #0 !dbg !47 {
     67 entry:
     68   %dog = alloca i32, align 4
     69   %cat = alloca i32, align 4
     70   %pangolin = alloca i32, align 4
     71   call void @llvm.dbg.declare(metadata i32* %dog, metadata !48, metadata !DIExpression()), !dbg !49
     72   store i32 1, i32* %dog, align 4, !dbg !49
     73   call void @llvm.dbg.declare(metadata i32* %cat, metadata !50, metadata !DIExpression()), !dbg !51
     74   store i32 2, i32* %cat, align 4, !dbg !51
     75   call void @llvm.dbg.declare(metadata i32* %pangolin, metadata !52, metadata !DIExpression()), !dbg !53
     76   store i32 3, i32* %pangolin, align 4, !dbg !53
     77   store i32 16, i32* %dog, align 4, !dbg !54
     78   %0 = load i32, i32* %dog, align 4, !dbg !55
     79   ret i32 %0, !dbg !56
     80 }
     81 
     82 define i32 @f3() #0 !dbg !57 {
     83 entry:
     84   %dog = alloca i32, align 4
     85   %cat = alloca i32, align 4
     86   %pangolin = alloca i32, align 4
     87   call void @llvm.dbg.declare(metadata i32* %dog, metadata !58, metadata !DIExpression()), !dbg !59
     88   store i32 1, i32* %dog, align 4, !dbg !59
     89   call void @llvm.dbg.declare(metadata i32* %cat, metadata !60, metadata !DIExpression()), !dbg !61
     90   store i32 2, i32* %cat, align 4, !dbg !61
     91   call void @llvm.dbg.declare(metadata i32* %pangolin, metadata !62, metadata !DIExpression()), !dbg !63
     92   store i32 3, i32* %pangolin, align 4, !dbg !63
     93   store i32 16, i32* %dog, align 4, !dbg !64
     94   %0 = load i32, i32* %dog, align 4, !dbg !65
     95   ret i32 %0, !dbg !66
     96 }
     97 
     98 define i32 @main() #0 !dbg !67 {
     99 entry:
    100   %retval = alloca i32, align 4
    101   %a = alloca i32, align 4
    102   store i32 0, i32* %retval, align 4
    103   call void @llvm.dbg.declare(metadata i32* %a, metadata !68, metadata !DIExpression()), !dbg !69
    104   store i32 4, i32* %a, align 4, !dbg !69
    105   %call = call i32 @f1() #2, !dbg !70
    106   %call1 = call i32 @f2() #2, !dbg !71
    107   %call2 = call i32 @f3() #2, !dbg !72
    108   ret i32 0, !dbg !73
    109 }
    110 
    111 ; CHECK: distinct !DISubprogram(name: "OUTLINED_FUNCTION_1",
    112 ; CHECK-SAME: scope: !1,
    113 ; CHECK-SAME: file: !1,
    114 ; CHECK-SAME: type: [[TYPE:![0-9]+]],
    115 ; CHECK-SAME: isLocal: false, 
    116 ; CHECK-SAME: isDefinition: true,
    117 ; CHECK-SAME: flags: DIFlagArtificial,
    118 ; CHECK-SAME: isOptimized: true,
    119 ; CHECK-SAME: unit: !0,
    120 ; CHECK-SAME: retainedNodes: [[VARS:![0-9]+]]
    121 
    122 ; CHECK: distinct !DISubprogram(name: "OUTLINED_FUNCTION_0",
    123 ; CHECK-SAME: scope: !1,
    124 ; CHECK-SAME: file: !1,
    125 ; CHECK-SAME: type: [[TYPE]],
    126 ; CHECK-SAME: isLocal: false, 
    127 ; CHECK-SAME: isDefinition: true,
    128 ; CHECK-SAME: flags: DIFlagArtificial,
    129 ; CHECK-SAME: isOptimized: true,
    130 ; CHECK-SAME: unit: !0,
    131 ; CHECK-SAME: retainedNodes: [[VARS]]
    132 
    133 attributes #0 = { noinline noredzone nounwind optnone ssp uwtable "no-frame-pointer-elim"="true"  }
    134 attributes #1 = { nounwind readnone speculatable }
    135 attributes #2 = { noredzone }
    136 
    137 !llvm.dbg.cu = !{!0}
    138 !llvm.module.flags = !{!3, !4, !5, !6}
    139 !llvm.ident = !{!7}
    140 
    141 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
    142 !1 = !DIFile(filename: "test.c", directory: "/")
    143 !2 = !{}
    144 !3 = !{i32 2, !"Dwarf Version", i32 4}
    145 !4 = !{i32 2, !"Debug Info Version", i32 3}
    146 !5 = !{i32 1, !"wchar_size", i32 4}
    147 !6 = !{i32 7, !"PIC Level", i32 2}
    148 !7 = !{!"clang"}
    149 !8 = distinct !DISubprogram(name: "f6", scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: false, unit: !0, retainedNodes: !2)
    150 !9 = !DISubroutineType(types: !10)
    151 !10 = !{null}
    152 !11 = !DILocalVariable(name: "dog", scope: !8, file: !1, line: 4, type: !12)
    153 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
    154 !13 = !DILocation(line: 4, column: 16, scope: !8)
    155 !14 = !DILocalVariable(name: "cat", scope: !8, file: !1, line: 5, type: !12)
    156 !15 = !DILocation(line: 5, column: 16, scope: !8)
    157 !16 = !DILocalVariable(name: "pangolin", scope: !8, file: !1, line: 6, type: !12)
    158 !17 = !DILocation(line: 6, column: 16, scope: !8)
    159 !18 = !DILocation(line: 7, column: 1, scope: !8)
    160 !19 = distinct !DISubprogram(name: "f5", scope: !1, file: !1, line: 9, type: !9, isLocal: false, isDefinition: true, scopeLine: 9, isOptimized: false, unit: !0, retainedNodes: !2)
    161 !20 = !DILocalVariable(name: "dog", scope: !19, file: !1, line: 10, type: !12)
    162 !21 = !DILocation(line: 10, column: 16, scope: !19)
    163 !22 = !DILocalVariable(name: "cat", scope: !19, file: !1, line: 11, type: !12)
    164 !23 = !DILocation(line: 11, column: 16, scope: !19)
    165 !24 = !DILocalVariable(name: "pangolin", scope: !19, file: !1, line: 12, type: !12)
    166 !25 = !DILocation(line: 12, column: 16, scope: !19)
    167 !26 = !DILocation(line: 13, column: 1, scope: !19)
    168 !27 = distinct !DISubprogram(name: "f4", scope: !1, file: !1, line: 15, type: !9, isLocal: false, isDefinition: true, scopeLine: 15, isOptimized: false, unit: !0, retainedNodes: !2)
    169 !28 = !DILocalVariable(name: "dog", scope: !27, file: !1, line: 16, type: !12)
    170 !29 = !DILocation(line: 16, column: 16, scope: !27)
    171 !30 = !DILocalVariable(name: "cat", scope: !27, file: !1, line: 17, type: !12)
    172 !31 = !DILocation(line: 17, column: 16, scope: !27)
    173 !32 = !DILocalVariable(name: "pangolin", scope: !27, file: !1, line: 18, type: !12)
    174 !33 = !DILocation(line: 18, column: 16, scope: !27)
    175 !34 = !DILocation(line: 19, column: 1, scope: !27)
    176 !35 = distinct !DISubprogram(name: "f1", scope: !1, file: !1, line: 21, type: !36, isLocal: false, isDefinition: true, scopeLine: 21, isOptimized: false, unit: !0, retainedNodes: !2)
    177 !36 = !DISubroutineType(types: !37)
    178 !37 = !{!12}
    179 !38 = !DILocalVariable(name: "dog", scope: !35, file: !1, line: 22, type: !12)
    180 !39 = !DILocation(line: 22, column: 16, scope: !35)
    181 !40 = !DILocalVariable(name: "cat", scope: !35, file: !1, line: 23, type: !12)
    182 !41 = !DILocation(line: 23, column: 16, scope: !35)
    183 !42 = !DILocalVariable(name: "pangolin", scope: !35, file: !1, line: 24, type: !12)
    184 !43 = !DILocation(line: 24, column: 16, scope: !35)
    185 !44 = !DILocation(line: 25, column: 7, scope: !35)
    186 !45 = !DILocation(line: 26, column: 10, scope: !35)
    187 !46 = !DILocation(line: 26, column: 3, scope: !35)
    188 !47 = distinct !DISubprogram(name: "f2", scope: !1, file: !1, line: 29, type: !36, isLocal: false, isDefinition: true, scopeLine: 29, isOptimized: false, unit: !0, retainedNodes: !2)
    189 !48 = !DILocalVariable(name: "dog", scope: !47, file: !1, line: 30, type: !12)
    190 !49 = !DILocation(line: 30, column: 16, scope: !47)
    191 !50 = !DILocalVariable(name: "cat", scope: !47, file: !1, line: 31, type: !12)
    192 !51 = !DILocation(line: 31, column: 16, scope: !47)
    193 !52 = !DILocalVariable(name: "pangolin", scope: !47, file: !1, line: 32, type: !12)
    194 !53 = !DILocation(line: 32, column: 16, scope: !47)
    195 !54 = !DILocation(line: 33, column: 7, scope: !47)
    196 !55 = !DILocation(line: 34, column: 10, scope: !47)
    197 !56 = !DILocation(line: 34, column: 3, scope: !47)
    198 !57 = distinct !DISubprogram(name: "f3", scope: !1, file: !1, line: 37, type: !36, isLocal: false, isDefinition: true, scopeLine: 37, isOptimized: false, unit: !0, retainedNodes: !2)
    199 !58 = !DILocalVariable(name: "dog", scope: !57, file: !1, line: 38, type: !12)
    200 !59 = !DILocation(line: 38, column: 16, scope: !57)
    201 !60 = !DILocalVariable(name: "cat", scope: !57, file: !1, line: 39, type: !12)
    202 !61 = !DILocation(line: 39, column: 16, scope: !57)
    203 !62 = !DILocalVariable(name: "pangolin", scope: !57, file: !1, line: 40, type: !12)
    204 !63 = !DILocation(line: 40, column: 16, scope: !57)
    205 !64 = !DILocation(line: 41, column: 7, scope: !57)
    206 !65 = !DILocation(line: 42, column: 10, scope: !57)
    207 !66 = !DILocation(line: 42, column: 3, scope: !57)
    208 !67 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 45, type: !36, isLocal: false, isDefinition: true, scopeLine: 45, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
    209 !68 = !DILocalVariable(name: "a", scope: !67, file: !1, line: 46, type: !12)
    210 !69 = !DILocation(line: 46, column: 16, scope: !67)
    211 !70 = !DILocation(line: 47, column: 3, scope: !67)
    212 !71 = !DILocation(line: 48, column: 3, scope: !67)
    213 !72 = !DILocation(line: 49, column: 3, scope: !67)
    214 !73 = !DILocation(line: 51, column: 3, scope: !67)
    215