blob: 637a2de42c8fc85e8593d19b255b69033a7e3438 [file] [log] [blame]
Daniel Dunbarc216edb2009-02-05 11:21:33 +00001// 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
16typedef int ScalarTy;
17typedef _Complex int ComplexTy;
18typedef struct { int a, b, c; } AggrTy;
19
20static int result;
21
22static AggrTy aggr_id(AggrTy a) { return a; }
23static ScalarTy scalar_id(ScalarTy a) { return a; }
24static ComplexTy complex_id(ComplexTy a) { return a; }
25
26static void aggr_mul(AggrTy a) { result *= a.a * a.b * a.c; }
27
28static void scalar_mul(ScalarTy a) { result *= a; }
29
30static void complex_mul(ComplexTy a) { result *= __real a * __imag a; }
31
32extern void g0(void);
33
34void 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