39 lines · c
1// REQUIRES: arm-registered-target2// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -S -emit-llvm -o - -mbranch-protection=none %s | FileCheck %s --check-prefix=CHECK --check-prefix=NONE3// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -S -emit-llvm -o - -mbranch-protection=pac-ret %s | FileCheck %s --check-prefix=CHECK --check-prefix=PART4// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -S -emit-llvm -o - -mbranch-protection=pac-ret+leaf %s | FileCheck %s --check-prefix=CHECK --check-prefix=ALL5// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -S -emit-llvm -o - -mbranch-protection=pac-ret+b-key %s | FileCheck %s --check-prefix=CHECK --check-prefix=PART6// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -S -emit-llvm -o - -mbranch-protection=bti %s | FileCheck %s --check-prefix=CHECK --check-prefix=BTE7 8// Check there are branch protection function attributes9 10// CHECK-LABEL: @foo() #[[#ATTR:]]11 12// NONE-NOT: attributes #[[#ATTR]] = { {{.*}} "sign-return-address"13// NONE-NOT: attributes #[[#ATTR]] = { {{.*}} "sign-return-address-key"14// NONE-NOT: attributes #[[#ATTR]] = { {{.*}} "branch-target-enforcement"15 16// ALL: attributes #[[#ATTR]] = { {{.*}} "sign-return-address"="all"17// PART: attributes #[[#ATTR]] = { {{.*}} "sign-return-address"="non-leaf"18// BTE: attributes #[[#ATTR]] = { {{.*}} "branch-target-enforcement"19 20 21// Check module attributes22 23// NONE-NOT: !"branch-target-enforcement"24// PART-NOT: !"branch-target-enforcement"25// ALL-NOT: !"branch-target-enforcement"26// BTE: !{i32 8, !"branch-target-enforcement", i32 2}27 28// NONE-NOT: !"sign-return-address"29// PART: !{i32 8, !"sign-return-address", i32 2}30// ALL: !{i32 8, !"sign-return-address", i32 2}31// BTE-NOT: !"sign-return-address"32 33// NONE-NOT: !"sign-return-address-all", i32 0}34// PART-NOT: !"sign-return-address-all", i32 0}35// ALL: !{i32 8, !"sign-return-address-all", i32 2}36// BTE-NOT: !"sign-return-address-all", i32 0}37 38void foo() {}39