Nick Sarnie e4c30c15c8
[SPIRV] Extend lowering of variadic functions (#178980)
Variadic function lowering for SPIR-V was initially added in
https://github.com/llvm/llvm-project/pull/175076.

However, I tried a full OpenMP offloading example that includes a vararg
call and hit a few issues:

1) The OpenMP Deivce library function `ompx::printf` was incorrectly
being considered a builtin `printf` function that would be handled
specifically by the SPIR-V backend.

The fix here is to remove the `printf` special handling.

2) We were getting an assert in ModuleVerifier saying the LLVM lifetime
intrinsics were being called with an argument that was neither an
`alloca` ptr or `poison`. The problem is the `alloca` was replaced with
a SPIR-V intrinsic `alloca` in `SPIRVPrepareFunctions`, but the lifetime
intrinsic added in `ExpandVariadics` was not lowered to the SPIR-V
lifetime intrinsic since `ExpandVariadics` is run after
`SPIRVPrepareFunctions`,

The fix here is to just run `ExpandVariadics` first.

3) There were `va` intrinsics taking in a `addrspace(4)` pointer that
were not being expanded.

The fix here is to extend `ExpandVariadics` to support expanding `va`
intrinsics with target-specific address spaces.

---------

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
Co-authored-by: Joseph Huber <huberjn@outlook.com>
2026-02-13 18:22:25 +00:00
..