1// RUN: %clang_cc1 -mconstructor-aliases -std=c++11 -fexceptions -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s -check-prefix=X86 2// RUN: %clang_cc1 -mconstructor-aliases -std=c++11 -fexceptions -emit-llvm %s -o - -triple=x86_64-pc-win32 | FileCheck %s -check-prefix=X64 3 4struct A { 5 A(int a); 6 A(const A &o); 7 ~A(); 8 int a; 9}; 10 11void foo(A a, A b, A c) { 12} 13 14// Order of destruction should be left to right. 15// 16// X86-LABEL: define void @"\01?foo@@YAXUA@@00@Z" 17// X86: ([[argmem_ty:<{ %struct.A, %struct.A, %struct.A }>]]* inalloca) 18// X86: %[[a:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %0, i32 0, i32 0 19// X86: %[[b:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %0, i32 0, i32 1 20// X86: %[[c:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %0, i32 0, i32 2 21// X86: call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %[[a]]) 22// X86: call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %[[b]]) 23// X86: call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %[[c]]) 24// X86: ret void 25 26// X64-LABEL: define void @"\01?foo@@YAXUA@@00@Z" 27// X64: (%struct.A* %[[a:[^,]*]], %struct.A* %[[b:[^,]*]], %struct.A* %[[c:[^)]*]]) 28// X64: call void @"\01??1A@@QEAA@XZ"(%struct.A* %[[a]]) 29// X64: call void @"\01??1A@@QEAA@XZ"(%struct.A* %[[b]]) 30// X64: call void @"\01??1A@@QEAA@XZ"(%struct.A* %[[c]]) 31// X64: ret void 32 33 34void call_foo() { 35 foo(A(1), A(2), A(3)); 36} 37 38// Order of evaluation should be right to left, and we should clean up the right 39// things as we unwind. 40// 41// X86-LABEL: define void @"\01?call_foo@@YAXXZ"() 42// X86: call i8* @llvm.stacksave() 43// X86: %[[argmem:[^ ]*]] = alloca inalloca [[argmem_ty]] 44// X86: %[[arg3:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %[[argmem]], i32 0, i32 2 45// X86: call x86_thiscallcc %struct.A* @"\01??0A@@QAE@H@Z"(%struct.A* %[[arg3]], i32 3) 46// X86: %[[arg2:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %[[argmem]], i32 0, i32 1 47// X86: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@H@Z"(%struct.A* %[[arg2]], i32 2) 48// X86: %[[arg1:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %[[argmem]], i32 0, i32 0 49// X86: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@H@Z"(%struct.A* %[[arg1]], i32 1) 50// X86: call void @"\01?foo@@YAXUA@@00@Z"([[argmem_ty]]* inalloca %[[argmem]]) 51// X86: call void @llvm.stackrestore 52// X86: ret void 53// 54// lpad2: 55// X86: cleanuppad within none [] 56// X86: call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %[[arg2]]) 57// X86: cleanupret 58// 59// ehcleanup: 60// X86: call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %[[arg3]]) 61 62// X64-LABEL: define void @"\01?call_foo@@YAXXZ"() 63// X64: call %struct.A* @"\01??0A@@QEAA@H@Z"(%struct.A* %[[arg3:[^,]*]], i32 3) 64// X64: invoke %struct.A* @"\01??0A@@QEAA@H@Z"(%struct.A* %[[arg2:[^,]*]], i32 2) 65// X64: invoke %struct.A* @"\01??0A@@QEAA@H@Z"(%struct.A* %[[arg1:[^,]*]], i32 1) 66// X64: call void @"\01?foo@@YAXUA@@00@Z" 67// X64: (%struct.A* %[[arg1]], %struct.A* %[[arg2]], %struct.A* %[[arg3]]) 68// X64: ret void 69// 70// lpad2: 71// X64: cleanuppad within none [] 72// X64: call void @"\01??1A@@QEAA@XZ"(%struct.A* %[[arg2]]) 73// X64: cleanupret 74// 75// ehcleanup: 76// X64: call void @"\01??1A@@QEAA@XZ"(%struct.A* %[[arg3]]) 77