[all-commits] [llvm/llvm-project] 486d00: [NVPTX] Implement variadic functions using IR lowe...
Joseph Huber via All-commits
all-commits at lists.llvm.org
Fri Jul 12 15:10:10 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 486d00eca6b6ab470e8324b52cdf9f32023c1c9a
https://github.com/llvm/llvm-project/commit/486d00eca6b6ab470e8324b52cdf9f32023c1c9a
Author: Joseph Huber <huberjn at outlook.com>
Date: 2024-07-12 (Fri, 12 Jul 2024)
Changed paths:
M clang/lib/Basic/Targets/NVPTX.h
M clang/lib/CodeGen/Targets/NVPTX.cpp
A clang/test/CodeGen/variadic-nvptx.c
M libc/config/gpu/entrypoints.txt
M libc/test/src/__support/CMakeLists.txt
M llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
M llvm/lib/Transforms/IPO/ExpandVariadics.cpp
A llvm/test/CodeGen/NVPTX/variadics-backend.ll
A llvm/test/CodeGen/NVPTX/variadics-lowering.ll
Log Message:
-----------
[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`.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list