22
33// Test that features requiring FEAT_PAuth fail early if the requirement is not met:
44//
5- // RUN: not %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -mbranch-protection=pauthabi 2>&1 | FileCheck %s --check-prefix=FAIL
6- // RUN: not %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -fptrauth-calls 2>&1 | FileCheck %s --check-prefix=FAIL
7- // RUN: not %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -fptrauth-returns 2>&1 | FileCheck %s --check-prefix=FAIL
8- // RUN: not %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -fptrauth-objc-isa 2>&1 | FileCheck %s --check-prefix=FAIL
5+ // RUN: not %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -mbranch-protection=pauthabi 2>&1 \
6+ // RUN: | FileCheck %s --check-prefixes=FAIL-INTRINSICS,FAIL-CALLS,FAIL-RETURNS,NO-UNEXPECTED
7+ // RUN: not %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -fptrauth-intrinsics 2>&1 \
8+ // RUN: | FileCheck %s --check-prefixes=FAIL-INTRINSICS,NO-UNEXPECTED
9+ // RUN: not %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -fptrauth-calls 2>&1 \
10+ // RUN: | FileCheck %s --check-prefixes=FAIL-CALLS,NO-UNEXPECTED
11+ // RUN: not %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -fptrauth-returns 2>&1 \
12+ // RUN: | FileCheck %s --check-prefixes=FAIL-RETURNS,NO-UNEXPECTED
13+ // RUN: not %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -fptrauth-objc-isa 2>&1 \
14+ // RUN: | FileCheck %s --check-prefixes=FAIL-OBJC-ISA,NO-UNEXPECTED
915//
1016// Test that no errors and warnings are generated if FEAT_PAUTH is supported:
1117// RUN: %clang %s -S -o - -target aarch64-linux-gnu -mcpu=apple-a12 -mbranch-protection=pauthabi 2>&1 \
1723// RUN: %clang %s -S -o - -target aarch64-linux-gnu -march=armv8.2-a+pauth -mbranch-protection=pauthabi 2>&1 \
1824// RUN: | FileCheck %s --check-prefix=PAUTH --implicit-check-not=error --implicit-check-not=warning
1925//
20- // Test a few combinations of options that should not generate warnings (technically, prefix is CHECK):
26+ // Test a few combinations of options that should not generate warnings (technically, the prefix is CHECK):
2127// RUN: %clang %s -S -o - -target aarch64-linux-gnu -march=armv8.3-a -fptrauth-returns 2>&1 \
22- // RUN: | FileCheck %s --allow-unused-prefixes --implicit- check-not=error --implicit-check-not=warning
28+ // RUN: | FileCheck %s --check-prefix=NO-UNEXPECTED
2329// RUN: %clang %s -S -o - -target aarch64-linux-gnu -march=armv8.3-a -fptrauth-objc-isa 2>&1 \
24- // RUN: | FileCheck %s --allow-unused-prefixes --implicit- check-not=error --implicit-check-not=warning
30+ // RUN: | FileCheck %s --check-prefix=NO-UNEXPECTED
2531// RUN: %clang %s -S -o - -target aarch64-linux-gnu -march=armv8.3-a -fptrauth-init-fini -fptrauth-calls 2>&1 \
26- // RUN: | FileCheck %s --allow-unused-prefixes --implicit- check-not=error --implicit-check-not=warning
32+ // RUN: | FileCheck %s --check-prefix=NO-UNEXPECTED
2733// RUN: %clang %s -S -o - -target aarch64-linux-gnu -march=armv8.3-a -fptrauth-init-fini -mbranch-protection=pauthabi 2>&1 \
28- // RUN: | FileCheck %s --allow-unused-prefixes --implicit- check-not=error --implicit-check-not=warning
34+ // RUN: | FileCheck %s --check-prefix=NO-UNEXPECTED
2935
3036// Test that the following options are still gated on -fptrauth-calls.
3137// If they are not, in assertion builds they would usually fail at asm printing time:
3238//
3339// RUN: %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -fptrauth-init-fini 2>&1 \
34- // RUN: | FileCheck %s --check-prefix=WARN -DOPTION=-fptrauth-init-fini
40+ // RUN: | FileCheck %s --check-prefixes=NO-PTRAUTH-CALLS,NO-UNEXPECTED -DOPTION=-fptrauth-init-fini
3541// RUN: %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -fptrauth-function-pointer-type-discrimination 2>&1 \
36- // RUN: | FileCheck %s --check-prefix=WARN -DOPTION=-fptrauth-function-pointer-type-discrimination
42+ // RUN: | FileCheck %s --check-prefixes=NO-PTRAUTH-CALLS,NO-UNEXPECTED -DOPTION=-fptrauth-function-pointer-type-discrimination
3743// RUN: %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -fptrauth-vtable-pointer-address-discrimination 2>&1 \
38- // RUN: | FileCheck %s --check-prefix=WARN -DOPTION=-fptrauth-vtable-pointer-address-discrimination
44+ // RUN: | FileCheck %s --check-prefixes=NO-PTRAUTH-CALLS,NO-UNEXPECTED -DOPTION=-fptrauth-vtable-pointer-address-discrimination
3945// RUN: %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -fptrauth-vtable-pointer-type-discrimination 2>&1 \
40- // RUN: | FileCheck %s --check-prefix=WARN -DOPTION=-fptrauth-vtable-pointer-type-discrimination
46+ // RUN: | FileCheck %s --check-prefixes=NO-PTRAUTH-CALLS,NO-UNEXPECTED -DOPTION=-fptrauth-vtable-pointer-type-discrimination
4147// RUN: %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -fptrauth-block-descriptor-pointers -fblocks -DBLOCKS 2>&1 \
42- // RUN: | FileCheck %s --check-prefix=WARN -DOPTION=-fptrauth-block-descriptor-pointers
48+ // RUN: | FileCheck %s --check-prefixes=NO-PTRAUTH-CALLS,NO-UNEXPECTED -DOPTION=-fptrauth-block-descriptor-pointers
4349
4450// Test that v8.2-compatible code is generated, if possible:
4551//
46- // RUN: %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -msign-return-address=all 2>&1 | FileCheck %s --check-prefix=COMPAT
47- // RUN: %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -mbranch-protection=pac-ret 2>&1 | FileCheck %s --check-prefix=COMPAT
48- // RUN: %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -mbranch-protection=pac-ret+b-key 2>&1 | FileCheck %s --check-prefix=COMPAT
52+ // RUN: %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -msign-return-address=all 2>&1 \
53+ // RUN: | FileCheck %s --check-prefix=COMPAT
54+ // RUN: %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -mbranch-protection=pac-ret 2>&1 \
55+ // RUN: | FileCheck %s --check-prefix=COMPAT
56+ // RUN: %clang %s -S -o - -target aarch64-linux-gnu -mcpu=cortex-a72 -mbranch-protection=pac-ret+b-key 2>&1 \
57+ // RUN: | FileCheck %s --check-prefix=COMPAT
4958
5059// arm64e has ptrauth enabled and assumes modern enough CPU by default:
5160//
52- // RUN: %clang %s -S -o - -target arm64e-apple-ios 2>&1 | FileCheck %s --check-prefix=PAUTH
53- // RUN: not %clang %s -S -o - -target arm64e-apple-ios -mcpu=cortex-a72 2>&1 | FileCheck %s --check-prefix=FAIL
61+ // RUN: %clang %s -S -o - -target arm64e-apple-ios 2>&1 \
62+ // RUN: | FileCheck %s --check-prefix=PAUTH
63+ // RUN: not %clang %s -S -o - -target arm64e-apple-ios -mcpu=cortex-a72 2>&1 \
64+ // RUN: | FileCheck %s --check-prefixes=FAIL-INTRINSICS,FAIL-CALLS,FAIL-RETURNS,FAIL-OBJC-ISA,NO-UNEXPECTED
5465
5566volatile int counter;
5667
5768void ext (void );
5869
5970// Basically check the code generated for `caller`, other functions and classes
60- // are provided just to ensure that assertion-enabled builds do not crash when
71+ // are provided just to check that assertion-enabled builds do not crash when
6172// generating code for constructors, vtable, etc.
6273
6374extern " C" int caller (void ) {
@@ -103,11 +114,13 @@ extern "C" void *create(bool f) {
103114 return new Derived ();
104115}
105116
106- // FIXME At now, the error message is printed twice.
107- // Ideally, this should be fixed, but it seems rather harmless.
108- //
109- // FAIL-COUNT-2: error: neither FEAT_PAUTH nor -fptrauth-soft is enabled. Most of PAuth features are unavailable
110- // WARN-COUNT-2: warning: [[OPTION]] is ignored because neither -fptrauth-calls nor -mbranch-protection=pauthabi is specified
117+ // NO-PTRAUTH-CALLS: warning: [[OPTION]] is ignored because neither -fptrauth-calls nor -mbranch-protection=pauthabi is specified
118+ // FAIL-INTRINSICS: error: -fptrauth-intrinsics or -mbranch-protection=pauthabi is passed that require either enabling PAuth CPU feature or passing -fptrauth-soft option
119+ // FAIL-CALLS: error: -fptrauth-calls or -mbranch-protection=pauthabi is passed that require either enabling PAuth CPU feature or passing -fptrauth-soft option
120+ // FAIL-RETURNS: error: -fptrauth-returns or -mbranch-protection=pauthabi is passed that require either enabling PAuth CPU feature or passing -fptrauth-soft option
121+ // FAIL-OBJC-ISA: error: -fptrauth-objc-isa=... or -mbranch-protection=pauthabi is passed that require either enabling PAuth CPU feature or passing -fptrauth-soft option
122+ // NO-UNEXPECTED-NOT: error:
123+ // NO-UNEXPECTED-NOT: warning:
111124
112125// COMPAT: caller:
113126// COMPAT: hint {{#25|#27}}
@@ -125,8 +138,8 @@ extern "C" void *create(bool f) {
125138// Just check that some assembler output is printed and -fptrauth-init-fini
126139// is disabled.
127140//
128- // WARN -NOT: @AUTH
141+ // NO-PTRAUTH-CALLS -NOT: @AUTH
129142//
130- // WARN : caller:
143+ // NO-PTRAUTH-CALLS : caller:
131144//
132- // WARN -NOT: @AUTH
145+ // NO-PTRAUTH-CALLS -NOT: @AUTH
0 commit comments