ZarkoT wrote:

I tried a testcase:
~~~
#include <stdio.h>


__attribute__((target_clones("cpu=pwr9", "cpu=pwr7", "cpu=pwr6", "cpu=pwr4", 
"cpu=power8", "default")))
int compute_sum(int *arr, int size) {
    int sum = 0;
    for (int i = 0; i < size; i++) {
        sum += arr[i];
    }
    return sum;
}

int main() {

    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    int sum = compute_sum(arr, 10);

    printf("Sum: %d ", sum);
    return 0;
}
~~~

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?

Also, changing `cpu=` to `tune=` gives the warning which looks correct:
~~~
./llvm/upstream/install/bin/clang -S -emit-llvm -O2 -m64 target_clones.c -o 
target_clones.ll
'+tune=pwr9' is not a recognized feature for this target (ignoring feature)
'+tune=pwr9' is not a recognized feature for this target (ignoring feature)
~~~

But using `arch` instead of `cpu` causes a crash:

~~~
./llvm/upstream/install/bin/clang -S -emit-llvm -O2 -m64 target_clones.c -o 
target_clones.ll
Assertion failed: Info.Features.empty() && "unhandled case", file  
/home/zarko/llvm/upstream/llvm-project/clang/lib/CodeGen/Targets/PPC.cpp, line 
170, virtual void (anonymous 
namespace)::AIXABIInfo::appendAttributeMangling(StringRef, raw_ostream &) 
const()
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: ./llvm/upstream/install/bin/clang -S -emit-llvm -O2 
-m64 target_clones.c -o target_clones.ll
1.      target_clones.c:16:1: current parser token 'int'
2.      target_clones.c:8:5: LLVM IR generation of declaration 'compute_sum'
3.      target_clones.c:8:5: Generating code for declaration 'compute_sum'
clang: error: clang frontend command failed with exit code 134 (use -v to see 
invocation)
clang version 23.0.0git
Target: powerpc64-ibm-aix7.2.0.0
Thread model: posix
InstalledDir: /home/zarko/llvm/upstream/install/bin
Build config: +assertions
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/target_clones-d8a7ed.c
clang: note: diagnostic msg: /tmp/target_clones-d8a7ed.sh
clang: note: diagnostic msg:

********************
~~~

Also, when I check the Function attributes for the cloned functions they look 
correct. Adding some test cases for that would be good. 

https://github.com/llvm/llvm-project/pull/177428
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to