mirror-llvm-project/clang/test/CodeGen/target-avx-function-abi.c
Benjamin Luke 315c8bba65
Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349)
https://github.com/llvm/llvm-project/pull/193298 was reverted because of
a compile time regression (see results
[here](https://llvm-compile-time-tracker.com/compare.php?from=b9869c8c920a7dfa983e215bc30729b13d8b353b&to=464b46a73b7592c95222cf2e64b34ffe6f2cf251&stat=instructions:u))

I added a conditional statement so that getFunctionFeatureMap and the
subsequent string lookup is only called if FD->hasAttr<TargetAttr>()
evaluates to true which should be very rare.

---------

Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
2026-07-21 09:04:03 -07:00

71 lines
2.8 KiB
C

// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=SYSV
// RUN: %clang_cc1 -triple x86_64-scei-ps4 -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=PS
// RUN: %clang_cc1 -triple x86_64-sie-ps5 -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=PS
typedef float v8f __attribute__((vector_size(32)));
typedef float v16f __attribute__((vector_size(64)));
v8f g256(v8f x) { return x; }
v16f g512(v16f x) { return x; }
__attribute__((target("avx"))) v8f l256(v8f x) { return x; }
__attribute__((target("avx512f"))) v16f l512(v16f x) { return x; }
__attribute__((target("avx"))) v8f call_l256(v8f x) { return l256(x); }
__attribute__((target("avx512f"))) v16f call_l512(v16f x) { return l512(x); }
__attribute__((target("avx"))) v8f call_ptr_l256(v8f x) {
v8f (*fp)(v8f) = l256;
return fp(x);
}
__attribute__((target("avx512f"))) v16f call_ptr_l512(v16f x) {
v16f (*fp)(v16f) = l512;
return fp(x);
}
// SYSV-LABEL: define dso_local <8 x float> @g256(
// SYSV: byval(<8 x float>) align 32
// SYSV-LABEL: define dso_local <16 x float> @g512(
// SYSV: byval(<16 x float>) align 64
// SYSV-LABEL: define dso_local <8 x float> @l256(<8 x float> noundef %x)
// SYSV-LABEL: define dso_local <16 x float> @l512(<16 x float> noundef %x)
// SYSV-LABEL: define dso_local <8 x float> @call_l256(<8 x float> noundef %x)
// SYSV: call <8 x float> @l256(<8 x float> noundef
// SYSV-LABEL: define dso_local <16 x float> @call_l512(<16 x float> noundef %x)
// SYSV: call <16 x float> @l512(<16 x float> noundef
// SYSV-LABEL: define dso_local <8 x float> @call_ptr_l256(<8 x float> noundef %x)
// SYSV: call <8 x float> %{{.*}}(<8 x float> noundef
// SYSV-LABEL: define dso_local <16 x float> @call_ptr_l512(<16 x float> noundef %x)
// SYSV: call <16 x float> %{{.*}}(<16 x float> noundef
// PlayStation keeps the legacy ABI which always returns AVX vectors in registers & only uses AVX level from module/TU level even with AVX target attributes.
// PS-LABEL: define dso_local <8 x float> @g256(
// PS: byval(<8 x float>) align 32
// PS-LABEL: define dso_local <16 x float> @g512(
// PS: byval(<16 x float>) align 64
// PS-LABEL: define dso_local <8 x float> @l256(
// PS: byval(<8 x float>) align 32
// PS-LABEL: define dso_local <16 x float> @l512(
// PS: byval(<16 x float>) align 64
// PS-LABEL: define dso_local <8 x float> @call_l256(
// PS: call <8 x float> @l256(ptr noundef byval(<8 x float>) align 32
// PS-LABEL: define dso_local <16 x float> @call_l512(
// PS: call <16 x float> @l512(ptr noundef byval(<16 x float>) align 64
// PS-LABEL: define dso_local <8 x float> @call_ptr_l256(
// PS: call <8 x float> %{{.*}}(ptr noundef byval(<8 x float>) align 32
// PS-LABEL: define dso_local <16 x float> @call_ptr_l512(
// PS: call <16 x float> %{{.*}}(ptr noundef byval(<16 x float>) align 64