[llvm] Fix i1 array global crash in NVPTXAsmPrinter. (PR #92506)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Sun May 19 15:54:18 PDT 2024
================
@@ -1847,9 +1847,13 @@ void NVPTXAsmPrinter::bufferLEByte(const Constant *CPV, int Bytes,
auto AddIntToBuffer = [AggBuffer, Bytes](const APInt &Val) {
size_t NumBytes = (Val.getBitWidth() + 7) / 8;
SmallVector<unsigned char, 16> Buf(NumBytes);
- for (unsigned I = 0; I < NumBytes; ++I) {
+ for (unsigned I = 0; I < NumBytes - 1; ++I) {
----------------
Artem-B wrote:
PR description only shows the expression for the failed assertion: `bitPosition < BitWidth && (numBits + bitPosition) <= BitWidth`, but it was not clear which part of that assertion has failed.
The substance of the fix LGTM.
That said, If I ever need to look at this code in the future, I'm pretty sure I'll have to scratch my head, again, pondering what's going on here. Hence, my suggestion that a comment would be helpful. We already have way too many puzzles, we do not need more.
https://github.com/llvm/llvm-project/pull/92506
More information about the llvm-commits
mailing list