diff options
author | Joseph Huber <huberjn@outlook.com> | 2024-07-12 17:09:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-12 17:09:48 -0500 |
commit | 486d00eca6b6ab470e8324b52cdf9f32023c1c9a (patch) | |
tree | d434eff08d64639fd3f20ca15e7d7d440a5aa331 /llvm/lib/CodeGen/MachineSink.cpp | |
parent | 2ad7b4af95bc333d8f216915cd1b9d688590dcc5 (diff) | |
download | llvm-486d00eca6b6ab470e8324b52cdf9f32023c1c9a.zip llvm-486d00eca6b6ab470e8324b52cdf9f32023c1c9a.tar.gz llvm-486d00eca6b6ab470e8324b52cdf9f32023c1c9a.tar.bz2 |
[NVPTX] Implement variadic functions using IR lowering (#96015)
Summary:
This patch implements support for variadic functions for NVPTX targets.
The implementation here mainly follows what was done to implement it for
AMDGPU in https://github.com/llvm/llvm-project/pull/93362.
We change the NVPTX codegen to lower all variadic arguments to functions
by-value. This creates a flattened set of arguments that the IR lowering
pass converts into a struct with the proper alignment.
The behavior of this function was determined by iteratively checking
what the NVCC copmiler generates for its output. See examples like
https://godbolt.org/z/KavfTGY93. I have noted the main methods that
NVIDIA uses to lower variadic functions.
1. All arguments are passed in a pointer to aggregate.
2. The minimum alignment for a plain argument is 4 bytes.
3. Alignment is dictated by the underlying type
4. Structs are flattened and do not have their alignment changed.
5. NVPTX never passes any arguments indirectly, even very large ones.
This patch passes the tests in the `libc` project currently, including
support for `sprintf`.
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
0 files changed, 0 insertions, 0 deletions