This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Fix integer overflow for alloca arrays
Needs ReviewPublic

Authored by AlexM on Apr 8 2023, 10:40 AM.

Details

Reviewers
tra
yaxunl
Summary

Similar to D146767

Diff Detail

Event Timeline

AlexM created this revision.Apr 8 2023, 10:40 AM
AlexM published this revision for review.Apr 8 2023, 10:52 AM
AlexM added a reviewer: yaxunl.
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2023, 10:53 AM
tra added inline comments.Apr 27 2023, 12:13 PM
llvm/test/CodeGen/NVPTX/local-variable-big.ll
9

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.