]> git.ipfire.org Git - thirdparty/gcc.git/commit
nvptx: Support '-mfake-ptx-alloca'
authorThomas Schwinge <tschwinge@baylibre.com>
Mon, 24 Feb 2025 15:13:11 +0000 (16:13 +0100)
committerThomas Schwinge <tschwinge@baylibre.com>
Thu, 27 Feb 2025 20:48:15 +0000 (21:48 +0100)
commit1146410c0feb0e82c689b1333fdf530a2b34dc2b
tree4016d7fb1339de238efc794e0ed6e999bb610193
parent22e76700aea63eb8c298403bb2e717a6a4fc9c1e
nvptx: Support '-mfake-ptx-alloca'

With '-mfake-ptx-alloca' enabled, the user-visible behavior changes only
for configurations where PTX 'alloca' is not available.  Rather than a
compile-time 'sorry, unimplemented: dynamic stack allocation not supported'
in presence of dynamic stack allocation, compilation and assembly then
succeeds.  However, attempting to link in such '*.o' files then fails due
to unresolved symbol '__GCC_nvptx__PTX_alloca_not_supported'.

This is meant to be used in scenarios where large volumes of code are
compiled, a small fraction of which runs into dynamic stack allocation, but
these parts are not important for specific use cases, and we'd thus like the
build to succeed, and error out just upon actual, very rare use of the
offending '*.o' files.

gcc/
* config/nvptx/nvptx.opt (-mfake-ptx-alloca): New.
* config/nvptx/nvptx-protos.h (nvptx_output_fake_ptx_alloca):
Declare.
* config/nvptx/nvptx.cc (nvptx_output_fake_ptx_alloca): New.
* config/nvptx/nvptx.md (define_insn "@nvptx_alloca_<mode>")
[!(TARGET_PTX_7_3 && TARGET_SM52)]: Use it for
'-mfake-ptx-alloca'.
gcc/testsuite/
* gcc.target/nvptx/alloca-1-O0_-mfake-ptx-alloca.c: New.
* gcc.target/nvptx/alloca-2-O0_-mfake-ptx-alloca.c: Likewise.
* gcc.target/nvptx/alloca-4-O3_-mfake-ptx-alloca.c: Likewise.
* gcc.target/nvptx/vla-1-O0_-mfake-ptx-alloca.c: Likewise.
* gcc.target/nvptx/alloca-4-O3.c:
'dg-additional-options -mfake-ptx-alloca'.
gcc/config/nvptx/nvptx-protos.h
gcc/config/nvptx/nvptx.cc
gcc/config/nvptx/nvptx.md
gcc/config/nvptx/nvptx.opt
gcc/testsuite/gcc.target/nvptx/alloca-1-O0_-mfake-ptx-alloca.c [new file with mode: 0644]
gcc/testsuite/gcc.target/nvptx/alloca-2-O0_-mfake-ptx-alloca.c [new file with mode: 0644]
gcc/testsuite/gcc.target/nvptx/alloca-4-O3.c
gcc/testsuite/gcc.target/nvptx/alloca-4-O3_-mfake-ptx-alloca.c [new file with mode: 0644]
gcc/testsuite/gcc.target/nvptx/vla-1-O0_-mfake-ptx-alloca.c [new file with mode: 0644]