[clang] [llvm] [AArch64] set AppleA14 architecture version to v8.5-a (PR #92600)

Tomas Matheson via cfe-commits cfe-commits at lists.llvm.org
Mon May 20 10:05:15 PDT 2024


tmatheson-arm wrote:

Thanks @AtariDreams for pointing that out. They do both seem to be "8.5 without BTI". I had a look at what current versions of clang/llvm do in this regard:

Current builds of clang set `__ARM_FEATURE_BTI` for these processors:
```
$ clang-19 ~/hello.c --target=aarch64 -march=armv8.4-a -E -dM -o - | rg __ARM_FEATURE_BTI

$ clang-19 ~/hello.c --target=aarch64 -march=armv8.5-a -E -dM -o - | rg __ARM_FEATURE_BTI
#define __ARM_FEATURE_BTI 1

$ clang-19 ~/hello.c --target=aarch64 -mcpu=apple-a14 -E -dM -o - | rg __ARM_FEATURE_BTI
#define __ARM_FEATURE_BTI 1

$ clang-19 ~/hello.c --target=aarch64 -mcpu=apple-m1 -E -dM -o - | rg __ARM_FEATURE_BTI
#define __ARM_FEATURE_BTI 1
```

They will also disassemble BTI instructions (rather than outputting "hint"):
```
$ clang-19 ~/hello.c --target=aarch64 -march=armv8.4-a -S -o - -mbranch-protection=pac-ret+bti | rg '(bti|hint)'
	hint	#34
$ clang-19 ~/hello.c --target=aarch64 -march=armv8.5-a -S -o - -mbranch-protection=pac-ret+bti | rg '(bti|hint)'
	bti	c
$ clang-19 ~/hello.c --target=aarch64 -mcpu=apple-a14 -S -o - -mbranch-protection=pac-ret+bti | rg '(bti|hint)'
	bti	c
$ clang-19 ~/hello.c --target=aarch64 -mcpu=apple-m1 -S -o - -mbranch-protection=pac-ret+bti | rg '(bti|hint)'
	bti	c
```

I don't think either of those is correct. Unfortunately in the backend we can't model negative features, so the best thing to do might be to model them as `armv8.4-a` and manually add all of the `8.5-a` `SubtargetFeature`s except for BTI. I have updated the PR to do that.

https://github.com/llvm/llvm-project/pull/92600


More information about the cfe-commits mailing list