aboutsummaryrefslogtreecommitdiff
path: root/libc/test
diff options
context:
space:
mode:
authorJon Chesterfield <jonathanchesterfield@gmail.com>2024-06-06 10:44:53 +0100
committerGitHub <noreply@github.com>2024-06-06 10:44:53 +0100
commit8516f54e6a984a79d1a988ec66a414b5cfbd7ec7 (patch)
treedcd1274861ca10fecc1256f91fe53cad4950bea8 /libc/test
parent4c6dd70ec4fb7491eb59e3efa6d3080499a15d4d (diff)
downloadllvm-8516f54e6a984a79d1a988ec66a414b5cfbd7ec7.zip
llvm-8516f54e6a984a79d1a988ec66a414b5cfbd7ec7.tar.gz
llvm-8516f54e6a984a79d1a988ec66a414b5cfbd7ec7.tar.bz2
[AMDGPU] Implement variadic functions by IR lowering (#93362)
This is a mostly-target-independent variadic function optimisation and lowering pass. It is only enabled for AMDGPU in this initial commit. The purpose is to make C style variadic functions a zero cost abstraction. They are lowered to equivalent IR which is then amenable to other optimisations. This is inherently slightly target specific but much less so than one might expect - the C varargs interface heavily constrains the ABI design divergence. The pass is primarily tested from webassembly. This is because wasm has a straightforward variadic lowering strategy which coincides exactly with what this pass transforms code into and a struct passing convention with few cases to check. Adding further targets conventions is straightforward and elided from this patch primarily to simplify the review. Implemented in other branches are Linux X86, AMD64, AArch64 and NVPTX. Testing for targets that have existing lowering for va_arg from clang is most efficiently done by checking that clang | opt completely elides the variadic syntax from test cases. The lowering produces a struct for each call site which can be inspected to check the various alignment and indirections are correct. AMDGPU presently has no variadic support other than some ad hoc printf handling. Combined with the pass being inactive on all other targets landing this represents strict increase in capability with zero risk. Testing and refining will continue post commit. In addition to the compiler tests included here, a self contained x64 clang/musl toolchain was constructed using the "lowering" instead of the systemv ABI and used to build various C programs like lua and libxml2.
Diffstat (limited to 'libc/test')
-rw-r--r--libc/test/src/__support/CMakeLists.txt4
1 files changed, 2 insertions, 2 deletions
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 663aa2b..5afc417 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -86,8 +86,8 @@ add_libc_test(
libc.src.__support.uint128
)
-# The GPU does not support varargs currently.
-if(NOT LIBC_TARGET_OS_IS_GPU)
+# NVPTX does not support varargs currently.
+if(NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
add_libc_test(
arg_list_test
SUITE