[clang] [clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation. (PR #193298)

Benjamin Luke via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 23 12:11:19 PDT 2026


freaknbigpanda wrote:

Hi @efriedma-quic I took a look at this today and I noticed that if the AVX level is part of the function type we get type mismatch compiler errors in situations like the following:

`
typedef float v8f __attribute__((vector_size(32)));
__attribute__((target("avx"))) v8f l256(v8f x) { return x; }
__attribute__((target("avx"))) v8f call_ptr_l256(v8f x) {
  v8f (*fp)(v8f) = l256;
  return fp(x);
}
`

`./clang -cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -emit-llvm -disable-llvm-passes ~/dev/test.cpp
/Users/bluke/dev/test.cpp:4:9: error: cannot initialize a variable of type 'v8f (*)(v8f)' with an lvalue of type 'v8f (v8f)'
    4 |   v8f (*fp)(v8f) = l256;
      |         ^          ~~~~
1 error generated.`

This can be solved using `__typeof__(l256) *fp = l256;` but I don't think this is intuitive for the user, we would at least need better diagnostics.

Also in situations like this:

`typedef float v8f __attribute__((vector_size(32)));
__attribute__((target("avx"))) v8f l256(v8f x) { return x; }

v8f call_ptr_l256(v8f x) {
  __typeof__(l256) *fp = l256;
  return fp(x);
}`

It calls l256 using AVX ABI but it actually shouldn't because call_ptr_l256 has no __attribute__((target("avx"))), it should be using the base no-AVX ABI.

What do you think about trying to extend my decl-based approach so that it works for indirect calls?

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


More information about the cfe-commits mailing list