1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

42 Commits

Author SHA1 Message Date
David Blaikie
60e6c80905 Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool>
This is to be consistent with StringSet and ultimately with the standard
library's associative container insert function.

This lead to updating SmallSet::insert to return pair<iterator, bool>,
and then to update SmallPtrSet::insert to return pair<iterator, bool>,
and then to update all the existing users of those functions...

llvm-svn: 222334
2014-11-19 07:49:26 +00:00
Craig Topper
baef4556f6 Fix an off by 1 bug that prevented SmallPtrSet from using all of its 'small' capacity. Then fix the early return in the move constructor that prevented 'small' moves from clearing the NumElements in the moved from object. The directed test missed this because it was always testing large moves due to the off by 1 bug.
llvm-svn: 216044
2014-08-20 04:41:36 +00:00
Craig Topper
ee78063a54 [C++11] Make use of 'nullptr' in the Support library.
llvm-svn: 205697
2014-04-07 04:17:22 +00:00
Chandler Carruth
df9f7f4aec [C++11] Remove the R-value reference #if usage from the ADT and Support
libraries. It is now always 1 in LLVM builds.

llvm-svn: 202580
2014-03-01 09:27:28 +00:00
Chandler Carruth
64c64740ea Rename the non-templated base class of SmallPtrSet to
'SmallPtrSetImplBase'. This more closely matches the organization of
SmallVector and should allow introducing a SmallPtrSetImpl which serves
the same purpose as SmallVectorImpl: isolating the element type from the
particular small size chosen. This in turn allows a lot of
simplification of APIs by not coding them against a specific small size
which is rarely needed.

llvm-svn: 200687
2014-02-03 11:24:18 +00:00
Chandler Carruth
dc82f92af7 Lift self-copy protection up to the header file and add self-move
protection to the same layer.

This is in line with Howard's advice on how best to handle self-move
assignment as he explained on SO[1]. It also ensures that implementing
swap with move assignment continues to work in the case of self-swap.

[1]: http://stackoverflow.com/questions/9322174/move-assignment-operator-and-if-this-rhs

llvm-svn: 195705
2013-11-26 00:54:44 +00:00
Chandler Carruth
9233af88ac Fix a self-memcpy which only breaks under Valgrind's memcpy
implementation. Silliness, but it'll be a trivial performance
optimization. This should clear up a failure on the vg_leak bot.

llvm-svn: 195704
2013-11-26 00:44:36 +00:00
Chandler Carruth
ffaacacd23 Make the moved-from SmallPtrSet be a valid, empty, small-state object.
Enhance the tests to actually require moves in C++11 mode, in addition
to testing the moved-from state. Further enhance the tests to cover
copy-assignment into a moved-from object and moving a large-state
object. (Note that we can't really test small-state vs. large-state as
that isn't an observable property of the API really.) This should finish
addressing review on r195239.

llvm-svn: 195261
2013-11-20 18:29:56 +00:00
Chandler Carruth
8070950ee8 Give SmallPtrSet move semantics when we have R-value references.
Somehow, this ADT got missed which is moderately terrifying considering
the efficiency of move for it.

The code to implement move semantics for it is pretty horrible
currently but was written to reasonably closely match the rest of the
code. Unittests that cover both copying and moving (at a basic level)
added.

llvm-svn: 195239
2013-11-20 11:14:33 +00:00
Aaron Ballman
fe287f3b35 Fixing a possible memory leak from a failing realloc() call.
llvm-svn: 195018
2013-11-18 17:33:32 +00:00
Jean-Luc Duprat
7776961622 SmallVector and SmallPtrSet allocations now power-of-two aligned.
This time tested on both OSX and Linux.

llvm-svn: 178377
2013-03-29 22:07:12 +00:00
Rafael Espindola
e78555387c Revert "Fix allocations of SmallVector and SmallPtrSet so they are more prone to"
This reverts commit 617330909f0c26a3f2ab8601a029b9bdca48aa61.

It broke the bots:

/home/clangbuild2/clang-ppc64-2/llvm.src/unittests/ADT/SmallVectorTest.cpp:150: PushPopTest
/home/clangbuild2/clang-ppc64-2/llvm.src/unittests/ADT/SmallVectorTest.cpp:118: Failure
Value of: v[i].getValue()
  Actual: 0
Expected: value
Which is: 2

llvm-svn: 178334
2013-03-29 07:11:21 +00:00
Jean-Luc Duprat
0ba254f23f Fix allocations of SmallVector and SmallPtrSet so they are more prone to
being power-of-two sized.

llvm-svn: 178332
2013-03-29 05:45:22 +00:00
Benjamin Kramer
ffa121d1ea SmallPtrSet: Reuse DenseMapInfo's pointer hash function instead of inventing a bad one ourselves.
DenseMap's hash function uses slightly more entropy and reduces hash collisions
significantly.  I also experimented with Hashing.h, but it didn't gave a lot of
improvement while being much more expensive to compute.

llvm-svn: 154996
2012-04-18 10:37:32 +00:00
Benjamin Kramer
8aa45ad186 Copy the right amount of elements.
llvm-svn: 152254
2012-03-07 22:48:42 +00:00
Benjamin Kramer
ef27a1e10d SmallPtrSet: Copy all the elements when swapping, not just numelements.
This fixes a build failure in webkit. Copying all elements shouldn't be
necessary, I'll look out for a better fix soon.

llvm-svn: 152252
2012-03-07 22:33:21 +00:00
Benjamin Kramer
0637e87d74 SmallPtrSet: Provide a more efficient implementation of swap than the default triple-copy std::swap.
This currently assumes that both sets have the same SmallSize to keep the implementation simple,
a limitation that can be lifted if someone cares.

llvm-svn: 152143
2012-03-06 20:40:02 +00:00
Jakob Stoklund Olesen
b4df99dc06 Prevent infinite growth of SmallPtrSet instances.
Rehash but don't grow when full of tombstones.

Patch by José Fonseca!

llvm-svn: 128566
2011-03-30 18:32:48 +00:00
Duncan Sands
de6d3111d0 Rather than giving SmallPtrSetImpl a member field SmallArray which is magically
replaced by a bigger array in SmallPtrSet (by overridding it), instead just use a
pointer to the start of the storage, and have SmallPtrSet pass in the value to use.
This has the disadvantage that SmallPtrSet becomes bigger by one pointer.  It has
the advantage that it no longer uses tricky C++ rules, and is clearly correct while
I'm not sure the previous version was.  This was inspired by g++-4.6 pointing out
that SmallPtrSetImpl was writing off the end of SmallArray, which it was.  Since
SmallArray is replaced with a bigger array in SmallPtrSet, the write was still to
valid memory.  But it was writing off the end of the declared array type - sounds
kind of dubious to me, like it sounded dubious to g++-4.6.  Maybe g++-4.6 is wrong
and this construct is perfectly valid and correctly compiled by all compilers, but
I think it is better to avoid the whole can of worms by avoiding this construct.

llvm-svn: 107285
2010-06-30 15:02:37 +00:00
Dan Gohman
de163bb39d Fix several const-correctness issues, resolving some -Wcast-qual warnings.
llvm-svn: 54349
2008-08-05 14:45:15 +00:00
Chris Lattner
ad9a6ccb83 Remove attribution from file headers, per discussion on llvmdev.
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Chris Lattner
edf6668dda make smallptrset more const and type correct, which caught a few
minor bugs.

llvm-svn: 43782
2007-11-06 22:12:43 +00:00
Anton Korobeynikov
958dcad32d Properly use const qualifiers
llvm-svn: 41111
2007-08-15 21:12:30 +00:00
Chris Lattner
10db9656ba When clearing a SmallPtrSet, if the set had a huge capacity, but the
contents of the set were small, deallocate and shrink the set.  This
avoids having us to memset as much data, significantly speeding up
some pathological cases.  For example, this speeds up the verifier
from 0.3899s to 0.0763 (5.1x) on the testcase from PR1432 in a 
release build.

llvm-svn: 40837
2007-08-05 07:32:14 +00:00
Owen Anderson
997b15d967 Allow SmallPtrSet to hold pointers to const data.
llvm-svn: 40556
2007-07-27 18:07:02 +00:00
Owen Anderson
f22326ad3d Make the copy constructor of SmallPtrSet much faster.
llvm-svn: 40474
2007-07-24 21:31:23 +00:00
Owen Anderson
21e3bd1cdc Remember to free the heap allocated array if we're not going to use it.
llvm-svn: 40043
2007-07-19 06:45:33 +00:00
Owen Anderson
03b56ad400 Fix an issue where assignments that caused a SmallPtrSet to become non-small
would result in calling realloc() on a null pointer.  Instead, if we encounter
this situation, make a normal call to malloc().

llvm-svn: 40014
2007-07-18 19:54:15 +00:00
Reid Spencer
3dd7b1699b Unbreak the build by putting calls to free into the implementation file and
having that implementation file #include <cstdlib>.

llvm-svn: 39952
2007-07-17 02:16:12 +00:00
Owen Anderson
f01c29815d Use realloc() to (potentially) resize the contents of SmallPtrSet in place.
llvm-svn: 39926
2007-07-16 21:27:44 +00:00
Owen Anderson
31bda05073 Make the assignment operator for SmallPtrSet much faster for normal cases.
llvm-svn: 38474
2007-07-09 22:27:20 +00:00
Owen Anderson
e48ed4f7a8 Make the assignment operator for SmallPtrSet return a reference, and fix a long-standing bug in the copy
ctor while I'm at it.

Thanks to Chris Lattner for help with this patch.

llvm-svn: 38470
2007-07-09 20:59:01 +00:00
Owen Anderson
e12cbdb0be Fix an error in the assignment operator that was causing an infinite loop in GVNPRE.cpp.
Patch by Chis Lattner.

llvm-svn: 38467
2007-07-09 18:51:15 +00:00
Chris Lattner
97ba0c99ed implement operator= for smallptrset
llvm-svn: 38460
2007-07-09 16:54:03 +00:00
Owen Anderson
41515dcd4b Fix a bug in SmallPtrSet that was causing GVNPRE to enter an infinite loop.
llvm-svn: 37697
2007-06-22 00:11:18 +00:00
Chris Lattner
3ac68a90f2 Two changes:
1. Make SmallPtrSet::erase faster in the small case by replacing a memmove
    with a pointer copy.
 2. Fix a bug where the null terminator at the end of the array in the small
    case was not copied

llvm-svn: 37696
2007-06-21 23:23:32 +00:00
Jeff Cohen
5a502fb622 Fix PR1329.
llvm-svn: 36016
2007-04-14 21:50:21 +00:00
Chris Lattner
2c3df2a958 do not let the table fill up with tombstones.
llvm-svn: 33973
2007-02-07 01:11:25 +00:00
Chris Lattner
153ccbe7f9 Fix a bug in smallptrset::erase: in the small case, return true if the
element was in the set.

llvm-svn: 33931
2007-02-05 23:10:31 +00:00
Chris Lattner
2ca5edd29e implement SmallPtrSet::erase
llvm-svn: 33581
2007-01-27 07:59:10 +00:00
Chris Lattner
a7fec4020b add a note
llvm-svn: 33578
2007-01-27 07:18:32 +00:00
Chris Lattner
22513a4828 Add a new SmallSet ADT specialized for pointers.
llvm-svn: 33577
2007-01-27 07:10:46 +00:00