xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/cleanuppad-inalloca.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Based on this C++:
4*9880d681SAndroid Build Coastguard Worker; struct A {
5*9880d681SAndroid Build Coastguard Worker;   int x;
6*9880d681SAndroid Build Coastguard Worker;   A();
7*9880d681SAndroid Build Coastguard Worker;   A(const A &a);
8*9880d681SAndroid Build Coastguard Worker;   ~A();
9*9880d681SAndroid Build Coastguard Worker; };
10*9880d681SAndroid Build Coastguard Worker; extern "C" void takes_two(A a1, A a2);
11*9880d681SAndroid Build Coastguard Worker; extern "C" void passes_two() { takes_two(A(), A()); }
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
14*9880d681SAndroid Build Coastguard Workertarget triple = "i686--windows-msvc"
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Worker%struct.A = type { i32 }
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Workerdefine void @passes_two() #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
19*9880d681SAndroid Build Coastguard Workerentry:
20*9880d681SAndroid Build Coastguard Worker  %argmem = alloca inalloca <{ %struct.A, %struct.A }>, align 4
21*9880d681SAndroid Build Coastguard Worker  %0 = getelementptr inbounds <{ %struct.A, %struct.A }>, <{ %struct.A, %struct.A }>* %argmem, i32 0, i32 1
22*9880d681SAndroid Build Coastguard Worker  %call = call x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"(%struct.A* %0)
23*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds <{ %struct.A, %struct.A }>, <{ %struct.A, %struct.A }>* %argmem, i32 0, i32 0
24*9880d681SAndroid Build Coastguard Worker  %call1 = invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"(%struct.A* %1)
25*9880d681SAndroid Build Coastguard Worker          to label %invoke.cont unwind label %ehcleanup
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerinvoke.cont:                                      ; preds = %entry
28*9880d681SAndroid Build Coastguard Worker  call void @takes_two(<{ %struct.A, %struct.A }>* inalloca nonnull %argmem)
29*9880d681SAndroid Build Coastguard Worker  ret void
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Workerehcleanup:                                        ; preds = %entry
32*9880d681SAndroid Build Coastguard Worker  %2 = cleanuppad within none []
33*9880d681SAndroid Build Coastguard Worker  call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %0) [ "funclet"(token %2) ]
34*9880d681SAndroid Build Coastguard Worker  cleanupret from %2 unwind to caller
35*9880d681SAndroid Build Coastguard Worker}
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Worker; CHECK: _passes_two:
38*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %ebp
39*9880d681SAndroid Build Coastguard Worker; CHECK: movl %esp, %ebp
40*9880d681SAndroid Build Coastguard Worker; CHECK: subl ${{[0-9]+}}, %esp
41*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %eax
42*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %eax
43*9880d681SAndroid Build Coastguard Worker; CHECK: calll "??0A@@QAE@XZ"
44*9880d681SAndroid Build Coastguard Worker; CHECK: calll "??0A@@QAE@XZ"
45*9880d681SAndroid Build Coastguard Worker; CHECK: calll _takes_two
46*9880d681SAndroid Build Coastguard Worker; 	ESP must be restored via EBP due to "dynamic" alloca.
47*9880d681SAndroid Build Coastguard Worker; CHECK: leal -{{[0-9]+}}(%ebp), %esp
48*9880d681SAndroid Build Coastguard Worker; CHECK: popl %ebp
49*9880d681SAndroid Build Coastguard Worker; CHECK: retl
50*9880d681SAndroid Build Coastguard Worker
51*9880d681SAndroid Build Coastguard Worker; CHECK: "?dtor$2@?0?passes_two@4HA":
52*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %ebp
53*9880d681SAndroid Build Coastguard Worker; CHECK: subl $8, %esp
54*9880d681SAndroid Build Coastguard Worker; CHECK: addl $12, %ebp
55*9880d681SAndroid Build Coastguard Worker; CHECK: {{movl|leal}} -{{[0-9]+}}(%ebp), %ecx
56*9880d681SAndroid Build Coastguard Worker; CHECK: calll "??1A@@QAE@XZ"
57*9880d681SAndroid Build Coastguard Worker; CHECK: addl $8, %esp
58*9880d681SAndroid Build Coastguard Worker; CHECK: retl
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Workerdeclare void @takes_two(<{ %struct.A, %struct.A }>* inalloca) #0
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Workerdeclare x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"(%struct.A* returned) #0
63*9880d681SAndroid Build Coastguard Worker
64*9880d681SAndroid Build Coastguard Workerdeclare i32 @__CxxFrameHandler3(...)
65*9880d681SAndroid Build Coastguard Worker
66*9880d681SAndroid Build Coastguard Workerdeclare x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A*) #0
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Workerattributes #0 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
69