Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 1 | ; Test of global initializers. |
| 2 | |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 3 | ; REQUIRES: allow_dump |
| 4 | |
Jan Voung | 58eea4d | 2015-06-15 15:11:56 -0700 | [diff] [blame^] | 5 | ; Test initializers with -filetype=asm. |
| 6 | ; RUN: %if --need=target_X8632 --command %p2i --filetype=asm --target x8632 \ |
| 7 | ; RUN: -i %s --args -O2 | %if --need=target_X8632 --command FileCheck %s |
Jan Voung | fe14fb8 | 2014-10-13 15:56:32 -0700 | [diff] [blame] | 8 | |
Jan Voung | 58eea4d | 2015-06-15 15:11:56 -0700 | [diff] [blame^] | 9 | ; RUN: %if --need=target_ARM32 --command %p2i --filetype=asm --target arm32 \ |
| 10 | ; RUN: -i %s --args -O2 --skip-unimplemented \ |
| 11 | ; RUN: | %if --need=target_ARM32 --command FileCheck %s |
| 12 | |
| 13 | ; Test instructions for materializing addresses. |
| 14 | ; RUN: %if --need=target_X8632 --command %p2i --filetype=asm --target x8632 \ |
| 15 | ; RUN: -i %s --args -O2 \ |
| 16 | ; RUN: | %if --need=target_X8632 --command FileCheck %s --check-prefix=X8632 |
| 17 | |
| 18 | ; Test instructions with -filetype=obj and try to cross reference instructions |
| 19 | ; w/ the symbol table. |
| 20 | ; RUN: %if --need=target_X8632 --command %p2i --assemble --disassemble \ |
| 21 | ; RUN: --target x8632 -i %s --args --verbose none \ |
| 22 | ; RUN: | %if --need=target_X8632 --command FileCheck --check-prefix=IAS %s |
| 23 | |
| 24 | ; RUN: %if --need=target_X8632 --command %p2i --assemble --disassemble \ |
| 25 | ; RUN: --dis-flags=-t --target x8632 -i %s --args --verbose none \ |
| 26 | ; RUN: | %if --need=target_X8632 --command FileCheck --check-prefix=SYMTAB %s |
| 27 | |
| 28 | ; Only checking symtab for ARM for now. TODO(jvoung): Need to lower |
| 29 | ; arguments at callsite. |
| 30 | ; RUN: %if --need=target_ARM32 --command %p2i --filetype=asm --assemble \ |
| 31 | ; RUN: --disassemble --dis-flags=-t --target arm32 -i %s \ |
| 32 | ; RUN: --args --verbose none --skip-unimplemented \ |
| 33 | ; RUN: | %if --need=target_ARM32 --command FileCheck --check-prefix=SYMTAB %s |
Jan Voung | fe14fb8 | 2014-10-13 15:56:32 -0700 | [diff] [blame] | 34 | |
Jim Stichnoth | d9f1f9f | 2015-06-11 10:19:32 -0700 | [diff] [blame] | 35 | define internal i32 @main(i32 %argc, i32 %argv) { |
| 36 | entry: |
| 37 | %expanded1 = ptrtoint [4 x i8]* @PrimitiveInit to i32 |
| 38 | call void @use(i32 %expanded1) |
| 39 | %expanded3 = ptrtoint [4 x i8]* @PrimitiveInitConst to i32 |
| 40 | call void @use(i32 %expanded3) |
| 41 | %expanded5 = ptrtoint [4 x i8]* @PrimitiveInitStatic to i32 |
| 42 | call void @use(i32 %expanded5) |
| 43 | %expanded7 = ptrtoint [4 x i8]* @PrimitiveUninit to i32 |
| 44 | call void @use(i32 %expanded7) |
| 45 | %expanded9 = ptrtoint [20 x i8]* @ArrayInit to i32 |
| 46 | call void @use(i32 %expanded9) |
| 47 | %expanded11 = ptrtoint [40 x i8]* @ArrayInitPartial to i32 |
| 48 | call void @use(i32 %expanded11) |
| 49 | %expanded13 = ptrtoint [20 x i8]* @ArrayUninit to i32 |
| 50 | call void @use(i32 %expanded13) |
| 51 | ret i32 0 |
| 52 | } |
Jan Voung | 58eea4d | 2015-06-15 15:11:56 -0700 | [diff] [blame^] | 53 | ; X8632-LABEL: main |
| 54 | ; X8632: movl $PrimitiveInit, |
| 55 | ; X8632: movl $PrimitiveInitConst, |
| 56 | ; X8632: movl $PrimitiveInitStatic, |
| 57 | ; X8632: movl $PrimitiveUninit, |
| 58 | ; X8632: movl $ArrayInit, |
| 59 | ; X8632: movl $ArrayInitPartial, |
| 60 | ; X8632: movl $ArrayUninit, |
Jim Stichnoth | d9f1f9f | 2015-06-11 10:19:32 -0700 | [diff] [blame] | 61 | |
| 62 | ; objdump does not indicate what symbol the mov/relocation applies to |
| 63 | ; so we grep for "mov {{.*}}, OFFSET, sec", along with |
| 64 | ; "OFFSET {{.*}} sec {{.*}} symbol" in the symbol table as a sanity check. |
| 65 | ; NOTE: The symbol table sorting has no relation to the code's references. |
| 66 | ; IAS-LABEL: main |
| 67 | ; SYMTAB-LABEL: SYMBOL TABLE |
| 68 | |
| 69 | ; SYMTAB-DAG: 00000000 {{.*}} .data {{.*}} PrimitiveInit |
| 70 | ; IAS: mov {{.*}},0x0 {{.*}} .data |
| 71 | ; IAS: call |
| 72 | |
| 73 | ; SYMTAB-DAG: 00000000 {{.*}} .rodata {{.*}} PrimitiveInitConst |
| 74 | ; IAS: mov {{.*}},0x0 {{.*}} .rodata |
| 75 | ; IAS: call |
| 76 | |
| 77 | ; SYMTAB-DAG: 00000000 {{.*}} .bss {{.*}} PrimitiveInitStatic |
| 78 | ; IAS: mov {{.*}},0x0 {{.*}} .bss |
| 79 | ; IAS: call |
| 80 | |
| 81 | ; SYMTAB-DAG: 00000004 {{.*}} .bss {{.*}} PrimitiveUninit |
| 82 | ; IAS: mov {{.*}},0x4 {{.*}} .bss |
| 83 | ; IAS: call |
| 84 | |
| 85 | ; SYMTAB-DAG: 00000004{{.*}}.data{{.*}}ArrayInit |
| 86 | ; IAS: mov {{.*}},0x4 {{.*}} .data |
| 87 | ; IAS: call |
| 88 | |
| 89 | ; SYMTAB-DAG: 00000018 {{.*}} .data {{.*}} ArrayInitPartial |
| 90 | ; IAS: mov {{.*}},0x18 {{.*}} .data |
| 91 | ; IAS: call |
| 92 | |
| 93 | ; SYMTAB-DAG: 00000008 {{.*}} .bss {{.*}} ArrayUninit |
| 94 | ; IAS: mov {{.*}},0x8 {{.*}} .bss |
| 95 | ; IAS: call |
| 96 | |
| 97 | |
| 98 | declare void @use(i32) |
| 99 | |
| 100 | define internal i32 @nacl_tp_tdb_offset(i32 %__0) { |
| 101 | entry: |
| 102 | ret i32 0 |
| 103 | } |
| 104 | |
| 105 | define internal i32 @nacl_tp_tls_offset(i32 %size) { |
| 106 | entry: |
| 107 | %result = sub i32 0, %size |
| 108 | ret i32 %result |
| 109 | } |
| 110 | |
| 111 | |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 112 | @PrimitiveInit = internal global [4 x i8] c"\1B\00\00\00", align 4 |
Jan Voung | 58eea4d | 2015-06-15 15:11:56 -0700 | [diff] [blame^] | 113 | ; CHECK: .type PrimitiveInit,%object |
| 114 | ; CHECK-NEXT: .section .data,"aw",%progbits |
| 115 | ; CHECK-NEXT: .p2align 2 |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 116 | ; CHECK-NEXT: PrimitiveInit: |
| 117 | ; CHECK-NEXT: .byte |
| 118 | ; CHECK: .size PrimitiveInit, 4 |
| 119 | |
| 120 | @PrimitiveInitConst = internal constant [4 x i8] c"\0D\00\00\00", align 4 |
Jan Voung | 58eea4d | 2015-06-15 15:11:56 -0700 | [diff] [blame^] | 121 | ; CHECK: .type PrimitiveInitConst,%object |
| 122 | ; CHECK-NEXT: .section .rodata,"a",%progbits |
| 123 | ; CHECK-NEXT: .p2align 2 |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 124 | ; CHECK-NEXT: PrimitiveInitConst: |
| 125 | ; CHECK-NEXT: .byte |
| 126 | ; CHECK: .size PrimitiveInitConst, 4 |
| 127 | |
| 128 | @ArrayInit = internal global [20 x i8] c"\0A\00\00\00\14\00\00\00\1E\00\00\00(\00\00\002\00\00\00", align 4 |
Jan Voung | 58eea4d | 2015-06-15 15:11:56 -0700 | [diff] [blame^] | 129 | ; CHECK: .type ArrayInit,%object |
| 130 | ; CHECK-NEXT: .section .data,"aw",%progbits |
| 131 | ; CHECK-NEXT: .p2align 2 |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 132 | ; CHECK-NEXT: ArrayInit: |
| 133 | ; CHECK-NEXT: .byte |
| 134 | ; CHECK: .size ArrayInit, 20 |
| 135 | |
| 136 | @ArrayInitPartial = internal global [40 x i8] c"<\00\00\00F\00\00\00P\00\00\00Z\00\00\00d\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", align 4 |
Jan Voung | 58eea4d | 2015-06-15 15:11:56 -0700 | [diff] [blame^] | 137 | ; CHECK: .type ArrayInitPartial,%object |
| 138 | ; CHECK-NEXT: .section .data,"aw",%progbits |
| 139 | ; CHECK-NEXT: .p2align 2 |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 140 | ; CHECK-NEXT: ArrayInitPartial: |
| 141 | ; CHECK-NEXT: .byte |
| 142 | ; CHECK: .size ArrayInitPartial, 40 |
| 143 | |
| 144 | @PrimitiveInitStatic = internal global [4 x i8] zeroinitializer, align 4 |
Jan Voung | 58eea4d | 2015-06-15 15:11:56 -0700 | [diff] [blame^] | 145 | ; CHECK: .type PrimitiveInitStatic,%object |
| 146 | ; CHECK-NEXT: .section .bss,"aw",%nobits |
| 147 | ; CHECK-NEXT: .p2align 2 |
Jan Voung | fed97af | 2015-01-25 10:46:00 -0800 | [diff] [blame] | 148 | ; CHECK-NEXT: PrimitiveInitStatic: |
| 149 | ; CHECK-NEXT: .zero 4 |
| 150 | ; CHECK-NEXT: .size PrimitiveInitStatic, 4 |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 151 | |
| 152 | @PrimitiveUninit = internal global [4 x i8] zeroinitializer, align 4 |
Jan Voung | 58eea4d | 2015-06-15 15:11:56 -0700 | [diff] [blame^] | 153 | ; CHECK: .type PrimitiveUninit,%object |
| 154 | ; CHECK-NEXT: .section .bss,"aw",%nobits |
| 155 | ; CHECK-NEXT: .p2align 2 |
Jan Voung | fed97af | 2015-01-25 10:46:00 -0800 | [diff] [blame] | 156 | ; CHECK-NEXT: PrimitiveUninit: |
| 157 | ; CHECK-NEXT: .zero 4 |
| 158 | ; CHECK-NEXT: .size PrimitiveUninit, 4 |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 159 | |
| 160 | @ArrayUninit = internal global [20 x i8] zeroinitializer, align 4 |
Jan Voung | 58eea4d | 2015-06-15 15:11:56 -0700 | [diff] [blame^] | 161 | ; CHECK: .type ArrayUninit,%object |
| 162 | ; CHECK-NEXT: .section .bss,"aw",%nobits |
| 163 | ; CHECK-NEXT: .p2align 2 |
Jan Voung | fed97af | 2015-01-25 10:46:00 -0800 | [diff] [blame] | 164 | ; CHECK-NEXT: ArrayUninit: |
| 165 | ; CHECK-NEXT: .zero 20 |
| 166 | ; CHECK-NEXT: .size ArrayUninit, 20 |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 167 | |
| 168 | @ArrayUninitConstDouble = internal constant [200 x i8] zeroinitializer, align 8 |
Jan Voung | 58eea4d | 2015-06-15 15:11:56 -0700 | [diff] [blame^] | 169 | ; CHECK: .type ArrayUninitConstDouble,%object |
| 170 | ; CHECK-NEXT: .section .rodata,"a",%progbits |
| 171 | ; CHECK-NEXT: .p2align 3 |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 172 | ; CHECK-NEXT: ArrayUninitConstDouble: |
| 173 | ; CHECK-NEXT: .zero 200 |
| 174 | ; CHECK-NEXT: .size ArrayUninitConstDouble, 200 |
| 175 | |
| 176 | @ArrayUninitConstInt = internal constant [20 x i8] zeroinitializer, align 4 |
Jan Voung | 58eea4d | 2015-06-15 15:11:56 -0700 | [diff] [blame^] | 177 | ; CHECK: .type ArrayUninitConstInt,%object |
| 178 | ; CHECK: .section .rodata,"a",%progbits |
| 179 | ; CHECK-NEXT: .p2align 2 |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 180 | ; CHECK-NEXT: ArrayUninitConstInt: |
| 181 | ; CHECK-NEXT: .zero 20 |
| 182 | ; CHECK-NEXT: .size ArrayUninitConstInt, 20 |
| 183 | |
| 184 | @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4 |
| 185 | @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4 |
| 186 | @__tls_template_start = internal constant [0 x i8] zeroinitializer, align 8 |
| 187 | @__tls_template_alignment = internal constant [4 x i8] c"\01\00\00\00", align 4 |