xref: /aosp_15_r20/external/llvm/test/Transforms/GlobalOpt/2008-12-16-HeapSRACrash-2.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -globalopt | llvm-dis
2*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
3*9880d681SAndroid Build Coastguard Workertarget triple = "i386-apple-darwin7"
4*9880d681SAndroid Build Coastguard Worker	%struct.foo = type { i32, i32 }
5*9880d681SAndroid Build Coastguard Worker@X = internal global %struct.foo* null		; <%struct.foo**> [#uses=2]
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Workerdefine void @bar(i32 %Size) nounwind noinline {
8*9880d681SAndroid Build Coastguard Workerentry:
9*9880d681SAndroid Build Coastguard Worker        %malloccall = tail call i8* @malloc(i32 trunc (i64 mul (i64 ptrtoint (i32* getelementptr (i32, i32* null, i32 1) to i64), i64 2000000) to i32))
10*9880d681SAndroid Build Coastguard Worker        %tmp = bitcast i8* %malloccall to [1000000 x %struct.foo]*
11*9880d681SAndroid Build Coastguard Worker	%.sub = getelementptr [1000000 x %struct.foo], [1000000 x %struct.foo]* %tmp, i32 0, i32 0		; <%struct.foo*> [#uses=1]
12*9880d681SAndroid Build Coastguard Worker	store %struct.foo* %.sub, %struct.foo** @X, align 4
13*9880d681SAndroid Build Coastguard Worker	ret void
14*9880d681SAndroid Build Coastguard Worker}
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Workerdeclare noalias i8* @malloc(i32)
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Workerdefine i32 @baz() nounwind readonly noinline {
20*9880d681SAndroid Build Coastguard Workerbb1.thread:
21*9880d681SAndroid Build Coastguard Worker	%tmpLD1 = load %struct.foo*, %struct.foo** @X, align 4		; <%struct.foo*> [#uses=2]
22*9880d681SAndroid Build Coastguard Worker	br label %bb1
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Workerbb1:		; preds = %bb1, %bb1.thread
25*9880d681SAndroid Build Coastguard Worker	%tmp = phi %struct.foo* [ %tmpLD1, %bb1.thread ], [ %tmpLD1, %bb1 ]		; <%struct.foo*> [#uses=1]
26*9880d681SAndroid Build Coastguard Worker	%0 = getelementptr %struct.foo, %struct.foo* %tmp, i32 1		; <%struct.foo*> [#uses=0]
27*9880d681SAndroid Build Coastguard Worker	br label %bb1
28*9880d681SAndroid Build Coastguard Worker}
29