aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/CodeGen
AgeCommit message (Collapse)AuthorFilesLines
2016-09-11CodeGen: Give MachineBasicBlock::reverse_iterator a handle to the current MIDuncan P. N. Exon Smith1-0/+22
Now that MachineBasicBlock::reverse_instr_iterator knows when it's at the end (since r281168 and r281170), implement MachineBasicBlock::reverse_iterator directly on top of an ilist::reverse_iterator by adding an IsReverse template parameter to MachineInstrBundleIterator. This replaces another hard-to-reason-about use of std::reverse_iterator on list iterators, matching the changes for ilist::reverse_iterator from r280032 (see the "out of scope" section at the end of that commit message). MachineBasicBlock::reverse_iterator now has a handle to the current node and has obvious invalidation semantics. r280032 has a more detailed explanation of how list-style reverse iterators (invalidated when the pointed-at node is deleted) are different from vector-style reverse iterators like std::reverse_iterator (invalidated on every operation). A great motivating example is this commit's changes to lib/CodeGen/DeadMachineInstructionElim.cpp. Note: If your out-of-tree backend deletes instructions while iterating on a MachineBasicBlock::reverse_iterator or converts between MachineBasicBlock::iterator and MachineBasicBlock::reverse_iterator, you'll need to update your code in similar ways to r280032. The following table might help: [Old] ==> [New] delete &*RI, RE = end() delete &*RI++ RI->erase(), RE = end() RI++->erase() reverse_iterator(I) std::prev(I).getReverse() reverse_iterator(I) ++I.getReverse() --reverse_iterator(I) I.getReverse() reverse_iterator(std::next(I)) I.getReverse() RI.base() std::prev(RI).getReverse() RI.base() ++RI.getReverse() --RI.base() RI.getReverse() std::next(RI).base() RI.getReverse() (For more details, have a look at r280032.) llvm-svn: 281172
2016-09-11CodeGen: Assert that bundle iterators are validDuncan P. N. Exon Smith1-0/+16
Add an assertion to the MachineInstrBundleIterator from instr_iterator that the underlying iterator is valid. This is possible know that we can check ilist_node::isSentinel (since r281168), and is consistent with the constructors from MachineInstr* and MachineInstr&. Avoiding the new assertion in operator== and operator!= requires four (!!!!) new overloads each. (As an aside, I'm strongly in favour of: - making the conversion from instr_iterator explicit; - making the conversion from pointer explicit; - making the conversion from reference explicit; and - removing all the extra overloads of operator== and operator!= except const_instr_iterator. I'm not signing up for that at this point, but being clear about when something is an MachineInstr-iterator (possibly instr_end()) vs MachineInstr-bundle-iterator (possibly end()) vs MachineInstr* (possibly nullptr) vs MachineInstr& (known valid) would surely make code cleaner... and it would remove a ton of boilerplate from MachineInstrBundleIterator operators.) llvm-svn: 281170
2016-09-11CodeGen: Turn on sentinel tracking for MachineInstr iteratorsDuncan P. N. Exon Smith1-1/+2
This is a prep commit before fixing MachineBasicBlock::reverse_iterator invalidation semantics, ala r281167 for ilist::reverse_iterator. This changes MachineBasicBlock::Instructions to track which node is the sentinel regardless of LLVM_ENABLE_ABI_BREAKING_CHECKS. There's almost no functionality change (aside from ABI). However, in the rare configuration: #if !defined(NDEBUG) && !defined(LLVM_ENABLE_ABI_BREAKING_CHECKS) the isKnownSentinel() assertions in ilist_iterator<>::operator* suddenly have teeth for MachineInstr. If these assertions start firing for your out-of-tree backend, have a look at the suggestions in the commit message for r279314, and at some of the commits leading up to it that avoid dereferencing the end() iterator. llvm-svn: 281168
2016-08-29GlobalISel: use multi-dimensional arrays for legalize actions.Tim Northover1-0/+2
Instead of putting all possible requests into a single table, we can perform the extremely dense lookup based on opcode and type-index in constant time using multi-dimensional array-like things. This roughly halves the time spent doing legalization, which was dominated by queries against the Actions table. llvm-svn: 280011
2016-08-26GlobalISel: legalize sdiv and srem operations.Tim Northover1-0/+2
llvm-svn: 279842
2016-08-23GlobalISel: extend legalizer interface to handle multiple types.Tim Northover1-22/+42
Instructions like G_ICMP have multiple types that may need to be legalized (the boolean output and nearly arbitrary inputs in this case). So the legalizer must be capable of deciding what to do for each of them separately. llvm-svn: 279554
2016-08-15GlobalISel: support loads and stores of strange types.Tim Northover1-4/+4
Before we mischaracterized structs and i1 types as a scalar with size 0 in various ways. llvm-svn: 278744
2016-08-12ADT: Remove all ilist_iterator => pointer casts, NFCDuncan P. N. Exon Smith2-0/+95
Remove all ilist_iterator to pointer casts. There were two reasons for casts: - Checking for an uninitialized (i.e., null) iterator. I added MachineInstrBundleIterator::isValid() to check for that case. - Comparing an iterator against the underlying pointer value while avoiding converting the pointer value to an iterator. This is occasionally necessary in MachineInstrBundleIterator, since there is an assertion in the constructors that the underlying MachineInstr is not bundled (but we don't care about that if we're just checking for pointer equality). To support the latter case, I rewrote the == and != operators for ilist_iterator and MachineInstrBundleIterator. - The implicit constructors now use enable_if to exclude const-iterator => non-const-iterator conversions from overload resolution (previously it was a compiler error on instantiation, now it's SFINAE). - The == and != operators are now global (friends), and are not templated. - MachineInstrBundleIterator has overloads to compare against both const_pointer and const_reference. This avoids the implicit conversions to MachineInstrBundleIterator that assert, instead just checking the address (and I added unit tests to confirm this). Notably, the only remaining uses of ilist_iterator::getNodePtrUnchecked are in ilist.h, and no code outside of ilist*.h directly relies on this UB end-iterator-to-pointer conversion anymore. It's still needed for ilist_*sentinel_traits, but I'll clean that up soon. llvm-svn: 278478
2016-08-04GlobalISel: refuse to halve size of 1-byte & odd-sized LLTs.Tim Northover1-9/+12
llvm-svn: 277768
2016-07-29[GlobalISel] Add missing link components to r277160 unittest. NFC.Ahmed Bougacha1-0/+2
It broke a shared builder: http://lab.llvm.org:8011/builders/llvm-mips-linux/builds/17320 llvm-svn: 277201
2016-07-29[GlobalISel] Add LLT::operator!=().Ahmed Bougacha1-0/+13
llvm-svn: 277162
2016-07-29[GlobalISel] Fix LLT::unsized to match LLT(LabelTy).Ahmed Bougacha1-0/+5
When coming from an IR label type, we set a 0 NumElements, but not when constructing an LLT using unsized(), causing comparisons to fail. Pick one variant and fix the other. llvm-svn: 277161
2016-07-29[GlobalISel] Add unittests for LowLevelType.Ahmed Bougacha2-0/+199
llvm-svn: 277160
2016-07-20GlobalISel: implement Legalization querying framework.Tim Northover3-0/+113
This adds an (incomplete, inefficient) framework for deciding what to do with some operation on a given type. llvm-svn: 276184
2016-07-13Fix header comment in unittests/CodeGen/DIEHashTest.cpp.Justin Lebar1-1/+1
llvm-svn: 275296
2016-01-26Remove autoconf supportChris Bieneman1-16/+0
Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened." - Obi Wan Kenobi Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D16471 llvm-svn: 258861
2015-06-25AsmPrinter: Use an intrusively linked list for DIE::ChildrenDuncan P. N. Exon Smith1-64/+63
Replace the `std::vector<>` for `DIE::Children` with an intrusively linked list. This is a strict memory improvement: it requires no auxiliary storage, and reduces `sizeof(DIE)` by one pointer. It also factors out the DIE-related malloc traffic. This drops llc memory usage from 735 MB down to 718 MB, or ~2.3%. (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) llvm-svn: 240736
2015-06-25AsmPrinter: Convert DIE::Values to a linked listDuncan P. N. Exon Smith1-161/+193
Change `DIE::Values` to a singly linked list, where each node is allocated on a `BumpPtrAllocator`. In order to support `push_back()`, the list is circular, and points at the tail element instead of the head. I abstracted the core list logic out to `IntrusiveBackList` so that it can be reused for `DIE::Children`, which also cares about `push_back()`. This drops llc memory usage from 799 MB down to 735 MB, about 8%. (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) llvm-svn: 240733
2015-05-27Reapply "AsmPrinter: Change DIEValue to be stored by value"Duncan P. N. Exon Smith1-153/+153
This reverts commit r238350, effectively reapplying r238349 after fixing (all?) the problems, all somehow related to how I was using `AlignedArrayCharUnion<>` inside `DIEValue`: - MSVC can only handle `sizeof()` on types, not values. Change the assert. - GCC doesn't know the `is_trivially_copyable` type trait. Instead of asserting it, add destructors. - Call placement new even when constructing POD (i.e., the pointers). - Instead of copying the char buffer, copy the casted classes. I've left in a couple of `static_assert`s that I think both MSVC and GCC know how to handle. If the bots disagree with me, I'll remove them. - Check that the constructed type is either standard layout or a pointer. This protects against a programming error: we really want the "small" `DIEValue`s to be small and simple, so don't accidentally change them not to be. - Similarly, check that the size of the buffer is no bigger than a `uint64_t` or a pointer. (I thought checking against `sizeof(uint64_t)` would be good enough, but Chandler suggested that pointers might sometimes be bigger than that in the context of sanitizers.) I've also committed r238359 in the meantime, which introduces a DIEValue.def to simplify dispatching between the various types (thanks to a review comment by David Blaikie). Without that, this commit would be almost unintelligible. Here's the original commit message: -- Change `DIEValue` to be stored/passed/etc. by value, instead of reference. It's now a discriminated union, with a `Val` field storing the actual type. The classes that used to inherit from `DIEValue` no longer do. There are two categories of these: - Small values fit in a single pointer and are stored by value. - Large values require auxiliary storage, and are stored by reference. The only non-mechanical change is to tools/dsymutil/DwarfLinker.cpp. It was relying on `DIEInteger`s being passed around by reference, so I replaced that assumption with a `PatchLocation` type that stores a safe reference to where the `DIEInteger` lives instead. This commit causes a temporary regression in memory usage, since I've left merging `DIEAbbrevData` into `DIEValue` for a follow-up commit. I measured an increase from 845 MB to 879 MB, around 3.9%. The follow-up drops it lower than the starting point, and I've only recently brought the memory this low anyway, so I'm committing these changes separately to keep them incremental. (I also considered swapping the commits, but the other one first would cause a lot more code churn.) (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) -- llvm-svn: 238362
2015-05-27Revert "AsmPrinter: Change DIEValue to be stored by value"Duncan P. N. Exon Smith1-153/+153
This reverts commit r238349, since it caused some errors on bots: - std::is_trivially_copyable isn't available until GCC 5.0. - It was complaining about strict aliasing with my use of ArrayCharUnion. llvm-svn: 238350
2015-05-27AsmPrinter: Change DIEValue to be stored by valueDuncan P. N. Exon Smith1-153/+153
Change `DIEValue` to be stored/passed/etc. by value, instead of reference. It's now a discriminated union, with a `Val` field storing the actual type. The classes that used to inherit from `DIEValue` no longer do. There are two categories of these: - Small values fit in a single pointer and are stored by value. - Large values require auxiliary storage, and are stored by reference. The only non-mechanical change is to tools/dsymutil/DwarfLinker.cpp. It was relying on `DIEInteger`s being passed around by reference, so I replaced that assumption with a `PatchLocation` type that stores a safe reference to where the `DIEInteger` lives instead. This commit causes a temporary regression in memory usage, since I've left merging `DIEAbbrevData` into `DIEValue` for a follow-up commit. I measured an increase from 845 MB to 879 MB, around 3.9%. The follow-up drops it lower than the starting point, and I've only recently brought the memory this low anyway, so I'm committing these changes separately to keep them incremental. (I also considered swapping the commits, but the other one first would cause a lot more code churn.) (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) llvm-svn: 238349
2015-05-24AsmPrinter: Make DIEString smallDuncan P. N. Exon Smith1-56/+70
Expose the `DwarfStringPool` entry in a header, and store a pointer to it directly in `DIEString`. Instead of choosing at creation time how to emit it, use the `dwarf::Form` to determine that at emission time. Besides avoiding the other `DIEValue`, this shaves two pointers off of `DIEString`; the data is now a single pointer. This is a nice cleanup on its own -- and drops memory usage from 861 MB down to 853 MB, around 0.9% -- but it's also preparation for passing `DIEValue`s by value. (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) llvm-svn: 238117
2015-01-14[cleanup] Re-sort all the #include lines in LLVM usingChandler Carruth1-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
2015-01-05Make DIE.h a public CodeGen header.Frederic Riss1-1/+1
dsymutil would like to use all the AsmPrinter/MCStreamer infrastructure to stream out the DWARF. In order to do so, it will reuse the DIE object and so this header needs to be public. The interface exposed here has some corners that cannot be used without a DwarfDebug object, but clients that want to stream Dwarf can just avoid these. Differential Revision: http://reviews.llvm.org/D6695 llvm-svn: 225208
2014-04-25DIE: Pass ownership of children via std::unique_ptr rather than raw pointer.David Blaikie1-62/+64
This should reduce the chance of memory leaks like those fixed in r207240. There's still some unclear ownership of DIEs happening in DwarfDebug. Pushing unique_ptr and references through more APIs should help expose the cases where ownership is a bit fuzzy. llvm-svn: 207263
2014-04-25DIEEntry: Refer to the specified DIE via reference rather than pointer.David Blaikie1-29/+29
Makes some more cases (the unit tests, specifically), lexically compatible with a change to unique_ptr. llvm-svn: 207261
2014-04-25PR19554: Fix some memory leaks in DIEHashTest.cppDavid Blaikie1-11/+11
llvm-svn: 207240
2014-02-20Add support for hashing attributes with DW_FORM_block. This requiredEric Christopher1-0/+55
passing down an AsmPrinter instance so we could compute the size of the block which could be target specific. All of the test cases in the unittest don't have any target specific data so we can use a NULL AsmPrinter there. This also depends upon block data being added as integers. We can now hash the entire fission-cu.ll compile unit so turn the flag on there with the hash value. llvm-svn: 201752
2014-02-20This tests DW_FORM_sdata, not DW_FORM_block. Make the test say so.Eric Christopher1-1/+1
llvm-svn: 201749
2014-02-20Fix commit thinkos from splitting out patches.Eric Christopher1-3/+1
llvm-svn: 201748
2014-02-20Add support for hashing DW_FORM_sdata and a small testcase.Eric Christopher1-0/+47
llvm-svn: 201747
2014-02-20Format.Eric Christopher1-4/+8
llvm-svn: 201746
2014-01-31Add support for DW_FORM_flag and DW_FORM_flag_present to the DIE hashingEric Christopher1-0/+31
algorithm. Sink the 'A' + Attribute hash into each form so we don't have to check valid forms before deciding whether or not we're going to hash which will let the default be to return without doing anything. llvm-svn: 200571
2014-01-31Fix name of nested type in comment to match code.Eric Christopher1-1/+1
llvm-svn: 200570
2014-01-07Re-sort all of the includes with ./utils/sort_includes.py so thatChandler Carruth1-1/+1
subsequent changes are easier to review. About to fix some layering issues, and wanted to separate out the necessary churn. Also comment and sink the include of "Windows.h" in three .inc files to match the usage in Memory.inc. llvm-svn: 198685
2013-12-10[CMake] Update LLVM_LINK_COMPONENTS for each CMakeLists.txt.NAKAMURA Takumi1-3/+2
llvm-svn: 196908
2013-10-25DIEHash: Summary hashing of member functionsDavid Blaikie1-0/+18
llvm-svn: 193432
2013-10-25DIEHash: Summary hashing of nested typesDavid Blaikie1-0/+19
llvm-svn: 193427
2013-10-24DIEHash: Const correct and use references where non-null/non-rebound.David Blaikie1-16/+16
llvm-svn: 193363
2013-10-24DIEHash: Do not use shallow type hashing for unnamed typesDavid Blaikie1-0/+35
llvm-svn: 193361
2013-10-22DWARF type hashing: pointers to membersDavid Blaikie1-0/+178
Includes a test case/FIXME demonstrating a bug/limitation in pointer to member hashing. To be honest I'm not sure why we don't just always use summary hashing for referenced types... but perhaps I'm missing something. llvm-svn: 193175
2013-10-21DWARF Type Hashing: Include reference and rvalue reference type in the ↵David Blaikie1-0/+66
declarable summary hashing path More support for 7.25 Part 5. llvm-svn: 193129
2013-10-21DWARF type hashing: begin implementing Step 5, summary hashing in declarable ↵David Blaikie1-6/+35
contexts There are several other tag types that need similar handling but to ensure test coverage they'll be coming incrementally. llvm-svn: 193126
2013-10-21DIEHashTest: Correct the order of operands to the TEST macroDavid Blaikie1-7/+7
And add the 'Test' suffix so the test case name matches the file name. llvm-svn: 193119
2013-10-21DWARF type hashing: Handle multiple (including recursive) references to the ↵David Blaikie1-1/+58
same type This uses a map, keeping the type DIE numbering separate from the DIEs themselves - alternatively we could do things the way GCC does if we want to add an integer to the DIE type to record the numbering there. llvm-svn: 193105
2013-10-17DIEHash: Support for simple (non-recursive, non-reused) type referencesDavid Blaikie1-7/+29
llvm-svn: 192924
2013-10-17DIEHash: Include the type's context in the type hash.David Blaikie1-7/+56
llvm-svn: 192856
2013-10-16DIEHash: Use DW_FORM_sdata for integers, per spec.David Blaikie1-1/+17
This allows us to produce the same hash as GCC for at least some simple examples. llvm-svn: 192855
2013-10-16Invert arguments to ASSERT_EQ to match gtest diagnostic printingDavid Blaikie1-1/+1
GTest assumes the left hand side of the assert is the expectation and the right hand side is the test result. It's easier to read gtest failures when these things are ordered correctly. llvm-svn: 192854
2013-10-16DIEHash: Include the trailing zero byte after the children of a DIEDavid Blaikie1-1/+1
llvm-svn: 192836