Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / cfi / simple-pass.cpp
blobde791fc1073ff0f16bac8bd82d96f09e8a03c282
1 // -mretpoline does not work yet on Darwin.
2 // XFAIL: darwin
4 // RUN: %clangxx_cfi -o %t %s
5 // RUN: %run %t
6 // RUN: %clangxx_cfi -mretpoline -o %t2 %s
7 // RUN: %run %t2
9 // Tests that the CFI mechanism does not crash the program when making various
10 // kinds of valid calls involving classes with various different linkages and
11 // types of inheritance, and both virtual and non-virtual member functions.
13 #include "utils.h"
15 struct A {
16 virtual void f();
17 void g();
20 void A::f() {}
21 void A::g() {}
23 struct A2 : A {
24 virtual void f();
25 void g();
28 void A2::f() {}
29 void A2::g() {}
31 struct B {
32 virtual void f() {}
33 void g() {}
36 struct B2 : B {
37 virtual void f() {}
38 void g() {}
41 namespace {
43 struct C {
44 virtual void f();
45 void g();
48 void C::f() {}
49 void C::g() {}
51 struct C2 : C {
52 virtual void f();
53 void g();
56 void C2::f() {}
57 void C2::g() {}
59 struct D {
60 virtual void f() {}
61 void g() {}
64 struct D2 : D {
65 virtual void f() {}
66 void g() {}
71 struct E {
72 virtual void f() {}
73 void g() {}
76 struct E2 : virtual E {
77 virtual void f() {}
78 void g() {}
81 int main() {
82 A *a = new A;
83 break_optimization(a);
84 a->f();
85 a->g();
86 a = new A2;
87 break_optimization(a);
88 a->f();
89 a->g();
91 B *b = new B;
92 break_optimization(b);
93 b->f();
94 b->g();
95 b = new B2;
96 break_optimization(b);
97 b->f();
98 b->g();
100 C *c = new C;
101 break_optimization(c);
102 c->f();
103 c->g();
104 c = new C2;
105 break_optimization(c);
106 c->f();
107 c->g();
109 D *d = new D;
110 break_optimization(d);
111 d->f();
112 d->g();
113 d = new D2;
114 break_optimization(d);
115 d->f();
116 d->g();
118 E *e = new E;
119 break_optimization(e);
120 e->f();
121 e->g();
122 e = new E2;
123 break_optimization(e);
124 e->f();
125 e->g();