1 ; Tests if we handle global variables with relocation initializers. 2 3 ; REQUIRES: allow_dump 4 5 ; Test that we handle it in the ICE converter. 6 ; RUN: %lc2i -i %s --args -verbose inst -threads=0 \ 7 ; RUN: | %iflc FileCheck %s 8 ; RUN: %lc2i -i %s --args -verbose inst,global_init -threads=0 \ 9 ; RUN: | %iflc FileCheck --check-prefix=DUMP %s 10 11 ; Test that we handle it using Subzero's bitcode reader. 12 ; RUN: %p2i -i %s --args -verbose inst -threads=0 \ 13 ; RUN: | FileCheck %s 14 ; RUN: %p2i -i %s --args -verbose inst,global_init -threads=0 \ 15 ; RUN: | FileCheck --check-prefix=DUMP %s 16 17 @bytes = internal global [7 x i8] c"abcdefg" 18 ; DUMP: @bytes = internal global [7 x i8] c"abcdefg" 19 ; CHECK: .type bytes,%object 20 ; CHECK: .section .data,"aw",%progbits 21 ; CHECK:bytes: 22 ; CHECK: .byte 97 23 ; CHECK: .byte 98 24 ; CHECK: .byte 99 25 ; CHECK: .byte 100 26 ; CHECK: .byte 101 27 ; CHECK: .byte 102 28 ; CHECK: .byte 103 29 ; CHECK: .size bytes, 7 30 31 @const_bytes = internal constant [7 x i8] c"abcdefg" 32 ; DUMP: @const_bytes = internal constant [7 x i8] c"abcdefg" 33 ; CHECK: .type const_bytes,%object 34 ; CHECK: .section .rodata,"a",%progbits 35 ; CHECK:const_bytes: 36 ; CHECK: .byte 97 37 ; CHECK: .byte 98 38 ; CHECK: .byte 99 39 ; CHECK: .byte 100 40 ; CHECK: .byte 101 41 ; CHECK: .byte 102 42 ; CHECK: .byte 103 43 ; CHECK: .size const_bytes, 7 44 45 @ptr_to_ptr = internal global i32 ptrtoint (i32* @ptr to i32) 46 ; DUMP: @ptr_to_ptr = internal global i32 ptrtoint (i32* @ptr to i32) 47 ; CHECK: .type ptr_to_ptr,%object 48 ; CHECK: .section .data,"aw",%progbits 49 ; CHECK:ptr_to_ptr: 50 ; CHECK: .long ptr 51 ; CHECK: .size ptr_to_ptr, 4 52 53 @const_ptr_to_ptr = internal constant i32 ptrtoint (i32* @ptr to i32) 54 ; DUMP: @const_ptr_to_ptr = internal constant i32 ptrtoint (i32* @ptr to i32) 55 ; CHECK: .type const_ptr_to_ptr,%object 56 ; CHECK: .section .rodata,"a",%progbits 57 ; CHECK:const_ptr_to_ptr: 58 ; CHECK: .long ptr 59 ; CHECK: .size const_ptr_to_ptr, 4 60 61 @ptr_to_func = internal global i32 ptrtoint (void ()* @func to i32) 62 ; DUMP: @ptr_to_func = internal global i32 ptrtoint (void ()* @func to i32) 63 ; CHECK: .type ptr_to_func,%object 64 ; CHECK: .section .data,"aw",%progbits 65 ; CHECK:ptr_to_func: 66 ; CHECK: .long func 67 ; CHECK: .size ptr_to_func, 4 68 69 @const_ptr_to_func = internal constant i32 ptrtoint (void ()* @func to i32) 70 ; DUMP: @const_ptr_to_func = internal constant i32 ptrtoint (void ()* @func to i32) 71 ; CHECK: .type const_ptr_to_func,%object 72 ; CHECK: .section .rodata,"a",%progbits 73 ; CHECK:const_ptr_to_func: 74 ; CHECK: .long func 75 ; CHECK: .size const_ptr_to_func, 4 76 77 @compound = internal global <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> 78 ; DUMP: @compound = internal global <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> 79 ; CHECK: .type compound,%object 80 ; CHECK: .section .data,"aw",%progbits 81 ; CHECK:compound: 82 ; CHECK: .byte 102 83 ; CHECK: .byte 111 84 ; CHECK: .byte 111 85 ; CHECK: .long func 86 ; CHECK: .size compound, 7 87 88 @const_compound = internal constant <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> 89 ; DUMP: @const_compound = internal constant <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> 90 ; CHECK: .type const_compound,%object 91 ; CHECK: .section .rodata,"a",%progbits 92 ; CHECK:const_compound: 93 ; CHECK: .byte 102 94 ; CHECK: .byte 111 95 ; CHECK: .byte 111 96 ; CHECK: .long func 97 ; CHECK: .size const_compound, 7 98 99 @ptr = internal global i32 ptrtoint ([7 x i8]* @bytes to i32) 100 ; DUMP: @ptr = internal global i32 ptrtoint ([7 x i8]* @bytes to i32) 101 ; CHECK: .type ptr,%object 102 ; CHECK: .section .data,"aw",%progbits 103 ; CHECK:ptr: 104 ; CHECK: .long bytes 105 ; CHECK: .size ptr, 4 106 107 @const_ptr = internal constant i32 ptrtoint ([7 x i8]* @bytes to i32) 108 ; DUMP: @const_ptr = internal constant i32 ptrtoint ([7 x i8]* @bytes to i32) 109 ; CHECK: .type const_ptr,%object 110 ; CHECK: .section .rodata,"a",%progbits 111 ; CHECK:const_ptr: 112 ; CHECK: .long bytes 113 ; CHECK: .size const_ptr, 4 114 115 @addend_ptr = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) 116 ; DUMP: @addend_ptr = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) 117 ; CHECK: .type addend_ptr,%object 118 ; CHECK: .section .data,"aw",%progbits 119 ; CHECK:addend_ptr: 120 ; CHECK: .long ptr + 1 121 ; CHECK: .size addend_ptr, 4 122 123 @const_addend_ptr = internal constant i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) 124 ; DUMP: @const_addend_ptr = internal constant i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) 125 ; CHECK: .type const_addend_ptr,%object 126 ; CHECK: .section .rodata,"a",%progbits 127 ; CHECK:const_addend_ptr: 128 ; CHECK: .long ptr + 1 129 ; CHECK: .size const_addend_ptr, 4 130 131 @addend_negative = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) 132 ; DUMP: @addend_negative = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) 133 ; CHECK: .type addend_negative,%object 134 ; CHECK: .section .data,"aw",%progbits 135 ; CHECK:addend_negative: 136 ; CHECK: .long ptr - 1 137 ; CHECK: .size addend_negative, 4 138 139 @const_addend_negative = internal constant i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) 140 ; DUMP: @const_addend_negative = internal constant i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) 141 ; CHECK: .type const_addend_negative,%object 142 ; CHECK: .section .rodata,"a",%progbits 143 ; CHECK:const_addend_negative: 144 ; CHECK: .long ptr - 1 145 ; CHECK: .size const_addend_negative, 4 146 147 @addend_array1 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1) 148 ; DUMP: @addend_array1 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1) 149 ; CHECK: .type addend_array1,%object 150 ; CHECK: .section .data,"aw",%progbits 151 ; CHECK:addend_array1: 152 ; CHECK: .long bytes + 1 153 ; CHECK: .size addend_array1, 4 154 155 @const_addend_array1 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1) 156 ; DUMP: @const_addend_array1 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1) 157 ; CHECK: .type const_addend_array1,%object 158 ; CHECK: .section .rodata,"a",%progbits 159 ; CHECK:const_addend_array1: 160 ; CHECK: .long bytes + 1 161 ; CHECK: .size const_addend_array1, 4 162 163 @addend_array2 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7) 164 ; DUMP: @addend_array2 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7) 165 ; CHECK: .type addend_array2,%object 166 ; CHECK: .section .data,"aw",%progbits 167 ; CHECK:addend_array2: 168 ; CHECK: .long bytes + 7 169 ; CHECK: .size addend_array2, 4 170 171 @const_addend_array2 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7) 172 ; DUMP: @const_addend_array2 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7) 173 ; CHECK: .type const_addend_array2,%object 174 ; CHECK: .section .rodata,"a",%progbits 175 ; CHECK:const_addend_array2: 176 ; CHECK: .long bytes + 7 177 ; CHECK: .size const_addend_array2, 4 178 179 @addend_array3 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9) 180 ; DUMP: @addend_array3 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9) 181 ; CHECK: .type addend_array3,%object 182 ; CHECK: .section .data,"aw",%progbits 183 ; CHECK:addend_array3: 184 ; CHECK: .long bytes + 9 185 ; CHECK: .size addend_array3, 4 186 187 @const_addend_array3 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9) 188 ; DUMP: @const_addend_array3 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9) 189 ; CHECK: .type const_addend_array3,%object 190 ; CHECK: .section .rodata,"a",%progbits 191 ; CHECK:const_addend_array3: 192 ; CHECK: .long bytes + 9 193 ; CHECK: .size const_addend_array3, 4 194 195 @addend_struct1 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1) 196 ; DUMP: @addend_struct1 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1) 197 ; CHECK: .type addend_struct1,%object 198 ; CHECK: .section .data,"aw",%progbits 199 ; CHECK:addend_struct1: 200 ; CHECK: .long compound + 1 201 ; CHECK: .size addend_struct1, 4 202 203 @const_addend_struct1 = internal constant i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1) 204 ; DUMP: @const_addend_struct1 = internal constant i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1) 205 ; CHECK: .type const_addend_struct1,%object 206 ; CHECK: .section .rodata,"a",%progbits 207 ; CHECK:const_addend_struct1: 208 ; CHECK: .long compound + 1 209 ; CHECK: .size const_addend_struct1, 4 210 211 @addend_struct2 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4) 212 ; DUMP: @addend_struct2 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4) 213 ; CHECK: .type addend_struct2,%object 214 ; CHECK: .section .data,"aw",%progbits 215 ; CHECK:addend_struct2: 216 ; CHECK: .long compound + 4 217 ; CHECK: .size addend_struct2, 4 218 219 @const_addend_struct2 = internal constant i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4) 220 ; DUMP: @const_addend_struct2 = internal constant i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4) 221 ; CHECK: .type const_addend_struct2,%object 222 ; CHECK: .section .rodata,"a",%progbits 223 ; CHECK:const_addend_struct2: 224 ; CHECK: .long compound + 4 225 ; CHECK: .size const_addend_struct2, 4 226 227 @ptr_to_func_align = internal global i32 ptrtoint (void ()* @func to i32), align 8 228 ; DUMP: @ptr_to_func_align = internal global i32 ptrtoint (void ()* @func to i32), align 8 229 ; CHECK: .type ptr_to_func_align,%object 230 ; CHECK: .section .data,"aw",%progbits 231 ; CHECK: .p2align 3 232 ; CHECK:ptr_to_func_align: 233 ; CHECK: .long func 234 ; CHECK: .size ptr_to_func_align, 4 235 236 @const_ptr_to_func_align = internal constant i32 ptrtoint (void ()* @func to i32), align 8 237 ; DUMP: @const_ptr_to_func_align = internal constant i32 ptrtoint (void ()* @func to i32), align 8 238 ; CHECK: .type const_ptr_to_func_align,%object 239 ; CHECK: .section .rodata,"a",%progbits 240 ; CHECK: .p2align 3 241 ; CHECK:const_ptr_to_func_align: 242 ; CHECK: .long func 243 ; CHECK: .size const_ptr_to_func_align, 4 244 245 @char = internal constant [1 x i8] c"0" 246 ; DUMP: @char = internal constant [1 x i8] c"0" 247 ; CHECK: .type char,%object 248 ; CHECK: .section .rodata,"a",%progbits 249 ; CHECK:char: 250 ; CHECK: .byte 48 251 ; CHECK: .size char, 1 252 253 @short = internal constant [2 x i8] zeroinitializer 254 ; DUMP: @short = internal constant [2 x i8] zeroinitializer 255 ; CHECK: .type short,%object 256 ; CHECK: .section .rodata,"a",%progbits 257 ; CHECK:short: 258 ; CHECK: .zero 2 259 ; CHECK: .size short, 2 260 261 define internal void @func() { 262 ret void 263 } 264 265 ; DUMP: define internal void @func() { 266