2013-03-13 00:27:52 +08:00
; REQUIRES: asserts
2016-04-26 07:36:50 +08:00
; RUN: opt < %s -globalopt -stats -disable-output 2>&1 | FileCheck %s
; CHECK: 1 globalopt - Number of global vars shrunk to booleans
2009-03-06 09:39:36 +08:00
2016-12-22 08:45:21 +08:00
source_filename = "test/Transforms/GlobalOpt/2009-03-05-dbg.ll"
2009-03-06 08:21:00 +08:00
2016-12-22 08:45:21 +08:00
@Stop = internal global i32 0 , !dbg !0
; Function Attrs: nounwind ssp
define i32 @foo ( i32 %i ) #0 {
2009-03-06 08:21:00 +08:00
entry:
2016-12-22 08:45:21 +08:00
%"alloca point" = bitcast i32 0 to i32
2017-07-29 04:21:02 +08:00
call void @llvm.dbg.value ( metadata i32 %i , metadata !8 , metadata !12 ) , !dbg !13
2016-12-22 08:45:21 +08:00
%0 = icmp eq i32 %i , 1 , !dbg !13
br i1 %0 , label %bb , label %bb1 , !dbg !13
2009-03-06 08:21:00 +08:00
2010-03-02 03:41:26 +08:00
bb: ; preds = %entry
2016-12-22 08:45:21 +08:00
store i32 0 , i32 * @Stop , align 4 , !dbg !15
%1 = mul nsw i32 %i , 42 , !dbg !16
2017-07-29 04:21:02 +08:00
call void @llvm.dbg.value ( metadata i32 %1 , metadata !8 , metadata !12 ) , !dbg !16
2016-12-22 08:45:21 +08:00
br label %bb2 , !dbg !16
2009-03-06 08:21:00 +08:00
2010-03-02 03:41:26 +08:00
bb1: ; preds = %entry
2016-12-22 08:45:21 +08:00
store i32 1 , i32 * @Stop , align 4 , !dbg !17
br label %bb2 , !dbg !17
2009-03-06 08:21:00 +08:00
2010-03-02 03:41:26 +08:00
bb2: ; preds = %bb1, %bb
2016-12-22 08:45:21 +08:00
%i_addr.0 = phi i32 [ %1 , %bb ] , [ %i , %bb1 ]
br label %return , !dbg !18
2010-03-02 03:41:26 +08:00
return: ; preds = %bb2
2016-12-22 08:45:21 +08:00
ret i32 %i_addr.0 , !dbg !18
2009-03-06 08:21:00 +08:00
}
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind readnone
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
2010-03-02 03:41:26 +08:00
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind ssp
define i32 @bar ( ) #0 {
2010-03-02 03:41:26 +08:00
entry:
2016-12-22 08:45:21 +08:00
%"alloca point" = bitcast i32 0 to i32
%0 = load i32 , i32 * @Stop , align 4 , !dbg !19
%1 = icmp eq i32 %0 , 1 , !dbg !19
br i1 %1 , label %bb , label %bb1 , !dbg !19
2010-03-02 03:41:26 +08:00
bb: ; preds = %entry
2016-12-22 08:45:21 +08:00
br label %bb2 , !dbg !24
2010-03-02 03:41:26 +08:00
bb1: ; preds = %entry
2016-12-22 08:45:21 +08:00
br label %bb2 , !dbg !25
2010-03-02 03:41:26 +08:00
bb2: ; preds = %bb1, %bb
2016-12-22 08:45:21 +08:00
%.0 = phi i32 [ 0 , %bb ] , [ 1 , %bb1 ]
br label %return , !dbg !25
2010-03-02 03:41:26 +08:00
return: ; preds = %bb2
2016-12-22 08:45:21 +08:00
ret i32 %.0 , !dbg !25
2010-03-02 03:41:26 +08:00
}
2009-03-06 08:21:00 +08:00
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind readnone
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata ) #1
2016-12-22 08:45:21 +08:00
attributes #0 = { nounwind ssp }
attributes #1 = { nounwind readnone }
!llvm.dbg.cu = ! { !2 }
!llvm.module.flags = ! { !6 , !7 }
!0 = !DIGlobalVariableExpression ( var: !1 )
!1 = !DIGlobalVariable ( name: "Stop" , scope: !2 , file: !3 , line: 2 , type: !5 , isLocal: true , isDefinition: true )
!2 = distinct !DICompileUnit ( language: D W _ L A N G _ C 89 , file: !3 , producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)" , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , globals: !4 )
!3 = !DIFile ( filename: "g.c" , directory: "/tmp" )
!4 = ! { !0 }
!5 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!6 = ! { i32 2 , !"Dwarf Version" , i32 2 }
!7 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!8 = !DILocalVariable ( name: "i" , arg: 1 , scope: !9 , file: !3 , line: 4 , type: !5 )
2017-02-18 07:57:42 +08:00
!9 = distinct !DISubprogram ( name: "foo" , linkageName: "foo" , scope: !2 , file: !3 , line: 4 , type: !10 , isLocal: false , isDefinition: true , virtualIndex: 6 , isOptimized: false , unit: !2 ) !10 = !DISubroutineType ( types: !11 ) !11 = ! { !5 , !5 } !12 = !DIExpression ( ) !13 = !DILocation ( line: 5 , scope: !14 ) !14 = distinct !DILexicalBlock ( scope: !9 , file: !3 ) !15 = !DILocation ( line: 6 , scope: !14 ) !16 = !DILocation ( line: 7 , scope: !14 ) !17 = !DILocation ( line: 9 , scope: !14 ) !18 = !DILocation ( line: 11 , scope: !14 ) !19 = !DILocation ( line: 14 , scope: !20 ) !20 = distinct !DILexicalBlock ( scope: !21 , file: !3 ) !21 = distinct !DISubprogram ( name: "bar" , linkageName: "bar" , scope: !2 , file: !3 , line: 13 , type: !22 , isLocal: false , isDefinition: true , virtualIndex: 6 , isOptimized: false , unit: !2 ) !22 = !DISubroutineType ( types: !23 ) !23 = ! { !5 } !24 = !DILocation ( line: 15 , scope: !20 ) !25 = !DILocation ( line: 16 , scope: !20 )