xref: /aosp_15_r20/external/clang/test/CodeGenCXX/pr20897.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -triple i686-windows-msvc -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s | FileCheck %s
2*67e74705SXin Li struct Base {};
3*67e74705SXin Li 
4*67e74705SXin Li // __declspec(dllexport) causes us to export the implicit constructor.
5*67e74705SXin Li struct __declspec(dllexport) Derived : virtual Base {
6*67e74705SXin Li // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc %struct.Derived* @"\01??0Derived@@QAE@ABU0@@Z"
7*67e74705SXin Li // CHECK:      %[[this:.*]] = load %struct.Derived*, %struct.Derived** {{.*}}
8*67e74705SXin Li // CHECK-NEXT: store %struct.Derived* %[[this]], %struct.Derived** %[[retval:.*]]
9*67e74705SXin Li // CHECK:      %[[dest_a_gep:.*]] = getelementptr inbounds %struct.Derived, %struct.Derived* %[[this]], i32 0, i32 1
10*67e74705SXin Li // CHECK-NEXT: %[[src_load:.*]]   = load %struct.Derived*, %struct.Derived** {{.*}}
11*67e74705SXin Li // CHECK-NEXT: %[[src_a_gep:.*]]  = getelementptr inbounds %struct.Derived, %struct.Derived* %[[src_load:.*]], i32 0, i32 1
12*67e74705SXin Li // CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %[[dest_a_gep]], i8* %[[src_a_gep]], i64 1, i32 4, i1 false)
13*67e74705SXin Li // CHECK-NEXT: %[[dest_this:.*]] = load %struct.Derived*, %struct.Derived** %[[retval]]
14*67e74705SXin Li // CHECK-NEXT: ret %struct.Derived* %[[dest_this]]
15*67e74705SXin Li   bool a : 1;
16*67e74705SXin Li   bool b : 1;
17*67e74705SXin Li };
18*67e74705SXin Li 
19*67e74705SXin Li // __declspec(dllexport) causes us to export the implicit copy constructor.
20*67e74705SXin Li struct __declspec(dllexport) Derived2 : virtual Base {
21*67e74705SXin Li // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc %struct.Derived2* @"\01??0Derived2@@QAE@ABU0@@Z"
22*67e74705SXin Li // CHECK:      %[[this:.*]] = load %struct.Derived2*, %struct.Derived2** {{.*}}
23*67e74705SXin Li // CHECK-NEXT: store %struct.Derived2* %[[this]], %struct.Derived2** %[[retval:.*]]
24*67e74705SXin Li // CHECK:      %[[dest_a_gep:.*]] = getelementptr inbounds %struct.Derived2, %struct.Derived2* %[[this]], i32 0, i32 1
25*67e74705SXin Li // CHECK-NEXT: %[[src_load:.*]]   = load %struct.Derived2*, %struct.Derived2** {{.*}}
26*67e74705SXin Li // CHECK-NEXT: %[[src_a_gep:.*]]  = getelementptr inbounds %struct.Derived2, %struct.Derived2* %[[src_load:.*]], i32 0, i32 1
27*67e74705SXin Li // CHECK-NEXT: %[[dest_a_bitcast:.*]]  = bitcast [1 x i32]* %[[dest_a_gep]] to i8*
28*67e74705SXin Li // CHECK-NEXT: %[[src_a_bitcast:.*]] = bitcast [1 x i32]* %[[src_a_gep]] to i8*
29*67e74705SXin Li // CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[dest_a_bitcast]], i8* %[[src_a_bitcast]], i32 4, i32 4, i1 false)
30*67e74705SXin Li // CHECK-NEXT: %[[dest_this:.*]] = load %struct.Derived2*, %struct.Derived2** %[[retval]]
31*67e74705SXin Li // CHECK-NEXT: ret %struct.Derived2* %[[dest_this]]
32*67e74705SXin Li   int Array[1];
33*67e74705SXin Li };
34