summaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
AgeCommit message (Collapse)Author
2015-03-17AsmWriter: Assert on unresolved metadata nodesDuncan P. N. Exon Smith
Assert that `MDNode::isResolved()`. While in theory the `Verifier` should catch this, it doesn't descend into all debug info, and the `DebugInfoVerifier` doesn't call into the `Verifier`. Besides, this helps to catch bugs when `-disable-verify=true`. Note that I haven't come across a place where this fails with clang today, so no testcase. llvm-svn: 232442
2015-03-13[opaque pointer type] Bitcode support for explicit type parameter on the gep ↵David Blaikie
operator This happened to be fairly easy to support backwards compatibility based on the number of operands (old format had an even number, new format has one more operand so an odd number). test/Bitcode/old-aliases.ll already appears to test old gep operators (if I remove the backwards compatibility in the BitcodeReader, this and another test fail) so I'm not adding extra test coverage here. llvm-svn: 232216
2015-02-25[opaque pointer type] Bitcode support for explicit type parameter on GEP.David Blaikie
Like r230414, add bitcode support including backwards compatibility, for an explicit type parameter to GEP. At the suggestion of Duncan I tried coalescing the two older bitcodes into a single new bitcode, though I did hit a wrinkle: I couldn't figure out how to create an explicit abbreviation for a record with a variable number of arguments (the indicies to the gep). This means the discriminator between inbounds and non-inbounds gep is a full variable-length field I believe? Is my understanding correct? Is there a way to create such an abbreviation? Should I just use two bitcodes as before? Reviewers: dexonsmith Differential Revision: http://reviews.llvm.org/D7736 llvm-svn: 230415
2015-02-25[opaque pointer type] bitcode support for explicit type parameter to the ↵David Blaikie
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
2015-02-25BitcodeWriter: Refactor common computation of bits required for a type index.David Blaikie
Suggested by Duncan. Happy to bikeshed the name, cache the result, etc. llvm-svn: 230410
2015-02-20Bitcode: Stop assuming non-null fieldsDuncan P. N. Exon Smith
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
2015-02-19IR: Drop scope from MDTemplateParameterDuncan P. N. Exon Smith
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
2015-02-17Prefer SmallVector::append/insert over push_back loops.Benjamin Kramer
Same functionality, but hoists the vector growth out of the loop. llvm-svn: 229500
2015-02-13AsmWriter/Bitcode: MDImportedEntityDuncan P. N. Exon Smith
llvm-svn: 229025
2015-02-13AsmWriter/Bitcode: MDObjCPropertyDuncan P. N. Exon Smith
llvm-svn: 229024
2015-02-13AsmWriter/Bitcode: MDExpressionDuncan P. N. Exon Smith
llvm-svn: 229023
2015-02-13AsmWriter/Bitcode: MDLocalVariableDuncan P. N. Exon Smith
llvm-svn: 229022
2015-02-13AsmWriter/Bitcode: MDGlobalVariableDuncan P. N. Exon Smith
llvm-svn: 229020
2015-02-13AsmWriter/Bitcode: MDTemplate{Type,Value}ParameterDuncan P. N. Exon Smith
llvm-svn: 229019
2015-02-13AsmWriter/Bitcode: MDNamespaceDuncan P. N. Exon Smith
llvm-svn: 229018
2015-02-13AsmWriter/Bitcode: MDLexicalBlockFileDuncan P. N. Exon Smith
llvm-svn: 229017
2015-02-13AsmWriter/Bitcode: MDLexicalBlockDuncan P. N. Exon Smith
llvm-svn: 229016
2015-02-13AsmWriter/Bitcode: MDSubprogramDuncan P. N. Exon Smith
llvm-svn: 229014
2015-02-13AsmWriter/Bitcode: MDCompileUnitDuncan P. N. Exon Smith
llvm-svn: 229013
2015-02-13AsmWriter/Bitcode: MDSubroutineTypeDuncan P. N. Exon Smith
llvm-svn: 229011
2015-02-13AsmWriter/Bitcode: MDDerivedType and MDCompositeTypeDuncan P. N. Exon Smith
llvm-svn: 229009
2015-02-13AsmWriter/Bitcode: MDFileDuncan P. N. Exon Smith
llvm-svn: 229007
2015-02-13AsmWriter/Bitcode: MDBasicTypeDuncan P. N. Exon Smith
llvm-svn: 229005
2015-02-13AsmWriter/Bitcode: MDEnumeratorDuncan P. N. Exon Smith
llvm-svn: 229004
2015-02-13AsmWriter/Bitcode: MDSubrangeDuncan P. N. Exon Smith
llvm-svn: 229003
2015-02-10IR: Add specialized debug info metadata nodesDuncan P. N. Exon Smith
Add specialized debug info metadata nodes that match the `DIDescriptor` wrappers (used by `DIBuilder`) closely. Assembly and bitcode support to follow soon (it'll mostly just be obvious), but this sketches in today's schema. This is the first big commit (well, the only *big* one aside from the testcase changes that'll come when I move this into place) for PR22464. I've marked a bunch of obvious changes as `TODO`s in the source; I plan to make those changes promptly after this hierarchy is moved underneath `DIDescriptor`, but for now I'm aiming mostly to match the status quo. llvm-svn: 228640
2015-02-04IR: Initialize MDNode abbreviations en masse, NFCDuncan P. N. Exon Smith
llvm-svn: 228203
2015-02-04Misc documentation/comment fixes.Peter Collingbourne
llvm-svn: 228093
2015-02-03IR: Assembly and bitcode for GenericDebugNodeDuncan P. N. Exon Smith
llvm-svn: 228041
2015-02-02IR: Split out DebugInfoMetadata.h, NFCDuncan P. N. Exon Smith
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
2015-01-22IR: DwarfNode => DebugNode, NFCDuncan P. N. Exon Smith
These things are potentially used for non-DWARF data (see the discussion in PR22235), so take the `Dwarf` out of the name. Since the new name gives fewer clues, update the doxygen to properly describe what they are. llvm-svn: 226874
2015-01-20Bitcode: Simplify MDNode subclass dispatch, NFCDuncan P. N. Exon Smith
llvm-svn: 226535
2015-01-20Bitcode: WriteMDNode() => WriteMDTuple(), NFCDuncan P. N. Exon Smith
llvm-svn: 226534
2015-01-20Bitcode: Add ValueEnumerator::getMetadataOrNullID(), NFCDuncan P. N. Exon Smith
llvm-svn: 226533
2015-01-19Bring r226038 back.Rafael Espindola
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
2015-01-16Revert r226242 - Revert Revert Don't create new comdats in CodeGenTimur Iskhodzhanov
This breaks AddressSanitizer (ninja check-asan) on Windows llvm-svn: 226251
2015-01-16Revert "Revert Don't create new comdats in CodeGen"Rafael Espindola
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
2015-01-15Revert Don't create new comdats in CodeGenTimur Iskhodzhanov
It breaks AddressSanitizer on Windows. llvm-svn: 226173
2015-01-14Don't create new comdats in CodeGen.Rafael Espindola
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
2015-01-14Add support for comdats with names larger than 256 characters.Rafael Espindola
llvm-svn: 226012
2015-01-13AsmParser/Bitcode: Add support for MDLocationDuncan P. N. Exon Smith
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
2015-01-12Bitcode: Range-based for, NFCDuncan P. N. Exon Smith
llvm-svn: 225716
2015-01-12Bitcode: Add abbreviation for METADATA_NAMEDuncan P. N. Exon Smith
llvm-svn: 225715
2015-01-12Bitcode: Range-based for, NFCDuncan P. N. Exon Smith
llvm-svn: 225714
2015-01-12Bitcode: Range-based for, NFCDuncan P. N. Exon Smith
llvm-svn: 225713
2015-01-12Bitcode: Simplify emission of METADATA_BLOCKDuncan P. N. Exon Smith
Refactor logic so that we know up-front whether to open a block and whether we need an MDString abbreviation. This is almost NFC, but will start emitting `MDString` abbreviations when the first record is not an `MDString`. llvm-svn: 225712
2015-01-09Revert "Bitcode: Move the DEBUG_LOC record to DEBUG_LOC_OLD"Duncan P. N. Exon Smith
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
2015-01-09Bitcode: Move the DEBUG_LOC record to DEBUG_LOC_OLDDuncan P. N. Exon Smith
Prepare to simplify the `DebugLoc` record. llvm-svn: 225498
2015-01-08IR: Add 'distinct' MDNodes to bitcode and assemblyDuncan P. N. Exon Smith
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
2015-01-08clang-format. NFC.Rafael Espindola
llvm-svn: 225454