1; REQUIRES: asserts 2; RUN: opt < %s -globalopt -stats -disable-output 2>&1 | FileCheck %s 3; CHECK: 1 globalopt - Number of global vars shrunk to booleans 4 5@Stop = internal global i32 0 ; <i32*> [#uses=3] 6 7define i32 @foo(i32 %i) nounwind ssp { 8entry: 9 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] 10 call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !3, metadata !{}) 11 %0 = icmp eq i32 %i, 1, !dbg !7 ; <i1> [#uses=1] 12 br i1 %0, label %bb, label %bb1, !dbg !7 13 14bb: ; preds = %entry 15 store i32 0, i32* @Stop, align 4, !dbg !9 16 %1 = mul nsw i32 %i, 42, !dbg !10 ; <i32> [#uses=1] 17 call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !3, metadata !{}), !dbg !10 18 br label %bb2, !dbg !10 19 20bb1: ; preds = %entry 21 store i32 1, i32* @Stop, align 4, !dbg !11 22 br label %bb2, !dbg !11 23 24bb2: ; preds = %bb1, %bb 25 %i_addr.0 = phi i32 [ %1, %bb ], [ %i, %bb1 ] ; <i32> [#uses=1] 26 br label %return, !dbg !12 27 28return: ; preds = %bb2 29 ret i32 %i_addr.0, !dbg !12 30} 31 32declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone 33 34define i32 @bar() nounwind ssp { 35entry: 36 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] 37 %0 = load i32, i32* @Stop, align 4, !dbg !13 ; <i32> [#uses=1] 38 %1 = icmp eq i32 %0, 1, !dbg !13 ; <i1> [#uses=1] 39 br i1 %1, label %bb, label %bb1, !dbg !13 40 41bb: ; preds = %entry 42 br label %bb2, !dbg !18 43 44bb1: ; preds = %entry 45 br label %bb2, !dbg !19 46 47bb2: ; preds = %bb1, %bb 48 %.0 = phi i32 [ 0, %bb ], [ 1, %bb1 ] ; <i32> [#uses=1] 49 br label %return, !dbg !19 50 51return: ; preds = %bb2 52 ret i32 %.0, !dbg !19 53} 54 55declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone 56 57!llvm.dbg.cu = !{!1} 58!0 = !DIGlobalVariable(name: "Stop", line: 2, isLocal: true, isDefinition: true, scope: !1, file: !1, type: !2, variable: i32* @Stop) 59!1 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: FullDebug, file: !20, enums: !21, retainedTypes: !21, globals: !{!0}) 60!2 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 61!3 = !DILocalVariable(name: "i", line: 4, arg: 1, scope: !4, file: !1, type: !2) 62!4 = distinct !DISubprogram(name: "foo", linkageName: "foo", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !1, scope: !1, type: !5) 63!5 = !DISubroutineType(types: !6) 64!6 = !{!2, !2} 65!7 = !DILocation(line: 5, scope: !8) 66!8 = distinct !DILexicalBlock(line: 0, column: 0, file: !20, scope: !4) 67!9 = !DILocation(line: 6, scope: !8) 68!10 = !DILocation(line: 7, scope: !8) 69!11 = !DILocation(line: 9, scope: !8) 70!12 = !DILocation(line: 11, scope: !8) 71!13 = !DILocation(line: 14, scope: !14) 72!14 = distinct !DILexicalBlock(line: 0, column: 0, file: !20, scope: !15) 73!15 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 13, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !1, scope: !1, type: !16) 74!16 = !DISubroutineType(types: !17) 75!17 = !{!2} 76!18 = !DILocation(line: 15, scope: !14) 77!19 = !DILocation(line: 16, scope: !14) 78!20 = !DIFile(filename: "g.c", directory: "/tmp") 79!21 = !{i32 0} 80