[PATCH] D147854: [NVPTX] Fix integer overflow for alloca arrays

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 27 12:13:14 PDT 2023


tra added inline comments.


================
Comment at: llvm/test/CodeGen/NVPTX/local-variable-big.ll:9
+;
+; CHECK: .local .align 1 .b8 	__local_depot0[4831838208];
+;
----------------
Such a large allocation will certainly cause all sorts of other issues -- we can't allocate that much on a GPU, as it would have to be done for thousands of threads simultaneously.
Also the stack register on NVIDIA GPUs is 32-bit.

PTXAS will accept large values, but appears to overflow internally, so the SASS it produces is broken. With valies more than 2GB (signed overflow?) it does not allocate anything on stack at all. With larger valies NVCC just crashes. https://godbolt.org/z/En716v36P

Ideally we should error out and tell the user that we can't produce sensible code for values that do not fit in 31 bits. 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147854/new/

https://reviews.llvm.org/D147854



More information about the llvm-commits mailing list