diff options
author | Chris Lattner <sabre@nondot.org> | 2013-01-21 18:24:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2013-01-21 18:24:49 +0000 |
commit | 1aeca1e8069ac5ff6c4e6ba35e7e1550d760461e (patch) | |
tree | 1c0e6ceae49cf6c0fd1cbc6c932c3f4f3b1aba3b /llvm/lib/Bitcode/Reader/BitstreamReader.cpp | |
parent | 3e3194f4ece2261b9b90d967793a1dd19281693e (diff) | |
download | bcm5719-llvm-1aeca1e8069ac5ff6c4e6ba35e7e1550d760461e.tar.gz bcm5719-llvm-1aeca1e8069ac5ff6c4e6ba35e7e1550d760461e.zip |
Fix a heinous inefficiency introduced in r149918, wherein reading each byte of a
BLOB (i.e., large, performance intensive data) in a bitcode file was switched to
invoking one virtual method call per byte read. Now we do one virtual call per
BLOB.
llvm-svn: 173065
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitstreamReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitstreamReader.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp index 92133bb969c..7984512b4b2 100644 --- a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp @@ -255,18 +255,17 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID, break; } - // Otherwise, read the number of bytes. If we can return a reference to - // the data, do so to avoid copying it. + // Otherwise, inform the streamer that we need these bytes in memory. + const char *Ptr = (const char*) + BitStream->getBitcodeBytes().getPointer(CurBitPos/8, NumElts); + + // If we can return a reference to the data, do so to avoid copying it. if (Blob) { - *Blob = - StringRef((const char*)BitStream->getBitcodeBytes().getPointer( - CurBitPos/8, NumElts), - NumElts); + *Blob = StringRef(Ptr, NumElts); } else { - // FIXME: This is a brutally inefficient way to do this. Why isn't this - // just using getPointer? + // Otherwise, unpack into Vals with zero extension. for (; NumElts; --NumElts) - Vals.push_back(Read(8)); + Vals.push_back((unsigned char)*Ptr++); } // Skip over tail padding. JumpToBit(NewEnd); |