blob: d4ee4e861c2d77df2275d54f67fe61343c8db30e [file] [log] [blame]
Victor Hernandez131e0fc2009-09-25 18:11:52 +00001; RUN: opt < %s -globalopt -S | not grep malloc
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002
Tanya Lattner4c4d0b82008-03-01 09:15:35 +00003@G = internal global i32* null ; <i32**> [#uses=4]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Tanya Lattner4c4d0b82008-03-01 09:15:35 +00005define void @init() {
6 %P = malloc i32, i32 100 ; <i32*> [#uses=1]
7 store i32* %P, i32** @G
8 %GV = load i32** @G ; <i32*> [#uses=1]
9 %GVe = getelementptr i32* %GV, i32 40 ; <i32*> [#uses=1]
10 store i32 20, i32* %GVe
11 ret void
Dan Gohmanf17a25c2007-07-18 16:29:46 +000012}
13
Tanya Lattner4c4d0b82008-03-01 09:15:35 +000014define i32 @get() {
15 %GV = load i32** @G ; <i32*> [#uses=1]
16 %GVe = getelementptr i32* %GV, i32 40 ; <i32*> [#uses=1]
17 %V = load i32* %GVe ; <i32> [#uses=1]
18 ret i32 %V
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019}
20
Tanya Lattner4c4d0b82008-03-01 09:15:35 +000021define i1 @check() {
22 %GV = load i32** @G ; <i32*> [#uses=1]
23 %V = icmp eq i32* %GV, null ; <i1> [#uses=1]
24 ret i1 %V
Dan Gohmanf17a25c2007-07-18 16:29:46 +000025}
Tanya Lattner4c4d0b82008-03-01 09:15:35 +000026