1 ; RUN: opt -S -globalopt -o - < %s | FileCheck %s
3 ; CHECK: [[G_INIT:@.*]] = internal unnamed_addr global i1 false
4 @g = internal global i32* null, align 8
6 ; CHECK-LABEL: define {{.*}} @f1(
7 ; CHECK-NEXT: [[G_INIT_VAL:%.*]] = load i1, i1* [[G_INIT]], align 1
8 ; CHECK-NEXT: call fastcc void @f2()
9 ; CHECK-NEXT: [[NOTINIT:%.*]] = xor i1 [[G_INIT_VAL]], true
10 ; CHECK-NEXT: br i1 [[NOTINIT]], label [[TMP1:%.*]], label [[TMP2:%.*]]
12 define internal i32 @f1() {
13 %1 = load i32*, i32** @g, align 8
15 %2 = icmp eq i32* %1, null
16 br i1 %2, label %3, label %4
25 %6 = phi i32 [ -1, %3 ], [ 1, %4 ]
29 ; CHECK-LABEL: define {{.*}} @f2(
30 ; CHECK-NEXT: store i1 true, i1* [[G_INIT]], align 1
31 ; CHECK-NEXT: ret void
33 define internal void @f2() {
34 %1 = call noalias i8* @malloc(i64 4)
35 %2 = bitcast i8* %1 to i32*
36 store i32* %2, i32** @g, align 8
40 ; CHECK-LABEL: define {{.*}} @main(
41 ; CHECK-NEXT: store i1 false, i1* [[G_INIT]], align 1
42 ; CHECK-NEXT: [[TMP1:%.*]] = call fastcc i32 @f1()
43 ; CHECK-NEXT: ret i32 [[TMP1]]
45 define dso_local i32 @main() {
46 store i32* null, i32** @g, align 8
51 declare dso_local noalias i8* @malloc(i64)