Dan Gohman | f2f6ce6 | 2009-09-11 18:01:28 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -globalopt -S | not grep global |
Chris Lattner | 95d0bbf | 2004-10-11 05:00:12 +0000 | [diff] [blame] | 2 | |
Tanya Lattner | ec9a35a | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 3 | @G = internal global i32* null ; <i32**> [#uses=3] |
Chris Lattner | 95d0bbf | 2004-10-11 05:00:12 +0000 | [diff] [blame] | 4 | |
Tanya Lattner | ec9a35a | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 5 | define void @init() { |
| 6 | %P = malloc i32 ; <i32*> [#uses=1] |
| 7 | store i32* %P, i32** @G |
| 8 | %GV = load i32** @G ; <i32*> [#uses=1] |
| 9 | store i32 0, i32* %GV |
| 10 | ret void |
Chris Lattner | 95d0bbf | 2004-10-11 05:00:12 +0000 | [diff] [blame] | 11 | } |
| 12 | |
Tanya Lattner | ec9a35a | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 13 | define i32 @get() { |
| 14 | %GV = load i32** @G ; <i32*> [#uses=1] |
| 15 | %V = load i32* %GV ; <i32> [#uses=1] |
| 16 | ret i32 %V |
Chris Lattner | 95d0bbf | 2004-10-11 05:00:12 +0000 | [diff] [blame] | 17 | } |
Tanya Lattner | ec9a35a | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 18 | |