summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/User.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Reinstate MSan suppression of PR24578.Evgenii Stepanov2019-11-221-1/+3
| | | | | | | | | | | | | | | | | | | Summary: Revert "Rollback of commit "Repress sanitization on User dtor."" There is no point in keeping an active MSan error in the codebase. PR24578 tracks the actual UB in LLVM code; this change enables testing of LLVM with MSAN + -fsanitize-memory-use-after-dtor. This reverts commit 21c1bc46aee2b69c2c48db8e961f0ce8394f21e1. Reviewers: vitalybuka Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70611
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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
* Remove redundant includes from lib/IR.Michael Zolotukhin2017-12-131-1/+0
| | | | llvm-svn: 320622
* [IR] De-virtualize ~Value to save a vptrReid Kleckner2017-05-181-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Implements PR889 Removing the virtual table pointer from Value saves 1% of RSS when doing LTO of llc on Linux. The impact on time was positive, but too noisy to conclusively say that performance improved. Here is a link to the spreadsheet with the original data: https://docs.google.com/spreadsheets/d/1F4FHir0qYnV0MEp2sYYp_BuvnJgWlWPhWOwZ6LbW7W4/edit?usp=sharing This change makes it invalid to directly delete a Value, User, or Instruction pointer. Instead, such code can be rewritten to a null check and a call Value::deleteValue(). Value objects tend to have their lifetimes managed through iplist, so for the most part, this isn't a big deal. However, there are some places where LLVM deletes values, and those places had to be migrated to deleteValue. I have also created llvm::unique_value, which has a custom deleter, so it can be used in place of std::unique_ptr<Value>. I had to add the "DerivedUser" Deleter escape hatch for MemorySSA, which derives from User outside of lib/IR. Code in IR cannot include MemorySSA headers or call the MemoryAccess object destructors without introducing a circular dependency, so we need some level of indirection. Unfortunately, no class derived from User may have any virtual methods, because adding a virtual method would break User::getHungOffOperands(), which assumes that it can find the use list immediately prior to the User object. I've added a static_assert to the appropriate OperandTraits templates to help people avoid this trap. Reviewers: chandlerc, mehdi_amini, pete, dberlin, george.burgess.iv Reviewed By: chandlerc Subscribers: krytarowski, eraman, george.burgess.iv, mzolotukhin, Prazek, nlewycky, hans, inglorion, pcc, tejohnson, dberlin, llvm-commits Differential Revision: https://reviews.llvm.org/D31261 llvm-svn: 303362
* Retire llvm::alignOf in favor of C++11 alignof.Benjamin Kramer2016-10-201-3/+2
| | | | | | No functionality change intended. llvm-svn: 284733
* [IR] Teach `llvm::User` to co-allocate a descriptor.Sanjoy Das2015-09-241-3/+61
| | | | | | | | | | | | | | | | | | | | | | | | Summary: With this change, subclasses of `llvm::User` will be able to co-allocate a variable number of bytes (called a "descriptor") with the `llvm::User` instance. The co-allocated descriptor can later be accessed using `llvm::User::getDescriptor`. This will be used in later changes to implement operand bundles. This change steals one bit from `NumUserOperands`, but given that it is still 28 bits wide I don't think this will be a practical issue. This change does not allow allocating hung off uses with descriptors. This only for simplicity, not for any fundamental reason; and we can easily add this functionality later if needed. Reviewers: reames, chandlerc, dexonsmith, kmod, majnemer, pete, JosephTremoulet Subscribers: pete, sanjoy, llvm-commits Differential Revision: http://reviews.llvm.org/D12455 llvm-svn: 248453
* 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
* Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)Alexander Kornienko2015-06-231-1/+1
| | | | | | Apparently, the style needs to be agreed upon first. llvm-svn: 240390
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-191-1/+1
| | | | | | | | | | | | | The patch is generated using this command: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ llvm/lib/ Thanks to Eugene Kosov for the original patch! llvm-svn: 240137
* Tweak wording of alignment static_assert messages.James Y Knight2015-06-171-3/+4
| | | | llvm-svn: 239907
* Fix alignment issues in LLVM.James Y Knight2015-06-171-0/+6
| | | | | | | | | | | | | | | | | | 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 OperandList to be allocated prior to User for hung off subclasses.Pete Cooper2015-06-121-11/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For hung off uses, we need a Use* to tell use where the operands are. This was User::OperandList but we want to remove that to save space of all subclasses which aren't making use of 'hung off uses'. Hung off uses now allocate their own 'OperandList' Use* in the User::new which they call. getOperandList() now uses the hung off uses bit to work out where the Use* for the OperandList lives. If a User has hung off uses, then this bit tells them to go back a single Use* from the User* and use that value as the OperandList. If a User has no hung off uses, then we get the first operand by subtracting (NumOperands * sizeof(Use)) from the User this pointer. This saves a pointer from User and all subclasses. Given the average size of a subclass of User is 112 or 128 bytes, this saves around 7% of space With malloc tending to align to 16-bytes the real saving is typically more like 3.5%. On 'opt -O2 verify-uselistorder.lto.bc', peak memory usage prior to this change is 149MB and after is 143MB so the savings are around 2.5% of peak. Looking at some passes which allocate many Instructions and Values, parseIR drops from 54.25MB to 52.21MB while the Inliner calls to Instruction::clone() drops from 28.20MB to 27.05MB. Reviewed by Duncan Exon Smith. llvm-svn: 239623
* Added a version of User::new for hung off uses.Pete Cooper2015-06-121-4/+12
| | | | | | | | | | | | | | | | | There are now 2 versions of User::new. The first takes a size_t and is the current implementation for subclasses which need 0 or more Use's allocated for their operands. The new version takes no extra arguments to say that this subclass needs 'hung off uses'. The HungOffUses bool is now set in this version of User::new and we can assert in allocHungOffUses that we are allowed to have hung off uses. This ensures we call the correct version of User::new for subclasses which need hung off uses. A future commit will then allocate space for a single Use* which will be used in place of User::OperandList once that field has been removed. Reviewed by Duncan Exon Smith. llvm-svn: 239622
* Rename NumOperands to make it clear its managed by the User. NFC.Pete Cooper2015-06-121-2/+3
| | | | | | | | | | | | | | | | | | | | | This is to try make it very clear that subclasses shouldn't be changing the value directly. Now that OperandList for normal instructions is computed using the NumOperands, its critical that the NumOperands is accurate or we could compute the wrong offset to the first operand. I looked over all places which update NumOperands and they are all safe. Hung off use User's don't use NumOperands to compute the OperandList so they are safe to continue to manipulate it. The only other User which changed it was GlobalVariable which has an optional init list but always allocated space for a single Use. It was correctly setting NumOperands to 1 before setting an initializer, and setting it to 0 after clearing the init list, so the order was safe. Added some comments to that code to make sure that this isn't changed in future without being aware of this constraint. Reviewed by Duncan Exon Smith. llvm-svn: 239621
* Replace all accesses to User::OperandList with getter and setter methods. NFC.Pete Cooper2015-06-121-4/+4
| | | | | | | | | | We don't want anyone to access OperandList directly as its going to be removed and computed instead. This uses getter's and setter's instead in which we can later change the underlying implementation of OperandList. Reviewed by Duncan Exon Smith. llvm-svn: 239620
* Stop returning a Use* from allocHungOffUses.Pete Cooper2015-06-101-4/+2
| | | | | | | | | This always just set the User::OperandList which is now set in that method instead of being returned. Reviewed by Duncan Exon Smith. llvm-svn: 239493
* Add User::growHungoffUses and use it to grow the hung off uses. NFC.Pete Cooper2015-06-101-0/+27
| | | | | | | | | | | | | PhiNode, SwitchInst, LandingPad and IndirectBr all had virtually identical logic for growing the hung off uses. Move it to User so that they can all call a single shared implementation. Their destructors were all empty after this change and were deleted. They all have virtual clone_impl methods which can be used as vtable anchors. Reviewed by Duncan Exon Smith. llvm-svn: 239492
* Make User track whether a class has 'hung off uses' and delete them in its ↵Pete Cooper2015-06-101-2/+7
| | | | | | | | | | | | | | | | | | | | | destructor. Currently all of the logic for deleting hung off uses, which PHI/switch/etc use, is in their classes. This adds a bit to Value which tracks whether that user had hung off uses, then User can be responsible for clearing them instead of the sub classes. Note, the bit used here was taken from NumOperands which was 30-bits. Given the reduction to 29 bits, and the average User being just over 100 bytes, a single User with 29-bits of num operands would need 50GB of RAM for itself so its reasonable to assume that 29-bits is enough for now. This is a step towards hiding all the hung off uses logic in the User. Reviewed by Duncan Exon Smith. llvm-svn: 239490
* Move the special Phi logic for hung off uses in to User::allocHungOffUses. NFC.Pete Cooper2015-06-101-1/+4
| | | | | | | | | | | | PhiNode's need to allocate space for an array of Use[N] and then BasicBlock*[N]. They had their own allocHungOffUses to handle all of this. This moves the logic in to User::allocHungOffUses and PhiNode passes in a bool to say to allocate the BB* space too. Reviewed by Duncan Exon Smith. llvm-svn: 239489
* IR: Cleanup comments for Value, User, and MDNodeDuncan P. N. Exon Smith2014-10-151-3/+0
| | | | | | | | | | | | | A follow-up commit will modify the memory-layout of `Value`, `User`, and `MDNode`. First fix the comments to be doxygen-friendly (and to follow the coding standards). - Use "\brief" instead of "repeatedName -". - Add a brief intro where it was missing. - Remove duplicated comments from source files (and a couple of noisy/trivial comments altogether). llvm-svn: 219844
* Disable Visual C++ warning 4722 about aborting a destructor,Yaron Keren2014-03-251-20/+0
| | | | | | it has no value for us. llvm-svn: 204704
* In Release modes, Visual Studio complains that the Operator destructor in ↵Yaron Keren2014-03-241-0/+20
| | | | | | | | | | | | | | | | | | | | | User.cpp never returns, which is true by design. Initially assumed that the reason is llvm_unreachable being dependent on NDEBUG. However, even if llvm_unreachable is replaced by __assume(false), VC still warns in Release modes but not in Debug modes... The real reason turned out to be optimization flags. With /Od in Debug modes the warning is not issued whereas with /O1 it is. I could not find any documentation to this effect, but it is reproducable: Try compiling http://msdn.microsoft.com/en-us/library/khwfyc5d(v=vs.90).aspx with /O1 and then with /Od. llvm-svn: 204659
* Move all of the header files which are involved in modelling the LLVM IRChandler Carruth2013-01-021-4/+4
| | | | | | | | | | | | | | | | | | | | | into their new header subdirectory: include/llvm/IR. This matches the directory structure of lib, and begins to correct a long standing point of file layout clutter in LLVM. There are still more header files to move here, but I wanted to handle them in separate commits to make tracking what files make sense at each layer easier. The only really questionable files here are the target intrinsic tablegen files. But that's a battle I'd rather not fight today. I've updated both CMake and Makefile build systems (I think, and my tests think, but I may have missed something). I've also re-sorted the includes throughout the project. I'll be committing updates to Clang, DragonEgg, and Polly momentarily. llvm-svn: 171366
* Rename VMCore directory to IR.Chandler Carruth2013-01-021-0/+90
Aside from moving the actual files, this patch only updates the build system and the source file comments under lib/... that are relevant. I'll be updating other docs and other files in smaller subsequnet commits. While I've tried to test this, but it is entirely possible that there will still be some build system fallout. Also, note that I've not changed the library name itself: libLLVMCore.a is still the library name. I'd be interested in others' opinions about whether we should rename this as well (I think we should, just not sure what it might break) llvm-svn: 171359
OpenPOWER on IntegriCloud