summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Bitcode
Commit message (Collapse)AuthorAgeFilesLines
* Add AutoUpgrade function to add new address space datalayout string to ↵Amy Huang2019-09-182-0/+60
| | | | | | | | | | | | | | | | | | | | | | existing datalayouts. Summary: Add function to AutoUpgrade to change the datalayout of old X86 datalayout strings. This adds "-p270:32:32-p271:32:32-p272:64:64" to X86 datalayouts that are otherwise valid and don't already contain it. This also removes the compatibility changes in https://reviews.llvm.org/D66843. Datalayout change in https://reviews.llvm.org/D64931. Reviewers: rnk, echristo Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67631 llvm-svn: 372267
* [Bitcode] Move Bitstream to a separate libraryFrancis Visoiu Mistrih2019-07-033-227/+0
| | | | | | | | | | | | | | | | | | | | | | | | | This moves Bitcode/Bitstream*, Bitcode/BitCodes.h to Bitstream/. This is needed to avoid a circular dependency when using the bitstream code for parsing optimization remarks. Since Bitcode uses Core for the IR part: libLLVMRemarks -> Bitcode -> Core and Core uses libLLVMRemarks to generate remarks (see IR/RemarkStreamer.cpp): Core -> libLLVMRemarks we need to separate the Bitstream and Bitcode part. For clang-doc, it seems that it doesn't need the whole bitcode layer, so I updated the CMake to only use the bitstream part. Differential Revision: https://reviews.llvm.org/D63899 llvm-svn: 365091
* BitStream reader: propagate errorsJF Bastien2019-06-261-11/+25
| | | | | | | | | | | | | | | | | | | | | | The bitstream reader handles errors poorly. This has two effects: * Bugs in file handling (especially modules) manifest as an "unexpected end of file" crash * Users of clang as a library end up aborting because the code unconditionally calls `report_fatal_error` The bitstream reader should be more resilient and return Expected / Error as soon as an error is encountered, not way late like it does now. This patch starts doing so and adopting the error handling where I think it makes sense. There's plenty more to do: this patch propagates errors to be minimally useful, and follow-ups will propagate them further and improve diagnostics. https://bugs.llvm.org/show_bug.cgi?id=42311 <rdar://problem/33159405> Differential Revision: https://reviews.llvm.org/D63518 llvm-svn: 364464
* Replace llvm::isPodLike<...> by llvm::is_trivially_copyable<...>Serge Guelton2019-01-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As noted in https://bugs.llvm.org/show_bug.cgi?id=36651, the specialization for isPodLike<std::pair<...>> did not match the expectation of std::is_trivially_copyable which makes the memcpy optimization invalid. This patch renames the llvm::isPodLike trait into llvm::is_trivially_copyable. Unfortunately std::is_trivially_copyable is not portable across compiler / STL versions. So a portable version is provided too. Note that the following specialization were invalid: std::pair<T0, T1> llvm::Optional<T> Tests have been added to assert that former specialization are respected by the standard usage of llvm::is_trivially_copyable, and that when a decent version of std::is_trivially_copyable is available, llvm::is_trivially_copyable is compared to std::is_trivially_copyable. As of this patch, llvm::Optional is no longer considered trivially copyable, even if T is. This is to be fixed in a later patch, as it has impact on a long-running bug (see r347004) Note that GCC warns about this UB, but this got silented by https://reviews.llvm.org/D50296. Differential Revision: https://reviews.llvm.org/D54472 llvm-svn: 351701
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-193-12/+9
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Pass a reference to a module to the bitcode writer.Rafael Espindola2018-02-141-1/+1
| | | | | | | This simplifies most callers as they are already using references or std::unique_ptr. llvm-svn: 325155
* Remove redundant includes from unittests.Michael Zolotukhin2017-12-131-4/+0
| | | | llvm-svn: 320630
* Re-sort #include lines for unittests. This uses a slightly modifiedChandler Carruth2017-06-062-2/+2
| | | | | | | | | | | | | | | clang-format (https://reviews.llvm.org/D33932) to keep primary headers at the top and handle new utility headers like 'gmock' consistently with other utility headers. No other change was made. I did no manual edits, all of this is clang-format. This should allow other changes to have more clear and focused diffs, and is especially motivated by moving some headers into more focused libraries. llvm-svn: 304786
* Reapply "Make BitCodeAbbrev ownership explicit using shared_ptr rather than ↵David Blaikie2017-01-041-2/+2
| | | | | | | | | | | | | | | | | IntrusiveRefCntPtr"" If this is a problem for anyone (shared_ptr is two pointers in size, whereas IntrusiveRefCntPtr is 1 - and the ref count control block that make_shared adds is probably larger than the one int in RefCountedBase) I'd prefer to address this by adding a lower-overhead version of shared_ptr (possibly refactoring IntrusiveRefCntPtr into such a thing) to avoid the intrusiveness - this allows memory ownership to remain orthogonal to types and at least to me, seems to make code easier to understand (since no implicit ownership acquisition can happen). This recommits 291006, reverted in r291007. llvm-svn: 291016
* Revert "Make BitCodeAbbrev ownership explicit using shared_ptr rather than ↵David Blaikie2017-01-041-2/+2
| | | | | | | | | | | IntrusiveRefCntPtr" Breaks Clang's use of bitcode. Reverting until I have a fix to go with it there. This reverts commit r291006. llvm-svn: 291007
* Make BitCodeAbbrev ownership explicit using shared_ptr rather than ↵David Blaikie2017-01-041-2/+2
| | | | | | | | | | | | | | | IntrusiveRefCntPtr If this is a problem for anyone (shared_ptr is two pointers in size, whereas IntrusiveRefCntPtr is 1 - and the ref count control block that make_shared adds is probably larger than the one int in RefCountedBase) I'd prefer to address this by adding a lower-overhead version of shared_ptr (possibly refactoring IntrusiveRefCntPtr into such a thing) to avoid the intrusiveness - this allows memory ownership to remain orthogonal to types and at least to me, seems to make code easier to understand (since no implicit ownership acquisition can happen). llvm-svn: 291006
* Bitcode: Change module reader functions to return an llvm::Expected.Peter Collingbourne2016-11-131-1/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D26562 llvm-svn: 286752
* Split Bitcode/ReaderWriter.h into separate reader and writer headersTeresa Johnson2016-11-111-2/+3
| | | | | | | | | | | | | | | | | | | | | Summary: Split ReaderWriter.h which contains the APIs into both the BitReader and BitWriter libraries into BitcodeReader.h and BitcodeWriter.h. This is to address Chandler's concern about sharing the same API header between multiple libraries (BitReader and BitWriter). That concern is why we create a single bitcode library in our downstream build of clang, which led to r286297 being reverted as it added a dependency that created a cycle only when there is a single bitcode library (not two as in upstream). Reviewers: mehdi_amini Subscribers: dlj, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D26502 llvm-svn: 286566
* Bitcode: Change the materializer interface to return llvm::Error.Peter Collingbourne2016-11-091-4/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D26439 llvm-svn: 286382
* IR, Bitcode: Change bitcode reader to no longer own its memory buffer.Peter Collingbourne2016-11-081-3/+1
| | | | | | | | | | | | | | | | | | Unique ownership is just one possible ownership pattern for the memory buffer underlying the bitcode reader. In practice, as this patch shows, ownership can often reside at a higher level. With the upcoming change to allow multiple modules in a single bitcode file, it will no longer be appropriate for modules to generally have unique ownership of their memory buffer. The C API exposes the ownership relation via the LLVMGetBitcodeModuleInContext and LLVMGetBitcodeModuleInContext2 functions, so we still need some way for the module to own the memory buffer. This patch does so by adding an owned memory buffer field to Module, and using it in a few other places where it is convenient. Differential Revision: https://reviews.llvm.org/D26384 llvm-svn: 286214
* Bitcode: Decouple block info block state from reader.Peter Collingbourne2016-11-081-27/+8
| | | | | | | | | | | | | | | | | As proposed on llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2016-October/106630.html Move block info block state to a new class, BitstreamBlockInfo. Clients may set the block info for a particular cursor with the BitstreamCursor::setBlockInfo() method. At this point BitstreamReader is not much more than a container for an ArrayRef<uint8_t>, so remove it and replace all uses with direct uses of memory buffers. Differential Revision: https://reviews.llvm.org/D26259 llvm-svn: 286207
* Bitcode: Fix short read implementation.Peter Collingbourne2016-11-021-0/+9
| | | | | | | We need to zero extend the byte in order to correctly shift it into a 64-bit value. llvm-svn: 285785
* Bitcode: Change reader interface to take memory buffers.Peter Collingbourne2016-11-022-170/+11
| | | | | | | | | | | | | | | | | | | As proposed on llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2016-October/106595.html This change also fixes an API oddity where BitstreamCursor::Read() would return zero for the first read past the end of the bitstream, but would report_fatal_error for subsequent reads. Now we always report_fatal_error for all reads past the end. Updated clients to check for the end of the bitstream before reading from it. I also needed to add padding to the invalid bitcode tests in test/Bitcode/. This is because the streaming interface was not checking that the file size is a multiple of 4. Differential Revision: https://reviews.llvm.org/D26219 llvm-svn: 285773
* Remove every uses of getGlobalContext() in LLVM (but the C API)Mehdi Amini2016-04-141-5/+5
| | | | | | | | | | | At the same time, fixes InstructionsTest::CastInst unittest: yes you can leave the IR in an invalid state and exit when you don't destroy the context (like the global one), no longer now. This is the first part of http://reviews.llvm.org/D19094 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266379
* Explicitly test BitstreamReader::setArtificialByteLimit, NFCDuncan P. N. Exon Smith2016-03-281-1/+7
| | | | | | | | | | | Explicitly check that artificial byte limit is rounded correctly by exposing BitstreamReader::Size through a new accessor, getSizeIfKnown. The original code for rounding (from r264547) wasn't obviously correct, and even though r264623 cleaned it up (by calling llvm::alignTo) I think it's worth testing. llvm-svn: 264650
* Remove accidentally duplicated testDuncan P. N. Exon Smith2016-03-281-13/+0
| | | | | | This was identical to setArtificialByteLimitNotWordBoundary. llvm-svn: 264646
* Bitcode: Fix MSVC bot failure from r264549Duncan P. N. Exon Smith2016-03-271-2/+3
| | | | | | make_unique => llvm::make_unique llvm-svn: 264553
* BitcodeWriter: Simplify and test writing blobs, NFCDuncan P. N. Exon Smith2016-03-272-0/+60
| | | | | | | | | Split helper out of EmitRecordWithAbbrevImpl called emitBlob to reduce code duplication, and add a few tests for it. No functionality change intended. llvm-svn: 264550
* Support: Implement StreamingMemoryObject::getPointerDuncan P. N. Exon Smith2016-03-271-0/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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::setArtificialByteLimitDuncan P. N. Exon Smith2016-03-271-0/+69
| | | | | | | | | Allow users of SimpleBitstreamCursor to limit the number of bytes available to the cursor. This is preparation for instantiating a cursor that isn't allowed to load more bytes from a StreamingMemoryObject (just move around the ones already-loaded). llvm-svn: 264547
* Bitcode: Add SimpleBitstreamCursor::getPointerToByte, etc.Duncan P. N. Exon Smith2016-03-271-0/+43
| | | | | | | | | | | | | | | 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
* Remove autoconf supportChris Bieneman2016-01-261-15/+0
| | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened." - Obi Wan Kenobi Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D16471 llvm-svn: 258861
* Drop support for dematerializing.Rafael Espindola2015-12-181-38/+0
| | | | | | | It was only used on lib/Linker and the use was "dead" since it was used on a function the IRMover had just moved. llvm-svn: 256019
* Fix memory leak in unit test of Bitcode/BitReaderTest.cppDerek Schuff2015-08-031-1/+3
| | | | | | | | | | | | Fixes obvious memory leak in test TestForEofAfterReadFailureOnDataStreamer. Also removes constexpr use from same test. Patch by Karl Schimpf. Differential Revision: http://reviews.llvm.org/D11735 llvm-svn: 243904
* Fix testing for end of stream in bitstream reader.Derek Schuff2015-08-031-0/+35
| | | | | | | | | | | | | | | | | | This fixes a bug found while working on the bitcode reader. In particular, the method BitstreamReader::AtEndOfStream doesn't always behave correctly when processing a data streamer. The method fillCurWord doesn't properly set CurWord/BitsInCurWord if the data streamer was already at eof, but GetBytes had not yet set the ObjectSize field of the streaming memory object. This patch fixes this problem, and provides a test to show that this problem has been fixed. Patch by Karl Schimpf. Differential Revision: http://reviews.llvm.org/D11391 llvm-svn: 243890
* Try to fix the MSVC build.Rafael Espindola2015-06-171-1/+1
| | | | llvm-svn: 239877
* Handle forward referenced function when streaming bitcode.Rafael Espindola2015-06-171-0/+45
| | | | | | | | Without this the included unit test would assert in assert(BasicBlockFwdRefs.empty() && "Unresolved blockaddress fwd references"); llvm-svn: 239871
* Return a unique_ptr from getLazyBitcodeModule and parseBitcodeFile. NFC.Rafael Espindola2015-06-161-2/+2
| | | | llvm-svn: 239858
* While in GlobalValue fix the function(s) that don't follow theEric Christopher2015-05-151-4/+4
| | | | | | naming convention and update users. llvm-svn: 237461
* Add bitcode test to verify functions can be materialized out of order.Derek Schuff2015-05-061-0/+64
| | | | | | | | | | | | | | | | | | Summary: Adds test to check that when getLazyBitcodeModule is called: 1) Functions are not materailzed by default. 2) Only the requested function gets materialized (if no block addresses are used). Reviewers: jvoung, rafael Reviewed By: rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8907 llvm-svn: 236611
* [cleanup] Re-sort all the #include lines in LLVM usingChandler Carruth2015-01-141-1/+1
| | | | | | | | | | | utils/sort_includes.py. I clearly haven't done this in a while, so more changed than usual. This even uncovered a missing include from the InstrProf library that I've added. No functionality changed here, just mechanical cleanup of the include order. llvm-svn: 225974
* [Bitcode] AtEndOfStream should only check against the size if it's known.Jordan Rose2014-11-132-0/+57
| | | | | | | | | | This avoids an issue where AtEndOfStream mistakenly returns true at the /start/ of a stream. (In the rare case that the size is known and actually 0, the slow path will still handle it correctly.) llvm-svn: 221840
* Modernize the error handling of the Materialize function.Rafael Espindola2014-10-241-3/+3
| | | | llvm-svn: 220600
* Do not destroy external linkage when deleting function bodyPetar Jovanovic2014-09-231-0/+24
| | | | | | | | | | | The function deleteBody() converts the linkage to external and thus destroys original linkage type value. Lack of correct linkage type causes wrong relocations to be emitted later. Calling dropAllReferences() instead of deleteBody() will fix the issue. Differential Revision: http://reviews.llvm.org/D5415 llvm-svn: 218302
* Pass a && to getLazyBitcodeModule.Rafael Espindola2014-09-031-1/+2
| | | | | | | | This forces callers to use std::move when calling it. It is somewhat odd to have code with std::move that doesn't always move, but it is also odd to have code without std::move that sometimes moves. llvm-svn: 217049
* Return a std::unique_ptr when creating a new MemoryBuffer.Rafael Espindola2014-08-271-2/+2
| | | | llvm-svn: 216583
* Pass a std::unique_ptr<MemoryBuffer>& to getLazyBitcodeModule.Rafael Espindola2014-08-261-1/+2
| | | | | | | By taking a reference we can do the ownership transfer in one place instead of expecting every caller to do it. llvm-svn: 216492
* Modernize the .ll parsing interface.Rafael Espindola2014-08-191-5/+3
| | | | | | | | | | * Use StringRef instead of std::string& * Return a std::unique_ptr<Module> instead of taking an optional module to write to (was not really used). * Use current comment style. * Use current naming convention. llvm-svn: 215989
* BitcodeTests: Fix LINK_COMPONENTS.NAKAMURA Takumi2014-08-022-2/+3
| | | | llvm-svn: 214598
* BitcodeReader: Fix some BlockAddress forward reference corner casesDuncan P. N. Exon Smith2014-08-011-0/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | `BlockAddress`es are interesting in that they can reference basic blocks from *outside* the block's function. Since basic blocks are not global values, this presents particular challenges for lazy parsing. One corner case was found in PR11677 and fixed in r147425. In that case, a global variable references a block address. It's necessary to load the relevant function to resolve the forward reference before doing anything with the module. By inspection, I found (and have fixed here) two other cases: - An instruction from one function references a block address from another function, and only the first function is lazily loaded. I fixed this the same way as PR11677: by eagerly loading the referenced function. - A function whose block address is taken is dematerialized, leaving invalid references to it. I fixed this by refusing to dematerialize functions whose block addresses are taken (if you have to load it, you can't unload it). llvm-svn: 214559
* Try to fix configure+make after r214556Duncan P. N. Exon Smith2014-08-011-1/+1
| | | | llvm-svn: 214558
* Rewrite BitReaderTest, NFCDuncan P. N. Exon Smith2014-08-012-32/+40
| | | | | | | | | | | | | | Rewrite the single unit test in `BitReaderTest` so that it's easier to add more tests. - Parse from an assembly string rather than using API. - Use more helper functions. - Use a separate context for the module on the other side. Aside from relying on the assembly parser, there's no functionality change intended. llvm-svn: 214556
* verify-di: Implement DebugInfoVerifierDuncan P. N. Exon Smith2014-04-151-0/+1
| | | | | | | | | | | | | | | | | | | | | Implement DebugInfoVerifier, which steals verification relying on DebugInfoFinder from Verifier. - Adds LegacyDebugInfoVerifierPassPass, a ModulePass which wraps DebugInfoVerifier. Uses -verify-di command-line flag. - Change verifyModule() to invoke DebugInfoVerifier as well as Verifier. - Add a call to createDebugInfoVerifierPass() wherever there was a call to createVerifierPass(). This implementation as a module pass should sidestep efficiency issues, allowing us to turn debug info verification back on. <rdar://problem/15500563> llvm-svn: 206300
* Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles2014-03-061-2/+2
| | | | | | | | | | This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
* Update getLazyBitcodeModule to use ErrorOr for error handling.Rafael Espindola2014-01-131-2/+3
| | | | llvm-svn: 199125
OpenPOWER on IntegriCloud