This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Fix integer overflow affecting array size calculation.
ClosedPublic

Authored by tra on Mar 23 2023, 3:29 PM.

Details

Summary

It turns out, 4GB+ large arrays are a thing and a 32-bit integer is just not
enough to handle them.

Diff Detail

Event Timeline

tra created this revision.Mar 23 2023, 3:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 3:29 PM
tra published this revision for review.Mar 23 2023, 3:32 PM
tra added a reviewer: yaxunl.
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 3:32 PM

Please don't use size_t to represent anything other than the size of a buffer allocated by the compiler itself; LLVM supports 32-bit hosts. We generally use uint64_t for the size of LLVM IR types.

tra updated this revision to Diff 507914.Mar 23 2023, 4:13 PM

Use uint64_t instead of size_t.

tra added a comment.Mar 23 2023, 4:13 PM

Please don't use size_t to represent anything other than the size of a buffer allocated by the compiler itself; LLVM supports 32-bit hosts. We generally use uint64_t for the size of LLVM IR types.

Good point. Fixed.

yaxunl accepted this revision.Mar 24 2023, 5:53 AM

LGTM.

This revision is now accepted and ready to land.Mar 24 2023, 5:53 AM