136 lines · plain
1// Test that basic COFF static initializers work. The main function in this2// test returns the expression a + b + c + 1. a is initialzed as -1 and c is3// initialized as -2 by static initializers. b is initialized as 2 by constant4// value. The test will succeeds only if static initializers are ran successfully.5//6// RUN: %clang -c -o %t %s7// RUN: %llvm_jitlink %t8 .text9 .def @feat.00;10 .scl 3;11 .type 0;12 .endef13 .globl @feat.0014.set @feat.00, 015 .file "static-initializer.cpp"16 .def init;17 .scl 2;18 .type 32;19 .endef20 .globl init # -- Begin function init21 .p2align 4, 0x9022init: # @init23# %bb.0:24 movl $4294967295, %eax # imm = 0xFFFFFFFF25 retq26 # -- End function27 .def init2;28 .scl 2;29 .type 32;30 .endef31 .globl init2 # -- Begin function init232 .p2align 4, 0x9033init2: # @init234# %bb.0:35 movl $4294967294, %eax # imm = 0xFFFFFFFE36 retq37 # -- End function38 .def "??__Ea@@YAXXZ";39 .scl 3;40 .type 32;41 .endef42 .p2align 4, 0x90 # -- Begin function ??__Ea@@YAXXZ43"??__Ea@@YAXXZ": # @"??__Ea@@YAXXZ"44.seh_proc "??__Ea@@YAXXZ"45# %bb.0:46 subq $40, %rsp47 .seh_stackalloc 4048 .seh_endprologue49 callq init50 movl %eax, a(%rip)51 addq $40, %rsp52 retq53 .seh_endproc54 # -- End function55 .def "??__Ec@@YAXXZ";56 .scl 3;57 .type 32;58 .endef59 .p2align 4, 0x90 # -- Begin function ??__Ec@@YAXXZ60"??__Ec@@YAXXZ": # @"??__Ec@@YAXXZ"61.seh_proc "??__Ec@@YAXXZ"62# %bb.0:63 subq $40, %rsp64 .seh_stackalloc 4065 .seh_endprologue66 callq init267 movl %eax, c(%rip)68 addq $40, %rsp69 retq70 .seh_endproc71 # -- End function72 .def main;73 .scl 2;74 .type 32;75 .endef76 .globl main # -- Begin function main77 .p2align 4, 0x9078main: # @main79.seh_proc main80# %bb.0:81 subq $56, %rsp82 .seh_stackalloc 5683 .seh_endprologue84 movl $0, 52(%rsp)85 movq %rdx, 40(%rsp)86 movl %ecx, 36(%rsp)87 movl a(%rip), %ecx88 addl b(%rip), %ecx89 addl c(%rip), %ecx90 addl $1, %ecx91 callq *__imp_llvm_jitlink_setTestResultOverride(%rip)92 xorl %eax, %eax93 addq $56, %rsp94 retq95 .seh_endproc96 # -- End function97 .def _GLOBAL__sub_I_static_initializer.cpp;98 .scl 3;99 .type 32;100 .endef101 .p2align 4, 0x90 # -- Begin function _GLOBAL__sub_I_static_initializer.cpp102_GLOBAL__sub_I_static_initializer.cpp: # @_GLOBAL__sub_I_static_initializer.cpp103.seh_proc _GLOBAL__sub_I_static_initializer.cpp104# %bb.0:105 subq $40, %rsp106 .seh_stackalloc 40107 .seh_endprologue108 callq "??__Ea@@YAXXZ"109 callq "??__Ec@@YAXXZ"110 nop111 addq $40, %rsp112 retq113 .seh_endproc114 # -- End function115 .bss116 .globl a # @a117 .p2align 2118a:119 .long 0 # 0x0120 121 .data122 .globl b # @b123 .p2align 2124b:125 .long 2 # 0x2126 127 .bss128 .globl c # @c129 .p2align 2130c:131 .long 0 # 0x0132 133 .section .CRT$XCU,"dr"134 .p2align 3135 .quad _GLOBAL__sub_I_static_initializer.cpp136