From: Rafael Espindola Date: Thu, 13 Nov 2014 22:29:02 +0000 (+0000) Subject: Move calls to push_back out of readAbbreviated(Literal|Field). X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=83e56d6b474d5424a1b3f680e93bb18ed74bee93;p=oota-llvm.git Move calls to push_back out of readAbbreviated(Literal|Field). These functions always return a single value and not all callers want to push them into a SmallVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221934 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bitcode/Reader/BitstreamReader.cpp b/lib/Bitcode/Reader/BitstreamReader.cpp index c88708ce4e8..27bb62f97d4 100644 --- a/lib/Bitcode/Reader/BitstreamReader.cpp +++ b/lib/Bitcode/Reader/BitstreamReader.cpp @@ -50,40 +50,27 @@ bool BitstreamCursor::EnterSubBlock(unsigned BlockID, unsigned *NumWordsP) { return false; } -static void readAbbreviatedLiteral(const BitCodeAbbrevOp &Op, - SmallVectorImpl &Vals) { - assert(Op.isLiteral() && "Not a literal"); - // If the abbrev specifies the literal value to use, use it. - Vals.push_back(Op.getLiteralValue()); -} - -static void readAbbreviatedField(BitstreamCursor &Cursor, - const BitCodeAbbrevOp &Op, - SmallVectorImpl &Vals) { - assert(!Op.isLiteral() && "Use ReadAbbreviatedLiteral for literals!"); +static uint64_t readAbbreviatedField(BitstreamCursor &Cursor, + const BitCodeAbbrevOp &Op) { + assert(!Op.isLiteral() && "Not to be used with literals!"); // Decode the value as we are commanded. - uint64_t Val; switch (Op.getEncoding()) { case BitCodeAbbrevOp::Array: case BitCodeAbbrevOp::Blob: llvm_unreachable("Should not reach here"); case BitCodeAbbrevOp::Fixed: - Val = Cursor.Read((unsigned)Op.getEncodingData()); - break; + return Cursor.Read((unsigned)Op.getEncodingData()); case BitCodeAbbrevOp::VBR: - Val = Cursor.ReadVBR64((unsigned)Op.getEncodingData()); - break; + return Cursor.ReadVBR64((unsigned)Op.getEncodingData()); case BitCodeAbbrevOp::Char6: - Val = BitCodeAbbrevOp::DecodeChar6(Cursor.Read(6)); - break; + return BitCodeAbbrevOp::DecodeChar6(Cursor.Read(6)); } - Vals.push_back(Val); } static void skipAbbreviatedField(BitstreamCursor &Cursor, const BitCodeAbbrevOp &Op) { - assert(!Op.isLiteral() && "Use ReadAbbreviatedLiteral for literals!"); + assert(!Op.isLiteral() && "Not to be used with literals!"); // Decode the value as we are commanded. switch (Op.getEncoding()) { @@ -179,22 +166,22 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID, // Read the record code first. assert(Abbv->getNumOperandInfos() != 0 && "no record code in abbreviation?"); const BitCodeAbbrevOp &CodeOp = Abbv->getOperandInfo(0); + unsigned Code; if (CodeOp.isLiteral()) - readAbbreviatedLiteral(CodeOp, Vals); + Code = CodeOp.getLiteralValue(); else - readAbbreviatedField(*this, CodeOp, Vals); - unsigned Code = (unsigned)Vals.pop_back_val(); + Code = readAbbreviatedField(*this, CodeOp); for (unsigned i = 1, e = Abbv->getNumOperandInfos(); i != e; ++i) { const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); if (Op.isLiteral()) { - readAbbreviatedLiteral(Op, Vals); + Vals.push_back(Op.getLiteralValue()); continue; } if (Op.getEncoding() != BitCodeAbbrevOp::Array && Op.getEncoding() != BitCodeAbbrevOp::Blob) { - readAbbreviatedField(*this, Op, Vals); + Vals.push_back(readAbbreviatedField(*this, Op)); continue; } @@ -208,7 +195,7 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID, // Read all the elements. for (; NumElts; --NumElts) - readAbbreviatedField(*this, EltEnc, Vals); + Vals.push_back(readAbbreviatedField(*this, EltEnc)); continue; }