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

621 Commits

Author SHA1 Message Date
Chandler Carruth
0cdc2e28c6 Fix PR13148, an inf-loop in StringMap.
StringMap suffered from the same bug as DenseMap: when you explicitly
construct it with a small number of buckets, you can arrange for the
tombstone-based growth path to be followed when the number of buckets
was less than '8'. In that case, even with a full map, it would compare
'0' as not less than '0', and refuse to grow the table, leading to
inf-loops trying to find an empty bucket on the next insertion. The fix
is very simple: use '<=' as the comparison. The same fix was applied to
DenseMap as well during its recent refactoring.

Thanks to Alex Bolz for the great report and test case. =]

llvm-svn: 158725
2012-06-19 17:40:35 +00:00
Chandler Carruth
7da26940bd Remove some superfluous SCOPED_TRACEs from this unit test.
GoogleTest already prints errors with all the information about which
test case contained the error.

llvm-svn: 158724
2012-06-19 17:40:29 +00:00
Benjamin Kramer
eefb2c3ad6 For reasons I can't fathom MSVC supports ULL but not LLU suffixes on long long integer literals.
llvm-svn: 158648
2012-06-17 14:53:53 +00:00
Benjamin Kramer
b72efb3341 Add missing unittest files to the cmake build.
llvm-svn: 158647
2012-06-17 14:42:49 +00:00
Benjamin Kramer
35708de228 Remove SmallMap unittests, unbreaking the build.
I don't know how useful these are for SmallDenseMap, I'll leave that decision to Chandler.

llvm-svn: 158646
2012-06-17 12:46:18 +00:00
Benjamin Kramer
d408a3b134 Bring the return value of SmallVector::insert in line with std::vector::insert.
It always returns the iterator for the first inserted element, or the passed in
iterator if the inserted range was empty. Flesh out the unit test more and fix
all the cases it uncovered so far.

llvm-svn: 158645
2012-06-17 12:46:13 +00:00
Benjamin Kramer
f78d0a14b0 SmallVector: return a valid iterator for the rare case of inserting an empty range into a SmallVector.
Patch by Johannes Schaub!

llvm-svn: 158643
2012-06-17 11:52:22 +00:00
Chandler Carruth
5b13784777 Add a unit test for 'swap', and fix a pile of bugs in
SmallDenseMap::swap.

First, make it parse cleanly. Yay for uninstantiated methods.

Second, make the inline-buckets case work correctly. This is way
trickier than it should be due to the uninitialized values in empty and
tombstone buckets.

Finally fix a few typos that caused construction/destruction mismatches
in the counting unittest.

llvm-svn: 158641
2012-06-17 11:28:13 +00:00
Chandler Carruth
e4486335fa Disable a particular assertion on MSVC... I'm deeply disturbed by its
implementation of the class layout for the V8 type.

llvm-svn: 158640
2012-06-17 10:36:49 +00:00
Chandler Carruth
ea5804adca Add tests for *DenesMap for both key and value types' construction and
destruction and fix a bug in SmallDenseMap they caught.

This is kind of a poor-man's version of the testing that just adds the
addresses to a set on construction and removes them on destruction. We
check that double construction and double destruction don't occur.
Amusingly enough, this is enough to catch a lot of SmallDenseMap issues
because we spend a lot of time with fixed stable addresses in the inline
buffer.

The SmallDenseMap bug fix included makes grow() not double-destroy in
some cases. It also fixes a FIXME there, the code was pretty crappy. We
now don't have any wasted initialization, but we do move the entries in
inline bucket array an extra time. It's probably a better tradeoff, and
is much easier to get correct.

llvm-svn: 158639
2012-06-17 10:33:51 +00:00
Chandler Carruth
1501b6be37 Introduce a SmallDenseMap container that re-uses the existing DenseMap
implementation.

This type includes an inline bucket array which is used initially. Once
it is exceeded, an array of 64 buckets is allocated on the heap. The
bucket count grows from there as needed. Some highlights of this
implementation:

- The inline buffer is very carefully aligned, and so supports types
  with alignment constraints.
- It works hard to avoid aliasing issues.
- Supports types with non-trivial constructors, destructors, copy
  constructions, etc. It works reasonably hard to minimize copies and
  unnecessary initialization. The most common initialization is to set
  keys to the empty key, and so that should be fast if at all possible.

This class has a performance / space trade-off. It tries to optimize for
relatively small maps, and so packs the inline bucket array densely into
the object. It will be marginally slower than a normal DenseMap in a few
use patterns, so it isn't appropriate everywhere.

The unit tests for DenseMap have been generalized a bit to support
running over different map implementations in addition to different
key/value types. They've then been automatically extended to cover the
new container through the magic of GoogleTest's typed tests.

All of this is still a bit rough though. I'm going to be cleaning up
some aspects of the implementation, documenting things better, and
adding tests which include non-trivial types. As soon as I'm comfortable
with the correctness, I plan to switch existing users of SmallMap over
to this class as it is already more correct w.r.t. construction and
destruction of objects iin the map.

Thanks to Benjamin Kramer for all the reviews of this and the lead-up
patches. That said, more review on this would really be appreciated. As
I've noted a few times, I'm quite surprised how hard it is to get the
semantics for a hashtable-based map container with a small buffer
optimization correct. =]

llvm-svn: 158638
2012-06-17 09:05:09 +00:00
Chandler Carruth
08db81867a Add some somewhat exhaustive tests of sizeof properties of this horrible
construct just for my sanity.

llvm-svn: 158637
2012-06-17 09:05:04 +00:00
Benjamin Kramer
3ff7fe9de6 Update CMake build.
llvm-svn: 158601
2012-06-16 10:53:58 +00:00
Benjamin Kramer
ed052699c6 Merge the SmallBitVector and BitVector unit tests with gtest's typed test magic and bring SmallBitVector up to date.
llvm-svn: 158600
2012-06-16 10:51:07 +00:00
Chandler Carruth
c8785a9807 Relax one assertion -- long double has strange alignments on lots of
platforms.

Also, remove one assertion on MSVC because it produces a completely
preposterous result, claiming something needs 12-byte alignment.

llvm-svn: 158599
2012-06-16 09:44:00 +00:00
Chandler Carruth
23c38972af Try to reduce the size of the array used for compile-time testing by
making the bounds all '1', and chunking it a bit.

llvm-svn: 158598
2012-06-16 09:25:11 +00:00
Chandler Carruth
7b9797e637 Add support to the alignment support header for conjuring a character
array of a suitable size and alignment for any of a number of different
types to be stored into the character array.

The mechanisms for producing an explicitly aligned type are fairly
complex because this operation is poorly supported on all compilers.
We've spent a fairly significant amount of time experimenting with
different implementations inside of Google, and the one using explicitly
expanded templates has been the most robust.

Credit goes to Nick Lewycky for writing the first 20 versions or so of
this logic we had inside of Google. I based this on the only one to
actually survive. In case anyone is worried, yes we are both explicitly
re-contributing and re-licensing it for LLVM. =]

Once the issues with actually specifying the alignment are finished, it
turns out that most compilers don't in turn align anything the way they
are instructed. Testing of this logic against both Clang and GCC
indicate that the alignment constraints are largely ignored by both
compilers! I've come up with and used a work-around by wrapping each
alignment-hinted type directly in a struct, and using that struct to
align the character array through a union. This elaborate hackery is
terrifying, but I've included testing that caught a terrifying number of
bugs in every other technique I've tried.

All of this in order to implement a poor C++98 programmers emulation of
C++11 unrestricted unions in classes such as SmallDenseMap.

llvm-svn: 158597
2012-06-16 08:52:57 +00:00
Chandler Carruth
6516b04810 Work around a bug with MSVC 10 where it fails to recognize a valid use
of typename. GCC and Clang were fine with this, but MSVC won't accept
it. Fortunately, it also doesn't need it. Yuck.

Thanks to Nakamura for pointing this out in IRC.

llvm-svn: 158593
2012-06-16 03:54:11 +00:00
Chandler Carruth
03bff6651c Type parameterize the DenseMap unit tests.
These were already trying to be type parameterized over different
key/value pairs. I've realized this goal using GoogleTest's typed test
functionality. This allows us to easily replicate the tests across
different key/value combinations and soon different mapping templates.

I've fixed a few bugs in the tests and extended them a bit in the
process as many tests were only applying to the int->int mapping.

llvm-svn: 158589
2012-06-16 01:31:33 +00:00
Benjamin Kramer
58b98297ac Round 2 of dead private variable removal.
LLVM is now -Wunused-private-field clean except for
- lib/MC/MCDisassembler/Disassembler.h. Not sure why it keeps all those unaccessible fields.
- gtest.

llvm-svn: 158096
2012-06-06 19:47:08 +00:00
Justin Holewinski
10ecba6fa8 Fix gtest build issue on Visual Studio 2012 RC
llvm-svn: 158046
2012-06-06 03:11:20 +00:00
Stepan Dyatkovskiy
37b3fe7fa7 IntegersSubsetMapping: added exclude operation, that allows to exclude subset of integers from current mapping.
llvm-svn: 157989
2012-06-05 07:57:36 +00:00
Stepan Dyatkovskiy
b0bae92021 IntegersSubsetMapping:
Changed type of Items collection: from std::vector to std::list.
Also some small fixes made in IntegersSubset.h, IntegersSubsetMapping.h and IntegersSubsetTest.cpp.

llvm-svn: 157987
2012-06-05 07:43:08 +00:00
Stepan Dyatkovskiy
aae17ee48f Added unittests for IntegersSubset and IntegersSubsetMapping.
- Fixed IntegersSubsetGeneric copy/assignment behaviour. 
- Fixed IntegersSubsetGeneric::getSize/getSingleValue methods.
- Fixed IntegersSubsetGeneric::verify method.

Also IntegersSubset.h and IntegersSubsetMapping.h headers was fixed.

llvm-svn: 157887
2012-06-02 13:47:12 +00:00
Benjamin Kramer
bb30e1face Fix typos found by http://github.com/lyda/misspell-check
llvm-svn: 157885
2012-06-02 10:20:22 +00:00
Justin Holewinski
ee3de35dee Remove the PTX back-end and all of its artifacts (triple, etc.)
This back-end was deprecated in favor of the NVPTX back-end.

NV_CONTRIB

llvm-svn: 157417
2012-05-24 21:38:21 +00:00
Nuno Lopes
328f9efec2 fix the quotient returned by sdivrem() for the case when LHS is negative and RHS is positive
based on a patch by Preston Briggs, with some modifications

llvm-svn: 157231
2012-05-22 01:09:48 +00:00
Nuno Lopes
cd83a81786 fix corner case in ConstantRange::intersectWith().
this fixes the missed optimization I was seeing in the CorrelatedValuePropagation pass

llvm-svn: 157032
2012-05-18 00:14:36 +00:00
Simon Atanasyan
8bc0051492 Disable JITTest.FunctionIsRecompiledAndRelinked and JITTest.NoStubs
on MIPS where they are not implemented.

llvm-svn: 156935
2012-05-16 19:07:55 +00:00
Bill Wendling
18c55548e9 Remove warning about testing unsigned int with int.
llvm-svn: 156812
2012-05-15 09:59:13 +00:00
Stepan Dyatkovskiy
6d83dd3cf8 Fixed one small stupid, but critical bug.
llvm-svn: 156810
2012-05-15 09:21:39 +00:00
Jakob Stoklund Olesen
184e921187 Remove the expensive BitVector::operator~().
Returning a temporary BitVector is very expensive. If you must, create
the temporary explicitly: Use BitVector(A).flip() instead of ~A.

llvm-svn: 156768
2012-05-14 15:46:27 +00:00
Jakob Stoklund Olesen
8783cdf045 Add BitVector::anyCommon().
The existing operation (A & B).any() is very slow.

llvm-svn: 156760
2012-05-14 15:01:19 +00:00
Michael J. Spencer
6161587c9f [Support/StringRef] Add find_last_not_of and {r,l,}trim.
llvm-svn: 156652
2012-05-11 22:08:50 +00:00
Chad Rosier
ccf58fa5fd Add unittests for Triple::getMacOSXVersion and Triple::getiOSVersion.
llvm-svn: 156507
2012-05-09 19:31:41 +00:00
Benjamin Kramer
74da5acd41 SmallVector: Don't rely on having an assignment operator around in push_back for POD-like types.
llvm-svn: 155791
2012-04-29 10:53:29 +00:00
Stepan Dyatkovskiy
4c3c675cca Fixed SmallMap test. The order of items is undefined in DenseMap. So being checking the increment for big mode, we can only check that all items are in map.
llvm-svn: 155651
2012-04-26 18:45:24 +00:00
Benjamin Kramer
36acdd4832 Reapply the SmallMap patch with a fix.
Comparing ~0UL with an unsigned will always return false when long is 64 bits long.

llvm-svn: 155568
2012-04-25 18:01:58 +00:00
Eric Christopher
d38d9bb28b Revert "First implementation of:"
This reverts commit 76271a3366731d4c372fdebcd8d3437e6e09a61b.

as it's breaking the bots.

llvm-svn: 155562
2012-04-25 17:51:00 +00:00
Stepan Dyatkovskiy
a580659b6c First implementation of:
- FlatArrayMap. Very simple map container that uses flat array inside.
- MultiImplMap. Map container interface, that has two modes, one for small amount of elements and one for big amount.
- SmallMap. SmallMap is DenseMap compatible MultiImplMap. It uses FlatArrayMap for small mode, and DenseMap for big mode. 

Also added unittests for new classes and update for ProgrammersManual.
For more details about new classes see ProgrammersManual and comments in sourcecode.

llvm-svn: 155557
2012-04-25 17:09:38 +00:00
Andrew Trick
56264ae675 SparseSet: Add support for key-derived indexes and arbitrary key types.
This nicely handles the most common case of virtual register sets, but
also handles anticipated cases where we will map pointers to IDs.

The goal is not to develop a completely generic SparseSet
template. Instead we want to handle the expected uses within llvm
without any template antics in the client code. I'm adding a bit of
template nastiness here, and some assumption about expected usage in
order to make the client code very clean.

The expected common uses cases I'm designing for:
- integer keys that need to be reindexed, and may map to additional
  data
- densely numbered objects where we want pointer keys because no
  number->object map exists.

llvm-svn: 155227
2012-04-20 20:05:28 +00:00
Manuel Klimek
47de8bd0ef Goodbye, JSONParser...
llvm-svn: 154930
2012-04-17 17:21:17 +00:00
Duncan Sands
518668bd76 Remove support for the special 'fast' value for fpmath accuracy for the moment.
llvm-svn: 154850
2012-04-16 19:39:33 +00:00
Duncan Sands
f61d49df40 Make it possible to indicate relaxed floating point requirements at the IR level
through the use of 'fpmath' metadata.  Currently this only provides a 'fpaccuracy'
value, which may be a number in ULPs or the keyword 'fast', however the intent is
that this will be extended with additional information about NaN's, infinities
etc later.  No optimizations have been hooked up to this so far.

llvm-svn: 154822
2012-04-16 16:28:59 +00:00
Duncan Sands
f6cbb0b2cb Add the MDBuilder helper class for conveniently creating metadata.
llvm-svn: 154766
2012-04-15 18:03:49 +00:00
Michael J. Spencer
2f9beb2374 Add YAML parser to Support.
llvm-svn: 153977
2012-04-03 23:09:22 +00:00
Hal Finkel
d6e526ae11 Add triple support for the IBM BG/P and BG/Q supercomputers.
llvm-svn: 153882
2012-04-02 18:31:33 +00:00
Duncan Sands
5165327295 I noticed in passing that the Metadata getIfExists method was creating a new
node and returning it if one didn't exist.

llvm-svn: 153798
2012-03-31 08:20:11 +00:00
Rafael Espindola
151b420718 Handle unreachable code in the dominates functions. This changes users when
needed for correctness, but still doesn't clean up code that now unnecessary
checks for reachability.

llvm-svn: 153755
2012-03-30 16:46:21 +00:00
Danil Malyshev
af13f55e11 Fix missed files in JIT unittests Makefile
llvm-svn: 153672
2012-03-29 18:53:15 +00:00