From: Jordan Rose Date: Fri, 10 May 2013 22:17:10 +0000 (+0000) Subject: Micro-optimization: don't shift an entire bitcode record over to get the code. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=1197e38f3338b8db76f0fa38c2687c65b2bcea5c Micro-optimization: don't shift an entire bitcode record over to get the code. Previously, BitstreamCursor read an abbreviated record by splatting the whole thing into a data vector, then extracting and removing the /first/ element. Now, it reads the first element--the record code--separately from the actual field values. No (intended) functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181639 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bitcode/Reader/BitstreamReader.cpp b/lib/Bitcode/Reader/BitstreamReader.cpp index 9dafe2a0367..1fd9abd8b18 100644 --- a/lib/Bitcode/Reader/BitstreamReader.cpp +++ b/lib/Bitcode/Reader/BitstreamReader.cpp @@ -204,7 +204,16 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID, const BitCodeAbbrev *Abbv = getAbbrev(AbbrevID); - for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) { + // Read the record code first. + assert(Abbv->getNumOperandInfos() != 0 && "no record code in abbreviation?"); + const BitCodeAbbrevOp &CodeOp = Abbv->getOperandInfo(0); + if (CodeOp.isLiteral()) + readAbbreviatedLiteral(CodeOp, Vals); + else + readAbbreviatedField(CodeOp, Vals); + unsigned Code = (unsigned)Vals.pop_back_val(); + + for (unsigned i = 1, e = Abbv->getNumOperandInfos(); i != e; ++i) { const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); if (Op.isLiteral()) { readAbbreviatedLiteral(Op, Vals); @@ -264,8 +273,6 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID, JumpToBit(NewEnd); } - unsigned Code = (unsigned)Vals[0]; - Vals.erase(Vals.begin()); return Code; }