Daniel Dunbar | c216edb | 2009-02-05 11:21:33 +0000 | [diff] [blame] | 1 | // Check the various ways in which the three classes of values |
| 2 | // (scalar, complex, aggregate) interact with parameter passing |
| 3 | // (function entry, function return, call argument, call result). |
| 4 | |
| 5 | // RUN: clang %s -triple i386-unknown-unknown -O3 -emit-llvm -o %t && |
| 6 | // RUN: not grep '@g0' %t && |
| 7 | |
| 8 | // FIXME: Enable once PR3489 is fixed. |
| 9 | // RUNX: clang %s -triple x86_64-unknown-unknown -O3 -emit-llvm -o %t && |
| 10 | // RUNX: not grep '@g0' %t && |
| 11 | |
| 12 | // RUN: clang %s -triple ppc-unknown-unknown -O3 -emit-llvm -o %t && |
| 13 | // RUN: not grep '@g0' %t && |
| 14 | // RUN: true |
| 15 | |
| 16 | typedef int ScalarTy; |
| 17 | typedef _Complex int ComplexTy; |
| 18 | typedef struct { int a, b, c; } AggrTy; |
| 19 | |
| 20 | static int result; |
| 21 | |
| 22 | static AggrTy aggr_id(AggrTy a) { return a; } |
| 23 | static ScalarTy scalar_id(ScalarTy a) { return a; } |
| 24 | static ComplexTy complex_id(ComplexTy a) { return a; } |
| 25 | |
| 26 | static void aggr_mul(AggrTy a) { result *= a.a * a.b * a.c; } |
| 27 | |
| 28 | static void scalar_mul(ScalarTy a) { result *= a; } |
| 29 | |
| 30 | static void complex_mul(ComplexTy a) { result *= __real a * __imag a; } |
| 31 | |
| 32 | extern void g0(void); |
| 33 | |
| 34 | void f0(void) { |
| 35 | result = 1; |
| 36 | |
| 37 | aggr_mul(aggr_id((AggrTy) { 2, 3, 5})); |
| 38 | scalar_mul(scalar_id(7)); |
| 39 | complex_mul(complex_id(11 + 13i)); |
| 40 | |
| 41 | // This call should be eliminated. |
| 42 | if (result != 30030) |
| 43 | g0(); |
| 44 | } |
| 45 | |