summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Metadata.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* IR: Lazily create ReplaceableMetadataImpl on MDNodeDuncan P. N. Exon Smith2016-04-031-31/+60
| | | | | | | | | | | | | | | | | | | RAUW support on MDNode usually requires an extra allocation for ReplaceableMetadataImpl. This is only strictly necessary if there are tracking references to the MDNode. Make the construction of ReplaceableMetadataImpl lazy, so that we don't get allocations if we don't need them. Since MDNode::isResolved now checks MDNode::isTemporary and MDNode::NumUnresolved instead of whether a ReplaceableMetadataImpl is allocated, the internal changes are intrusive (at various internal checkpoints, isResolved now has a different answer). However, there should be no real functionality change here; just slightly lazier allocation behaviour. The external semantics should be identical. llvm-svn: 265279
* [ThinLTO] Remove post-pass metadata linking supportTeresa Johnson2016-03-291-6/+1
| | | | | | | | | | | Since we have moved to a model where functions are imported in bulk from each source module after making summary-based importing decisions, there is no longer a need to link metadata as a postpass, and all users have been removed. This essentially reverts r255909 and follow-on fixes. llvm-svn: 264763
* Query the StringMap only once when creating MDString (NFC)Mehdi Amini2016-03-251-11/+6
| | | | | | | | | | | | | | | | Summary: Loading IR with debug info improves MDString::get() from 19ms to 10ms. This is a rework of D16597 with adding an "emplace" method on the StringMap to avoid requiring the MDString move ctor to be public. Reviewers: dexonsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17920 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264386
* fix documentation comments; NFCSanjay Patel2016-03-121-7/+2
| | | | llvm-svn: 263346
* Revert "Query the StringMap only once when creating MDString (NFC)"Mehdi Amini2016-02-171-6/+11
| | | | | | | | | This reverts commit r261030 and r261036. (The revision was marked "approved" on phabricator, but some concerns were raised on the mailing list. Thanks D. Blaikie for notifying me.) From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 261055
* Query the StringMap only once when creating MDString (NFC)Mehdi Amini2016-02-161-11/+6
| | | | | | | | | | | | | Summary: Loading IR with debug info improves MDString::get() from 19ms to 10ms. Reviewers: dexonsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D16597 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 261030
* Relax assertion in ReplaceableMetadataImpl::replaceAllUsesWith().Adrian Prantl2016-02-061-2/+0
| | | | | | | | | | There is a legitimate use-case in clang where we need to replace a temporary placeholder node with the temporary node that may be a forward declaration. <rdar://problem/24493203> llvm-svn: 259973
* Update to use new name alignTo().Rui Ueyama2016-01-141-2/+2
| | | | llvm-svn: 257804
* Split resolveCycles(bool AllowTemps) into two interfaces and documentTeresa Johnson2016-01-111-1/+1
| | | | | | | | | | | | | | Address review feedback from r255909. Move body of resolveCycles(bool AllowTemps) to resolveRecursivelyImpl(bool AllowTemps). Revert resolveCycles back to asserting on temps, and add new resolveNonTemporaries interface to invoke the new implementation with AllowTemps=true. Document the differences between these interfaces, specifically the effect on RAUW support and uniquing. Call appropriate interface from ValueMapper. llvm-svn: 257389
* [ThinLTO] Rename variables used in metadata linking (NFC)Teresa Johnson2015-12-301-2/+2
| | | | | | | | As suggested in review for r255909, rename MDMaterialized to AllowTemps, and identify the name of the boolean flag being set in calls to saveMetadataList. llvm-svn: 256653
* Ensure MDNode used as key in metadata linking map cannot be RAUWedTeresa Johnson2015-12-301-0/+2
| | | | | | | | | | | | As suggested in review for r255909, add a way to ensure that temporary MD used as keys in the MetadataToID map during ThinLTO importing are not RAUWed. Add support for marking an MDNode as not replaceable. Clear the new CanReplace flag when adding a temporary MD node to the MetadataToID map and clear it when destroying the map. llvm-svn: 256648
* [ptr-traits] Merge the MetadataTracking helpers into the MetadataChandler Carruth2015-12-291-0/+38
| | | | | | | | | | | | | | | | | | | | header. This is part of a series of patches to allow LLVM to check for complete pointee types when computing its pointer traits. This is absolutely necessary to get correct (or reproducible) results for things like how many low bits are guaranteed to be zero. The MetadataTracking helpers aren't actually independent. They rely on constructing a PointerUnion between Metadata and MetadataAsValue pointers, which requires know the alignment of pointers to those types which requires them to be complete. The .cpp file even defined a method declared in Metadata.h! These really don't seem like something that is separable, and there is no real layering problem with just placing them together. llvm-svn: 256531
* [ThinLTO] Metadata linking for imported functionsTeresa Johnson2015-12-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | Summary: Second patch split out from http://reviews.llvm.org/D14752. Maps metadata as a post-pass from each module when importing complete, suturing up final metadata to the temporary metadata left on the imported instructions. This entails saving the mapping from bitcode value id to temporary metadata in the importing pass, and from bitcode value id to final metadata during the metadata linking postpass. Depends on D14825. Reviewers: dexonsmith, joker.eph Subscribers: davidxl, llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D14838 llvm-svn: 255909
* Preserve load alignment and dereferenceable metadata during some transformationsArtur Pilipenko2015-11-021-0/+11
| | | | | | | | Reviewed By: hfinkel Differential Revision: http://reviews.llvm.org/D13953 llvm-svn: 251809
* Rollback of commit "Repress sanitization on User dtor."Naomi Musgrave2015-08-311-3/+1
| | | | | | | | | | | This would have suppressed bug 24578, about use-after- destroy on User and MDNode. Rolled back suppression for the sake of code cleanliness, in preferance for bug tracking to keep track of this issue. This reverts commit 6ff2baabc4625d5b0a8dccf76aa0f72d930ea6c0. llvm-svn: 246484
* Undo reversion on commit: Revert "Revert "Repress sanitization on User dtor.Naomi Musgrave2015-08-311-1/+3
| | | | | | | | Modify msan macros for applying attribute"" This reverts commit 020e70a79878c96457e6882bcdfaf6628baf32b7. llvm-svn: 246470
* Revert "Repress sanitization on User dtor. Modify msan macros for applying ↵Naomi Musgrave2015-08-311-3/+1
| | | | | | | | attribute" This reverts commit 5e3bfbb38eb3fb6f568b107f6b239e0aa4c5f334. llvm-svn: 246450
* Repress sanitization on User dtor. Modify msan macros for applying attributeNaomi Musgrave2015-08-311-1/+3
| | | | | | | | | | | | | | | to repress sanitization. Move attribute for repressing sanitization to operator delete for User, MDNode. Summary: In response to bug 24578, reported against failing LLVM test. Reviewers: chandlerc, rsmith, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12335 llvm-svn: 246449
* DI: Add Function::getSubprogram()Duncan P. N. Exon Smith2015-08-281-0/+8
| | | | | | | | | | | | | | | | | | Add `Function::setSubprogram()` and `Function::getSubprogram()`, convenience methods to forward to `setMetadata()` and `getMetadata()`, respectively, and deal in `DISubprogram` instead of `MDNode`. Also add a verifier check to enforce that `!dbg` attachments are always subprograms. Originally (when I had the llvm-dev discussion back in April) I thought I'd store a pointer directly on `llvm::Function` for these attachments -- we frequently have debug info, and that's much cheaper than using map in the context if there are no other function-level attachments -- but for now I'm just using the generic infrastructure. Let's add the extra complexity only if this shows up in a profile. llvm-svn: 246339
* fix typo; NFCSanjay Patel2015-08-241-1/+1
| | | | llvm-svn: 245896
* Rename Instruction::dropUnknownMetadata() to dropUnknownNonDebugMetadata()Adrian Prantl2015-08-201-5/+1
| | | | | | | | | | | and make it always preserve debug locations, since all callers wanted this behavior anyway. This is addressing a post-commit review feedback for r245589. NFC (inside the LLVM tree). llvm-svn: 245622
* Fix a bug that caused SimplifyCFG to drop DebugLocs.Adrian Prantl2015-08-201-1/+1
| | | | | | | | | | | Instruction::dropUnknownMetadata(KnownSet) is supposed to preserve all metadata in KnownSet, but the condition for DebugLocs was inverted. Most users of dropUnknownMetadata() actually worked around this by not adding LLVMContext::MD_dbg to their list of KnowIDs. This is now made explicit. llvm-svn: 245589
* DI: Disallow uniquable DICompileUnitsDuncan P. N. Exon Smith2015-08-031-4/+16
| | | | | | | | | | | | | | | | | | Since r241097, `DIBuilder` has only created distinct `DICompileUnit`s. The backend is liable to start relying on that (if it hasn't already), so make uniquable `DICompileUnit`s illegal and automatically upgrade old bitcode. This is a nice cleanup, since we can remove an unnecessary `DenseSet` (and the associated uniquing info) from `LLVMContextImpl`. Almost all the testcases were updated with this script: git grep -e '= !DICompileUnit' -l -- test | grep -v test/Bitcode | xargs sed -i '' -e 's,= !DICompileUnit,= distinct !DICompileUnit,' I imagine something similar should work for out-of-tree testcases. llvm-svn: 243885
* Tweak wording of alignment static_assert messages.James Y Knight2015-06-171-3/+3
| | | | llvm-svn: 239907
* Fix alignment issues in LLVM.James Y Knight2015-06-171-5/+20
| | | | | | | | | | | | | | | | | | Adds static_asserts to ensure alignment of concatenated objects is correct, and fixes them where they are not. Also changes the definition of AlignOf to use constexpr, except on MSVC, to avoid enum comparison warnings from GCC. (There's not too much of this in llvm itself, most of the fun is in clang). This seems to make LLVM actually work without Bus Error on 32bit sparc. Differential Revision: http://reviews.llvm.org/D10271 llvm-svn: 239872
* Move the name pointer out of Value into a map that lives on theOwen Anderson2015-06-011-7/+7
| | | | | | | | | | | | | | | | LLVMContext. Production builds of clang do not set names on most Value's, so this is wasted space on almost all subclasses of Value. This reduces the size of all Value subclasses by 8 bytes on 64 bit hosts. The one tricky part of this change is averting compile time regression by keeping Value::hasName() fast. This required stealing bits out of NumOperands. With this change, peak memory usage on verify-uselistorder-nodbg.lto.bc is decreased by approximately 2.3% (~3MB absolute on my machine). llvm-svn: 238791
* IR: Add Function metadata attachmentsDuncan P. N. Exon Smith2015-04-241-0/+76
| | | | | | | | Add IR support for `Metadata` attachments. Assembly and bitcode support will follow shortly, but for now we just have unit tests. This is part of PR23340. llvm-svn: 235783
* IR: Extract set logic from Instruction attachments, NFCDuncan P. N. Exon Smith2015-04-241-54/+60
| | | | | | | | | | | Extract the set logic for metadata attachments from `Instruction` so it can be reused for `Function` (PR23340). This data structure makes a `SmallVector<>` look (a little) like a map, just doing the bare minimum to support the `Instruction` (and soon, `Function`) metadata API. llvm-svn: 235769
* IR: Use remove_if for Instruction::dropUnknownMetadata()Duncan P. N. Exon Smith2015-04-241-16/+8
| | | | | | | | | | Technically the operations are different -- the old logic moved items from the back into the opened-up slots, instead of the usual `remove_if()` logic of a slow and a fast iterator -- but unless a profile tells us otherwise I prefer the simpler logic here. Regardless, there shouldn't be an observable function change. llvm-svn: 235767
* IR: Remove MDMapTy and MDPairTy typedefs, NFCDuncan P. N. Exon Smith2015-04-241-13/+7
| | | | | | | Remove some typedefs in preparation for factoring out attachment logic from `Instruction`. llvm-svn: 235764
* IR: Rename LLVMContextImpl::MetadataStore to InstructionMetadataDuncan P. N. Exon Smith2015-04-241-17/+20
| | | | | | | Rename `MetadataStore` to the more explicit `InstructionMetadata`. This will make room for `FunctionMetadata` (start of PR23340). llvm-svn: 235763
* IR: Enable uniquing callbacks during MDNode::replaceWithUniqued()Duncan P. N. Exon Smith2015-03-311-0/+4
| | | | | | | | | | | | | | | | Uniqued nodes have more complete registration with `ReplaceableMetadataImpl` so that they can update themselves when operands change. Fix a bug where `MDNode::replaceWithUniqued()` wasn't enabling these callbacks. The two most obvious ways missing callbacks causes problems is that auto-resolution fails and re-uniquing (on changed operands) just doesn't happen. I've added tests for both -- in both cases, I confirmed that the final check was failing before the fix. rdar://problem/20365935 llvm-svn: 233751
* IR: Use the new DebugLoc API, NFCDuncan P. N. Exon Smith2015-03-301-2/+2
| | | | | | | | Update lib/IR and lib/Bitcode to use the new `DebugLoc` API. Added an explicit conversion to `bool` (avoiding a conversion to `MDLocation`), since a couple of these use cases need to handle broken code. llvm-svn: 233585
* IR: Add MDNode::replaceWithPermanent()Duncan P. N. Exon Smith2015-02-101-0/+16
| | | | | | | | | | | | | | | | Add new API for converting temporaries that may self-reference. Self-referencing nodes are not allowed to be uniqued, so sending them into `replaceWithUniqued()` is dangerous (and this commit adds assertions that prevent it). `replaceWithPermanent()` has similar semantics to `get()` followed by calls to `replaceOperandWith()`. In particular, if there's a self-reference, it returns a distinct node; otherwise, it returns a uniqued one. Like `replaceWithUniqued()` and `replaceWithDistinct()` (well, it calls out to them) it mutates the temporary node in place if possible, only calling `replaceAllUsesWith()` on a uniquing collision. llvm-svn: 228726
* Metadata: Use <algorithm> to simplify code. NFC.Benjamin Kramer2015-02-081-30/+12
| | | | llvm-svn: 228550
* Correctly combine alias.scope metadata by a union instead of intersectingBjorn Steinbrink2015-02-081-0/+22
| | | | | | | | | | | | | | | | | Summary: The alias.scope metadata represents sets of things an instruction might alias with. When generically combining the metadata from two instructions the result must be the union of the original sets, because the new instruction might alias with anything any of the original instructions aliased with. Reviewers: hfinkel Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7490 llvm-svn: 228525
* IR: Split out DebugInfoMetadata.h, NFCDuncan P. N. Exon Smith2015-02-021-105/+2
| | | | | | | | | 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
* Fix some file headers, NFCDuncan P. N. Exon Smith2015-02-021-1/+1
| | | | llvm-svn: 227826
* IR: Change GenericDwarfNode::getHeader() to StringRefDuncan P. N. Exon Smith2015-01-221-6/+4
| | | | | | | Simplify the API to use a `StringRef` directly rather than exposing the `MDString` bits underneath. llvm-svn: 226876
* IR: DwarfNode => DebugNode, NFCDuncan P. N. Exon Smith2015-01-221-7/+7
| | | | | | | | | 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
* IR: Update references to temporaries before deletingDuncan P. N. Exon Smith2015-01-221-0/+1
| | | | | | | | | | | | | | | | During `MDNode::deleteTemporary()`, call `replaceAllUsesWith(nullptr)` to update all tracking references to `nullptr`. This fixes PR22280, where inverted destruction order between tracking references and the temporaries themselves caused a use-after-free in `LLParser`. An alternative fix would be to add an assertion that there are no users, and continue to fix inverted destruction order in clients (like `LLParser`), but instead I decided to make getting-teardown-right easy. (If someone disagrees let me know.) llvm-svn: 226866
* IR: Move MDNode clone() methods from ValueMapper to MDNode, NFCDuncan P. N. Exon Smith2015-01-201-0/+11
| | | | | | | | Now that the clone methods used by `MapMetadata()` don't do any remapping (and return a temporary), they make more sense as member functions on `MDNode` (and subclasses). llvm-svn: 226541
* IR: Canonicalize GenericDwarfNode empty headers to nullDuncan P. N. Exon Smith2015-01-201-0/+4
| | | | llvm-svn: 226532
* IR: Detect whether to call recalculateHash() via SFINAE, NFCDuncan P. N. Exon Smith2015-01-201-18/+33
| | | | | | | | Rather than relying on updating switch statements correctly, detect whether `setHash()` exists in the subclass. If so, call `recalculateHash()` and `setHash(0)` appropriately. llvm-svn: 226531
* IR: Introduce GenericDwarfNodeDuncan P. N. Exon Smith2015-01-201-5/+40
| | | | | | | | | | | | As part of PR22235, introduce `DwarfNode` and `GenericDwarfNode`. The former is a metadata node with a DWARF tag. The latter matches our current (generic) schema of a header with string (and stringified integer) data and an arbitrary number of operands. This doesn't move it into place yet; that change will require a large number of testcase updates. llvm-svn: 226529
* IR: Cleanup MDNode field use, NFCDuncan P. N. Exon Smith2015-01-191-19/+14
| | | | | | | | | Swap usage of `SubclassData32` and `MDNodeSubclassData`, and rename `MDNodeSubclassData` to `NumUnresolved`. Small drive-by cleanup to `countUnresolvedOperands()` since otherwise the name clash with local vars named `NumUnresolved` would be confusing. llvm-svn: 226523
* IR: Move replaceWithUniqued(), etc., to source file, NFCDuncan P. N. Exon Smith2015-01-191-0/+19
| | | | llvm-svn: 226522
* IR: Cleanup MDNode::MDNode(), NFCDuncan P. N. Exon Smith2015-01-191-10/+9
| | | | llvm-svn: 226521
* IR: Merge UniquableMDNode back into MDNode, NFCDuncan P. N. Exon Smith2015-01-191-41/+36
| | | | | | | | | 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: Extract MDNodeOpsKey, NFCDuncan P. N. Exon Smith2015-01-191-27/+2
| | | | | | Make the MDTuple operand hashing logic reusable. llvm-svn: 226519
OpenPOWER on IntegriCloud