summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [opaque pointer type] bitcode support for explicit type parameter to the ↵David Blaikie2015-02-251-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | load instruction Summary: I've taken my best guess at this, but I've cargo culted in places & so explanations/corrections would be great. This seems to pass all the tests (check-all, covering clang and llvm) so I believe that pretty well exercises both the backwards compatibility and common (same version) compatibility given the number of checked in bitcode files we already have. Is that a reasonable approach to testing here? Would some more explicit tests be desired? 1) is this the right way to do back-compat in this case (looking at the number of entries in the bitcode record to disambiguate between the old schema and the new?) 2) I don't quite understand the logarithm logic to choose the encoding type of the type parameter in the abbreviation description, but I found another instruction doing the same thing & it seems to work. Is that the right approach? Reviewers: dexonsmith Differential Revision: http://reviews.llvm.org/D7655 llvm-svn: 230414
* Use common parse routine to read alignment values from bitcodeJF Bastien2015-02-221-14/+42
| | | | | | | | | | While fuzzing LLVM bitcode files, I discovered that (1) the bitcode reader doesn't check that alignments are no larger than 2**29; (2) downstream code doesn't check the range; and (3) for values out of range, corresponding large memory requests (based on alignment size) will fail. This code fixes the bitcode reader to check for valid alignments, fixing this problem. This CL fixes alignment value on global variables, functions, and instructions: alloca, load, load atomic, store, store atomic. Patch by Karl Schimpf (kschimpf@google.com). llvm-svn: 230180
* Bitcode: Stop assuming non-null fieldsDuncan P. N. Exon Smith2015-02-201-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When writing the bitcode serialization for the new debug info hierarchy, I assumed two fields would never be null. Drop that assumption, since it's brittle (and crashes the `BitcodeWriter` if wrong), and is a check better left for the verifier anyway. (No need for a bitcode upgrade here, since the new hierarchy is still not in place.) The fields in question are `MDCompileUnit::getFile()` and `MDDerivedType::getBaseType()`, the latter of which isn't null in test/Transforms/Mem2Reg/ConvertDebugInfo2.ll (see !14, a pointer to nothing). While the testcase might have bitrotted, there's no reason for the bitcode format to rely on non-null for metadata operands. This also fixes a bug in `AsmWriter` where if the `file:` is null it isn't emitted (caught by the double-round trip in the testcase I'm adding) -- this is a required field in `LLParser`. I'll circle back to ConvertDebugInfo2. Once the specialized nodes are in place, I'll be trying to turn the debug info verifier back on by default (in the newer module pass form committed r206300) and throwing more logic in there. If the testcase has bitrotted (as opposed to me not understanding the schema correctly) I'll fix it then. llvm-svn: 229960
* IR: Drop scope from MDTemplateParameterDuncan P. N. Exon Smith2015-02-191-10/+9
| | | | | | | | | | Follow-up to r229740, which removed `DITemplate*::getContext()` after my upgrade script revealed that scopes are always `nullptr` for template parameters. This is the other shoe: drop `scope:` from `MDTemplateParameter` and its two subclasses. (Note: a bitcode upgrade would be pointless, since the hierarchy hasn't been moved into place.) llvm-svn: 229791
* Bitcode: Fix major regression: large files w/ debug infoDuncan P. N. Exon Smith2015-02-161-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The metadata/value split introduced a major regression reading large bitcode files that contain debug info (or other cyclic (non-self reference) metadata graphs). For the first time in a while, I dropped from libLTO.dylib down to `llvm-lto` with a non-trivial bitcode file (~350MB), and I hit this when reading the result of ld64's `-save-temps` in `llvm-lto`. Here's pseudo-code for what was going on: read-main-metadata-block: for each md: if has-fwd-ref: // Only true for cyclic graphs. any-fwd-refs <- true if any-fwd-refs: foreach md: resolve-cycles(md) // Handle cycles. foreach function: read-function-metadata-block: // Such as !alias, !loop if any-fwd-refs: foreach md: // (all metadata, not just this block) resolve-cycles(md) // A no-op, but the loop is expensive!! This commit resets the `AnyFwdRefs` flag to `false`. This on its own was enough to change my Release+Asserts `llvm-lto` time for reading this bitcode from over 20 minutes (I gave up on it) to 20 seconds. I've gone further by tracking the min/max metadata forward-references in a metadata block. This protects against a schema that has lots of functions that each reference their own metadata cycle. Unfortunately, this regression is in the 3.6 branch as well. llvm-svn: 229421
* [Bitcode reader] Fix a few assertions when reading invalid filesFilipe Cabecinhas2015-02-161-0/+32
| | | | | | | | | | | | | | | | Summary: When creating {insert,extract}value instructions from a BitcodeReader, we weren't verifying the fields were valid. Bugs found with afl-fuzz Reviewers: rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7325 llvm-svn: 229345
* Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for ↵Aaron Ballman2015-02-151-1/+1
| | | | | | requiring the macro. NFC; LLVM edition. llvm-svn: 229340
* AsmWriter/Bitcode: MDImportedEntityDuncan P. N. Exon Smith2015-02-131-0/+12
| | | | llvm-svn: 229025
* AsmWriter/Bitcode: MDObjCPropertyDuncan P. N. Exon Smith2015-02-131-0/+13
| | | | llvm-svn: 229024
* AsmWriter/Bitcode: MDExpressionDuncan P. N. Exon Smith2015-02-131-0/+10
| | | | llvm-svn: 229023
* AsmWriter/Bitcode: MDLocalVariableDuncan P. N. Exon Smith2015-02-131-0/+13
| | | | llvm-svn: 229022
* AsmWriter/Bitcode: MDGlobalVariableDuncan P. N. Exon Smith2015-02-131-0/+14
| | | | llvm-svn: 229020
* AsmWriter/Bitcode: MDTemplate{Type,Value}ParameterDuncan P. N. Exon Smith2015-02-131-0/+23
| | | | llvm-svn: 229019
* AsmWriter/Bitcode: MDNamespaceDuncan P. N. Exon Smith2015-02-131-0/+12
| | | | llvm-svn: 229018
* AsmWriter/Bitcode: MDLexicalBlockFileDuncan P. N. Exon Smith2015-02-131-0/+11
| | | | llvm-svn: 229017
* AsmWriter/Bitcode: MDLexicalBlockDuncan P. N. Exon Smith2015-02-131-0/+11
| | | | llvm-svn: 229016
* AsmWriter/Bitcode: MDSubprogramDuncan P. N. Exon Smith2015-02-131-0/+16
| | | | llvm-svn: 229014
* AsmWriter/Bitcode: MDCompileUnitDuncan P. N. Exon Smith2015-02-131-0/+15
| | | | llvm-svn: 229013
* AsmWriter/Bitcode: MDSubroutineTypeDuncan P. N. Exon Smith2015-02-131-0/+10
| | | | llvm-svn: 229011
* AsmWriter/Bitcode: MDDerivedType and MDCompositeTypeDuncan P. N. Exon Smith2015-02-131-3/+38
| | | | llvm-svn: 229009
* AsmWriter/Bitcode: MDFileDuncan P. N. Exon Smith2015-02-131-0/+10
| | | | llvm-svn: 229007
* AsmWriter/Bitcode: MDBasicTypeDuncan P. N. Exon Smith2015-02-131-0/+11
| | | | llvm-svn: 229005
* AsmWriter/Bitcode: MDEnumeratorDuncan P. N. Exon Smith2015-02-131-0/+10
| | | | llvm-svn: 229004
* AsmWriter/Bitcode: MDSubrangeDuncan P. N. Exon Smith2015-02-131-0/+12
| | | | llvm-svn: 229003
* Misc documentation/comment fixes.Peter Collingbourne2015-02-041-1/+2
| | | | llvm-svn: 228093
* IR: Assembly and bitcode for GenericDebugNodeDuncan P. N. Exon Smith2015-02-031-0/+32
| | | | llvm-svn: 228041
* IR: Split out DebugInfoMetadata.h, NFCDuncan P. N. Exon Smith2015-02-021-0/+1
| | | | | | | | | Move debug-info-centred `Metadata` subclasses into their own header/source file. A couple of private template functions are needed from both `Metadata.cpp` and `DebugInfoMetadata.cpp`, so I've moved them to `lib/IR/MetadataImpl.h`. llvm-svn: 227835
* Check bit widths before trying to get a type.Filipe Cabecinhas2015-01-301-2/+7
| | | | | | | | | Added a test case for it. Also added run lines for the test case in r227566. Bugs found with afl-fuzz llvm-svn: 227589
* [bitcode reader] Fix an assert on invalid type tablesFilipe Cabecinhas2015-01-301-1/+3
| | | | | | Bug found with afl-fuzz llvm-svn: 227566
* Bitcode: Don't create comdats when autoupgrading macho bitcodeDavid Majnemer2015-01-201-2/+9
| | | | | | | Don't infer COMDAT groups from older bitcode if the target is macho, it doesn't have COMDATs. llvm-svn: 226546
* IR: Merge UniquableMDNode back into MDNode, NFCDuncan P. N. Exon Smith2015-01-191-1/+1
| | | | | | | | | As pointed out in r226501, the distinction between `MDNode` and `UniquableMDNode` is confusing. When we need subclasses of `MDNode` that don't use all its functionality it might make sense to break it apart again, but until then this makes the code clearer. llvm-svn: 226520
* IR: Return unique_ptr from MDNode::getTemporary()Duncan P. N. Exon Smith2015-01-191-3/+2
| | | | | | | | | | | | Change `MDTuple::getTemporary()` and `MDLocation::getTemporary()` to return (effectively) `std::unique_ptr<T, MDNode::deleteTemporary>`, and clean up call sites. (For now, `DIBuilder` call sites just call `release()` immediately.) There's an accompanying change in each of clang and polly to use the new API. llvm-svn: 226504
* IR: Remove MDNodeFwdDeclDuncan P. N. Exon Smith2015-01-191-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove `MDNodeFwdDecl` (as promised in r226481). Aside from API changes, there's no real functionality change here. `MDNode::getTemporary()` now forwards to `MDTuple::getTemporary()`, which returns a tuple with `isTemporary()` equal to true. The main point is that we can now add temporaries of other `MDNode` subclasses, needed for PR22235 (I introduced `MDNodeFwdDecl` in the first place because I didn't recognize this need, and thought they were only needed to handle forward references). A few things left out of (or highlighted by) this commit: - I've had to remove the (few) uses of `std::unique_ptr<>` to deal with temporaries, since the destructor is no longer public. `getTemporary()` should probably return the equivalent of `std::unique_ptr<T, MDNode::deleteTemporary>`. - `MDLocation::getTemporary()` doesn't exist yet (worse, it actually does exist, but does the wrong thing: `MDNode::getTemporary()` is inherited and returns an `MDTuple`). - `MDNode` now only has one subclass, `UniquableMDNode`, and the distinction between them is actually somewhat confusing. I'll fix those up next. llvm-svn: 226501
* Bring r226038 back.Rafael Espindola2015-01-191-14/+42
| | | | | | | | | | | | | | | | No change in this commit, but clang was changed to also produce trivial comdats when needed. Original message: Don't create new comdats in CodeGen. This patch stops the implicit creation of comdats during codegen. Clang now sets the comdat explicitly when it is required. With this patch clang and gcc now produce the same result in pr19848. llvm-svn: 226467
* Revert r226242 - Revert Revert Don't create new comdats in CodeGenTimur Iskhodzhanov2015-01-161-42/+14
| | | | | | This breaks AddressSanitizer (ninja check-asan) on Windows llvm-svn: 226251
* Revert "Revert Don't create new comdats in CodeGen"Rafael Espindola2015-01-161-14/+42
| | | | | | | | | | | | | | | | | | This reverts commit r226173, adding r226038 back. No change in this commit, but clang was changed to also produce trivial comdats for costructors, destructors and vtables when needed. Original message: Don't create new comdats in CodeGen. This patch stops the implicit creation of comdats during codegen. Clang now sets the comdat explicitly when it is required. With this patch clang and gcc now produce the same result in pr19848. llvm-svn: 226242
* Revert Don't create new comdats in CodeGenTimur Iskhodzhanov2015-01-151-42/+14
| | | | | | It breaks AddressSanitizer on Windows. llvm-svn: 226173
* Don't create new comdats in CodeGen.Rafael Espindola2015-01-141-14/+42
| | | | | | | | | This patch stops the implicit creation of comdats during codegen. Clang now sets the comdat explicitly when it is required. With this patch clang and gcc now produce the same result in pr19848. llvm-svn: 226038
* [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
* AsmParser/Bitcode: Add support for MDLocationDuncan P. N. Exon Smith2015-01-131-0/+14
| | | | | | | | | | | | This adds assembly and bitcode support for `MDLocation`. The assembly side is rather big, since this is the first `MDNode` subclass (that isn't `MDTuple`). Part of PR21433. (If you're wondering where the mountains of testcase updates are, we don't need them until I update `DILocation` and `DebugLoc` to actually use this class.) llvm-svn: 225830
* IR: Split GenericMDNode into MDTuple and UniquableMDNodeDuncan P. N. Exon Smith2015-01-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Split `GenericMDNode` into two classes (with more descriptive names). - `UniquableMDNode` will be a common subclass for `MDNode`s that are sometimes uniqued like constants, and sometimes 'distinct'. This class gets the (short-lived) RAUW support and related API. - `MDTuple` is the basic tuple that has always been returned by `MDNode::get()`. This is as opposed to more specific nodes to be added soon, which have additional fields, custom assembly syntax, and extra semantics. This class gets the hash-related logic, since other sublcasses of `UniquableMDNode` may need to hash based on other fields. To keep this diff from getting too big, I've added casts to `MDTuple` that won't really scale as new subclasses of `UniquableMDNode` are added, but I'll clean those up incrementally. (No functionality change intended.) llvm-svn: 225682
* Use the DiagnosticHandler to print diagnostics when reading bitcode.Rafael Espindola2015-01-101-281/+312
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bitcode reading interface used std::error_code to report an error to the callers and it is the callers job to print diagnostics. This is not ideal for error handling or diagnostic reporting: * For error handling, all that the callers care about is 3 possibilities: * It worked * The bitcode file is corrupted/invalid. * The file is not bitcode at all. * For diagnostic, it is user friendly to include far more information about the invalid case so the user can find out what is wrong with the bitcode file. This comes up, for example, when a developer introduces a bug while extending the format. The compromise we had was to have a lot of error codes. With this patch we use the DiagnosticHandler to communicate with the human and std::error_code to communicate with the caller. This allows us to have far fewer error codes and adds the infrastructure to print better diagnostics. This is so because the diagnostics are printed when he issue is found. The code that detected the problem in alive in the stack and can pass down as much context as needed. As an example the patch updates test/Bitcode/invalid.ll. Using a DiagnosticHandler also moves the fatal/non-fatal error decision to the caller. A simple one like llvm-dis can just use fatal errors. The gold plugin needs a bit more complex treatment because of being passed non-bitcode files. An hypothetical interactive tool would make all bitcode errors non-fatal. llvm-svn: 225562
* Revert "Bitcode: Move the DEBUG_LOC record to DEBUG_LOC_OLD"Duncan P. N. Exon Smith2015-01-091-1/+1
| | | | | | | | | | | | | | | This reverts commit r225498 (but leaves r225499, which was a worthy cleanup). My plan was to change `DEBUG_LOC` to store the `MDNode` directly rather than its operands (patch was to go out this morning), but on reflection it's not clear that it's strictly better. (I had missed that the current code is unlikely to emit the `MDNode` at all.) Conflicts: lib/Bitcode/Reader/BitcodeReader.cpp (due to r225499) llvm-svn: 225531
* Bitcode: Share logic for last instruction, NFCDuncan P. N. Exon Smith2015-01-091-14/+10
| | | | | | Share logic for getting the last instruction emitted. llvm-svn: 225499
* Bitcode: Move the DEBUG_LOC record to DEBUG_LOC_OLDDuncan P. N. Exon Smith2015-01-091-1/+1
| | | | | | Prepare to simplify the `DebugLoc` record. llvm-svn: 225498
* IR: Add 'distinct' MDNodes to bitcode and assemblyDuncan P. N. Exon Smith2015-01-081-1/+7
| | | | | | | | | | | | | | | | | | Propagate whether `MDNode`s are 'distinct' through the other types of IR (assembly and bitcode). This adds the `distinct` keyword to assembly. Currently, no one actually calls `MDNode::getDistinct()`, so these nodes only get created for: - self-references, which are never uniqued, and - nodes whose operands are replaced that hit a uniquing collision. The concept of distinct nodes is still not quite first-class, since distinct-ness doesn't yet survive across `MapMetadata()`. Part of PR22111. llvm-svn: 225474
* Explicitly handle LinkOnceODRAutoHideLinkage. NFC. We already have a test.Rafael Espindola2015-01-081-0/+2
| | | | llvm-svn: 225449
* Update naming style and clang-format. NFC.Rafael Espindola2015-01-081-17/+30
| | | | llvm-svn: 225448
* Fix Visual C++ error "'llvm::make_unique' : ambiguous call to overloaded ↵Yaron Keren2014-12-181-2/+2
| | | | | | function". llvm-svn: 224506
* Modernize the getStreamedBitcodeModule interface a bit. NFC.Rafael Espindola2014-12-181-18/+14
| | | | llvm-svn: 224499
OpenPOWER on IntegriCloud