Home | History | Annotate | Download | only in GlobalOpt
      1 ; RUN: opt < %s -globalopt -stats -disable-output |& grep "1 globalopt - Number of global vars shrunk to booleans"
      2 
      3 @Stop = internal global i32 0                     ; <i32*> [#uses=3]
      4 
      5 define i32 @foo(i32 %i) nounwind ssp {
      6 entry:
      7   %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
      8   call void @llvm.dbg.value(metadata !{i32 %i}, i64 0, metadata !3)
      9   %0 = icmp eq i32 %i, 1, !dbg !7                 ; <i1> [#uses=1]
     10   br i1 %0, label %bb, label %bb1, !dbg !7
     11 
     12 bb:                                               ; preds = %entry
     13   store i32 0, i32* @Stop, align 4, !dbg !9
     14   %1 = mul nsw i32 %i, 42, !dbg !10               ; <i32> [#uses=1]
     15   call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !3), !dbg !10
     16   br label %bb2, !dbg !10
     17 
     18 bb1:                                              ; preds = %entry
     19   store i32 1, i32* @Stop, align 4, !dbg !11
     20   br label %bb2, !dbg !11
     21 
     22 bb2:                                              ; preds = %bb1, %bb
     23   %i_addr.0 = phi i32 [ %1, %bb ], [ %i, %bb1 ]   ; <i32> [#uses=1]
     24   br label %return, !dbg !12
     25 
     26 return:                                           ; preds = %bb2
     27   ret i32 %i_addr.0, !dbg !12
     28 }
     29 
     30 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
     31 
     32 define i32 @bar() nounwind ssp {
     33 entry:
     34   %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
     35   %0 = load i32* @Stop, align 4, !dbg !13         ; <i32> [#uses=1]
     36   %1 = icmp eq i32 %0, 1, !dbg !13                ; <i1> [#uses=1]
     37   br i1 %1, label %bb, label %bb1, !dbg !13
     38 
     39 bb:                                               ; preds = %entry
     40   br label %bb2, !dbg !18
     41 
     42 bb1:                                              ; preds = %entry
     43   br label %bb2, !dbg !19
     44 
     45 bb2:                                              ; preds = %bb1, %bb
     46   %.0 = phi i32 [ 0, %bb ], [ 1, %bb1 ]           ; <i32> [#uses=1]
     47   br label %return, !dbg !19
     48 
     49 return:                                           ; preds = %bb2
     50   ret i32 %.0, !dbg !19
     51 }
     52 
     53 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
     54 
     55 !llvm.dbg.gv = !{!0}
     56 
     57 !0 = metadata !{i32 458804, i32 0, metadata !1, metadata !"Stop", metadata !"Stop", metadata !"", metadata !1, i32 2, metadata !2, i1 true, i1 true, i32* @Stop} ; [ DW_TAG_variable ]
     58 !1 = metadata !{i32 458769, i32 0, i32 1, metadata !"g.c", metadata !"/tmp", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
     59 !2 = metadata !{i32 458788, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
     60 !3 = metadata !{i32 459009, metadata !4, metadata !"i", metadata !1, i32 4, metadata !2} ; [ DW_TAG_arg_variable ]
     61 !4 = metadata !{i32 458798, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"foo", metadata !1, i32 4, metadata !5, i1 false, i1 true, i32 0, i32 0, null, i1 false} ; [ DW_TAG_subprogram ]
     62 !5 = metadata !{i32 458773, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !6, i32 0, null} ; [ DW_TAG_subroutine_type ]
     63 !6 = metadata !{metadata !2, metadata !2}
     64 !7 = metadata !{i32 5, i32 0, metadata !8, null}
     65 !8 = metadata !{i32 458763, metadata !4, i32 0, i32 0} ; [ DW_TAG_lexical_block ]
     66 !9 = metadata !{i32 6, i32 0, metadata !8, null}
     67 !10 = metadata !{i32 7, i32 0, metadata !8, null}
     68 !11 = metadata !{i32 9, i32 0, metadata !8, null}
     69 !12 = metadata !{i32 11, i32 0, metadata !8, null}
     70 !13 = metadata !{i32 14, i32 0, metadata !14, null}
     71 !14 = metadata !{i32 458763, metadata !15, i32 0, i32 0} ; [ DW_TAG_lexical_block ]
     72 !15 = metadata !{i32 458798, i32 0, metadata !1, metadata !"bar", metadata !"bar", metadata !"bar", metadata !1, i32 13, metadata !16, i1 false, i1 true, i32 0, i32 0, null, i1 false} ; [ DW_TAG_subprogram ]
     73 !16 = metadata !{i32 458773, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !17, i32 0, null} ; [ DW_TAG_subroutine_type ]
     74 !17 = metadata !{metadata !2}
     75 !18 = metadata !{i32 15, i32 0, metadata !14, null}
     76 !19 = metadata !{i32 16, i32 0, metadata !14, null}
     77