1// Test that basic COFF static initializers work. The main function in this 2// test returns the expression a + b + c + 1. a is initialzed as -1 and c is 3// initialized as -2 by static initializers. b is initialized as 2 by constant 4// value. The test will succeeds only if static initializers are ran successfully. 5// 6// RUN: %clang -c -o %t %s 7// RUN: %llvm_jitlink %t 8 .text 9 .def @feat.00; 10 .scl 3; 11 .type 0; 12 .endef 13 .globl @feat.00 14.set @feat.00, 0 15 .file "static-initializer.cpp" 16 .def init; 17 .scl 2; 18 .type 32; 19 .endef 20 .globl init # -- Begin function init 21 .p2align 4, 0x90 22init: # @init 23# %bb.0: 24 movl $4294967295, %eax # imm = 0xFFFFFFFF 25 retq 26 # -- End function 27 .def init2; 28 .scl 2; 29 .type 32; 30 .endef 31 .globl init2 # -- Begin function init2 32 .p2align 4, 0x90 33init2: # @init2 34# %bb.0: 35 movl $4294967294, %eax # imm = 0xFFFFFFFE 36 retq 37 # -- End function 38 .def "??__Ea@@YAXXZ"; 39 .scl 3; 40 .type 32; 41 .endef 42 .p2align 4, 0x90 # -- Begin function ??__Ea@@YAXXZ 43"??__Ea@@YAXXZ": # @"??__Ea@@YAXXZ" 44.seh_proc "??__Ea@@YAXXZ" 45# %bb.0: 46 subq $40, %rsp 47 .seh_stackalloc 40 48 .seh_endprologue 49 callq init 50 movl %eax, a(%rip) 51 addq $40, %rsp 52 retq 53 .seh_endproc 54 # -- End function 55 .def "??__Ec@@YAXXZ"; 56 .scl 3; 57 .type 32; 58 .endef 59 .p2align 4, 0x90 # -- Begin function ??__Ec@@YAXXZ 60"??__Ec@@YAXXZ": # @"??__Ec@@YAXXZ" 61.seh_proc "??__Ec@@YAXXZ" 62# %bb.0: 63 subq $40, %rsp 64 .seh_stackalloc 40 65 .seh_endprologue 66 callq init2 67 movl %eax, c(%rip) 68 addq $40, %rsp 69 retq 70 .seh_endproc 71 # -- End function 72 .def main; 73 .scl 2; 74 .type 32; 75 .endef 76 .globl main # -- Begin function main 77 .p2align 4, 0x90 78main: # @main 79.seh_proc main 80# %bb.0: 81 subq $56, %rsp 82 .seh_stackalloc 56 83 .seh_endprologue 84 movl $0, 52(%rsp) 85 movq %rdx, 40(%rsp) 86 movl %ecx, 36(%rsp) 87 movl a(%rip), %ecx 88 addl b(%rip), %ecx 89 addl c(%rip), %ecx 90 addl $1, %ecx 91 callq *__imp_llvm_jitlink_setTestResultOverride(%rip) 92 xorl %eax, %eax 93 addq $56, %rsp 94 retq 95 .seh_endproc 96 # -- End function 97 .def _GLOBAL__sub_I_static_initializer.cpp; 98 .scl 3; 99 .type 32; 100 .endef 101 .p2align 4, 0x90 # -- Begin function _GLOBAL__sub_I_static_initializer.cpp 102_GLOBAL__sub_I_static_initializer.cpp: # @_GLOBAL__sub_I_static_initializer.cpp 103.seh_proc _GLOBAL__sub_I_static_initializer.cpp 104# %bb.0: 105 subq $40, %rsp 106 .seh_stackalloc 40 107 .seh_endprologue 108 callq "??__Ea@@YAXXZ" 109 callq "??__Ec@@YAXXZ" 110 nop 111 addq $40, %rsp 112 retq 113 .seh_endproc 114 # -- End function 115 .bss 116 .globl a # @a 117 .p2align 2 118a: 119 .long 0 # 0x0 120 121 .data 122 .globl b # @b 123 .p2align 2 124b: 125 .long 2 # 0x2 126 127 .bss 128 .globl c # @c 129 .p2align 2 130c: 131 .long 0 # 0x0 132 133 .section .CRT$XCU,"dr" 134 .p2align 3 135 .quad _GLOBAL__sub_I_static_initializer.cpp 136