Skip to content

Commit bfa8150

Browse files
authored
Explain partial byte extraction logic. (#92868)
This is a follow-up to #92506.
1 parent 34033dc commit bfa8150

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
@@ -1845,6 +1845,10 @@ void NVPTXAsmPrinter::bufferLEByte(const Constant *CPV, int Bytes,
18451845
auto AddIntToBuffer = [AggBuffer, Bytes](const APInt &Val) {
18461846
size_t NumBytes = (Val.getBitWidth() + 7) / 8;
18471847
SmallVector<unsigned char, 16> Buf(NumBytes);
1848+
// `extractBitsAsZExtValue` does not allow the extraction of bits beyond the
1849+
// input's bit width, and i1 arrays may not have a length that is a multuple
1850+
// of 8. We handle the last byte separately, so we never request out of
1851+
// bounds bits.
18481852
for (unsigned I = 0; I < NumBytes - 1; ++I) {
18491853
Buf[I] = Val.extractBitsAsZExtValue(8, I * 8);
18501854
}

0 commit comments

Comments
 (0)