Home | History | Annotate | Download | only in X86
      1 ; RUN: llc -start-after=codegenprepare -stop-before expand-isel-pseudos -o - %s | FileCheck %s
      2 
      3 ; This test case was generated from the following debug.c program,
      4 ; using: clang debug.c -g -O1 -S -o dbg_value_phi_isel1.ll -emit-llvm
      5 ; --------------------------------------
      6 ; int end = 10;
      7 ;
      8 ; int main() {
      9 ;   int x = 9;
     10 ;   int y = 13;
     11 ;   for (int u = 0; u < end; ++u) {
     12 ;     x += y;
     13 ;     y = y * 3;
     14 ;   }
     15 ;
     16 ;   volatile int arr[80];
     17 ;   for (int q = 0; q < 64; ++q) {
     18 ;     arr[q] = q + 3;
     19 ;   }
     20 ;
     21 ;   return x;
     22 ; }
     23 ; --------------------------------------
     24 ;
     25 
     26 ; ModuleID = 'debug.c'
     27 source_filename = "debug.c"
     28 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
     29 target triple = "x86_64-unknown-linux-gnu"
     30 
     31 @end = dso_local local_unnamed_addr global i32 10, align 4, !dbg !0
     32 
     33 ; Function Attrs: nounwind uwtable
     34 define dso_local i32 @main() local_unnamed_addr #0 !dbg !11 {
     35 ; CHECK-LABEL: name:            main
     36 entry:
     37   %arr = alloca [80 x i32], align 16
     38   call void @llvm.dbg.value(metadata i32 9, metadata !15, metadata !DIExpression()), !dbg !26
     39   call void @llvm.dbg.value(metadata i32 13, metadata !16, metadata !DIExpression()), !dbg !27
     40   call void @llvm.dbg.value(metadata i32 0, metadata !17, metadata !DIExpression()), !dbg !28
     41   %0 = load i32, i32* @end, align 4, !dbg !29, !tbaa !31
     42   %cmp20 = icmp sgt i32 %0, 0, !dbg !35
     43   br i1 %cmp20, label %for.body.lr.ph, label %for.cond.cleanup, !dbg !36
     44 
     45 for.body.lr.ph:                                   ; preds = %entry
     46   %1 = load i32, i32* @end, align 4, !tbaa !31
     47   br label %for.body, !dbg !36
     48 
     49 for.cond.cleanup:                                 ; preds = %for.body, %entry
     50 ; CHECK-LABEL: bb.{{.*}}.for.cond.cleanup:
     51 ; CHECK:      [[REG1:%[0-9]+]]:gr32 = PHI
     52 ; CHECK-NEXT: DBG_VALUE debug-use [[REG1]]
     53   %x.0.lcssa = phi i32 [ 9, %entry ], [ %add, %for.body ]
     54   call void @llvm.dbg.value(metadata i32 %x.0.lcssa, metadata !15, metadata !DIExpression()), !dbg !26
     55   %2 = bitcast [80 x i32]* %arr to i8*, !dbg !37
     56   call void @llvm.lifetime.start.p0i8(i64 320, i8* nonnull %2) #3, !dbg !37
     57   call void @llvm.dbg.declare(metadata [80 x i32]* %arr, metadata !19, metadata !DIExpression()), !dbg !38
     58   call void @llvm.dbg.value(metadata i32 0, metadata !24, metadata !DIExpression()), !dbg !39
     59   br label %for.body4, !dbg !40
     60 
     61 for.body:                                         ; preds = %for.body.lr.ph, %for.body
     62 ; CHECK-LABEL: bb.{{.*}}.for.body:
     63 ; CHECK:      [[REG2:%[0-9]+]]:gr32 = PHI
     64 ; CHECK-NEXT: [[REG3:%[0-9]+]]:gr32 = PHI
     65 ; CHECK-NEXT: [[REG4:%[0-9]+]]:gr32 = PHI
     66 ; CHECK-NEXT: DBG_VALUE debug-use [[REG2]]
     67 ; CHECK-NEXT: DBG_VALUE debug-use [[REG3]]
     68 ; CHECK-NEXT: DBG_VALUE debug-use [[REG4]]
     69   %u.023 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
     70   %y.022 = phi i32 [ 13, %for.body.lr.ph ], [ %mul, %for.body ]
     71   %x.021 = phi i32 [ 9, %for.body.lr.ph ], [ %add, %for.body ]
     72   call void @llvm.dbg.value(metadata i32 %u.023, metadata !17, metadata !DIExpression()), !dbg !28
     73   call void @llvm.dbg.value(metadata i32 %y.022, metadata !16, metadata !DIExpression()), !dbg !27
     74   call void @llvm.dbg.value(metadata i32 %x.021, metadata !15, metadata !DIExpression()), !dbg !26
     75   %add = add nuw nsw i32 %y.022, %x.021, !dbg !41
     76   %mul = mul nsw i32 %y.022, 3, !dbg !43
     77   %inc = add nuw nsw i32 %u.023, 1, !dbg !44
     78   call void @llvm.dbg.value(metadata i32 %inc, metadata !17, metadata !DIExpression()), !dbg !28
     79   call void @llvm.dbg.value(metadata i32 %mul, metadata !16, metadata !DIExpression()), !dbg !27
     80   call void @llvm.dbg.value(metadata i32 %add, metadata !15, metadata !DIExpression()), !dbg !26
     81   %cmp = icmp slt i32 %inc, %1, !dbg !35
     82   br i1 %cmp, label %for.body, label %for.cond.cleanup, !dbg !36, !llvm.loop !45
     83 
     84 for.cond.cleanup3:                                ; preds = %for.body4
     85   call void @llvm.lifetime.end.p0i8(i64 320, i8* nonnull %2) #3, !dbg !47
     86   ret i32 %x.0.lcssa, !dbg !48
     87 
     88 for.body4:                                        ; preds = %for.body4, %for.cond.cleanup
     89   %indvars.iv = phi i64 [ 0, %for.cond.cleanup ], [ %indvars.iv.next, %for.body4 ]
     90   call void @llvm.dbg.value(metadata i64 %indvars.iv, metadata !24, metadata !DIExpression()), !dbg !39
     91   %arrayidx = getelementptr inbounds [80 x i32], [80 x i32]* %arr, i64 0, i64 %indvars.iv, !dbg !49
     92   %3 = trunc i64 %indvars.iv to i32, !dbg !52
     93   %4 = add i32 %3, 3, !dbg !52
     94   store volatile i32 %4, i32* %arrayidx, align 4, !dbg !52, !tbaa !31
     95   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !53
     96   call void @llvm.dbg.value(metadata i32 undef, metadata !24, metadata !DIExpression(DW_OP_plus_uconst, 1, DW_OP_stack_value)), !dbg !39
     97   %exitcond = icmp eq i64 %indvars.iv.next, 64, !dbg !54
     98   br i1 %exitcond, label %for.cond.cleanup3, label %for.body4, !dbg !40, !llvm.loop !55
     99 }
    100 
    101 ; Function Attrs: argmemonly nounwind
    102 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
    103 
    104 ; Function Attrs: nounwind readnone speculatable
    105 declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
    106 
    107 ; Function Attrs: argmemonly nounwind
    108 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
    109 
    110 ; Function Attrs: nounwind readnone speculatable
    111 declare void @llvm.dbg.value(metadata, metadata, metadata) #2
    112 
    113 attributes #0 = { nounwind uwtable }
    114 attributes #1 = { argmemonly nounwind }
    115 attributes #2 = { nounwind readnone speculatable }
    116 attributes #3 = { nounwind }
    117 
    118 !llvm.dbg.cu = !{!2}
    119 !llvm.module.flags = !{!7, !8, !9}
    120 !llvm.ident = !{!10}
    121 
    122 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
    123 !1 = distinct !DIGlobalVariable(name: "end", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
    124 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (x)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
    125 !3 = !DIFile(filename: "debug.c", directory: "")
    126 !4 = !{}
    127 !5 = !{!0}
    128 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
    129 !7 = !{i32 2, !"Dwarf Version", i32 4}
    130 !8 = !{i32 2, !"Debug Info Version", i32 3}
    131 !9 = !{i32 1, !"wchar_size", i32 4}
    132 !10 = !{!"clang version 7.0.0 (x)"}
    133 !11 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 3, type: !12, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !2, retainedNodes: !14)
    134 !12 = !DISubroutineType(types: !13)
    135 !13 = !{!6}
    136 !14 = !{!15, !16, !17, !19, !24}
    137 !15 = !DILocalVariable(name: "x", scope: !11, file: !3, line: 4, type: !6)
    138 !16 = !DILocalVariable(name: "y", scope: !11, file: !3, line: 5, type: !6)
    139 !17 = !DILocalVariable(name: "u", scope: !18, file: !3, line: 6, type: !6)
    140 !18 = distinct !DILexicalBlock(scope: !11, file: !3, line: 6, column: 3)
    141 !19 = !DILocalVariable(name: "arr", scope: !11, file: !3, line: 11, type: !20)
    142 !20 = !DICompositeType(tag: DW_TAG_array_type, baseType: !21, size: 2560, elements: !22)
    143 !21 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !6)
    144 !22 = !{!23}
    145 !23 = !DISubrange(count: 80)
    146 !24 = !DILocalVariable(name: "q", scope: !25, file: !3, line: 12, type: !6)
    147 !25 = distinct !DILexicalBlock(scope: !11, file: !3, line: 12, column: 3)
    148 !26 = !DILocation(line: 4, column: 7, scope: !11)
    149 !27 = !DILocation(line: 5, column: 7, scope: !11)
    150 !28 = !DILocation(line: 6, column: 12, scope: !18)
    151 !29 = !DILocation(line: 6, column: 23, scope: !30)
    152 !30 = distinct !DILexicalBlock(scope: !18, file: !3, line: 6, column: 3)
    153 !31 = !{!32, !32, i64 0}
    154 !32 = !{!"int", !33, i64 0}
    155 !33 = !{!"omnipotent char", !34, i64 0}
    156 !34 = !{!"Simple C/C++ TBAA"}
    157 !35 = !DILocation(line: 6, column: 21, scope: !30)
    158 !36 = !DILocation(line: 6, column: 3, scope: !18)
    159 !37 = !DILocation(line: 11, column: 3, scope: !11)
    160 !38 = !DILocation(line: 11, column: 16, scope: !11)
    161 !39 = !DILocation(line: 12, column: 12, scope: !25)
    162 !40 = !DILocation(line: 12, column: 3, scope: !25)
    163 !41 = !DILocation(line: 7, column: 7, scope: !42)
    164 !42 = distinct !DILexicalBlock(scope: !30, file: !3, line: 6, column: 33)
    165 !43 = !DILocation(line: 8, column: 11, scope: !42)
    166 !44 = !DILocation(line: 6, column: 28, scope: !30)
    167 !45 = distinct !{!45, !36, !46}
    168 !46 = !DILocation(line: 9, column: 3, scope: !18)
    169 !47 = !DILocation(line: 17, column: 1, scope: !11)
    170 !48 = !DILocation(line: 16, column: 3, scope: !11)
    171 !49 = !DILocation(line: 13, column: 5, scope: !50)
    172 !50 = distinct !DILexicalBlock(scope: !51, file: !3, line: 12, column: 32)
    173 !51 = distinct !DILexicalBlock(scope: !25, file: !3, line: 12, column: 3)
    174 !52 = !DILocation(line: 13, column: 12, scope: !50)
    175 !53 = !DILocation(line: 12, column: 27, scope: !51)
    176 !54 = !DILocation(line: 12, column: 21, scope: !51)
    177 !55 = distinct !{!55, !40, !56}
    178 !56 = !DILocation(line: 14, column: 3, scope: !25)
    179