llvm-project/clang/test/Frontend/arm-ignore-branch-protection-option.c
Daniel Kiss b0343a38a5 Support the min of module flags when linking, use for AArch64 BTI/PAC-RET
LTO objects might compiled with different `mbranch-protection` flags which will cause an error in the linker.
Such a setup is allowed in the normal build with this change that is possible.

Reviewed By: pcc

Differential Revision: https://reviews.llvm.org/D123493
2022-04-13 09:31:51 +02:00

19 lines
829 B
C

// REQUIRES: arm-registered-target
/// Check warning for
// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -mbranch-protection=bti %s -S -emit-llvm -o - 2>&1 | FileCheck %s
__attribute__((target("arch=cortex-m0"))) void f() {}
// CHECK: warning: ignoring the 'branch-protection' attribute because the 'cortex-m0' architecture does not support it [-Wbranch-protection]
// CHECK-NEXT: __attribute__((target("arch=cortex-m0"))) void f() {}
/// 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"
/// Check that there are branch protection module attributes despite the warning.
// CHECK: !{i32 8, !"branch-target-enforcement", i32 1}