200 lines · plain
1# RUN: llc -o - %s -mtriple=x86_64-unknown-windows-msvc \2# RUN: -run-pass=x86-wineh-unwindv2 | FileCheck %s3 4# Regression test for Win x64 unwind v2: in some cases it is better to use5# push+pop to adjust the stack, rather than sub+add. This is permitted with6# unwind v2 as the requirement is that the epilog finishes adjusting the stack7# before popping the registers listed in the unwind table.8 9# Pushes and pops the same register.10# CHECK-LABEL: name: push_pop_same11# CHECK: body:12# CHECK-NEXT: bb.013# CHECK-NEXT: SEH_UnwindVersion 214# CHECK-NEXT: frame-setup PUSH64r undef $rax15# CHECK-NEXT: frame-setup SEH_StackAlloc 816# CHECK-NEXT: frame-setup SEH_EndPrologue17# CHECK-NEXT: SEH_BeginEpilogue18# CHECK-NEXT: $rax = frame-destroy19# CHECK-NEXT: SEH_UnwindV2Start20# CHECK-NEXT: SEH_EndEpilogue21# CHECK-NEXT: RET6422 23# Pushes and pops a different register.24# CHECK-LABEL: name: push_pop_different25# CHECK: body:26# CHECK-NEXT: bb.027# CHECK-NEXT: SEH_UnwindVersion 228# CHECK-NEXT: frame-setup PUSH64r undef $rax29# CHECK-NEXT: frame-setup SEH_StackAlloc 830# CHECK-NEXT: frame-setup SEH_EndPrologue31# CHECK: SEH_BeginEpilogue32# CHECK-NEXT: $rcx = frame-destroy POP64r33# CHECK-NEXT: SEH_UnwindV2Start34# CHECK-NEXT: SEH_EndEpilogue35# CHECK-NEXT: RET64 $eax36 37# Pushes in the prolog, adds in the epilog.38# CHECK-LABEL: name: push_add39# CHECK: body:40# CHECK-NEXT: bb.041# CHECK-NEXT: SEH_UnwindVersion 242# CHECK-NEXT: frame-setup PUSH64r killed $r1543# CHECK-NEXT: frame-setup SEH_PushReg 12644# CHECK-NEXT: frame-setup PUSH64r killed $r1445# CHECK-NEXT: frame-setup SEH_PushReg 12546# CHECK-NEXT: frame-setup PUSH64r killed $rsi47# CHECK-NEXT: frame-setup SEH_PushReg 6048# CHECK-NEXT: frame-setup PUSH64r killed $rdi49# CHECK-NEXT: frame-setup SEH_PushReg 5550# CHECK-NEXT: frame-setup PUSH64r killed $rbx51# CHECK-NEXT: frame-setup SEH_PushReg 5352# CHECK-NEXT: frame-setup PUSH64r undef $rax53# CHECK-NEXT: frame-setup SEH_StackAlloc 854# CHECK-NEXT: frame-setup SEH_EndPrologue55# CHECK: SEH_BeginEpilogue56# CHECK-NEXT: $rsp = frame-destroy ADD64ri32 $rsp, 857# CHECK-NEXT: SEH_UnwindV2Start58# CHECK-NEXT: $rbx = frame-destroy POP64r59# CHECK-NEXT: $rdi = frame-destroy POP64r60# CHECK-NEXT: $rsi = frame-destroy POP64r61# CHECK-NEXT: $r14 = frame-destroy POP64r62# CHECK-NEXT: $r15 = frame-destroy POP64r63# CHECK-NEXT: SEH_EndEpilogue64# CHECK-NEXT: RET6465 66--- |67 define void @push_pop_same() {68 %small_alloca = alloca i32, align 469 ret void70 }71 72 define i32 @push_pop_different(i32 %x, i32 %y) {73 %small_alloca = alloca i32, align 474 %sum = add i32 %x, %y75 ret i32 %sum76 }77 78 define void @push_add(ptr %a, ptr %b, ptr %out) {79 %small_alloca = alloca i32, align 480 %av = load i256, ptr %a, align 1681 %bv = load i256, ptr %b, align 1682 %r = mul i256 %av, %bv83 store i256 %r, ptr %out, align 1684 ret void85 }86 87 !llvm.module.flags = !{!0}88 89 !0 = !{i32 1, !"winx64-eh-unwindv2", i32 2}90...91---92name: push_pop_same93body: |94 bb.0 (%ir-block.0):95 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp96 frame-setup SEH_StackAlloc 897 frame-setup SEH_EndPrologue98 SEH_BeginEpilogue99 $rax = frame-destroy POP64r implicit-def $rsp, implicit $rsp100 SEH_EndEpilogue101 RET64102...103---104name: push_pop_different105body: |106 bb.0 (%ir-block.0):107 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp108 frame-setup SEH_StackAlloc 8109 frame-setup SEH_EndPrologue110 renamable $edx = KILL $edx, implicit-def $rdx111 renamable $ecx = KILL $ecx, implicit-def $rcx112 renamable $eax = LEA64_32r killed renamable $rcx, 1, killed renamable $rdx, 0, $noreg113 SEH_BeginEpilogue114 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp115 SEH_EndEpilogue116 RET64 $eax117...118---119name: push_add120body: |121 bb.0 (%ir-block.0):122 123 frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp124 frame-setup SEH_PushReg 126125 frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp126 frame-setup SEH_PushReg 125127 frame-setup PUSH64r killed $rsi, implicit-def $rsp, implicit $rsp128 frame-setup SEH_PushReg 60129 frame-setup PUSH64r killed $rdi, implicit-def $rsp, implicit $rsp130 frame-setup SEH_PushReg 55131 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp132 frame-setup SEH_PushReg 53133 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp134 frame-setup SEH_StackAlloc 8135 frame-setup SEH_EndPrologue136 $rsi = MOV64rr $rdx137 renamable $r9 = MOV64rm renamable $rcx, 1, $noreg, 0, $noreg :: (load (s64) from %ir.a, align 16)138 renamable $rdi = MOV64rm renamable $rcx, 1, $noreg, 8, $noreg :: (load (s64) from %ir.a + 8, basealign 16)139 renamable $rbx = MOV64rm renamable $rcx, 1, $noreg, 16, $noreg :: (load (s64) from %ir.a + 16, align 16)140 renamable $r10 = MOV64rm $rdx, 1, $noreg, 16, $noreg :: (load (s64) from %ir.b + 16, align 16)141 renamable $r11 = MOV64rm $rdx, 1, $noreg, 0, $noreg :: (load (s64) from %ir.b, align 16)142 renamable $r14 = MOV64rm $rdx, 1, $noreg, 8, $noreg :: (load (s64) from %ir.b + 8, basealign 16)143 renamable $r15 = MOV64rm killed renamable $rcx, 1, $noreg, 24, $noreg :: (load (s64) from %ir.a + 24, basealign 16)144 renamable $r15 = IMUL64rr killed renamable $r15, renamable $r11, implicit-def dead $eflags145 $rax = MOV64rr $r11146 MUL64r renamable $rbx, implicit-def $rax, implicit-def $rdx, implicit-def dead $eflags, implicit $rax147 $rcx = MOV64rr $rax148 renamable $rbx = IMUL64rr killed renamable $rbx, renamable $r14, implicit-def dead $eflags149 renamable $rbx = ADD64rr killed renamable $rbx, killed renamable $rdx, implicit-def dead $eflags150 renamable $rbx = ADD64rr killed renamable $rbx, killed renamable $r15, implicit-def dead $eflags151 $r15 = MOV64rr $r10152 renamable $r15 = IMUL64rr killed renamable $r15, renamable $rdi, implicit-def dead $eflags153 $rax = MOV64rr killed $r10154 MUL64r renamable $r9, implicit-def $rax, implicit-def $rdx, implicit-def dead $eflags, implicit $rax155 $r10 = MOV64rr $rax156 renamable $rdx = ADD64rr killed renamable $rdx, killed renamable $r15, implicit-def dead $eflags157 renamable $r15 = MOV64rm killed renamable $rsi, 1, $noreg, 24, $noreg :: (load (s64) from %ir.b + 24, basealign 16)158 renamable $r15 = IMUL64rr killed renamable $r15, renamable $r9, implicit-def dead $eflags159 renamable $r15 = ADD64rr killed renamable $r15, killed renamable $rdx, implicit-def dead $eflags160 renamable $r10 = ADD64rr killed renamable $r10, killed renamable $rcx, implicit-def $eflags161 renamable $r15 = ADC64rr killed renamable $r15, killed renamable $rbx, implicit-def dead $eflags, implicit killed $eflags162 $rax = MOV64rr $r9163 MUL64r renamable $r11, implicit-def $rax, implicit-def $rdx, implicit-def dead $eflags, implicit $rax164 $rcx = MOV64rr $rdx165 $rsi = MOV64rr $rax166 $rax = MOV64rr $rdi167 MUL64r killed renamable $r11, implicit-def $rax, implicit-def $rdx, implicit-def dead $eflags, implicit $rax168 $r11 = MOV64rr $rdx169 $rbx = MOV64rr $rax170 renamable $rbx = ADD64rr killed renamable $rbx, killed renamable $rcx, implicit-def $eflags171 renamable $r11 = ADC64ri32 killed renamable $r11, 0, implicit-def dead $eflags, implicit killed $eflags172 $rax = MOV64rr killed $r9173 MUL64r renamable $r14, implicit-def $rax, implicit-def $rdx, implicit-def dead $eflags, implicit $rax174 $rcx = MOV64rr $rdx175 $r9 = MOV64rr $rax176 renamable $r9 = ADD64rr killed renamable $r9, killed renamable $rbx, implicit-def $eflags177 renamable $rcx = ADC64rr killed renamable $rcx, killed renamable $r11, implicit-def $eflags, implicit killed $eflags178 renamable $al = SETCCr 2, implicit killed $eflags179 renamable $r11d = MOVZX32rr8 killed renamable $al, implicit-def $r11180 $rax = MOV64rr killed $rdi181 MUL64r killed renamable $r14, implicit-def $rax, implicit-def $rdx, implicit-def dead $eflags, implicit $rax182 renamable $rax = ADD64rr killed renamable $rax, killed renamable $rcx, implicit-def $eflags183 renamable $rdx = ADC64rr killed renamable $rdx, killed renamable $r11, implicit-def dead $eflags, implicit killed $eflags184 renamable $rax = ADD64rr killed renamable $rax, killed renamable $r10, implicit-def $eflags185 renamable $rdx = ADC64rr killed renamable $rdx, killed renamable $r15, implicit-def dead $eflags, implicit killed $eflags186 MOV64mr renamable $r8, 1, $noreg, 0, $noreg, killed renamable $rsi :: (store (s64) into %ir.out, align 16)187 MOV64mr renamable $r8, 1, $noreg, 8, $noreg, killed renamable $r9 :: (store (s64) into %ir.out + 8, basealign 16)188 MOV64mr renamable $r8, 1, $noreg, 16, $noreg, killed renamable $rax :: (store (s64) into %ir.out + 16, align 16)189 MOV64mr killed renamable $r8, 1, $noreg, 24, $noreg, killed renamable $rdx :: (store (s64) into %ir.out + 24, basealign 16)190 SEH_BeginEpilogue191 $rsp = frame-destroy ADD64ri32 $rsp, 8, implicit-def dead $eflags192 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp193 $rdi = frame-destroy POP64r implicit-def $rsp, implicit $rsp194 $rsi = frame-destroy POP64r implicit-def $rsp, implicit $rsp195 $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp196 $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp197 SEH_EndEpilogue198 RET64199...200