Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -O0 -mcpu=corei7 -mtriple=x86_64-pc-win32 | FileCheck %s -check-prefix=WIN64
      2 ; RUN: llc < %s -O0 -mcpu=corei7 -mtriple=x86_64-pc-mingw32 | FileCheck %s -check-prefix=WIN64
      3 
      4 ; Check function without prolog
      5 define void @foo0() uwtable {
      6 entry:
      7   ret void
      8 }
      9 ; WIN64-LABEL: foo0:
     10 ; WIN64: .seh_proc foo0
     11 ; WIN64: .seh_endprologue
     12 ; WIN64: ret
     13 ; WIN64: .seh_endproc
     14 
     15 ; Checks a small stack allocation
     16 define void @foo1() uwtable {
     17 entry:
     18   %baz = alloca [2000 x i16], align 2
     19   ret void
     20 }
     21 ; WIN64-LABEL: foo1:
     22 ; WIN64: .seh_proc foo1
     23 ; WIN64: subq $4000, %rsp
     24 ; WIN64: .seh_stackalloc 4000
     25 ; WIN64: .seh_endprologue
     26 ; WIN64: addq $4000, %rsp
     27 ; WIN64: ret
     28 ; WIN64: .seh_endproc
     29 
     30 ; Checks a stack allocation requiring call to __chkstk/___chkstk_ms
     31 define void @foo2() uwtable {
     32 entry:
     33   %baz = alloca [4000 x i16], align 2
     34   ret void
     35 }
     36 ; WIN64-LABEL: foo2:
     37 ; WIN64: .seh_proc foo2
     38 ; WIN64: movabsq $8000, %rax
     39 ; WIN64: callq {{__chkstk|___chkstk_ms}}
     40 ; WIN64: subq %rax, %rsp
     41 ; WIN64: .seh_stackalloc 8000
     42 ; WIN64: .seh_endprologue
     43 ; WIN64: addq $8000, %rsp
     44 ; WIN64: ret
     45 ; WIN64: .seh_endproc
     46 
     47 
     48 ; Checks stack push
     49 define i32 @foo3(i32 %f_arg, i32 %e_arg, i32 %d_arg, i32 %c_arg, i32 %b_arg, i32 %a_arg) uwtable {
     50 entry:
     51   %a = alloca i32
     52   %b = alloca i32
     53   %c = alloca i32
     54   %d = alloca i32
     55   %e = alloca i32
     56   %f = alloca i32
     57   store i32 %a_arg, i32* %a
     58   store i32 %b_arg, i32* %b
     59   store i32 %c_arg, i32* %c
     60   store i32 %d_arg, i32* %d
     61   store i32 %e_arg, i32* %e
     62   store i32 %f_arg, i32* %f
     63   %tmp = load i32* %a
     64   %tmp1 = mul i32 %tmp, 2
     65   %tmp2 = load i32* %b
     66   %tmp3 = mul i32 %tmp2, 3
     67   %tmp4 = add i32 %tmp1, %tmp3
     68   %tmp5 = load i32* %c
     69   %tmp6 = mul i32 %tmp5, 5
     70   %tmp7 = add i32 %tmp4, %tmp6
     71   %tmp8 = load i32* %d
     72   %tmp9 = mul i32 %tmp8, 7
     73   %tmp10 = add i32 %tmp7, %tmp9
     74   %tmp11 = load i32* %e
     75   %tmp12 = mul i32 %tmp11, 11
     76   %tmp13 = add i32 %tmp10, %tmp12
     77   %tmp14 = load i32* %f
     78   %tmp15 = mul i32 %tmp14, 13
     79   %tmp16 = add i32 %tmp13, %tmp15
     80   ret i32 %tmp16
     81 }
     82 ; WIN64-LABEL: foo3:
     83 ; WIN64: .seh_proc foo3
     84 ; WIN64: pushq %rsi
     85 ; WIN64: .seh_pushreg 6
     86 ; WIN64: subq $24, %rsp
     87 ; WIN64: .seh_stackalloc 24
     88 ; WIN64: .seh_endprologue
     89 ; WIN64: addq $24, %rsp
     90 ; WIN64: popq %rsi
     91 ; WIN64: ret
     92 ; WIN64: .seh_endproc
     93 
     94 
     95 ; Check emission of eh handler and handler data
     96 declare i32 @_d_eh_personality(i32, i32, i64, i8*, i8*)
     97 declare void @_d_eh_resume_unwind(i8*)
     98 
     99 declare i32 @bar()
    100 
    101 define i32 @foo4() #0 {
    102 entry:
    103   %step = alloca i32, align 4
    104   store i32 0, i32* %step
    105   %tmp = load i32* %step
    106 
    107   %tmp1 = invoke i32 @bar()
    108           to label %finally unwind label %landingpad
    109 
    110 finally:
    111   store i32 1, i32* %step
    112   br label %endtryfinally
    113 
    114 landingpad:
    115   %landing_pad = landingpad { i8*, i32 } personality i32 (i32, i32, i64, i8*, i8*)* @_d_eh_personality
    116           cleanup
    117   %tmp3 = extractvalue { i8*, i32 } %landing_pad, 0
    118   store i32 2, i32* %step
    119   call void @_d_eh_resume_unwind(i8* %tmp3)
    120   unreachable
    121 
    122 endtryfinally:
    123   %tmp10 = load i32* %step
    124   ret i32 %tmp10
    125 }
    126 ; WIN64-LABEL: foo4:
    127 ; WIN64: .seh_proc foo4
    128 ; WIN64: .seh_handler _d_eh_personality, @unwind, @except
    129 ; WIN64: subq $56, %rsp
    130 ; WIN64: .seh_stackalloc 56
    131 ; WIN64: .seh_endprologue
    132 ; WIN64: addq $56, %rsp
    133 ; WIN64: ret
    134 ; WIN64: .seh_handlerdata
    135 ; WIN64: .seh_endproc
    136 
    137 
    138 ; Check stack re-alignment and xmm spilling
    139 define void @foo5() uwtable {
    140 entry:
    141   %s = alloca i32, align 64
    142   call void asm sideeffect "", "~{rbx},~{rdi},~{xmm6},~{xmm7}"()
    143   ret void
    144 }
    145 ; WIN64-LABEL: foo5:
    146 ; WIN64: .seh_proc foo5
    147 ; WIN64: pushq %rbp
    148 ; WIN64: .seh_pushreg 5
    149 ; WIN64: movq  %rsp, %rbp
    150 ; WIN64: pushq %rdi
    151 ; WIN64: .seh_pushreg 7
    152 ; WIN64: pushq %rbx
    153 ; WIN64: .seh_pushreg 3
    154 ; WIN64: andq  $-64, %rsp
    155 ; WIN64: subq  $128, %rsp
    156 ; WIN64: .seh_stackalloc 48
    157 ; WIN64: .seh_setframe 5, 64
    158 ; WIN64: movaps  %xmm7, -32(%rbp)        # 16-byte Spill
    159 ; WIN64: movaps  %xmm6, -48(%rbp)        # 16-byte Spill
    160 ; WIN64: .seh_savexmm 6, 16
    161 ; WIN64: .seh_savexmm 7, 32
    162 ; WIN64: .seh_endprologue
    163 ; WIN64: movaps  -48(%rbp), %xmm6        # 16-byte Reload
    164 ; WIN64: movaps  -32(%rbp), %xmm7        # 16-byte Reload
    165 ; WIN64: leaq  -16(%rbp), %rsp
    166 ; WIN64: popq  %rbx
    167 ; WIN64: popq  %rdi
    168 ; WIN64: popq  %rbp
    169 ; WIN64: retq
    170 ; WIN64: .seh_endproc
    171