John Criswell | 57886cb | 2003-07-21 19:41:51 +0000 | [diff] [blame] | 1 | ; |
| 2 | ; Test: ExternalConstant |
| 3 | ; |
| 4 | ; Description: |
| 5 | ; This regression test helps check whether the instruction combining |
| 6 | ; optimization pass correctly handles global variables which are marked |
| 7 | ; as external and constant. |
| 8 | ; |
| 9 | ; If a problem occurs, we should die on an assert(). Otherwise, we |
| 10 | ; should pass through the optimizer without failure. |
| 11 | ; |
| 12 | ; Extra code: |
Dan Gohman | 1880092 | 2009-09-11 18:01:28 +0000 | [diff] [blame] | 13 | ; RUN: opt < %s -instcombine |
Tanya Lattner | aa6f5c9 | 2008-03-09 08:16:40 +0000 | [diff] [blame] | 14 | ; END. |
John Criswell | 57886cb | 2003-07-21 19:41:51 +0000 | [diff] [blame] | 15 | |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 16 | target datalayout = "e-p:32:32" |
| 17 | @silly = external constant i32 ; <i32*> [#uses=1] |
John Criswell | 57886cb | 2003-07-21 19:41:51 +0000 | [diff] [blame] | 18 | |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 19 | declare void @bzero(i8*, i32) |
John Criswell | 57886cb | 2003-07-21 19:41:51 +0000 | [diff] [blame] | 20 | |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 21 | declare void @bcopy(i8*, i8*, i32) |
John Criswell | 57886cb | 2003-07-21 19:41:51 +0000 | [diff] [blame] | 22 | |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 23 | declare i32 @bcmp(i8*, i8*, i32) |
John Criswell | 57886cb | 2003-07-21 19:41:51 +0000 | [diff] [blame] | 24 | |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 25 | declare i32 @fputs(i8*, i8*) |
John Criswell | 57886cb | 2003-07-21 19:41:51 +0000 | [diff] [blame] | 26 | |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 27 | declare i32 @fputs_unlocked(i8*, i8*) |
John Criswell | 57886cb | 2003-07-21 19:41:51 +0000 | [diff] [blame] | 28 | |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 29 | define i32 @function(i32 %a.1) { |
| 30 | entry: |
| 31 | %a.0 = alloca i32 ; <i32*> [#uses=2] |
| 32 | %result = alloca i32 ; <i32*> [#uses=2] |
| 33 | store i32 %a.1, i32* %a.0 |
| 34 | %tmp.0 = load i32* %a.0 ; <i32> [#uses=1] |
| 35 | %tmp.1 = load i32* @silly ; <i32> [#uses=1] |
| 36 | %tmp.2 = add i32 %tmp.0, %tmp.1 ; <i32> [#uses=1] |
| 37 | store i32 %tmp.2, i32* %result |
| 38 | br label %return |
John Criswell | 57886cb | 2003-07-21 19:41:51 +0000 | [diff] [blame] | 39 | |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 40 | return: ; preds = %entry |
| 41 | %tmp.3 = load i32* %result ; <i32> [#uses=1] |
| 42 | ret i32 %tmp.3 |
John Criswell | 57886cb | 2003-07-21 19:41:51 +0000 | [diff] [blame] | 43 | } |
Tanya Lattner | 5640bd1 | 2008-03-01 09:15:35 +0000 | [diff] [blame] | 44 | |