Reid Kleckner | 9779741 | 2015-10-07 23:55:01 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s | FileCheck %s |
| 2 | |
| 3 | ; Based on this C++: |
| 4 | ; struct A { |
| 5 | ; int x; |
| 6 | ; A(); |
| 7 | ; A(const A &a); |
| 8 | ; ~A(); |
| 9 | ; }; |
| 10 | ; extern "C" void takes_two(A a1, A a2); |
| 11 | ; extern "C" void passes_two() { takes_two(A(), A()); } |
| 12 | |
| 13 | target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" |
| 14 | target triple = "i686--windows-msvc" |
| 15 | |
| 16 | %struct.A = type { i32 } |
| 17 | |
| 18 | define void @passes_two() #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) { |
| 19 | entry: |
| 20 | %argmem = alloca inalloca <{ %struct.A, %struct.A }>, align 4 |
| 21 | %0 = getelementptr inbounds <{ %struct.A, %struct.A }>, <{ %struct.A, %struct.A }>* %argmem, i32 0, i32 1 |
| 22 | %call = call x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"(%struct.A* %0) |
| 23 | %1 = getelementptr inbounds <{ %struct.A, %struct.A }>, <{ %struct.A, %struct.A }>* %argmem, i32 0, i32 0 |
| 24 | %call1 = invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"(%struct.A* %1) |
| 25 | to label %invoke.cont unwind label %ehcleanup |
| 26 | |
| 27 | invoke.cont: ; preds = %entry |
| 28 | call void @takes_two(<{ %struct.A, %struct.A }>* inalloca nonnull %argmem) |
| 29 | ret void |
| 30 | |
| 31 | ehcleanup: ; preds = %entry |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 32 | %2 = cleanuppad within none [] |
David Majnemer | 3bb88c0 | 2015-12-15 21:27:27 +0000 | [diff] [blame] | 33 | call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %0) [ "funclet"(token %2) ] |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 34 | cleanupret from %2 unwind to caller |
Reid Kleckner | 9779741 | 2015-10-07 23:55:01 +0000 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | ; CHECK: _passes_two: |
| 38 | ; CHECK: pushl %ebp |
| 39 | ; CHECK: movl %esp, %ebp |
| 40 | ; CHECK: subl ${{[0-9]+}}, %esp |
Hans Wennborg | 8eb336c | 2016-05-18 16:10:17 +0000 | [diff] [blame] | 41 | ; CHECK: pushl %eax |
| 42 | ; CHECK: pushl %eax |
Reid Kleckner | 9779741 | 2015-10-07 23:55:01 +0000 | [diff] [blame] | 43 | ; CHECK: calll "??0A@@QAE@XZ" |
| 44 | ; CHECK: calll "??0A@@QAE@XZ" |
| 45 | ; CHECK: calll _takes_two |
| 46 | ; ESP must be restored via EBP due to "dynamic" alloca. |
| 47 | ; CHECK: leal -{{[0-9]+}}(%ebp), %esp |
| 48 | ; CHECK: popl %ebp |
| 49 | ; CHECK: retl |
| 50 | |
| 51 | ; CHECK: "?dtor$2@?0?passes_two@4HA": |
| 52 | ; CHECK: pushl %ebp |
| 53 | ; CHECK: subl $8, %esp |
David Majnemer | cb305de | 2016-03-01 04:30:16 +0000 | [diff] [blame] | 54 | ; CHECK: addl $12, %ebp |
Reid Kleckner | 9779741 | 2015-10-07 23:55:01 +0000 | [diff] [blame] | 55 | ; CHECK: {{movl|leal}} -{{[0-9]+}}(%ebp), %ecx |
| 56 | ; CHECK: calll "??1A@@QAE@XZ" |
| 57 | ; CHECK: addl $8, %esp |
| 58 | ; CHECK: retl |
| 59 | |
| 60 | declare void @takes_two(<{ %struct.A, %struct.A }>* inalloca) #0 |
| 61 | |
| 62 | declare x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"(%struct.A* returned) #0 |
| 63 | |
| 64 | declare i32 @__CxxFrameHandler3(...) |
| 65 | |
| 66 | declare x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A*) #0 |
| 67 | |
| 68 | attributes #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" } |