Home | History | Annotate | Download | only in CodeGen
      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 i32 %{{.*}} 7
     15     // AAPCS: and i32 %{{.*}} -8
     16     // APCS-GNU-NOT: add i32 %{{.*}} 7
     17     // APCS-GNU-NOT: and i32 %{{.*}} -8
     18     long long ll = __builtin_va_arg(ap, long long);
     19     __builtin_va_end(ap);
     20     return ll;
     21 }
     22 double t2(int i, ...) {
     23     // AAPCS: t2
     24     // APCS-GNU: t2
     25     __builtin_va_list ap;
     26     __builtin_va_start(ap, i);
     27     // AAPCS: add i32 %{{.*}} 7
     28     // AAPCS: and i32 %{{.*}} -8
     29     // APCS-GNU-NOT: add i32 %{{.*}} 7
     30     // APCS-GNU-NOT: and i32 %{{.*}} -8
     31     double ll = __builtin_va_arg(ap, double);
     32     __builtin_va_end(ap);
     33     return ll;
     34 }
     35