blob: a920b611501c080b19eaaeed359f78d8bdd17c41 [file] [log] [blame]
Victor Hernandez6203d9d2009-10-17 00:00:19 +00001; RUN: opt < %s -globalopt -globaldce -S | not grep malloc
2target 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"
3target triple = "i686-apple-darwin8"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Tanya Lattner4c4d0b82008-03-01 09:15:35 +00005@G = internal global i32* null ; <i32**> [#uses=4]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006
Tanya Lattner4c4d0b82008-03-01 09:15:35 +00007define void @init() {
8 %P = malloc i32, i32 100 ; <i32*> [#uses=1]
9 store i32* %P, i32** @G
10 %GV = load i32** @G ; <i32*> [#uses=1]
11 %GVe = getelementptr i32* %GV, i32 40 ; <i32*> [#uses=1]
12 store i32 20, i32* %GVe
13 ret void
Dan Gohmanf17a25c2007-07-18 16:29:46 +000014}
15
Tanya Lattner4c4d0b82008-03-01 09:15:35 +000016define i32 @get() {
17 %GV = load i32** @G ; <i32*> [#uses=1]
18 %GVe = getelementptr i32* %GV, i32 40 ; <i32*> [#uses=1]
19 %V = load i32* %GVe ; <i32> [#uses=1]
20 ret i32 %V
Dan Gohmanf17a25c2007-07-18 16:29:46 +000021}
22
Tanya Lattner4c4d0b82008-03-01 09:15:35 +000023define i1 @check() {
24 %GV = load i32** @G ; <i32*> [#uses=1]
25 %V = icmp eq i32* %GV, null ; <i1> [#uses=1]
26 ret i1 %V
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027}
Tanya Lattner4c4d0b82008-03-01 09:15:35 +000028