summaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
AgeCommit message (Collapse)Author
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
2014-12-11Bitcode: Use unsigned char to record MDStringsDuncan P. N. Exon Smith
`MDString`s can have arbitrary characters in them. Prevent an assertion that fired in `BitcodeWriter` because of sign extension by copying the characters into the record as `unsigned char`s. Based on a patch by Keno Fischer; fixes PR21882. llvm-svn: 224077
2014-12-11Bitcode: Add METADATA_NODE and METADATA_VALUEDuncan P. N. Exon Smith
This reflects the typelessness of `Metadata` in the bitcode format, removing types from all metadata operands. `METADATA_VALUE` represents a `ValueAsMetadata`, and always has two fields: the type and the value. `METADATA_NODE` represents an `MDNode`, and unlike `METADATA_OLD_NODE`, doesn't store types. It stores operands at their ID+1 so that `0` can reference `nullptr` operands. Part of PR21532. llvm-svn: 224073
2014-12-11Bitcode: Add `OLD_` prefix to metadata node recordsDuncan P. N. Exon Smith
I'm about to change these, so move the old ones out of the way. Part of PR21532. llvm-svn: 224070
2014-12-09IR: Split Metadata from ValueDuncan P. N. Exon Smith
Split `Metadata` away from the `Value` class hierarchy, as part of PR21532. Assembly and bitcode changes are in the wings, but this is the bulk of the change for the IR C++ API. I have a follow-up patch prepared for `clang`. If this breaks other sub-projects, I apologize in advance :(. Help me compile it on Darwin I'll try to fix it. FWIW, the errors should be easy to fix, so it may be simpler to just fix it yourself. This breaks the build for all metadata-related code that's out-of-tree. Rest assured the transition is mechanical and the compiler should catch almost all of the problems. Here's a quick guide for updating your code: - `Metadata` is the root of a class hierarchy with three main classes: `MDNode`, `MDString`, and `ValueAsMetadata`. It is distinct from the `Value` class hierarchy. It is typeless -- i.e., instances do *not* have a `Type`. - `MDNode`'s operands are all `Metadata *` (instead of `Value *`). - `TrackingVH<MDNode>` and `WeakVH` referring to metadata can be replaced with `TrackingMDNodeRef` and `TrackingMDRef`, respectively. If you're referring solely to resolved `MDNode`s -- post graph construction -- just use `MDNode*`. - `MDNode` (and the rest of `Metadata`) have only limited support for `replaceAllUsesWith()`. As long as an `MDNode` is pointing at a forward declaration -- the result of `MDNode::getTemporary()` -- it maintains a side map of its uses and can RAUW itself. Once the forward declarations are fully resolved RAUW support is dropped on the ground. This means that uniquing collisions on changing operands cause nodes to become "distinct". (This already happened fairly commonly, whenever an operand went to null.) If you're constructing complex (non self-reference) `MDNode` cycles, you need to call `MDNode::resolveCycles()` on each node (or on a top-level node that somehow references all of the nodes). Also, don't do that. Metadata cycles (and the RAUW machinery needed to construct them) are expensive. - An `MDNode` can only refer to a `Constant` through a bridge called `ConstantAsMetadata` (one of the subclasses of `ValueAsMetadata`). As a side effect, accessing an operand of an `MDNode` that is known to be, e.g., `ConstantInt`, takes three steps: first, cast from `Metadata` to `ConstantAsMetadata`; second, extract the `Constant`; third, cast down to `ConstantInt`. The eventual goal is to introduce `MDInt`/`MDFloat`/etc. and have metadata schema owners transition away from using `Constant`s when the type isn't important (and they don't care about referring to `GlobalValue`s). In the meantime, I've added transitional API to the `mdconst` namespace that matches semantics with the old code, in order to avoid adding the error-prone three-step equivalent to every call site. If your old code was: MDNode *N = foo(); bar(isa <ConstantInt>(N->getOperand(0))); baz(cast <ConstantInt>(N->getOperand(1))); bak(cast_or_null <ConstantInt>(N->getOperand(2))); bat(dyn_cast <ConstantInt>(N->getOperand(3))); bay(dyn_cast_or_null<ConstantInt>(N->getOperand(4))); you can trivially match its semantics with: MDNode *N = foo(); bar(mdconst::hasa <ConstantInt>(N->getOperand(0))); baz(mdconst::extract <ConstantInt>(N->getOperand(1))); bak(mdconst::extract_or_null <ConstantInt>(N->getOperand(2))); bat(mdconst::dyn_extract <ConstantInt>(N->getOperand(3))); bay(mdconst::dyn_extract_or_null<ConstantInt>(N->getOperand(4))); and when you transition your metadata schema to `MDInt`: MDNode *N = foo(); bar(isa <MDInt>(N->getOperand(0))); baz(cast <MDInt>(N->getOperand(1))); bak(cast_or_null <MDInt>(N->getOperand(2))); bat(dyn_cast <MDInt>(N->getOperand(3))); bay(dyn_cast_or_null<MDInt>(N->getOperand(4))); - A `CallInst` -- specifically, intrinsic instructions -- can refer to metadata through a bridge called `MetadataAsValue`. This is a subclass of `Value` where `getType()->isMetadataTy()`. `MetadataAsValue` is the *only* class that can legally refer to a `LocalAsMetadata`, which is a bridged form of non-`Constant` values like `Argument` and `Instruction`. It can also refer to any other `Metadata` subclass. (I'll break all your testcases in a follow-up commit, when I propagate this change to assembly.) llvm-svn: 223802
2014-12-03Prologue supportPeter Collingbourne
Patch by Ben Gamari! This redefines the `prefix` attribute introduced previously and introduces a `prologue` attribute. There are a two primary usecases that these attributes aim to serve, 1. Function prologue sigils 2. Function hot-patching: Enable the user to insert `nop` operations at the beginning of the function which can later be safely replaced with a call to some instrumentation facility 3. Runtime metadata: Allow a compiler to insert data for use by the runtime during execution. GHC is one example of a compiler that needs this functionality for its tables-next-to-code functionality. Previously `prefix` served cases (1) and (2) quite well by allowing the user to introduce arbitrary data at the entrypoint but before the function body. Case (3), however, was poorly handled by this approach as it required that prefix data was valid executable code. Here we redefine the notion of prefix data to instead be data which occurs immediately before the function entrypoint (i.e. the symbol address). Since prefix data now occurs before the function entrypoint, there is no need for the data to be valid code. The previous notion of prefix data now goes under the name "prologue data" to emphasize its duality with the function epilogue. The intention here is to handle cases (1) and (2) with prologue data and case (3) with prefix data. References ---------- This idea arose out of discussions[1] with Reid Kleckner in response to a proposal to introduce the notion of symbol offsets to enable handling of case (3). [1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-May/073235.html Test Plan: testsuite Differential Revision: http://reviews.llvm.org/D6454 llvm-svn: 223189
2014-11-17Pass a reference to ValueEnumerator.Rafael Espindola
NFC. This will just make it easier to use std::unique_ptr in a caller. llvm-svn: 222170
2014-11-11Revert "IR: MDNode => Value"Duncan P. N. Exon Smith
Instead, we're going to separate metadata from the Value hierarchy. See PR21532. This reverts commit r221375. This reverts commit r221373. This reverts commit r221359. This reverts commit r221167. This reverts commit r221027. This reverts commit r221024. This reverts commit r221023. This reverts commit r220995. This reverts commit r220994. llvm-svn: 221711