blob: 4404de0f88e5b3cb4a64786a19ba5f5cd08270a3 [file] [log] [blame]
Daniel Dunbar9430d5a2010-05-11 21:15:36 +00001// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -o - %s | FileCheck %s
Anders Carlssonbfc008d2010-01-27 03:22:55 +00002
3// Non-trivial dtors, should both be passed indirectly.
4struct S {
5 ~S();
Chris Lattner7e21ffb2010-05-05 22:55:13 +00006 short s;
Anders Carlssonbfc008d2010-01-27 03:22:55 +00007};
8
Bill Wendling5e314742013-01-31 23:17:12 +00009// CHECK: define void @_Z1fv(%struct.S* noalias sret %
Anders Carlssonbfc008d2010-01-27 03:22:55 +000010S f() { return S(); }
11// CHECK: define void @_Z1f1S(%struct.S*)
12void f(S) { }
13
14// Non-trivial dtors, should both be passed indirectly.
15class C {
Daniel Dunbar9430d5a2010-05-11 21:15:36 +000016public:
Anders Carlssonbfc008d2010-01-27 03:22:55 +000017 ~C();
18 double c;
19};
20
Bill Wendling5e314742013-01-31 23:17:12 +000021// CHECK: define void @_Z1gv(%class.C* noalias sret %
Anders Carlssonbfc008d2010-01-27 03:22:55 +000022C g() { return C(); }
23
24// CHECK: define void @_Z1f1C(%class.C*)
25void f(C) { }
Chris Lattner7e21ffb2010-05-05 22:55:13 +000026
27
28
29
30// PR7058 - Missing byval on MI thunk definition.
31
32// CHECK: define void @_ZThn4_N18BasicAliasAnalysis13getModRefInfoE8CallSite
33// ...
Bill Wendlingc1ea4b92013-02-15 05:25:49 +000034// CHECK: %struct.CallSite* byval align 4 %CS)
Chris Lattner7e21ffb2010-05-05 22:55:13 +000035struct CallSite {
36 unsigned Ptr;
37 CallSite(unsigned XX) : Ptr(XX) {}
38};
39
40struct AliasAnalysis {
41 virtual void xyz();
42 virtual void getModRefInfo(CallSite CS) = 0;
43};
44
45struct ModulePass {
46 virtual void xx();
47};
48
49struct BasicAliasAnalysis : public ModulePass, public AliasAnalysis {
50 void getModRefInfo(CallSite CS);
51};
52
53void BasicAliasAnalysis::getModRefInfo(CallSite CS) {
54}
Daniel Dunbar9430d5a2010-05-11 21:15:36 +000055
56// Check various single element struct type conditions.
57//
58// PR7098.
59
60// CHECK: define i64 @_Z2f0v()
61struct s0_0 { int x; };
62struct s0_1 : s0_0 { int* y; };
63s0_1 f0() { return s0_1(); }
64
65// CHECK: define i32 @_Z2f1v()
66struct s1_0 { int x; };
67struct s1_1 : s1_0 { };
68s1_1 f1() { return s1_1(); }
69
70// CHECK: define double @_Z2f2v()
71struct s2_0 { double x; };
72struct s2_1 : s2_0 { };
73s2_1 f2() { return s2_1(); }
74
75// CHECK: define double @_Z2f3v()
76struct s3_0 { };
77struct s3_1 { double x; };
78struct s3_2 : s3_0, s3_1 { };
79s3_2 f3() { return s3_2(); }
80
81// CHECK: define i64 @_Z2f4v()
82struct s4_0 { float x; };
83struct s4_1 { float x; };
84struct s4_2 : s4_0, s4_1 { };
85s4_2 f4() { return s4_2(); }
Daniel Dunbara1842d32010-05-14 03:40:53 +000086
Eli Friedmanbd4d3bc2011-11-18 01:25:50 +000087// CHECK: define i32* @_Z2f5v()
Daniel Dunbara1842d32010-05-14 03:40:53 +000088struct s5 { s5(); int &x; };
89s5 f5() { return s5(); }
Daniel Dunbar77115232010-05-15 00:00:30 +000090
91// CHECK: define i32 @_Z4f6_0M2s6i(i32 %a)
Bill Wendlingc1ea4b92013-02-15 05:25:49 +000092// CHECK: define i64 @_Z4f6_1M2s6FivE({ i32, i32 }* byval align 4)
Daniel Dunbar77115232010-05-15 00:00:30 +000093// FIXME: It would be nice to avoid byval on the previous case.
94struct s6 {};
95typedef int s6::* s6_mdp;
96typedef int (s6::*s6_mfp)();
97s6_mdp f6_0(s6_mdp a) { return a; }
98s6_mfp f6_1(s6_mfp a) { return a; }
Daniel Dunbar5ea68612010-05-17 16:46:00 +000099
100// CHECK: define double @_Z2f7v()
101struct s7_0 { unsigned : 0; };
102struct s7_1 { double x; };
103struct s7 : s7_0, s7_1 { };
104s7 f7() { return s7(); }
105
Bill Wendling5e314742013-01-31 23:17:12 +0000106// CHECK: define void @_Z2f8v(%struct.s8* noalias sret %agg.result)
Daniel Dunbar5ea68612010-05-17 16:46:00 +0000107struct s8_0 { };
108struct s8_1 { double x; };
109struct s8 { s8_0 a; s8_1 b; };
110s8 f8() { return s8(); }
111
Bill Wendling5e314742013-01-31 23:17:12 +0000112// CHECK: define void @_Z2f9v(%struct.s9* noalias sret %agg.result)
Daniel Dunbar5ea68612010-05-17 16:46:00 +0000113struct s9_0 { unsigned : 0; };
114struct s9_1 { double x; };
115struct s9 { s9_0 a; s9_1 b; };
116s9 f9() { return s9(); }