[clang] [FMV][AIX] Implement target_clones (PR #177428)

Wael Yehia via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 6 10:47:54 PST 2026


w2yehia wrote:

> It doesn't look like we create a clone for pwr6 and pwr4. Those are no longer supported so it makes sense but is it a good idea to add a follow on PR to warn that using those won't do anything?

In my build of this PR, I see the clones:
```
clang --target=powerpc-ibm-aix-xcoff tt.c -emit-llvm -S -o -|grep "define.*cpu"
define internal i32 @compute_sum.cpu_pwr9(ptr noundef %arr, i32 noundef %size) #0 {
define internal i32 @compute_sum.cpu_pwr7(ptr noundef %arr, i32 noundef %size) #1 {
define internal i32 @compute_sum.cpu_pwr6(ptr noundef %arr, i32 noundef %size) #2 {
define internal i32 @compute_sum.cpu_pwr4(ptr noundef %arr, i32 noundef %size) #3 {
define internal i32 @compute_sum.cpu_pwr8(ptr noundef %arr, i32 noundef %size) #4 {
```

> But using arch instead of cpu causes a crash:

We don't support the `-march` flag on AIX, neither does GCC:
```
> clang tt.c -march=power7
clang: error: unsupported option '-march=' for target 'powerpc64le-unknown-linux-gnu'
> clang --target=powerpc-ibm-aix-xcoff tt.c -march=power7
clang: error: unsupported option '-march=' for target 'powerpc-ibm-aix-xcoff'
> gcc -c -march=power7 tt.c
gcc: error: unrecognized command-line option "-march=power7" did you mean "-mcpu=power7"?
```
but we shouldn't crash, I'll make the FE error on "arch=<cpu>" in the target_clones.
GCC errors too:
```
$ gcc -c tt.c
tt.c:5:5: error: __attribute__((__target__("arch=power9"))) is invalid
    5 | int compute_sum(int *arr, int size) {
      |     ^~~~~~~~~~~
```

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


More information about the cfe-commits mailing list