summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT
Commit message (Collapse)AuthorAgeFilesLines
* [ADT] Add a new data structure for managing a priority worklist whereChandler Carruth2016-06-302-0/+107
| | | | | | | | | | | | | | | | | | | | | | | | re-insertion of entries into the worklist moves them to the end. This is fairly similar to a SetVector, but helps in the case where in addition to not inserting duplicates you want to adjust the sequence of a pop-off-the-back worklist. I'm not at all attached to the name of this data structure if others have better suggestions, but this is one that David Majnemer brought up in IRC discussions that seems plausible. I've trimmed the interface down somewhat from SetVector's interface because several things make less sense here IMO: iteration primarily. I'd prefer to add these back as we have users that need them. My use case doesn't even need all of what is provided here. =] I've also included a basic unittest to make sure this functions reasonably. Differential Revision: http://reviews.llvm.org/D21866 llvm-svn: 274198
* [Triple] Reimplement isLittleEndian(). Now it works for arm too.Davide Italiano2016-06-291-0/+8
| | | | | | Differential Revision: http://reviews.llvm.org/D21846 llvm-svn: 274154
* Add support for musl-libc on ARM Linux.Rafael Espindola2016-06-241-0/+6
| | | | | | Patch by Lei Zhang! llvm-svn: 273726
* Fix BitVector move ctor/assignment.Evgeniy Stepanov2016-06-161-0/+26
| | | | | | | | Current implementation leaves the object in an invalid state. This reverts commit bf0c389ac683cd6c0e5959b16537e59e5f4589e3. llvm-svn: 272965
* Add a Musl environment to the triple.Rafael Espindola2016-06-141-0/+6
| | | | | | | | It will be used in clang. Patch by Lei Zhang. llvm-svn: 272660
* Adding reserve and capacity methods to FoldingSetBen Craig2016-06-031-0/+133
| | | | | | http://reviews.llvm.org/D20930 llvm-svn: 271669
* [ADT] Pass ArrayRef::slice size_t instead of unsigned.Ahmed Bougacha2016-06-021-0/+15
| | | | | | | | | | Also fix slice wrappers drop_front and drop_back. The unittests are pretty awkward, but do the job; alternatives welcome! ..and yes, I do have ArrayRefs with more than 4 billion elements. llvm-svn: 271546
* Don't allocate in APInt::slt. NFC.Pete Cooper2016-05-261-0/+28
| | | | | | | | | | | | | | | | | | | | | | | APInt::slt was copying the LHS and RHS in to temporaries then making them unsigned so that it could use an unsigned comparision. It did this even on the paths which were trivial to give results for, such as the sign bit of the LHS being set while RHS was not set. This changes the logic to return out immediately in the trivial cases, and use an unsigned comparison in the remaining cases. But this time, just use the unsigned comparison directly without creating any temporaries. This works because, for example: true = (-2 slt -1) = (0xFE ult 0xFF) Also added some tests explicitly for slt with APInt's larger than 64-bits so that this new code is tested. Using the memory for 'opt -O2 verify-uselistorder.lto.opt.bc -o opt.bc' (see r236629 for details), this reduces the number of allocations from 26.8M to 23.9M. llvm-svn: 270881
* [ADT] Add an 'llvm::seq' function which produces an iterator range overChandler Carruth2016-05-132-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | a sequence of values. It increments through the values in the half-open range: [Begin, End), producing those values when indirecting the iterator. It should support integers, iterators, and any other type providing these basic arithmetic operations. This came up in the C++ standards committee meeting, and it seemed like a useful construct that LLVM might want as well, and I wanted to understand how easily we could solve it. I suspect this can be used to write simpler counting loops even in LLVM along the lines of: for (int i : seq(0, v.size())) { ... }; As part of this, I had to fix the lack of a proxy object returned from the operator[] in our iterator facade. Differential Revision: http://reviews.llvm.org/D17870 llvm-svn: 269390
* [ADT] Add drop_front method to ArrayRefReid Kleckner2016-05-031-0/+7
| | | | | | | | We have it for StringRef but not ArrayRef, and ArrayRef has drop_back, so I see no reason it shouldn't have drop_front. Splitting this out of a change that I have that will use this funcitonality. llvm-svn: 268434
* Add a CachedHash structure.Rafael Espindola2016-04-211-0/+49
| | | | | | | | | | | | | A DenseMap doesn't store the hashes, so it needs to recompute them when the table is resized. In some applications the hashing cost is noticeable. That is the case for example in lld for symbol names (StringRef). This patch adds a templated structure that can wraps any value that can go in a DenseMap and caches the hash. llvm-svn: 266981
* [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
OpenPOWER on IntegriCloud