Daniel Dunbar | 9430d5a | 2010-05-11 21:15:36 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -o - %s | FileCheck %s |
Anders Carlsson | bfc008d | 2010-01-27 03:22:55 +0000 | [diff] [blame] | 2 | |
| 3 | // Non-trivial dtors, should both be passed indirectly. |
| 4 | struct S { |
| 5 | ~S(); |
Chris Lattner | 7e21ffb | 2010-05-05 22:55:13 +0000 | [diff] [blame] | 6 | short s; |
Anders Carlsson | bfc008d | 2010-01-27 03:22:55 +0000 | [diff] [blame] | 7 | }; |
| 8 | |
Chris Lattner | fb97cf2 | 2010-04-20 05:44:43 +0000 | [diff] [blame] | 9 | // CHECK: define void @_Z1fv(%struct.S* sret % |
Anders Carlsson | bfc008d | 2010-01-27 03:22:55 +0000 | [diff] [blame] | 10 | S f() { return S(); } |
| 11 | // CHECK: define void @_Z1f1S(%struct.S*) |
| 12 | void f(S) { } |
| 13 | |
| 14 | // Non-trivial dtors, should both be passed indirectly. |
| 15 | class C { |
Daniel Dunbar | 9430d5a | 2010-05-11 21:15:36 +0000 | [diff] [blame] | 16 | public: |
Anders Carlsson | bfc008d | 2010-01-27 03:22:55 +0000 | [diff] [blame] | 17 | ~C(); |
| 18 | double c; |
| 19 | }; |
| 20 | |
Chris Lattner | fb97cf2 | 2010-04-20 05:44:43 +0000 | [diff] [blame] | 21 | // CHECK: define void @_Z1gv(%class.C* sret % |
Anders Carlsson | bfc008d | 2010-01-27 03:22:55 +0000 | [diff] [blame] | 22 | C g() { return C(); } |
| 23 | |
| 24 | // CHECK: define void @_Z1f1C(%class.C*) |
| 25 | void f(C) { } |
Chris Lattner | 7e21ffb | 2010-05-05 22:55:13 +0000 | [diff] [blame] | 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | // PR7058 - Missing byval on MI thunk definition. |
| 31 | |
| 32 | // CHECK: define void @_ZThn4_N18BasicAliasAnalysis13getModRefInfoE8CallSite |
| 33 | // ... |
| 34 | // CHECK: %struct.CallSite* byval %CS) |
| 35 | struct CallSite { |
| 36 | unsigned Ptr; |
| 37 | CallSite(unsigned XX) : Ptr(XX) {} |
| 38 | }; |
| 39 | |
| 40 | struct AliasAnalysis { |
| 41 | virtual void xyz(); |
| 42 | virtual void getModRefInfo(CallSite CS) = 0; |
| 43 | }; |
| 44 | |
| 45 | struct ModulePass { |
| 46 | virtual void xx(); |
| 47 | }; |
| 48 | |
| 49 | struct BasicAliasAnalysis : public ModulePass, public AliasAnalysis { |
| 50 | void getModRefInfo(CallSite CS); |
| 51 | }; |
| 52 | |
| 53 | void BasicAliasAnalysis::getModRefInfo(CallSite CS) { |
| 54 | } |
Daniel Dunbar | 9430d5a | 2010-05-11 21:15:36 +0000 | [diff] [blame] | 55 | |
| 56 | // Check various single element struct type conditions. |
| 57 | // |
| 58 | // PR7098. |
| 59 | |
| 60 | // CHECK: define i64 @_Z2f0v() |
| 61 | struct s0_0 { int x; }; |
| 62 | struct s0_1 : s0_0 { int* y; }; |
| 63 | s0_1 f0() { return s0_1(); } |
| 64 | |
| 65 | // CHECK: define i32 @_Z2f1v() |
| 66 | struct s1_0 { int x; }; |
| 67 | struct s1_1 : s1_0 { }; |
| 68 | s1_1 f1() { return s1_1(); } |
| 69 | |
| 70 | // CHECK: define double @_Z2f2v() |
| 71 | struct s2_0 { double x; }; |
| 72 | struct s2_1 : s2_0 { }; |
| 73 | s2_1 f2() { return s2_1(); } |
| 74 | |
| 75 | // CHECK: define double @_Z2f3v() |
| 76 | struct s3_0 { }; |
| 77 | struct s3_1 { double x; }; |
| 78 | struct s3_2 : s3_0, s3_1 { }; |
| 79 | s3_2 f3() { return s3_2(); } |
| 80 | |
| 81 | // CHECK: define i64 @_Z2f4v() |
| 82 | struct s4_0 { float x; }; |
| 83 | struct s4_1 { float x; }; |
| 84 | struct s4_2 : s4_0, s4_1 { }; |
| 85 | s4_2 f4() { return s4_2(); } |
Daniel Dunbar | a1842d3 | 2010-05-14 03:40:53 +0000 | [diff] [blame] | 86 | |
| 87 | // CHECK: define i32 @_Z2f5v() |
| 88 | struct s5 { s5(); int &x; }; |
| 89 | s5 f5() { return s5(); } |
Daniel Dunbar | 7711523 | 2010-05-15 00:00:30 +0000 | [diff] [blame^] | 90 | |
| 91 | // CHECK: define i32 @_Z4f6_0M2s6i(i32 %a) |
| 92 | // CHECK: define i64 @_Z4f6_1M2s6FivE(%{{.*}} byval %a) |
| 93 | // FIXME: It would be nice to avoid byval on the previous case. |
| 94 | struct s6 {}; |
| 95 | typedef int s6::* s6_mdp; |
| 96 | typedef int (s6::*s6_mfp)(); |
| 97 | s6_mdp f6_0(s6_mdp a) { return a; } |
| 98 | s6_mfp f6_1(s6_mfp a) { return a; } |