Skip to content

Commit f7257bb

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

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,9 @@ 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. We handle the last byte separately, so we never
1856+
// request out of bounds bits.
18541857
for (unsigned I = 0; I < NumBytes - 1; ++I) {
18551858
Buf[I] = Val.extractBitsAsZExtValue(8, I * 8);
18561859
}

0 commit comments

Comments
 (0)