Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 1 | ; Tests if we handle global variables with relocation initializers. |
| 2 | |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 3 | ; RUN: %p2i -i %s --insts | FileCheck %s |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 4 | ; RUN: %l2i -i %s --insts | %ifl FileCheck %s |
| 5 | ; RUN: %lc2i -i %s --insts | %iflc FileCheck %s |
Jim Stichnoth | 0d4fc92 | 2015-12-13 21:36:33 -0800 | [diff] [blame^] | 6 | ; RUN: %p2i -i %s --args -notranslate -timing | \ |
Karl Schimpf | 6fcbddd | 2014-11-06 09:49:24 -0800 | [diff] [blame] | 7 | ; RUN: FileCheck --check-prefix=NOIR %s |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 8 | |
| 9 | @bytes = internal global [7 x i8] c"abcdefg" |
| 10 | ; CHECK: @bytes = internal global [7 x i8] c"abcdefg" |
| 11 | |
| 12 | @const_bytes = internal constant [7 x i8] c"abcdefg" |
| 13 | ; CHECK-NEXT: @const_bytes = internal constant [7 x i8] c"abcdefg" |
| 14 | |
| 15 | @ptr_to_ptr = internal global i32 ptrtoint (i32* @ptr to i32) |
| 16 | ; CHECK-NEXT: @ptr_to_ptr = internal global i32 ptrtoint (i32* @ptr to i32) |
| 17 | |
| 18 | @const_ptr_to_ptr = internal constant i32 ptrtoint (i32* @ptr to i32) |
| 19 | ; CHECK-NEXT: @const_ptr_to_ptr = internal constant i32 ptrtoint (i32* @ptr to i32) |
| 20 | |
| 21 | @ptr_to_func = internal global i32 ptrtoint (void ()* @func to i32) |
| 22 | ; CHECK-NEXT: @ptr_to_func = internal global i32 ptrtoint (void ()* @func to i32) |
| 23 | |
| 24 | @const_ptr_to_func = internal constant i32 ptrtoint (void ()* @func to i32) |
| 25 | ; CHECK-NEXT: @const_ptr_to_func = internal constant i32 ptrtoint (void ()* @func to i32) |
| 26 | |
| 27 | @compound = internal global <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> |
| 28 | ; CHECK-NEXT: @compound = internal global <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> |
| 29 | |
| 30 | @const_compound = internal constant <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> |
| 31 | |
| 32 | ; CHECK-NEXT: @const_compound = internal constant <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> |
| 33 | |
| 34 | @ptr = internal global i32 ptrtoint ([7 x i8]* @bytes to i32) |
| 35 | ; CHECK-NEXT: @ptr = internal global i32 ptrtoint ([7 x i8]* @bytes to i32) |
| 36 | |
| 37 | @const_ptr = internal constant i32 ptrtoint ([7 x i8]* @bytes to i32) |
| 38 | ; CHECK-NEXT: @const_ptr = internal constant i32 ptrtoint ([7 x i8]* @bytes to i32) |
| 39 | |
| 40 | @addend_ptr = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) |
| 41 | ; CHECK-NEXT: @addend_ptr = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) |
| 42 | |
| 43 | @const_addend_ptr = internal constant i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) |
| 44 | ; CHECK-NEXT: @const_addend_ptr = internal constant i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) |
| 45 | |
| 46 | @addend_negative = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) |
| 47 | ; CHECK-NEXT: @addend_negative = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) |
| 48 | |
| 49 | @const_addend_negative = internal constant i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) |
| 50 | ; CHECK-NEXT: @const_addend_negative = internal constant i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) |
| 51 | |
| 52 | @addend_array1 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1) |
| 53 | ; CHECK-NEXT: @addend_array1 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1) |
| 54 | |
| 55 | @const_addend_array1 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1) |
| 56 | ; CHECK-NEXT: @const_addend_array1 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1) |
| 57 | |
| 58 | @addend_array2 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7) |
| 59 | ; CHECK-NEXT: @addend_array2 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7) |
| 60 | |
| 61 | @const_addend_array2 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7) |
| 62 | ; CHECK-NEXT: @const_addend_array2 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7) |
| 63 | |
| 64 | @addend_array3 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9) |
| 65 | ; CHECK-NEXT: @addend_array3 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9) |
| 66 | |
| 67 | @const_addend_array3 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9) |
| 68 | ; CHECK-NEXT: @const_addend_array3 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9) |
| 69 | |
| 70 | @addend_struct1 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1) |
| 71 | ; CHECK-NEXT: @addend_struct1 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1) |
| 72 | |
| 73 | @const_addend_struct1 = internal constant i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1) |
| 74 | ; CHECK-NEXT: @const_addend_struct1 = internal constant i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1) |
| 75 | |
| 76 | @addend_struct2 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4) |
| 77 | ; CHECK-NEXT: @addend_struct2 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4) |
| 78 | |
| 79 | @const_addend_struct2 = internal constant i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4) |
| 80 | ; CHECK-NEXT: @const_addend_struct2 = internal constant i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4) |
| 81 | |
| 82 | @ptr_to_func_align = internal global i32 ptrtoint (void ()* @func to i32), align 8 |
| 83 | ; CHECK-NEXT: @ptr_to_func_align = internal global i32 ptrtoint (void ()* @func to i32), align 8 |
| 84 | |
| 85 | @const_ptr_to_func_align = internal constant i32 ptrtoint (void ()* @func to i32), align 8 |
| 86 | ; CHECK-NEXT: @const_ptr_to_func_align = internal constant i32 ptrtoint (void ()* @func to i32), align 8 |
| 87 | |
| 88 | @char = internal constant [1 x i8] c"0" |
| 89 | ; CHECK-NEXT: @char = internal constant [1 x i8] c"0" |
| 90 | |
| 91 | @short = internal constant [2 x i8] zeroinitializer |
| 92 | ; CHECK-NEXT: @short = internal constant [2 x i8] zeroinitializer |
| 93 | |
Karl Schimpf | 57d31ac | 2015-10-07 09:53:12 -0700 | [diff] [blame] | 94 | define internal void @func() { |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 95 | ret void |
| 96 | } |
| 97 | |
Karl Schimpf | 57d31ac | 2015-10-07 09:53:12 -0700 | [diff] [blame] | 98 | ; CHECK-NEXT: define internal void @func() { |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 99 | |
Karl Schimpf | 6fcbddd | 2014-11-06 09:49:24 -0800 | [diff] [blame] | 100 | ; NOIR: Total across all functions |