[all-commits] [llvm/llvm-project] 8516f5: [AMDGPU] Implement variadic functions by IR loweri...

Jon Chesterfield via All-commits all-commits at lists.llvm.org
Thu Jun 6 02:45:15 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8516f54e6a984a79d1a988ec66a414b5cfbd7ec7
      https://github.com/llvm/llvm-project/commit/8516f54e6a984a79d1a988ec66a414b5cfbd7ec7
  Author: Jon Chesterfield <jonathanchesterfield at gmail.com>
  Date:   2024-06-06 (Thu, 06 Jun 2024)

  Changed paths:
    M clang/lib/CodeGen/Targets/AMDGPU.cpp
    A clang/test/CodeGen/voidptr-vaarg.c
    A clang/test/CodeGenCXX/inline-then-fold-variadics.cpp
    M libc/config/gpu/entrypoints.txt
    M libc/test/src/__support/CMakeLists.txt
    M llvm/include/llvm/IR/InstrTypes.h
    M llvm/include/llvm/InitializePasses.h
    A llvm/include/llvm/Transforms/IPO/ExpandVariadics.h
    M llvm/lib/Passes/PassBuilder.cpp
    M llvm/lib/Passes/PassRegistry.def
    M llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
    M llvm/lib/Transforms/IPO/CMakeLists.txt
    A llvm/lib/Transforms/IPO/ExpandVariadics.cpp
    A llvm/test/CodeGen/AMDGPU/expand-variadic-call.ll
    M llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
    M llvm/test/CodeGen/AMDGPU/unsupported-calls.ll
    A llvm/test/CodeGen/WebAssembly/expand-variadic-call.ll
    A llvm/test/CodeGen/WebAssembly/vararg-frame.ll
    A llvm/test/Transforms/ExpandVariadics/expand-va-intrinsic-split-linkage.ll
    A llvm/test/Transforms/ExpandVariadics/expand-va-intrinsic-split-simple.ll
    A llvm/test/Transforms/ExpandVariadics/indirect-calls.ll
    A llvm/test/Transforms/ExpandVariadics/intrinsics.ll
    A llvm/test/Transforms/ExpandVariadics/invoke.ll
    A llvm/test/Transforms/ExpandVariadics/pass-byval-byref.ll
    A llvm/test/Transforms/ExpandVariadics/pass-indirect.ll
    A llvm/test/Transforms/ExpandVariadics/pass-integers.ll

  Log Message:
  -----------
  [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.



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