[IR] Reformulate LLVM's EH funclet IR
[oota-llvm.git] / test / CodeGen / X86 / win-catchpad-varargs.ll
index 03c6c70dc69a999fda6041168c607195552ed1f2..6508f3bd7d644967f66a9315f62e4238cdf9338b 100644 (file)
@@ -13,20 +13,17 @@ entry:
           to label %return unwind label %catch.dispatch
 
 catch.dispatch:                                   ; preds = %entry
-  %0 = catchpad [i8* null, i32 64, i8* null]
-          to label %catch unwind label %catchendblock
+  %cs1 = catchswitch within none [label %catch] unwind to caller
 
 catch:                                            ; preds = %catch.dispatch
+  %0 = catchpad within %cs1 [i8* null, i32 64, i8* null]
   %ap1 = bitcast i8** %ap to i8*
   call void @llvm.va_start(i8* %ap1)
   %argp.cur = load i8*, i8** %ap
   %1 = bitcast i8* %argp.cur to i32*
   %arg2 = load i32, i32* %1
   call void @llvm.va_end(i8* %ap1)
-  catchret %0 to label %return
-
-catchendblock:                                    ; preds = %catch.dispatch
-  catchendpad unwind to caller
+  catchret from %0 to label %return
 
 return:                                           ; preds = %entry, %catch
   %retval.0 = phi i32 [ %arg2, %catch ], [ -1, %entry ]
@@ -35,40 +32,34 @@ return:                                           ; preds = %entry, %catch
 
 ; X64-LABEL: .seh_proc f
 ; X64: pushq %rbp
-; X64: pushq %rsi
-; X64: subq $56, %rsp
-; X64: leaq 48(%rsp), %rbp
-; X64: movq $-2, (%rbp)
+; X64: subq $64, %rsp
+; X64: leaq 64(%rsp), %rbp
+; X64: movq $-2, -8(%rbp)
+; X64: movl    $-1, -20(%rbp) # 4-byte Folded Spill
 ; X64: callq g
-; X64: movl %esi, %eax
-; X64: addq $56, %rsp
-; X64: popq %rsi
+; X64: .LBB0_1
+; X64: movl    -20(%rbp), %eax # 4-byte Reload
+; X64: addq $64, %rsp
 ; X64: popq %rbp
 
-; X64: movl -4(%rbp), %esi
-; X64: jmp
-
-; X64-LABEL: "?catch$1@?0?f@4HA":
-; X64: .seh_proc "?catch$1@?0?f@4HA"
+; X64-LABEL: "?catch${{[0-9]}}@?0?f@4HA":
+; X64: .seh_proc "?catch${{[0-9]}}@?0?f@4HA"
 ; X64:         movq    %rdx, 16(%rsp)
 ; X64:         pushq   %rbp
-; X64:         pushq   %rsi
-; X64:         subq    $40, %rsp
-; X64:         leaq    48(%rdx), %rbp
+; X64:         subq    $32, %rsp
+; X64:         leaq    64(%rdx), %rbp
 ; arg2 is at RBP+40:
 ; start at arg2
 ; + 8 for arg1
 ; + 8 for retaddr
 ; + 8 for RBP
-; + 8 for RSI
-; + 56 for stackalloc
-; - 48 for setframe
+; + 64 for stackalloc
+; - 64 for setframe
 ; = 40
-; X64:         movl    40(%rbp), %eax
-; X64:         movl    %eax, -4(%rbp)
-; X64:         leaq    .LBB0_2(%rip), %rax
-; X64:         addq    $40, %rsp
-; X64:                popq    %rsi
+; X64:         movl    24(%rbp), %eax
+; X64:         movl    %eax, -20(%rbp)  # 4-byte Spill
+; X64:         leaq    .LBB0_1(%rip), %rax
+; X64:         addq    $32, %rsp
 ; X64:         popq    %rbp
 ; X64:         retq                            # CATCHRET
 
@@ -78,27 +69,33 @@ return:                                           ; preds = %entry, %catch
 ; X86:         pushl   %ebx
 ; X86:         pushl   %edi
 ; X86:         pushl   %esi
-; X86:         subl    $28, %esp
-; X86:                movl    $-1, -40(%ebp)
+; X86:         subl    $24, %esp
+; X86:                movl    $-1, -36(%ebp)
 ; X86:         calll   _g
-; X86:         movl    -40(%ebp), %eax
-; X86:         addl    $28, %esp
+; X86: LBB0_[[retbb:[0-9]+]]:
+; X86:         movl    -36(%ebp), %eax
+; X86:         addl    $24, %esp
 ; X86:         popl    %esi
 ; X86:         popl    %edi
 ; X86:         popl    %ebx
 ; X86:         popl    %ebp
 ; X86:         retl
 
-; X86-LABEL: "?catch$1@?0?f@4HA":
-; X86:         pushl   %ebp
-; X86:         addl    $12, %ebp
+; X86: LBB0_[[restorebb:[0-9]+]]: # Block address taken
+; X86: addl $12, %ebp
 ; arg2 is at EBP offset 12:
 ; + 4 for arg1
 ; + 4 for retaddr
 ; + 4 for EBP
+; X86: movl 12(%ebp), %eax
+; X86: movl %eax, -36(%ebp)
+; X86: jmp LBB0_[[retbb]]
+
+; X86-LABEL: "?catch${{[0-9]}}@?0?f@4HA":
+; X86:         pushl   %ebp
+; X86:         addl    $12, %ebp
 ; Done due to mov %esp, %ebp
-; X86:         movl    12(%ebp), %eax
-; X86:         movl    %eax, -32(%ebp)
-; X86:         movl    $LBB0_2, %eax
+; X86:         leal    12(%ebp), %eax
+; X86:         movl    $LBB0_[[restorebb]], %eax
 ; X86:         popl    %ebp
 ; X86:         retl                            # CATCHRET