Skip to content

Commit d2809a8

Browse files
committed
Explain partial byte extraction logic.
This is a follow-up to #92506.
1 parent 566431c commit d2809a8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,10 @@ void NVPTXAsmPrinter::bufferLEByte(const Constant *CPV, int Bytes,
18511851
auto AddIntToBuffer = [AggBuffer, Bytes](const APInt &Val) {
18521852
size_t NumBytes = (Val.getBitWidth() + 7) / 8;
18531853
SmallVector<unsigned char, 16> Buf(NumBytes);
1854+
// `extractBitsAsZExtValue` does not allow the extraction of bits beyond the
1855+
// input's bit width, and i1 arrays may not have a length that is a multuple
1856+
// of 8. We handle the last byte separately, so we never request out of
1857+
// bounds bits.
18541858
for (unsigned I = 0; I < NumBytes - 1; ++I) {
18551859
Buf[I] = Val.extractBitsAsZExtValue(8, I * 8);
18561860
}

0 commit comments

Comments
 (0)