xref: /llvm-project/clang/test/CodeGen/AArch64/fixed-register-global.c (revision a6b5e18fc6fa0e8d9bf10020e8f6070951630d42)
1 /// Check that -ffixed register handled for globals.
2 /// Regression test for #76426, #109778
3 // REQUIRES: aarch64-registered-target
4 
5 // RUN: %clang -c --target=aarch64-none-gnu -ffixed-x15 %s -o /dev/null 2>&1 | count 0
6 
7 // RUN: not %clang -c --target=aarch64-none-gnu %s -o /dev/null 2>&1 | \
8 // RUN:   FileCheck %s --check-prefix=ERR_INVREG
9 // ERR_INVREG: error: register 'x15' unsuitable for global register variables on this target
10 
11 // RUN: not %clang -c --target=aarch64-none-gnu -ffixed-x15 -DTYPE=short %s -o /dev/null 2>&1 | \
12 // RUN:   FileCheck %s --check-prefix=ERR_SIZE
13 // ERR_SIZE: error: size of register 'x15' does not match variable size
14 
15 #ifndef TYPE
16 #define TYPE long
17 #endif
18 
19 register TYPE x15 __asm__("x15");
20 
21 TYPE foo() {
22   return x15;
23 }
24