summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT
Commit message (Collapse)AuthorAgeFilesLines
...
* [NFC] Header cleanupMehdi Amini2016-04-182-3/+0
| | | | | | | | | | | | | | Removed some unused headers, replaced some headers with forward class declarations. Found using simple scripts like this one: clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap' Patch by Eugene Kosov <claprix@yandex.ru> Differential Revision: http://reviews.llvm.org/D19219 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266595
* Remove some unneeded headers and replace some headers with forward class ↵Mehdi Amini2016-04-162-2/+3
| | | | | | | | | | | declarations (NFC) Differential Revision: http://reviews.llvm.org/D19154 Patch by Eugene Kosov <claprix@yandex.ru> From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266524
* APInt: Add overload of isMaskMatt Arsenault2016-04-121-0/+17
| | | | | | | This mimics the version in MathExtras.h which isn't testing for a specific mask size. llvm-svn: 266101
* Revert "Fix Clang-tidy modernize-deprecated-headers warnings in remaining ↵Duncan P. N. Exon Smith2016-04-053-23/+15
| | | | | | | | | | files; other minor fixes." This reverts commit r265454 since it broke the build. E.g.: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/22413/ llvm-svn: 265459
* Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; ↵Eugene Zelenko2016-04-053-15/+23
| | | | | | | | | | | | other minor fixes. Some Include What You Use suggestions were used too. Use anonymous namespaces in source files. Differential revision: http://reviews.llvm.org/D18778 llvm-svn: 265454
* Add a copy constructor to StringMapHal Finkel2016-03-301-0/+27
| | | | | | | | | | There is code under review that requires StringMap to have a copy constructor, and this makes StringMap more consistent with our other containers (like DenseMap) that have copy constructors. Differential Revision: http://reviews.llvm.org/D18506 llvm-svn: 264906
* StringMap/DenseMap unittests: use piecewise_construct and ensure no copy occurs.Mehdi Amini2016-03-252-22/+22
| | | | | | | | This makes us no longer relying on move-construction elision by the compiler. Suggested by D. Blaikie. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264475
* [SetVector] Add erase() methodJun Bum Lim2016-03-252-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | This is a recommit of r264414 after fixing the buildbot failure caused by incompatible use of std::vector.erase(). The original message: Add erase() which returns an iterator pointing to the next element after the erased one. This makes it possible to erase selected elements while iterating over the SetVector : while (I != E) if (test(*I)) I = SetVector.erase(I); else ++I; Reviewers: qcolombet, mcrosier, MatzeB, dblaikie Subscribers: dberlin, dblaikie, mcrosier, llvm-commits Differential Revision: http://reviews.llvm.org/D18281 llvm-svn: 264450
* Revert "[SetVector] Add erase() method"Jun Bum Lim2016-03-252-35/+0
| | | | | | This reverts commit r264414. llvm-svn: 264420
* Improve StringMap unittests: reintroduce move count, but shield against ↵Mehdi Amini2016-03-251-5/+12
| | | | | | | std::pair internals From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264418
* Ensure that the StringMap does not grow during the test for ↵Mehdi Amini2016-03-251-0/+3
| | | | | | | pre-allocation/reserve From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264416
* [SetVector] Add erase() methodJun Bum Lim2016-03-252-0/+35
| | | | | | | | | | | | | | | | | | | | Summary: Add erase() which returns an iterator pointing to the next element after the erased one. This makes it possible to erase selected elements while iterating over the SetVector : while (I != E) if (test(*I)) I = SetVector.erase(I); else ++I; Reviewers: qcolombet, mcrosier, MatzeB, dblaikie Subscribers: dberlin, dblaikie, mcrosier, llvm-commits Differential Revision: http://reviews.llvm.org/D18281 llvm-svn: 264414
* Disable counting the number of move in the unittest, it seems to rely on ↵Mehdi Amini2016-03-252-4/+9
| | | | | | | move-construction elision From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264412
* Query the StringMap only once when creating MDString (NFC)Mehdi Amini2016-03-251-14/+47
| | | | | | | | | | | | | | | | 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
* Adjust initial size in StringMap constructor to guarantee no grow()Mehdi Amini2016-03-251-3/+42
| | | | | | | | | | | | | | | | | | Summary: StringMap ctor accepts an initialize size, but expect it to be rounded to the next power of 2. The ctor can handle that directly instead of expecting clients to round it. Also, since the map will resize itself when 75% full, take this into account an initialize a larger initial size to avoid any growth. Reviewers: dblaikie Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D18344 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264385
* Fix DenseMap::reserve(): the formula was wrongMehdi Amini2016-03-251-7/+118
| | | | | | | | | | | | | | | | | | | | | | Summary: Just running the loop in the unittests for a few more iterations (till 48) exhibit that the condition on the limit was not handled properly in r263522. Rewrite the test to use a class to count move/copies that happens when inserting into the map. Also take the opportunity to refactor the logic to compute the number of buckets required for a given number of entries in the map. Use this when constructing a DenseMap with a desired size given to the constructor (and add a tests for this). Reviewers: dblaikie Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D18345 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264384
* [ADT] C++11ify SmallVector::erase's arguments from iterator to const_iteratorDavid Blaikie2016-03-241-2/+4
| | | | llvm-svn: 264330
* APFloat: Fix signalling nans for scalbnMatt Arsenault2016-03-231-1/+16
| | | | llvm-svn: 264219
* StringRef::copy shouldn't allocate anything for length 0 strings.Pete Cooper2016-03-231-0/+9
| | | | | | | | | | | The BumpPtrAllocator currently doesn't handle zero length allocations well. The discussion for how to fix that is ongoing. However, there's no need for StringRef::copy to actually allocate anything here anyway, so just return StringRef() when we get a zero length copy. Reviewed by David Blaikie llvm-svn: 264201
* Fix unittests: resize() -> reserve()Mehdi Amini2016-03-221-1/+1
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264029
* APFloat: Add frexpMatt Arsenault2016-03-211-1/+127
| | | | llvm-svn: 263950
* Implement constant folding for bitreverseMatt Arsenault2016-03-211-0/+42
| | | | llvm-svn: 263945
* Revert "allow lambdas in mapped_iterator"Mike Aizatsky2016-03-172-52/+0
| | | | | | | | | | | | | | | MSVC as usual: C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include\llvm/ADT/STLExtras.h(120): error C2100: illegal indirection C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include\llvm/IR/Instructions.h(3966): note: see reference to class template instantiation 'llvm::mapped_iterator<llvm::User::op_iterator,llvm::CatchSwitchInst::DerefFnTy>' being compiled This reverts commit e091dd63f1f34e043748e28ad160d3bc17731168. llvm-svn: 263760
* allow lambdas in mapped_iteratorMike Aizatsky2016-03-172-0/+52
| | | | | | Differential Revision: http://reviews.llvm.org/D17311 llvm-svn: 263759
* DenseMap: make .resize() do the intuitive thingFiona Glaser2016-03-151-0/+13
| | | | | | | | | | | | | | | | | | | In some places, like InstCombine, we resize a DenseMap to fit the elements we intend to put in it, then insert those elements (to avoid continual reallocations as it grows). But .resize(foo) doesn't actually do what people think; it resizes to foo buckets (which is really an implementation detail the user of DenseMap probably shouldn't care about), not the space required to fit foo elements. DenseMap grows if 3/4 of its buckets are full, so this actually causes one forced reallocation every time instead of avoiding a reallocation. This patch makes .resize(foo) do the intuitive thing: it grows to the size necessary to fit foo elements without new allocations. Also include a test to verify that .resize() actually does what we think it does. llvm-svn: 263522
* [ADT] Add a pop_back_val method to the SparseSet container.Quentin Colombet2016-03-141-0/+20
| | | | | | The next commit will use it. llvm-svn: 263455
* APFloat: Fix ilogb for denormalsMatt Arsenault2016-03-131-2/+16
| | | | llvm-svn: 263370
* APFloat: Fix scalbn handling of denormalsMatt Arsenault2016-03-131-22/+135
| | | | | | | This was incorrect for denormals, and also failed on longer exponent ranges. llvm-svn: 263369
* [ADT] Fix PointerEmbeddedInt when the underlying type is uintptr_t.Jordan Rose2016-02-181-0/+34
| | | | | | ...and when you try to store negative values in it. llvm-svn: 261259
* [ADT] Add StringRef::{l,r}trim(char) overloads (NFC)Vedant Kumar2016-02-161-1/+1
| | | | | | | | | Add support for trimming a single kind of character from a StringRef. This makes the common case of trimming null bytes much neater. It's also probably a bit speedier too, since it avoids creating a std::bitset in find_{first,last}_not_of. llvm-svn: 260925
* Add AMDGPU related triple vendors/OSesMatt Arsenault2016-02-131-0/+12
| | | | | | | | As support expands to more runtimes, we'll need to distinguish between more than just HSA and unknown. This also lets us stop using unknown everywhere. llvm-svn: 260790
* [ADT] Revert the llvm/ADT/OptionSet.h header and unit test.Argyrios Kyrtzidis2016-02-122-116/+0
| | | | llvm-svn: 260714
* [unittests/ADT] OptionSetTest: ifdef out for now a specific test that fails ↵Argyrios Kyrtzidis2016-02-121-0/+4
| | | | | | on MSVC. llvm-svn: 260663
* [unittests/ADT] OptionSetTest: ifdef out a part that fails to compile on MSVC.Argyrios Kyrtzidis2016-02-121-0/+3
| | | | llvm-svn: 260655
* [ADT] Introduce ‘OptionSet’ in llvm/ADT headers, which is a utility ↵Argyrios Kyrtzidis2016-02-122-0/+109
| | | | | | class that makes it convenient to work with enumerators representing bit options. llvm-svn: 260652
* ARMv7k: use Cortex-A7 by default even for tvOSTim Northover2016-02-111-0/+12
| | | | | | Also actually test the default CPU from those triples. llvm-svn: 260621
* [lanai] Add Lanai triple.Jacques Pienaar2016-02-111-0/+21
| | | | | | | | | | Add triple for the Lanai backend. General Lanai backend discussion on llvm-dev thread "[RFC] Lanai backend". Differential Revision: http://reviews.llvm.org/D17003 llvm-svn: 260545
* SmallPtrSetTest: More checks for the swap() testingMatthias Braun2016-01-291-0/+24
| | | | llvm-svn: 259152
* SmallPtrSetTest: Check that iterators are still valid after erase()Matthias Braun2016-01-291-0/+39
| | | | llvm-svn: 259151
* Remove autoconf supportChris Bieneman2016-01-261-23/+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
* Fix PointerIntPair so that it can use an enum class as its integer template ↵Michael Gottesman2016-01-131-0/+27
| | | | | | | | | | | | | | | | | | | | argument. Summary: The problem here is that an enum class can not be implicitly converted to an integer. That assumption snuck back into PointerIntPair. This commit fixes the issue and more importantly adds some unittests to make sure that we do not break this again. rdar://23594806 Reviewers: gribozavr Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D16131 llvm-svn: 257574
* [ADT] Add an abstraction for embedding an integer within a pointer-likeChandler Carruth2016-01-102-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | type. This makes it easy and safe to use a set of flags as one elmenet of a tagged union with pointers. There is quite a bit of code that has historically done this by casting arbitrary integers to "pointers" and assuming that this was safe and reliable. It is neither, and has started to rear its head by triggering safety asserts in various abstractions like PointerLikeTypeTraits when the integers chosen are invariably poor choices for *some* platform and *some* situation. Not to mention the (hopefully unlikely) prospect of one of these integers actually getting allocated! With this, it will be straightforward to build type safe abstractions like this without being error prone. The abstraction itself is also remarkably simple thanks to the implicit conversion. This use case and pattern was also independently created by the folks working on Swift, and they're going to incrementally add any missing functionality they find. Differential Revision: http://reviews.llvm.org/D15844 llvm-svn: 257284
* [ADT] Add a sum type abstraction for pointer-like types.Chandler Carruth2016-01-102-0/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a much more general and powerful form of PointerUnion. It provides a reasonably complete sum type (from type theory) for pointer-like types. It has several significant advantages over the existing PointerUnion infrastructure: 1) It allows more than two pointer types to participate without awkward nesting structures. 2) It directly exposes the tag so that it is convenient to write switches over the possible members. 3) It can re-use the same type for multiple tag values, something that has been worked around by either abusing PointerIntPair or defining nonce types and doing unsafe pointer casting. 4) It supports customization of the PointerLikeTypeTraits used for specific member types. This means it could (in theory) be used even with types that are over-aligned on allocation to expose larger numbers of bits to the tag. All in all, I think it is at least complimentary to the existing infrastructure, and a strict improvement for some use cases. Differential Revision: http://reviews.llvm.org/D15843 llvm-svn: 257282
* [ADT] Use a nonce type with at least 4 byte alignment.Chandler Carruth2015-12-291-0/+1
| | | | | | | | | We didn't actually statically check this, and so it worked 25% of the time for me. =/ Really sorry it took so long to fix, I shouldn't leave the commit log editor window open without saving and landing the commit. =[ llvm-svn: 256528
* [ADT] Don't use a fixture just to get a nonce type for this unittest.Chandler Carruth2015-12-281-12/+12
| | | | | | | Instead, actually produce a nonce type in the test and use that. This makes the test, IMO, both simpler and more clear. llvm-svn: 256518
* Handle ARMv6-J as an alias, instead of fake architectureArtyom Skrobov2015-11-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: This follows D14577 to treat ARMv6-J as an alias for ARMv6, instead of an architecture in its own right. The functional change is that the default CPU when targeting ARMv6-J changes from arm1136j-s to arm1136jf-s, which is currently used as the default CPU for ARMv6; both are, in fact, ARMv6-J CPUs. The J-bit (Jazelle support) is irrelevant to LLVM, and it doesn't affect code generation, attributes, optimizations, or anything else, apart from selecting the default CPU. Reviewers: rengolin, logan, compnerd Subscribers: aemerson, llvm-commits, rengolin Differential Revision: http://reviews.llvm.org/D14755 llvm-svn: 253675
* Add isInteger() to APFloat.Stephen Canon2015-11-161-1/+15
| | | | | | | | Useful utility function; this wasn't too hard to do before, but also wasn't obviously discoverable. Make it explicit. Reviewed offline by Michael Gottesman. llvm-svn: 253254
* Handle ARMv6KZ namingArtyom Skrobov2015-11-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | | Summary: * ARMv6KZ is the "canonical" name, given in the ARMARM * ARMv6Z is an "official abbreviation" for it, mentioned in the ARMARM * ARMv6ZK is a popular misspelling, which we should support as an alias. The patch corrects the handling of the names. Functional changes: * ARMv6Z no longer treated as an architecture in its own right * ARMv6ZK renamed to ARMv6KZ, accepting ARMv6ZK as an alias * arm1176jz-s and arm1176jzf-s recognized as ARMv6ZK, instead of ARMv6K * default ARMv6K CPU changed to arm1176j-s Reviewers: rengolin, logan, compnerd Subscribers: aemerson, llvm-commits, rengolin Differential Revision: http://reviews.llvm.org/D14568 llvm-svn: 253206
* ADT: Avoid relying on UB in ilist_node::getNextNode()Duncan P. N. Exon Smith2015-11-111-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Re-implement `ilist_node::getNextNode()` and `getPrevNode()` without relying on the sentinel having a "next" pointer. Instead, get access to the owning list and compare against the `begin()` and `end()` iterators. This only works when the node *can* get access to the owning list. The new support is in `ilist_node_with_parent<>`, and any class `Ty` inheriting from `ilist_node<NodeTy>` that wants `getNextNode()` and/or `getPrevNode()` should inherit from `ilist_node_with_parent<NodeTy, ParentTy>` instead. The requirements: - `NodeTy` must have a `getParent()` function that returns the parent. - `ParentTy` must have a `getSublistAccess()` static that, given a(n ignored) `NodeTy*` (to determine which list), returns a member field pointer to the appropriate `ilist<>`. This isn't the cleanest way to get access to the owning list, but it leverages the API already used in the IR hierarchy (see, e.g., `Instruction::getSublistAccess()`). If anyone feels like ripping out the calls to `getNextNode()` and `getPrevNode()` and replacing with direct iterator logic, they can also remove the access function, etc., but as an incremental step, I'm maintaining the API where it's currently used in tree. If these requirements are *not* met, call sites with access to the ilist can call `iplist<NodeTy>::getNextNode(NodeTy*)` directly, as in ilistTest.cpp. Why rewrite this? The old code was broken, calling `getNext()` on a sentinel that possibly didn't have a "next" pointer at all! The new code avoids that particular flavour of UB (see the commit message for r252538 for more details about the "lucky" memory layout that made this function so interesting). There's still some UB here: the end iterator gets downcast to `NodeTy*`, even when it's a sentinel (which is typically `ilist_half_node<NodeTy*>`). I'll tackle that in follow-up commits. See this llvm-dev thread for more details: http://lists.llvm.org/pipermail/llvm-dev/2015-October/091115.html What's the danger? There might be some code that relies on `getNextNode()` or `getPrevNode()` *never* returning `nullptr` -- i.e., that relies on them being broken when the sentinel is an `ilist_half_node<NodeTy>`. I tried to root out those cases with the audits I did leading up to r252380, but it's possible I missed one or two. I hope not. (If (1) you have out-of-tree code, (2) you've reverted r252380 temporarily, and (3) you get some weird crashes with this commit, then I recommend un-reverting r252380 and auditing the compile errors looking for "strange" implicit conversions.) llvm-svn: 252694
* Add a unittest for SmallDenseMap that tests assigning a SmallDenseMap when ↵Michael Gottesman2015-10-311-0/+16
| | | | | | | | | | it is not small. This complements CopyConstructorNotSmallTest. If we are testing the copy constructor in such a way, we should also probably test assignment in the same way. llvm-svn: 251736
OpenPOWER on IntegriCloud