xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/win32-seh-catchpad-realign.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -stack-symbol-ordering=0 < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; The aligned alloca means that we have to realign the stack, which forces the
4*9880d681SAndroid Build Coastguard Worker; use of ESI to address local variables.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
7*9880d681SAndroid Build Coastguard Workertarget triple = "i686--windows-msvc"
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
10*9880d681SAndroid Build Coastguard Workerdefine void @realigned_try() personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) {
11*9880d681SAndroid Build Coastguard Workerentry:
12*9880d681SAndroid Build Coastguard Worker  %x = alloca [4 x i32], align 16
13*9880d681SAndroid Build Coastguard Worker  %arrayidx = getelementptr inbounds [4 x i32], [4 x i32]* %x, i32 0, i32 0
14*9880d681SAndroid Build Coastguard Worker  invoke void @useit(i32* %arrayidx)
15*9880d681SAndroid Build Coastguard Worker          to label %__try.cont unwind label %catch.dispatch
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Workercatch.dispatch:                                   ; preds = %entry
18*9880d681SAndroid Build Coastguard Worker  %cs1 = catchswitch within none [label %__except.ret] unwind to caller
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker__except.ret:                                     ; preds = %catch.dispatch
21*9880d681SAndroid Build Coastguard Worker  %pad = catchpad within %cs1 [i8* bitcast (i32 ()* @"\01?filt$0@0@realigned_try@@" to i8*)]
22*9880d681SAndroid Build Coastguard Worker  catchret from %pad to label %__try.cont
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Worker__try.cont:                                       ; preds = %entry, %__except.ret
25*9880d681SAndroid Build Coastguard Worker  ret void
26*9880d681SAndroid Build Coastguard Worker}
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind argmemonly
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
31*9880d681SAndroid Build Coastguard Workerdefine internal i32 @"\01?filt$0@0@realigned_try@@"() {
32*9880d681SAndroid Build Coastguard Workerentry:
33*9880d681SAndroid Build Coastguard Worker  ret i32 1
34*9880d681SAndroid Build Coastguard Worker}
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Workerdeclare void @useit(i32*)
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Workerdeclare i32 @_except_handler3(...)
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: _realigned_try:
41*9880d681SAndroid Build Coastguard Worker; Prologue
42*9880d681SAndroid Build Coastguard Worker; CHECK: pushl   %ebp
43*9880d681SAndroid Build Coastguard Worker; CHECK: movl    %esp, %ebp
44*9880d681SAndroid Build Coastguard Worker; CHECK: pushl   %ebx
45*9880d681SAndroid Build Coastguard Worker; CHECK: pushl   %edi
46*9880d681SAndroid Build Coastguard Worker; CHECK: pushl   %esi
47*9880d681SAndroid Build Coastguard Worker; CHECK: andl    $-16, %esp
48*9880d681SAndroid Build Coastguard Worker; CHECK: subl    $64, %esp
49*9880d681SAndroid Build Coastguard Worker; CHECK: movl    %esp, %esi
50*9880d681SAndroid Build Coastguard Worker; Spill EBP
51*9880d681SAndroid Build Coastguard Worker; CHECK: movl    %ebp, 12(%esi)
52*9880d681SAndroid Build Coastguard Worker; Spill ESP
53*9880d681SAndroid Build Coastguard Worker; CHECK: movl    %esp, 36(%esi)
54*9880d681SAndroid Build Coastguard Worker; The state is stored at ESI+56, the end of the node is ESI+60.
55*9880d681SAndroid Build Coastguard Worker; CHECK: movl    $-1, 56(%esi)
56*9880d681SAndroid Build Coastguard Worker;
57*9880d681SAndroid Build Coastguard Worker; __try
58*9880d681SAndroid Build Coastguard Worker; CHECK: calll _useit
59*9880d681SAndroid Build Coastguard Worker;
60*9880d681SAndroid Build Coastguard Worker; Epilogue
61*9880d681SAndroid Build Coastguard Worker; CHECK: LBB0_2:       # %__try.cont
62*9880d681SAndroid Build Coastguard Worker; CHECK: leal    -12(%ebp), %esp
63*9880d681SAndroid Build Coastguard Worker; CHECK: popl    %esi
64*9880d681SAndroid Build Coastguard Worker; CHECK: popl    %edi
65*9880d681SAndroid Build Coastguard Worker; CHECK: popl    %ebx
66*9880d681SAndroid Build Coastguard Worker; CHECK: popl    %ebp
67*9880d681SAndroid Build Coastguard Worker; CHECK: retl
68*9880d681SAndroid Build Coastguard Worker;
69*9880d681SAndroid Build Coastguard Worker; CHECK: LBB0_1:                                 # %__except.ret
70*9880d681SAndroid Build Coastguard Worker; Restore ESP
71*9880d681SAndroid Build Coastguard Worker; CHECK: movl    -24(%ebp), %esp
72*9880d681SAndroid Build Coastguard Worker; Recompute ESI by subtracting 60 from the end of the registration node.
73*9880d681SAndroid Build Coastguard Worker; CHECK: leal    -60(%ebp), %esi
74*9880d681SAndroid Build Coastguard Worker; Restore EBP
75*9880d681SAndroid Build Coastguard Worker; CHECK: movl    12(%esi), %ebp
76*9880d681SAndroid Build Coastguard Worker; Rejoin normal control flow
77*9880d681SAndroid Build Coastguard Worker; CHECK: jmp     LBB0_2
78