Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / parameter-passing.c
blob40610af9d7d09a2fee43558bc7399ccf0f34fd4e
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 // We also check _Bool and empty structures, as these can have annoying
6 // corner cases.
8 // RUN: %clang_cc1 %s -triple i386-unknown-unknown -O3 -emit-llvm -o - | FileCheck %s
9 // RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -O3 -emit-llvm -o - | FileCheck %s
10 // RUN: %clang_cc1 %s -triple powerpc-unknown-unknown -O3 -emit-llvm -o - | FileCheck %s
11 // CHECK-NOT: @g0
13 typedef _Bool BoolTy;
14 typedef int ScalarTy;
15 typedef _Complex int ComplexTy;
16 typedef struct { int a, b, c; } AggrTy;
17 typedef struct { int a[0]; } EmptyTy;
19 static int result;
21 static BoolTy bool_id(BoolTy a) { return a; }
22 static AggrTy aggr_id(AggrTy a) { return a; }
23 static EmptyTy empty_id(EmptyTy a) { return a; }
24 static ScalarTy scalar_id(ScalarTy a) { return a; }
25 static ComplexTy complex_id(ComplexTy a) { return a; }
27 static void bool_mul(BoolTy a) { result *= a; }
29 static void aggr_mul(AggrTy a) { result *= a.a * a.b * a.c; }
31 static void empty_mul(EmptyTy a) { result *= 53; }
33 static void scalar_mul(ScalarTy a) { result *= a; }
35 static void complex_mul(ComplexTy a) { result *= __real a * __imag a; }
37 extern void g0(void);
39 void f0(void) {
40 result = 1;
42 bool_mul(bool_id(1));
43 aggr_mul(aggr_id((AggrTy) { 2, 3, 5}));
44 empty_mul(empty_id((EmptyTy) {}));
45 scalar_mul(scalar_id(7));
46 complex_mul(complex_id(11 + 13i));
48 // This call should be eliminated.
49 if (result != 2 * 3 * 5 * 7 * 11 * 13 * 53)
50 g0();