summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-05-10 22:17:10 +0000
committerJordan Rose <jordan_rose@apple.com>2013-05-10 22:17:10 +0000
commit6ac4ba23fdfc3ea91e21372b73a4f6e2f3410a39 (patch)
tree45f58c3b18a82139e288e558aef0469e730971dc /llvm/lib/Bitcode
parent940e80502e5746e0cc6342990c5d1f2e42cf1612 (diff)
downloadbcm5719-llvm-6ac4ba23fdfc3ea91e21372b73a4f6e2f3410a39.tar.gz
bcm5719-llvm-6ac4ba23fdfc3ea91e21372b73a4f6e2f3410a39.zip
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. llvm-svn: 181639
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r--llvm/lib/Bitcode/Reader/BitstreamReader.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
index 9dafe2a0367..1fd9abd8b18 100644
--- a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
+++ b/llvm/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;
}
OpenPOWER on IntegriCloud