
Branch protection in M-class is supported by - Armv8.1-M.Main - Armv8-M.Main - Armv7-M Attempting to enable this for other architectures, either by command-line (e.g -mbranch-protection=bti) or by target attribute in source code (e.g. __attribute__((target("branch-protection=..."))) ) will generate a warning. In both cases function attributes related to branch protection will not be emitted. Regardless of the warning, module level attributes related to branch protection will be emitted when it is enabled via the command-line. The following people also contributed to this patch: - Victor Campos Reviewed By: chill Differential Revision: https://reviews.llvm.org/D115501
28 lines
1.5 KiB
C
28 lines
1.5 KiB
C
// REQUIRES: arm-registered-target
|
|
|
|
/// Check warning for
|
|
// RUN: %clang -target arm-arm-none-eabi %s -S -o - 2>&1 | FileCheck %s
|
|
|
|
__attribute__((target("branch-protection=bti"))) void f1() {}
|
|
__attribute__((target("branch-protection=pac-ret"))) void f2() {}
|
|
__attribute__((target("branch-protection=bti+pac-ret"))) void f3() {}
|
|
__attribute__((target("branch-protection=bti+pac-ret+leaf"))) void f4() {}
|
|
|
|
// CHECK: warning: unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored [-Wignored-attributes]
|
|
// CHECK-NEXT: __attribute__((target("branch-protection=bti"))) void f1() {}
|
|
|
|
// CHECK: warning: unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored [-Wignored-attributes]
|
|
// CHECK-NEXT: __attribute__((target("branch-protection=pac-ret"))) void f2() {}
|
|
|
|
// CHECK: warning: unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored [-Wignored-attributes]
|
|
// CHECK-NEXT: __attribute__((target("branch-protection=bti+pac-ret"))) void f3() {}
|
|
|
|
// CHECK: warning: unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored [-Wignored-attributes]
|
|
// CHECK-NEXT: __attribute__((target("branch-protection=bti+pac-ret+leaf"))) void f4() {}
|
|
|
|
/// Check there are no branch protection function attributes
|
|
|
|
// CHECK-NOT: attributes { {{.*}} "sign-return-address"
|
|
// CHECK-NOT: attributes { {{.*}} "sign-return-address-key"
|
|
// CHECK-NOT: attributes { {{.*}} "branch-target-enforcement"
|