Skip to content

Commit

Permalink
Encode bitwidth once for ConstantRangeList kind attr
Browse files Browse the repository at this point in the history
  • Loading branch information
haopliu committed May 9, 2024
1 parent e52fd9d commit 8e64fa9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2344,13 +2344,14 @@ Error BitcodeReader::parseAttributeGroupBlock() {

SmallVector<ConstantRange, 2> Val;
unsigned RangeSize = Record[++i];
unsigned BitWidth = Record[++i];
if (i + 2 * RangeSize >= e)
return error("Incomplete constant range list");
for (unsigned Idx = 0; Idx < RangeSize; ++Idx) {
int64_t Start = BitcodeReader::decodeSignRotatedValue(Record[++i]);
int64_t End = BitcodeReader::decodeSignRotatedValue(Record[++i]);
Val.push_back(
ConstantRange(APInt(64, Start, true), APInt(64, End, true)));
Val.push_back(ConstantRange(APInt(BitWidth, Start, true),
APInt(BitWidth, End, true)));
}
B.addConstantRangeListAttr(Kind, Val);
} else {
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ void ModuleBitcodeWriter::writeAttributeGroupTable() {
Record.push_back(getAttrKindEncoding(Attr.getKindAsEnum()));
ArrayRef<ConstantRange> Val = Attr.getValueAsConstantRangeList();
Record.push_back(Val.size());
Record.push_back(Val[0].getBitWidth());
for (auto &CR : Val) {
emitConstantRange(Record, CR, /*EmitBitWidth=*/false);
}
Expand Down

0 comments on commit 8e64fa9

Please sign in to comment.