summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [LLVM] Fix some Clang-tidy modernize-use-using and Include What You Use warningsEugene Zelenko2016-08-181-5/+4
| | | | | | Differential revision: https://reviews.llvm.org/D23675 llvm-svn: 279102
* Support: Implement StreamingMemoryObject::getPointerDuncan P. N. Exon Smith2016-03-271-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation is fairly obvious. This is preparation for using some blobs in bitcode. For clarity (and perhaps future-proofing?), I moved the call to JumpToBit in BitstreamCursor::readRecord ahead of calling MemoryObject::getPointer, since JumpToBit can theoretically (a) read bytes, which (b) invalidates the blob pointer. This isn't strictly necessary the two memory objects we have: - The return of RawMemoryObject::getPointer is valid until the memory object is destroyed. - StreamingMemoryObject::getPointer is valid until the next chunk is read from the stream. Since the JumpToBit call is only going ahead to a word boundary, we'll never load another chunk. However, reordering makes it clear by inspection that the blob returned by BitstreamCursor::readRecord will be valid. I added some tests for StreamingMemoryObject::getPointer and BitstreamCursor::readRecord. llvm-svn: 264549
* Bitcode: Add SimpleBitstreamCursor::getPointerToByte, etc.Duncan P. N. Exon Smith2016-03-271-3/+1
| | | | | | | | | | | | | | | Add API to SimpleBitstreamCursor to allow users to translate between byte addresses and pointers. - jumpToPointer: move the bit position to a particular pointer. - getPointerToByte: get the pointer for a particular byte. - getPointerToBit: get the pointer for the byte of the current bit. - getCurrentByteNo: convenience function for assertions and tests. Mainly adds unit tests (getPointerToBit/Byte already has a use), but also preparation for eventually using jumpToPointer. llvm-svn: 264546
* Bitcode: Split out SimpleBitstreamCursorDuncan P. N. Exon Smith2016-03-271-9/+13
| | | | | | | | | | | Split out SimpleBitstreamCursor from BitstreamCursor, which is a lower-level cursor with no knowledge of bitcode blocks, abbreviations, or records. It just knows how to read bits and navigate the stream. This is mainly organizational, to separate the API for manipulating raw bits from that for bitcode concepts like Record and Block. llvm-svn: 264545
* Revert "Bitcode: Collect all MDString records into a single blob"Duncan P. N. Exon Smith2016-03-251-4/+2
| | | | | | | This reverts commit r264409 since it failed to bootstrap: http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_build/8302/ llvm-svn: 264410
* Bitcode: Collect all MDString records into a single blobDuncan P. N. Exon Smith2016-03-251-2/+4
| | | | | | | | | | | | | | | | | | | | | | | Optimize output of MDStrings in bitcode. This emits them in big blocks (currently 1024) in a pair of records: - BULK_STRING_SIZES: the sizes of the strings in the block, and - BULK_STRING_DATA: a single blob, which is the concatenation of all the strings. Inspired by Mehdi's similar patch, http://reviews.llvm.org/D18342, this should (a) slightly reduce bitcode size, since there is less record overhead, and (b) greatly improve reading speed, since blobs are super cheap to deserialize. I needed to add support for blobs to streaming input to get the test suite passing. - StreamingMemoryObject::getPointer reads ahead and returns the address of the blob. - To avoid a possible reallocation of StreamingMemoryObject::Bytes, BitstreamCursor::readRecord needs to move the call to JumpToEnd forward so that getPointer is the last bitstream operation. llvm-svn: 264409
* Bitcode reader: Inline readAbbreviatedField in readRecord and move the ↵Mehdi Amini2016-03-071-7/+34
| | | | | | | | | | | | | | | enclosing loop in each case (NFC) Summary: This make readRecord 20% faster, measured on an LTO build Reviewers: rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17911 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 262811
* [BitstreamReader] Make sure the Array operand type is an encodingFilipe Cabecinhas2015-05-271-0/+3
| | | | | | Bug found with AFL fuzz. llvm-svn: 238269
* clang-format a couple of linesFilipe Cabecinhas2015-05-271-2/+2
| | | | llvm-svn: 238268
* [BitcodeReader] Make sure abbrev records have at least one operand (record code)Filipe Cabecinhas2015-05-261-0/+3
| | | | | | Bug found with AFL fuzz. llvm-svn: 238265
* Simplify boolean conditional return statements.Rafael Espindola2015-05-251-4/+1
| | | | | | Patch by Richard <legalize@xmission.com> llvm-svn: 238134
* [BitcodeReader] It's a malformed block if CodeLenWidth is too bigFilipe Cabecinhas2015-05-191-0/+4
| | | | | | Bug found with AFL fuzz. llvm-svn: 237646
* Turn an assert into report_fatal_error since it's reachable based on user inputFilipe Cabecinhas2015-04-291-1/+2
| | | | | | Bug found with AFL fuzz. llvm-svn: 236076
* Be more strict about the operand for the array type in BitcodeReaderFilipe Cabecinhas2015-04-231-0/+3
| | | | | | | | | | | | Summary: Bug found with AFL fuzz. Reviewers: rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9016 llvm-svn: 235596
* Verify sizes when trying to read a BitcodeAbbrevOpFilipe Cabecinhas2015-04-231-0/+9
| | | | | | | | | | | | | | | | Summary: Make sure the abbrev operands are valid and that we can read/skip them afterwards. Bug found with AFL fuzz. Reviewers: rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9030 llvm-svn: 235595
* Revert "Verify sizes when trying to read a VBR"Filipe Cabecinhas2015-04-151-2/+0
| | | | | | | This reverts r234984 since it seems to break some bots (most of them seemed arm*-selfhost). llvm-svn: 234998
* Verify sizes when trying to read a VBRFilipe Cabecinhas2015-04-151-0/+2
| | | | | | Also added an assert to ReadVBR64. llvm-svn: 234984
* Simplify expressions involving boolean constants with clang-tidyDavid Blaikie2015-03-091-1/+1
| | | | | | | | Patch by Richard (legalize at xmission dot com). Differential Revision: http://reviews.llvm.org/D8154 llvm-svn: 231617
* Clean up some inappropriate choices of type in the bitcode reader. None ofRichard Smith2015-02-131-1/+1
| | | | | | these are expected to fix any 64->32 bit real truncation issues. llvm-svn: 229153
* [Bitcode] Diagnose errors instead of asserting from bad inputFilipe Cabecinhas2015-01-241-1/+5
| | | | | | | | | | | | | | | Eventually we can make some of these pass the error along to the caller. Reports a fatal error if: We find an invalid abbrev record We try to get an invalid abbrev number We can't fill the current word due to an EOF Fixed an invalid bitcode test to check for output with FileCheck Bugs found with afl-fuzz llvm-svn: 226986
* Silence MSVC warning on missing return after fully covered switchReid Kleckner2014-11-131-0/+1
| | | | llvm-svn: 221943
* Move calls to push_back out of readAbbreviated(Literal|Field).Rafael Espindola2014-11-131-26/+13
| | | | | | | These functions always return a single value and not all callers want to push them into a SmallVector. llvm-svn: 221934
* Make a few helper functions static. NFC.Rafael Espindola2014-11-131-16/+18
| | | | llvm-svn: 221930
* Factor out call to push_back. NFC.Rafael Espindola2014-11-061-3/+5
| | | | llvm-svn: 221490
* Use IntrusiveRefCntPtr to manage the lifetime of BitCodeAbbrevs.Benjamin Kramer2014-09-151-36/+3
| | | | | | | | | This doesn't change the interface or gives additional safety but removes a ton of retain/release boilerplate. No functionality change. llvm-svn: 217778
* Replace some assert(0)'s with llvm_unreachable.Craig Topper2014-06-181-2/+2
| | | | llvm-svn: 211141
* [C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper2014-04-151-1/+1
| | | | | | instead of comparing to nullptr. llvm-svn: 206252
* Micro-optimization: don't shift an entire bitcode record over to get the code.Jordan Rose2013-05-101-3/+10
| | | | | | | | | | | 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
* Whitespace cleanupJoe Abbey2013-04-011-1/+1
| | | | llvm-svn: 178454
* Simplify code. No functionality change.Jakub Staszak2013-02-191-14/+7
| | | | llvm-svn: 175501
* Fix the underlying problem that was causing read(0) to be called: sometimes theChris Lattner2013-02-091-3/+14
| | | | | | | | | | | | | | | bitcode writer would generate abbrev records saying that the abbrev should be filled with fixed zero-bit bitfields (this happens in the .bc writer when the number of types used in a module is exactly one, since log2(1) == 0). In this case, just handle it as a literal zero. We can't "just fix" the writer without breaking compatibility with existing bc files, so have the abbrev reader do the substitution. Strengthen the assert in read to reject reads of zero bits so we catch such crimes in the future, and remove the special case designed to handle this. llvm-svn: 174801
* Code Custodian (trivial whitespace cleanup)Joe Abbey2013-02-061-39/+38
| | | | llvm-svn: 174550
* Fix a heinous inefficiency introduced in r149918, wherein reading each byte of aChris Lattner2013-01-211-9/+8
| | | | | | | | 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
* wean Blob handling logic off of banging on NextChar directly. Instead, makeChris Lattner2013-01-211-10/+13
| | | | | | | it reason about the current bit position, which is always independent of the underlying cursors word size. llvm-svn: 173063
* rename "SkipToWord" to "SkipToFourByteBoundary" since a word is not always 4 ↵Chris Lattner2013-01-211-3/+3
| | | | | | bytes. llvm-svn: 173062
* convert the bitstream reader itself and the IR .bc file parser to use the ↵Chris Lattner2013-01-201-10/+14
| | | | | | | | new advance() APIs, simplifying things and making a bunch of details more private to BitstreamCursor. llvm-svn: 172947
* stringref'ize readRecord and properly capitalize it. Add a compatibility ↵Chris Lattner2013-01-201-6/+7
| | | | | | | | method to easy the transition. llvm-svn: 172940
* move some private methods out of line, add a skipRecord() method.Chris Lattner2013-01-201-3/+111
| | | | llvm-svn: 172931
* Add a new BitstreamEntry concept, and add two helper methods for walkingChris Lattner2013-01-191-1/+1
| | | | | | | | through a BitstreamCursor that produce it: advance() and advanceSkippingSubblocks(), representing the two most common ways clients want to walk through bitcode. llvm-svn: 172919
* BitstreamReader hasn't aged well. It's been hacked on by various people andChris Lattner2013-01-191-0/+253
has past the point of making sense. Lets tidy things up: first step, moving a ton of big functions out of line. llvm-svn: 172904
OpenPOWER on IntegriCloud