[PATCH] D115140: [ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

2021-12-09 Thread Ties Stuij via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbfe07195bb1f: [ARM][clang] Option b-key must not affect 
__ARM_FEATURE_PAC_DEFAULT (authored by stuij).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115140/new/

https://reviews.llvm.org/D115140

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/arm-target-features.c


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
 // CHECK-NOBTI-NOT: #define __ARM_FEATURE_BTI_DEFAULT
 // CHECK-NOPAC-NOT: #define __ARM_FEATURE_PAC_DEFAULT
 // CHECK-BTI: #define __ARM_FEATURE_BTI_DEFAULT 1
 // CHECK-PAC: #define __ARM_FEATURE_PAC_DEFAULT 1
-// CHECK-PAC-BKEY: #define __ARM_FEATURE_PAC_DEFAULT 2
 // CHECK-PAC-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 5
-// CHECK-PAC-BKEY-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 6
 
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI-EXT,CHECK-NOPAC-EXT %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv7-m+pacbti -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-PACBTI-EXT %s
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -911,7 +911,7 @@
 Builder.defineMacro("__ARM_FEATURE_BTI_DEFAULT", "1");
 
   if (Opts.hasSignReturnAddress()) {
-unsigned Value = Opts.isSignReturnAddressWithAKey() ? 1 : 2;
+unsigned Value = 1;
 if (Opts.isSignReturnAddressScopeAll())
   Value |= 1 << 2;
 Builder.defineMacro("__ARM_FEATURE_PAC_DEFAULT", Twine(Value));


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbranch-protection=bti -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbranch-protection=pac-ret -x c -E -dM %s -o - | 

[PATCH] D115140: [ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

2021-12-09 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 393096.
stuij added a comment.

rebasing


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115140/new/

https://reviews.llvm.org/D115140

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/arm-target-features.c


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
 // CHECK-NOBTI-NOT: #define __ARM_FEATURE_BTI_DEFAULT
 // CHECK-NOPAC-NOT: #define __ARM_FEATURE_PAC_DEFAULT
 // CHECK-BTI: #define __ARM_FEATURE_BTI_DEFAULT 1
 // CHECK-PAC: #define __ARM_FEATURE_PAC_DEFAULT 1
-// CHECK-PAC-BKEY: #define __ARM_FEATURE_PAC_DEFAULT 2
 // CHECK-PAC-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 5
-// CHECK-PAC-BKEY-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 6
 
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI-EXT,CHECK-NOPAC-EXT %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv7-m+pacbti -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-PACBTI-EXT %s
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -911,7 +911,7 @@
 Builder.defineMacro("__ARM_FEATURE_BTI_DEFAULT", "1");
 
   if (Opts.hasSignReturnAddress()) {
-unsigned Value = Opts.isSignReturnAddressWithAKey() ? 1 : 2;
+unsigned Value = 1;
 if (Opts.isSignReturnAddressScopeAll())
   Value |= 1 << 2;
 Builder.defineMacro("__ARM_FEATURE_PAC_DEFAULT", Twine(Value));


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbranch-protection=bti -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 

[PATCH] D115140: [ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

2021-12-07 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss accepted this revision.
danielkiss added a comment.
This revision is now accepted and ready to land.

In D115140#3176800 , @stuij wrote:

> @danielkiss Yes that needs to be addressed, but we are doing that in another 
> patch that will (hopefully) cover all permutations of architecture and branch 
> protection values on both the cmdline and as function attributes.

sound good, Thanks!

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115140/new/

https://reviews.llvm.org/D115140

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115140: [ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

2021-12-07 Thread Ties Stuij via Phabricator via cfe-commits
stuij added a comment.

@danielkiss Yes that needs to be addressed, but we are doing that in another 
patch that will (hopefully) cover all permutations of architecture and branch 
protection values on both the cmdline and as function attributes.

So this patch is just about not having logic in the ARM code that shouldn't be 
there.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115140/new/

https://reviews.llvm.org/D115140

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115140: [ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

2021-12-06 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added a comment.

I think rejecting\warning the `b-key` from the command line maybe a more 
developer friendly way.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115140/new/

https://reviews.llvm.org/D115140

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115140: [ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

2021-12-06 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 392021.
stuij added a comment.

another tickle


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115140/new/

https://reviews.llvm.org/D115140

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/arm-target-features.c


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
 // CHECK-NOBTI-NOT: #define __ARM_FEATURE_BTI_DEFAULT
 // CHECK-NOPAC-NOT: #define __ARM_FEATURE_PAC_DEFAULT
 // CHECK-BTI: #define __ARM_FEATURE_BTI_DEFAULT 1
 // CHECK-PAC: #define __ARM_FEATURE_PAC_DEFAULT 1
-// CHECK-PAC-BKEY: #define __ARM_FEATURE_PAC_DEFAULT 2
 // CHECK-PAC-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 5
-// CHECK-PAC-BKEY-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 6
 
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI-EXT,CHECK-NOPAC-EXT %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv7-m+pacbti -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-PACBTI-EXT %s
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -911,7 +911,7 @@
 Builder.defineMacro("__ARM_FEATURE_BTI_DEFAULT", "1");
 
   if (Opts.hasSignReturnAddress()) {
-unsigned Value = Opts.isSignReturnAddressWithAKey() ? 1 : 2;
+unsigned Value = 1;
 if (Opts.isSignReturnAddressScopeAll())
   Value |= 1 << 2;
 Builder.defineMacro("__ARM_FEATURE_PAC_DEFAULT", Twine(Value));


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbranch-protection=bti -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 

[PATCH] D115140: [ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

2021-12-06 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 392013.
stuij added a comment.

tickling the commit so the buildbot picks up the dependency


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115140/new/

https://reviews.llvm.org/D115140

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/arm-target-features.c


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
 // CHECK-NOBTI-NOT: #define __ARM_FEATURE_BTI_DEFAULT
 // CHECK-NOPAC-NOT: #define __ARM_FEATURE_PAC_DEFAULT
 // CHECK-BTI: #define __ARM_FEATURE_BTI_DEFAULT 1
 // CHECK-PAC: #define __ARM_FEATURE_PAC_DEFAULT 1
-// CHECK-PAC-BKEY: #define __ARM_FEATURE_PAC_DEFAULT 2
 // CHECK-PAC-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 5
-// CHECK-PAC-BKEY-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 6
 
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI-EXT,CHECK-NOPAC-EXT %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv7-m+pacbti -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-PACBTI-EXT %s
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -911,7 +911,7 @@
 Builder.defineMacro("__ARM_FEATURE_BTI_DEFAULT", "1");
 
   if (Opts.hasSignReturnAddress()) {
-unsigned Value = Opts.isSignReturnAddressWithAKey() ? 1 : 2;
+unsigned Value = 1;
 if (Opts.isSignReturnAddressScopeAll())
   Value |= 1 << 2;
 Builder.defineMacro("__ARM_FEATURE_PAC_DEFAULT", Twine(Value));


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbranch-protection=bti -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang 

[PATCH] D115140: [ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

2021-12-06 Thread Ties Stuij via Phabricator via cfe-commits
stuij created this revision.
Herald added a subscriber: kristof.beyls.
stuij requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When using -mbranch-protection=pac-ret+b-key, macro __ARM_FEATURE_PAC_DEFAULT
should still have the value corresponding to a-key, because b-key is only valid
for AArch64.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

The following people contributed to this patch:

- Victor Campos


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115140

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/arm-target-features.c


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
 // CHECK-NOBTI-NOT: #define __ARM_FEATURE_BTI_DEFAULT
 // CHECK-NOPAC-NOT: #define __ARM_FEATURE_PAC_DEFAULT
 // CHECK-BTI: #define __ARM_FEATURE_BTI_DEFAULT 1
 // CHECK-PAC: #define __ARM_FEATURE_PAC_DEFAULT 1
-// CHECK-PAC-BKEY: #define __ARM_FEATURE_PAC_DEFAULT 2
 // CHECK-PAC-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 5
-// CHECK-PAC-BKEY-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 6
 
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI-EXT,CHECK-NOPAC-EXT %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv7-m+pacbti -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-PACBTI-EXT %s
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -911,7 +911,7 @@
 Builder.defineMacro("__ARM_FEATURE_BTI_DEFAULT", "1");
 
   if (Opts.hasSignReturnAddress()) {
-unsigned Value = Opts.isSignReturnAddressWithAKey() ? 1 : 2;
+unsigned Value = 1;
 if (Opts.isSignReturnAddressScopeAll())
   Value |= 1 << 2;
 Builder.defineMacro("__ARM_FEATURE_PAC_DEFAULT", Twine(Value));


Index: clang/test/Preprocessor/arm-target-features.c