/// 2. It could be an encoding specification ("this operand encoded like so").
///
class BitCodeAbbrevOp {
- uint64_t Val; // A literal value or data for an encoding.
- bool IsLiteral : 1; // Indicate whether this is a literal value or not.
- unsigned Enc : 3; // The encoding to use.
+ uint64_t Val; // A literal value or data for an encoding.
+ bool IsLiteral : 1; // Indicate whether this is a literal value or not.
+ unsigned Enc : 3; // The encoding to use.
public:
enum Encoding {
FixedWidth = 1, // A fixed with field, Val specifies number of bits.
class BitCodeAbbrev {
SmallVector<BitCodeAbbrevOp, 8> OperandList;
+ unsigned char RefCount; // Number of things using this.
+ ~BitCodeAbbrev() {}
public:
+ BitCodeAbbrev() : RefCount(1) {}
+ void addRef() { ++RefCount; }
+ void dropRef() { if (--RefCount == 0) delete this; }
+
unsigned getNumOperandInfos() const { return OperandList.size(); }
const BitCodeAbbrevOp &getOperandInfo(unsigned N) const {
return OperandList[N];
// Abbrevs could still exist if the stream was broken. If so, don't leak
// them.
for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
- delete CurAbbrevs[i];
+ CurAbbrevs[i]->dropRef();
for (unsigned S = 0, e = BlockScope.size(); S != e; ++S) {
std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs;
for (unsigned i = 0, e = Abbrevs.size(); i != e; ++i)
- delete Abbrevs[i];
+ Abbrevs[i]->dropRef();
}
}
// Delete abbrevs from popped scope.
for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
- delete CurAbbrevs[i];
+ CurAbbrevs[i]->dropRef();
BlockScope.back().PrevAbbrevs.swap(CurAbbrevs);
BlockScope.pop_back();