Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / microsoft-abi-virtual-inheritance-vtordisps.cpp
blob691fccf9930af939b8806e8bd08dc1ee79d6643c
1 // RUN: %clang_cc1 %s -fno-rtti -triple=i386-pc-win32 -emit-llvm -o - | FileCheck %s
3 // For now, just make sure x86_64 doesn't crash.
4 // RUN: %clang_cc1 %s -fno-rtti -triple=x86_64-pc-win32 -emit-llvm -o %t
6 struct A {
7 virtual void f();
8 };
10 struct B {
11 virtual void f();
14 struct C : A, B {};
16 struct D : virtual C {
17 D();
18 ~D();
19 virtual void f();
20 void g();
21 int xxx;
24 D::D() {} // Forces vftable emission.
26 // CHECK-LABEL: define linkonce_odr dso_local x86_thiscallcc void @"?f@D@@$4PPPPPPPM@A@AEXXZ"
27 // Note that the vtordisp is applied before really adjusting to D*.
28 // CHECK: %[[ECX:.*]] = load ptr, ptr %{{.*}}
29 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, ptr %[[ECX]], i32 -4
30 // CHECK: %[[VTORDISP:.*]] = load i32, ptr %[[VTORDISP_PTR_i8]]
31 // CHECK: %[[VTORDISP_NEG:.*]] = sub i32 0, %[[VTORDISP]]
32 // CHECK: %[[ADJUSTED_i8:.*]] = getelementptr i8, ptr %[[ECX]], i32 %[[VTORDISP_NEG]]
33 // CHECK: call x86_thiscallcc void @"?f@D@@UAEXXZ"(ptr noundef %[[ADJUSTED_i8]])
34 // CHECK: ret void
36 // CHECK-LABEL: define linkonce_odr dso_local x86_thiscallcc void @"?f@D@@$4PPPPPPPI@3AEXXZ"
37 // CHECK: %[[ECX:.*]] = load ptr, ptr %{{.*}}
38 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, ptr %[[ECX]], i32 -8
39 // CHECK: %[[VTORDISP:.*]] = load i32, ptr %[[VTORDISP_PTR_i8]]
40 // CHECK: %[[VTORDISP_NEG:.*]] = sub i32 0, %[[VTORDISP]]
41 // CHECK: %[[VTORDISP_ADJUSTED_i8:.*]] = getelementptr i8, ptr %[[ECX]], i32 %[[VTORDISP_NEG]]
42 // CHECK: %[[ADJUSTED_i8:.*]] = getelementptr i8, ptr %[[VTORDISP_ADJUSTED_i8]], i32 -4
43 // CHECK: call x86_thiscallcc void @"?f@D@@UAEXXZ"(ptr noundef %[[ADJUSTED_i8]])
44 // CHECK: ret void
46 struct E : virtual A {
47 virtual void f();
48 ~E();
51 struct F {
52 virtual void z();
55 struct G : virtual F, virtual E {
56 int ggg;
57 G();
58 ~G();
61 G::G() {} // Forces vftable emission.
63 // CHECK-LABEL: define linkonce_odr dso_local x86_thiscallcc void @"?f@E@@$R4BA@M@PPPPPPPM@7AEXXZ"(ptr
64 // CHECK: %[[ECX:.*]] = load ptr, ptr %{{.*}}
65 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, ptr %[[ECX]], i32 -4
66 // CHECK: %[[VTORDISP:.*]] = load i32, ptr %[[VTORDISP_PTR_i8]]
67 // CHECK: %[[VTORDISP_NEG:.*]] = sub i32 0, %[[VTORDISP]]
68 // CHECK: %[[VTORDISP_ADJUSTED_i8:.*]] = getelementptr i8, ptr %[[ECX]], i32 %[[VTORDISP_NEG]]
69 // CHECK: %[[VBPTR_i8:.*]] = getelementptr inbounds i8, ptr %[[VTORDISP_ADJUSTED_i8]], i32 -16
70 // CHECK: %[[VBTABLE:.*]] = load ptr, ptr %[[VBPTR_i8]]
71 // CHECK: %[[VBOFFSET_PTR:.*]] = getelementptr inbounds i32, ptr %[[VBTABLE]], i32 3
72 // CHECK: %[[VBASE_OFFSET:.*]] = load i32, ptr %[[VBOFFSET_PTR]]
73 // CHECK: %[[VBASE:.*]] = getelementptr inbounds i8, ptr %[[VBPTR_i8]], i32 %[[VBASE_OFFSET]]
74 // CHECK: %[[ARG_i8:.*]] = getelementptr i8, ptr %[[VBASE]], i32 8
75 // CHECK: call x86_thiscallcc void @"?f@E@@UAEXXZ"(ptr noundef %[[ARG_i8]])
76 // CHECK: ret void