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

104 Commits

Author SHA1 Message Date
Pete Cooper
090f52e5c9 Template specialize SmallVector::push_back based on POD-ness of the type. Reduces clang binary by 188KB
llvm-svn: 150662
2012-02-16 04:58:48 +00:00
Benjamin Kramer
0d983ac1b6 SmallVector's construct_range is the same thing as std::uninitialized_fill, no need to reinvent it.
llvm-svn: 149851
2012-02-05 22:48:31 +00:00
Benjamin Kramer
5e6c218c54 Simplify code. No functionality change.
llvm-svn: 149850
2012-02-05 22:14:48 +00:00
Benjamin Kramer
14636e5e0a Protect SmallVectorImpl's constructor and a few other methods that aren't meant to be public.
llvm-svn: 148550
2012-01-20 16:39:46 +00:00
Ted Kremenek
ee0970dabc Add a generic 'capacity_in_bytes' function to allow inspection of memory usage of various data structures.
llvm-svn: 136233
2011-07-27 18:40:45 +00:00
Owen Anderson
461ad5951b Fix a subtle issue in SmallVector. The following code did not work as expected:
vec.insert(vec.begin(), vec[3]);
The issue was that vec[3] returns a reference into the vector, which is invalidated when insert() memmove's the elements down to make space.  The method needs to specifically detect and handle this case to correctly match std::vector's semantics.

Thanks to Howard Hinnant for clarifying the correct behavior, and explaining how std::vector solves this problem.

llvm-svn: 134554
2011-07-06 22:36:59 +00:00
Nick Lewycky
c85935836b Add missing standard headers. Patch by Joerg Sonnenberger!
llvm-svn: 122193
2010-12-19 20:43:38 +00:00
Michael J. Spencer
c4c4e1133d Support: Move c_str from SmallVector back to SmallString and add a free standing
templated c_str in Windows.h to replace it.

llvm-svn: 121381
2010-12-09 17:37:18 +00:00
Michael J. Spencer
e5298b0f07 Support/ADT: Move c_str() from SmallString to SmallVectorImpl. The Windows PathV2
implementation needs it for wchar_t and SmallVectorImpl in general.

llvm-svn: 120984
2010-12-06 04:27:42 +00:00
Michael J. Spencer
0d9fb7f72e Fix spelling!
llvm-svn: 120167
2010-11-26 04:16:20 +00:00
Michael J. Spencer
b2cfb3b443 Fix Whitespace.
llvm-svn: 120166
2010-11-26 04:16:08 +00:00
Duncan Sands
6284b3db58 GCC extensions are no longer used here - update the comment.
llvm-svn: 115463
2010-10-03 15:31:50 +00:00
Duncan Sands
39e0233734 Remove two uses of the gcc specific 'aligned' attribute. This
is partly because this attribute caused trouble in the past (the
SmallVector one had to be changed from aligned to aligned(8) due
to causing crashes on i386 for example; in theory the same might
be needed in the Allocator case...).  But it's mostly because
there seems to be no point in special casing gcc here.  Using the
same implementation for all compilers results in better testing.

llvm-svn: 115462
2010-10-03 15:15:19 +00:00
John McCall
b91df6e799 After some discussion with djg, teach SmallVector to grow from a zero
capacity and remove the workaround in SmallVector<T,0>.  There are some
theoretical benefits to a N->2N+1 growth policy anyway.

llvm-svn: 112870
2010-09-02 21:55:03 +00:00
John McCall
33faad67cc SmallVector's growth policies don't like starting from zero capacity.
I think there are good reasons to change this, but in the interests
of short-term stability, make SmallVector<...,0> reserve non-zero
capacity in its constructors.  This means that SmallVector<...,0>
uses more memory than SmallVector<...,1> and should really only be
used (unless/until this workaround is removed) by clients that
care about using SmallVector with an incomplete type.

llvm-svn: 112147
2010-08-26 02:11:48 +00:00
John McCall
0c3659857d Provide an explicit specialization of SmallVector at N=0 which does
not require its type argument to be complete if no members are
actually used.

llvm-svn: 112106
2010-08-25 23:11:24 +00:00
Chris Lattner
7420a283cf disable SmallVectorImpl's copy constructor. This prevents a class
of base class slicing bugs reported on irc

llvm-svn: 106028
2010-06-15 18:59:43 +00:00
Duncan Sands
78593d094f Add includes to get ptrdiff_t. This is needed by gcc-4.6 which has
done some more header trimming, resulting in cstdef being included
by less header files.

llvm-svn: 105786
2010-06-10 10:13:58 +00:00
Benjamin Kramer
d62b29412b Use realloc instead of malloc+memcpy when growing a POD SmallVector. A smart
realloc implementation can try to expand the allocated memory block in-place,
avoiding the copy.

llvm-svn: 105605
2010-06-08 11:44:30 +00:00
Jim Grosbach
90ca622864 remove trailing whitespace
llvm-svn: 105333
2010-06-02 17:45:54 +00:00
Torok Edwin
9ddbae859f Fix PR6910.
Limit alignment in SmallVector 8, otherwise GCC assumes 16 byte alignment.
opetaror new, and malloc only return 8-byte aligned memory on 32-bit Linux,
which cause a crash if code is compiled with -O3 (or -ftree-vectorize) and some
SmallVector code is vectorized.

llvm-svn: 102604
2010-04-29 06:43:12 +00:00
Dan Gohman
8d37faa2f7 Fix SmallVector's insert to handle non-random-access iterators.
llvm-svn: 99633
2010-03-26 18:53:37 +00:00
Benjamin Kramer
d6a976f1da Fix a name clash that was breaking MSVC builds.
llvm-svn: 98852
2010-03-18 19:34:06 +00:00
Dan Gohman
24dc8de2a9 Fix a bug found by inspection; in the __GNUC__ code, the alignment
doesn't apply to the type, only to the variable, so subsequent uses
of U which expect it to be aligned weren't actually aligned.

llvm-svn: 98843
2010-03-18 18:40:47 +00:00
Chris Lattner
2e0b4ea606 tabs -> spaces.
llvm-svn: 91622
2009-12-17 21:23:46 +00:00
Steve Naroff
cbffdd23ee Fix Windows build breakage...
llvm-svn: 91617
2009-12-17 20:39:34 +00:00
Eric Christopher
9219efa49e Fix unused variable warning.
llvm-svn: 91609
2009-12-17 19:07:19 +00:00
Daniel Dunbar
9d1eac0cdd Fix one more missing this-> to placate that picky clang++.
llvm-svn: 91536
2009-12-16 11:38:03 +00:00
Chris Lattner
4b21831c59 fix more missing this->'s to placate clang++
llvm-svn: 91531
2009-12-16 09:17:12 +00:00
Chris Lattner
ccad2e6bd4 Fix a missing this-> that clang++ notices.
llvm-svn: 91530
2009-12-16 09:09:54 +00:00
Chris Lattner
eee37b7ba5 now that libsystem no longer uses SmallVector, we can move
SmallVectorBase::grow_pod out of line, finally satisfying PR3758.

llvm-svn: 91529
2009-12-16 08:44:24 +00:00
Chris Lattner
7ea3176b0c factor out the grow() method for all pod implementations into one
common function.  It is still an inline method, which will be fixed next.

llvm-svn: 91526
2009-12-16 08:34:40 +00:00
Chris Lattner
bc295111a1 pull destroy_range and uninitialized_copy up to the
SmallVectorTemplateBase class, which allows us to statically
dispatch on isPodLike instead of dynamically.

llvm-svn: 91523
2009-12-16 08:09:23 +00:00
Chris Lattner
c9b5e915c2 sink most of the meat in smallvector back from SmallVectorTemplateCommon
down into SmallVectorImpl.  This requires sprinking a ton of this->'s in,
but gives us a place to factor.

llvm-svn: 91522
2009-12-16 08:05:48 +00:00
Chris Lattner
19ee3f5216 substantial refactoring of SmallVector, now most code is in SmallVectorTemplateCommon,
and there is a new SmallVectorTemplateBase class in between it and SmallVectorImpl.
SmallVectorTemplateBase can be specialized based on isPodLike.

llvm-svn: 91518
2009-12-16 06:55:45 +00:00
Chris Lattner
b3db396df3 a few improvements:
1. Use std::equal instead of reinventing it.
2. don't run dtors in destroy_range if element is pod-like.
3. Use isPodLike to decide between memcpy/uninitialized_copy 
   instead of is_class.  isPodLike is more generous in some cases.

llvm-svn: 91427
2009-12-15 08:34:01 +00:00
Chris Lattner
f4e5966cf1 hoist the begin/end/capacity members and a few trivial methods
up into the non-templated SmallVectorBase class.

llvm-svn: 91426
2009-12-15 08:29:22 +00:00
Chris Lattner
f1a0d32b5f improve isPodLike to know that all non-class types are pod.
llvm-svn: 91425
2009-12-15 07:40:44 +00:00
Gabor Greif
cc8681cea3 Clean up the minor mess I caused with removing iterator.h. I shall take care of 80-col violations and the FIXME later. (Thanks goodness that I live in another continent, so the monkeypox did not strike me :-)
llvm-svn: 80224
2009-08-27 06:41:46 +00:00
Daniel Dunbar
6812c0db35 Add SmallVector::{capacity,set_size}.
- These allow clients to make use of the extra elements in the vector which
   have already been allocated, without requiring them to be value initialized.

llvm-svn: 79433
2009-08-19 17:48:28 +00:00
Jay Foad
c934b656f9 Tighten up the asserts in SmallVector::operator[]().
If this causes any new assertion failures that I didn't catch in
testing, the fix is usually to change "&v[0]" to "v.data()" for some
SmallVector v.

llvm-svn: 72221
2009-05-21 19:48:58 +00:00
Jay Foad
2ca356aa76 Implement new SmallVector::data() methods.
llvm-svn: 72209
2009-05-21 09:00:37 +00:00
Owen Anderson
dd6babaa30 Fix for PR3946, in which SmallVector could behave strangely in corner cases.
Patch by Peter Johnson.

llvm-svn: 69785
2009-04-22 07:16:54 +00:00
Chris Lattner
09cab2de98 fix overflow checks in SmallVector:
"The code was doing "if (End+NumInputs > Capacity) ...". If End is
close to 0xFFFFFFFF and NumInputs is large, it'll overflow, the
condition will come out false, and the vector won't grow to
accommodate the new elements, and the program will crash in memmove."

Patch by Jeffrey Yasskin!

llvm-svn: 68277
2009-04-02 03:06:26 +00:00
Chris Lattner
9c7b21d369 Fix PR3860 by correcting a predicate.
llvm-svn: 67473
2009-03-22 19:22:53 +00:00
Misha Brukman
380e3db1b4 Fixed lint errors:
* Alphabetized #includes
* Removed trailing whitespace
* Wrapped or shortened lines over 80 chars

llvm-svn: 65181
2009-02-20 22:20:18 +00:00
Dan Gohman
30770ee7b3 Add explicit keywords.
llvm-svn: 64915
2009-02-18 16:37:45 +00:00
Misha Brukman
da77da48f3 Removed trailing whitespace.
llvm-svn: 62000
2009-01-09 19:25:42 +00:00
Cedric Venet
b260c282bc Add explicit this-> for some member function in templated base class.
These call are probably dependent but VS with /Za don't seems to think so. We need to help him.

llvm-svn: 60978
2008-12-13 10:55:13 +00:00
Chris Lattner
5a1d7ab054 add a new pop_back_val method which returns the value popped. This is
heretical from a STL standpoint, but is oh-so-useful for things that 
can't throw exceptions when copied, like, well, everything in LLVM.

llvm-svn: 60587
2008-12-05 07:11:05 +00:00