[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / arm-vaarg-align.c
blob410c1ebd5d1469408418308113ad06141a0588e6
1 // REQUIRES: arm-registered-target
2 // RUN: %clang_cc1 -triple arm -target-abi aapcs %s -emit-llvm -o - | FileCheck -check-prefix=AAPCS %s
3 // RUN: %clang_cc1 -triple arm -target-abi apcs-gnu %s -emit-llvm -o - | FileCheck -check-prefix=APCS-GNU %s
4 /*
5 * Check that va_arg accesses stack according to ABI alignment
6 * long long and double require 8-byte alignment under AAPCS
7 * however, they only require 4-byte alignment under APCS
8 */
9 long long t1(int i, ...) {
10 // AAPCS: t1
11 // APCS-GNU: t1
12 __builtin_va_list ap;
13 __builtin_va_start(ap, i);
14 // AAPCS: [[ADD:%.*]] = getelementptr inbounds i8, ptr %argp.cur, i32 7
15 // AAPCS = call ptr @llvm.ptrmask.p0.i32(ptr [[ADD]], i32 -8)
17 // APCS-GNU-NOT: getelementptr {{.*}}, i32 7
18 // APCS-GNU-NOT: llvm.ptrmask.p0
19 long long ll = __builtin_va_arg(ap, long long);
20 __builtin_va_end(ap);
21 return ll;
23 double t2(int i, ...) {
24 // AAPCS: t2
25 // APCS-GNU: t2
26 __builtin_va_list ap;
27 __builtin_va_start(ap, i);
28 // AAPCS: [[ADD:%.*]] = getelementptr inbounds i8, ptr %argp.cur, i32 7
29 // AAPCS = call ptr @llvm.ptrmask.p0.i32(ptr [[ADD]], i32 -8)
31 // APCS-GNU-NOT: getelementptr {{.*}}, i32 7
32 // APCS-GNU-NOT: llvm.ptrmask.p0
33 double ll = __builtin_va_arg(ap, double);
34 __builtin_va_end(ap);
35 return ll;