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

960 Commits

Author SHA1 Message Date
Michael Pozulp
e4566d8d18 [ADT] Enable set_difference() to be used on StringSet
Summary: Re-land r362766 after it was reverted in r362823.

Reviewers: jhenderson, dsanders, aaron.ballman, MatzeB, lhames, dblaikie

Reviewed By: dblaikie

Subscribers: smeenai, mgrang, mgorny, dexonsmith, kristina, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62369

llvm-svn: 362835
2019-06-07 20:23:03 +00:00
Vlad Tsyrklevich
202a53b7e4 Revert "[ADT] Enable set_difference() to be used on StringSet"
This reverts commit 0bddef79019a23ab14fcdb27028e55e484674c88, it was
causing ASan failures on the sanitizer bots:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/32800

llvm-svn: 362823
2019-06-07 18:34:29 +00:00
Michael Pozulp
07dc77da65 [ADT] Enable set_difference() to be used on StringSet
Subscribers: mgorny, mgrang, dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62992

llvm-svn: 362766
2019-06-07 03:23:00 +00:00
Simon Pilgrim
c219588067 [APInt] Add PR40897 test case
In reality APInt::getBitsNeeded(INT_MIN, base) cases require one less bit than is returned

llvm-svn: 362301
2019-06-01 14:58:36 +00:00
Richard Trieu
3924f2e9bc Fix broken test case.
EXPECT_EQ takes two arguments, not a single expression that evaluates to bool.

llvm-svn: 360969
2019-05-17 01:17:32 +00:00
Richard Smith
af0a7d857e Convert PointerUnion to a variadic template.
Summary:
Rather than duplicating code between PointerUnion, PointerUnion3, and
PointerUnion4 (and missing things from the latter cases, such as some of the
DenseMap support and operator==), convert PointerUnion to a variadic template
that can be used as a union of any number of pointers.

(This doesn't support PointerUnion<> right now. Adding a special case for that
would be possible, and perhaps even useful in some situations, but it doesn't
seem worthwhile until we have a concrete use case.)

Reviewers: dblaikie

Subscribers: dexonsmith, kristina, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62027

llvm-svn: 360962
2019-05-17 00:39:38 +00:00
Tim Northover
78bb84d35c arm64_32: add some unittests that were in the wrong commit.
Accidentally dropped them when committing the arm64_32 binutils support.
There's no change to real code.

llvm-svn: 360763
2019-05-15 12:01:04 +00:00
Dan Gohman
670234800e [WebAssembly] Test the "wasm32-wasi" triple
Add triple tests for "wasm32-wasi" and "wasm64-wasi", and also remove the
"-musl" component from the existing wasm triple tests as we're not using that
in practice (WASI libc is derived in part from musl, but it is not fully
musl-compatible).

Differential Revision: https://reviews.llvm.org/D61334

Reviewer: sbc100
llvm-svn: 359629
2019-04-30 23:04:49 +00:00
Joel E. Denny
ab225e9daf [APSInt][OpenMP] Fix isNegative, etc. for unsigned types
Without this patch, APSInt inherits APInt::isNegative, which merely
checks the sign bit without regard to whether the type is actually
signed.  isNonNegative and isStrictlyPositive call isNegative and so
are also affected.

This patch adjusts APSInt to override isNegative, isNonNegative, and
isStrictlyPositive with implementations that consider whether the type
is signed.

A large set of Clang OpenMP tests are affected.  Without this patch,
these tests assume that `true` is not a valid argument for clauses
like `collapse`.  Indeed, `true` fails APInt::isStrictlyPositive but
not APSInt::isStrictlyPositive.  This patch adjusts those tests to
assume `true` should be accepted.

This patch also adds tests revealing various other similar fixes due
to APSInt::isNegative calls in Clang's ExprConstant.cpp and
SemaExpr.cpp: `++` and `--` overflow in `constexpr`, evaluated object
size based on `alloc_size`, `<<` and `>>` shift count validation, and
OpenMP array section validation.

Reviewed By: lebedev.ri, ABataev, hfinkel

Differential Revision: https://reviews.llvm.org/D59712

llvm-svn: 359012
2019-04-23 17:04:15 +00:00
Sam McCall
cd2e6380fb [ADT] Avoid warning in bsearch testcase
llvm-svn: 358811
2019-04-20 11:48:11 +00:00
Fangrui Song
5cc0ceba59 [APInt] Optimize umul_ov
Change two costly udiv() calls to lshr(1)*RHS + left-shift + plus

On one 64-bit umul_ov benchmark, I measured an obvious improvement: 12.8129s -> 3.6257s

Note, there may be some value to special case 64-bit (the most common
case) with __builtin_umulll_overflow().

Differential Revision: https://reviews.llvm.org/D60669

llvm-svn: 358730
2019-04-19 02:06:06 +00:00
Sam McCall
c06d4974d8 [ADT] llvm::bsearch, binary search for mere mortals
Summary:
Add to STLExtras a binary search function with a simple mental model:
You provide a range and a predicate which is true above a certain point.
bsearch() tells you that point.
Overloads are provided for integers, iterators, and containers.

This is more suitable than std:: alternatives in many cases:
 - std::binary_search only indicates presence/absence
 - upper_bound/lower_bound give you the opportunity to pick the wrong one
 - all of the options have confusing names and definitions when your predicate
   doesn't have simple "less than" semantics
 - all of the options require iterators
 - we plumb around a useless `value` parameter that should be a lambda capture

The API is inspired by Go's standard library, but we add an extra parameter as
well as some overloads and templates to show how clever C++ is.

Reviewers: ilya-biryukov, gribozavr

Subscribers: dexonsmith, kristina, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60779

llvm-svn: 358540
2019-04-16 23:53:28 +00:00
Fangrui Song
b9c43998e1 [ADT] Fix OwningArrayRef's move ctor
llvm-svn: 358332
2019-04-13 13:52:11 +00:00
Eli Friedman
d78fb504e2 [MC] Fix floating-point literal lexing.
This patch has three related fixes to improve float literal lexing:

1. Make AsmLexer::LexDigit handle floats without a decimal point more
   consistently.
2. Make AsmLexer::LexFloatLiteral print an error for floats which are
   apparently missing an "e".
3. Make APFloat::convertFromString use binutils-compatible exponent
   parsing.

Together, this fixes some cases where a float would be incorrectly
rejected, fixes some cases where the compiler would crash, and improves
diagnostics in some cases.

Patch by Brandon Jones.

Differential Revision: https://reviews.llvm.org/D57321

llvm-svn: 357214
2019-03-28 21:12:28 +00:00
Fangrui Song
6799203cd2 [ADT] Update SmallVectorTest.EmplaceBack tests after rL356312
rL356312 changed the return type of emplace_back from void to reference.
Update the tests to check the behavior.

Reviewers: dblaikie

Reviewed By: dblaikie

Subscribers: dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59809

llvm-svn: 356980
2019-03-26 05:33:52 +00:00
Jason Liu
65a0422be5 Add XCOFF triple object format type for AIX
This patch adds an XCOFF triple object format type into LLVM.
This XCOFF triple object file type will be used later by object file and assembly generation for the AIX platform.

Differential Revision: https://reviews.llvm.org/D58930

llvm-svn: 355989
2019-03-12 22:01:10 +00:00
Daniel Sanders
9daa37762d Add partial implementation of std::to_address() as llvm::to_address()
Summary:
Following on from the review for D58088, this patch provides the
prerequisite to_address() implementation that's needed to have
pointer_iterator support unique_ptr.

The late bound return should be removed once we move to C++14 to better
align with the C++20 declaration. Also, this implementation can be removed
once we move to C++20 where it's defined as std::to_addres()

The std::pointer_traits<>::to_address(p) variations of these overloads has
not been implemented.

Reviewers: dblaikie, paquette

Reviewed By: dblaikie

Subscribers: dexonsmith, kristina, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58421

llvm-svn: 354491
2019-02-20 18:08:48 +00:00
Serge Guelton
afd2d12460 [NFC] Make Optional<T> trivially copyable when T is trivially copyable
This is a follow-up to r354246 and a reimplementation of https://reviews.llvm.org/D57097?id=186600
that should not trigger any UB thanks to the use of an union.

This may still be subject to the problem solved by std::launder, but I'm unsure how it interacts whith union.
/me plans to revert if this triggers any relevant bot failure. At least this validates in Release mode with
clang 6.0.1 and gcc 4.8.5.

llvm-svn: 354264
2019-02-18 12:07:12 +00:00
Serge Guelton
662ff1b052 Revert r354199: Make Optional<T> Trivially Copyable when T is trivially copyable
llvm-svn: 354200
2019-02-16 09:47:23 +00:00
Serge Guelton
457d171662 Make Optional<T> Trivially Copyable when T is trivially copyable
This is another attempt in the process, works nicely on my setup,
let's check how it behaves on other targets.

llvm-svn: 354199
2019-02-16 09:19:58 +00:00
Hans Wennborg
b1bfc59f94 Speculatively revert r354051 "Recommit Optional specialization for trivially copyable types"
and
r354055 "Optional specialization for trivially copyable types, part2"

These are suspected to cause Clang to get miscompiled on Ubuntu 14.04
(Trusty) which uses GCC 4.8.4. Reverting for an hour to see if this
helps. See llvm-commits thread.

> Recommit Optional specialization for trivially copyable types
>
> Unfortunately the original code gets misscompiled by GCC (at least 8.1),
> this is a tentative workaround using std::memcpy instead of inplace new
> for trivially copyable types. I'll revert if it breaks.
>
> Original revision: https://reviews.llvm.org/D57097

llvm-svn: 354126
2019-02-15 12:20:33 +00:00
Serge Guelton
b0dbfc4fd4 Recommit Optional specialization for trivially copyable types
Unfortunately the original code gets misscompiled by GCC (at least 8.1),
this is a tentative workaround using std::memcpy instead of inplace new
for trivially copyable types. I'll revert if it breaks.

Original revision: https://reviews.llvm.org/D57097

llvm-svn: 354051
2019-02-14 19:17:00 +00:00
Serge Guelton
a27afd3444 Revert r353962
Specialization of Optional for trivially copyable types yields failure on the buildbots I fail to reproduce locally.
Better safe than sorry, reverting.

llvm-svn: 353982
2019-02-13 22:11:09 +00:00
Serge Guelton
6a3f368498 Re-commit rL353927, patch included
Make llvm::Optional<T> trivially copyable when T is trivially copyable

This is an ever-recurring issue (see https://bugs.llvm.org/show_bug.cgi?id=39427 and https://bugs.llvm.org/show_bug.cgi?id=35978)
but I believe that thanks to https://reviews.llvm.org/D54472 we can now ship a decent implementation of this.

Basically the fact that llvm::is_trivially_copyable has a consistent behavior across compilers should prevent any ABI issue,
and using in-place new instead of memcpy should keep compiler bugs away.

This patch is slightly different from the original revision https://reviews.llvm.org/rL353927 but achieves the same goal. It just avoids
going through std::conditional which may the code more explicit.

llvm-svn: 353962
2019-02-13 18:12:04 +00:00
Serge Guelton
b303bcb9be Revert r353927
llvm-svn: 353940
2019-02-13 11:35:45 +00:00
Serge Guelton
00030ece69 Missing header
llvm-svn: 353933
2019-02-13 10:19:06 +00:00
Serge Guelton
920e69d8bf Make llvm::Optional<T> trivially copyable when T is trivially copyable
This is an ever-recurring issue (see https://bugs.llvm.org/show_bug.cgi?id=39427 and https://bugs.llvm.org/show_bug.cgi?id=35978)
but I believe that thanks to https://reviews.llvm.org/D54472 we can now ship a decent implementation of this.

Basically the fact that llvm::is_trivially_copyable has a consistent behavior across compilers should prevent any ABI issue,
and using in-place new instead of memcpy should keep compiler bugs away.

Differential Revision: https://reviews.llvm.org/D57097

llvm-svn: 353927
2019-02-13 09:31:22 +00:00
Lang Hames
f9bddc40cd [ADT] Add a fallible_iterator wrapper.
A fallible iterator is one whose increment or decrement operations may fail.
This would usually be supported by replacing the ++ and -- operators with
methods that return error:

    class MyFallibleIterator {
    public:
      // ...
      Error inc();
      Errro dec();
      // ...
    };

The downside of this style is that it no longer conforms to the C++ iterator
concept, and can not make use of standard algorithms and features such as
range-based for loops.

The fallible_iterator wrapper takes an iterator written in the style above
and adapts it to (mostly) conform with the C++ iterator concept. It does this
by providing standard ++ and -- operator implementations, returning any errors
generated via a side channel (an Error reference passed into the wrapper at
construction time), and immediately jumping the iterator to a known 'end'
value upon error. It also marks the Error as checked any time an iterator is
compared with a known end value and found to be inequal, allowing early exit
from loops without redundant error checking*.

Usage looks like:

    MyFallibleIterator I = ..., E = ...;

    Error Err = Error::success();
    for (auto &Elem : make_fallible_range(I, E, Err)) {
      // Loop body is only entered when safe.

      // Early exits from loop body permitted without checking Err.
      if (SomeCondition)
        return;

    }
    if (Err)
      // Handle error.

* Since failure causes a fallible iterator to jump to end, testing that a
  fallible iterator is not an end value implicitly verifies that the error is a
  success value, and so is equivalent to an error check.

Reviewers: dblaikie, rupprecht

Subscribers: mgorny, dexonsmith, kristina, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57618

llvm-svn: 353237
2019-02-05 23:17:11 +00:00
Clement Courbet
9fd325a694 Revert r351954 "Add a value_type to ArrayRef."
This breaks arm self-hosted buildbots.

llvm-svn: 352206
2019-01-25 15:25:52 +00:00
Reid Kleckner
aec41a7a6c [ADT] Notify ilist traits about in-list transfers
Summary:
Previously no client of ilist traits has needed to know about transfers
of nodes within the same list, so as an optimization, ilist doesn't call
transferNodesFromList in that case. However, now there are clients that
want to use ilist traits to cache instruction ordering information to
optimize dominance queries of instructions in the same basic block.
This change updates the existing ilist traits users to detect in-list
transfers and do nothing in that case.

After this change, we can start caching instruction ordering information
in LLVM IR data structures. There are two main ways to do that:
- by putting an order integer into the Instruction class
- by maintaining order integers in a hash table on BasicBlock

I plan to implement and measure both, but I wanted to commit this change
first to enable other out of tree ilist clients to implement this
optimization as well.

Reviewers: lattner, hfinkel, chandlerc

Subscribers: hiraditya, dexonsmith, llvm-commits

Differential Revision: https://reviews.llvm.org/D57120

llvm-svn: 351992
2019-01-23 22:59:52 +00:00
Clement Courbet
6a2ddc7b79 Re-land rL322538 "Add a value_type to ArrayRef."
llvm-svn: 351954
2019-01-23 14:20:59 +00:00
Pavel Labath
38ec165096 Fix compilation error with gcc 4.8
This version of gcc seems to be having issues with raw literals inside macro
arguments. I change the string to use regular string literals instead.

llvm-svn: 351756
2019-01-21 18:21:03 +00:00
Serge Guelton
b20ef5f960 Replace llvm::isPodLike<...> by llvm::is_trivially_copyable<...>
As noted in https://bugs.llvm.org/show_bug.cgi?id=36651, the specialization for
isPodLike<std::pair<...>> did not match the expectation of
std::is_trivially_copyable which makes the memcpy optimization invalid.

This patch renames the llvm::isPodLike trait into llvm::is_trivially_copyable.
Unfortunately std::is_trivially_copyable is not portable across compiler / STL
versions. So a portable version is provided too.

Note that the following specialization were invalid:

    std::pair<T0, T1>
    llvm::Optional<T>

Tests have been added to assert that former specialization are respected by the
standard usage of llvm::is_trivially_copyable, and that when a decent version
of std::is_trivially_copyable is available, llvm::is_trivially_copyable is
compared to std::is_trivially_copyable.

As of this patch, llvm::Optional is no longer considered trivially copyable,
even if T is. This is to be fixed in a later patch, as it has impact on a
long-running bug (see r347004)

Note that GCC warns about this UB, but this got silented by https://reviews.llvm.org/D50296.

Differential Revision: https://reviews.llvm.org/D54472

llvm-svn: 351701
2019-01-20 21:19:56 +00:00
Chandler Carruth
ae65e281f3 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Pavel Labath
40e9380144 [ADT] Add streaming operators for llvm::Optional
Summary:
The operators simply print the underlying value or "None".

The trickier part of this patch is making sure the streaming operators
work even in unit tests (which was my primary motivation, though I can
also see them being useful elsewhere). Since the stream operator was a
template, implicit conversions did not kick in, and our gtest glue code
was explicitly introducing an implicit conversion to make sure other
implicit conversions do not kick in :P. I resolve that by specializing
llvm_gtest::StreamSwitch for llvm:Optional<T>.

Reviewers: sammccall, dblaikie

Reviewed By: sammccall

Subscribers: mgorny, dexonsmith, kristina, llvm-commits

Differential Revision: https://reviews.llvm.org/D56795

llvm-svn: 351548
2019-01-18 12:52:03 +00:00
Dan Gohman
406710c394 [WebAssembly] COWS has been renamed to WASI.
llvm-svn: 351297
2019-01-16 05:23:52 +00:00
Dan Gohman
338ca07ad3 [WebAssembly] Support multilibs for wasm32 and add a wasm OS that uses it
This adds support for multilib paths for wasm32 targets, following
[Debian's Multiarch conventions], and also adds an experimental OS name in
order to test it.

[Debian's Multiarch conventions]: https://wiki.debian.org/Multiarch/

Differential Revision: https://reviews.llvm.org/D56553

llvm-svn: 351163
2019-01-15 06:58:13 +00:00
Pavel Labath
f04e6f0687 [ADT] IntervalMap: add overlaps(a, b) method
Summary:
This function checks whether the mappings in the interval map overlap
with the given range [a;b]. The motivation is to enable checking for
overlap before inserting a new interval into the map.

Reviewers: vsk, dblaikie

Subscribers: dexonsmith, kristina, llvm-commits

Differential Revision: https://reviews.llvm.org/D55760

llvm-svn: 349898
2018-12-21 13:04:34 +00:00
Zachary Turner
6370c21596 [ADT] Fix bugs in SmallBitVector.
Fixes:
  * find_last/find_last_unset - off-by-one error
  * Compound assignment ops and operator== when mixing big/small modes

Patch by Brad Moody
Differential Revision: https://reviews.llvm.org/D54933

llvm-svn: 349173
2018-12-14 18:21:20 +00:00
JF Bastien
3b1f6df294 APFloat: allow 64-bit of payload
Summary: The APFloat and Constant APIs taking an APInt allow arbitrary payloads,
and that's great. There's a convenience API which takes an unsigned, and that's
silly because it then directly creates a 64-bit APInt. Just change it to 64-bits
directly.

At the same time, add ConstantFP NaN getters which match the APFloat ones (with
getQNaN / getSNaN and APInt parameters).

Improve the APFloat testing to set more payload bits.

Reviewers: scanon, rjmccall

Subscribers: jkorous, dexonsmith, kristina, llvm-commits

Differential Revision: https://reviews.llvm.org/D55460

llvm-svn: 348791
2018-12-10 19:27:38 +00:00
Michael Kruse
67da1c2e76 [ADT] Add zip_longest iterators.
Like the already existing zip_shortest/zip_first iterators, zip_longest
iterates over multiple iterators at once, but has as many iterations as
the longest sequence.

This means some iterators may reach the end before others do.
zip_longest uses llvm::Optional's None value to mark a
past-the-end value.

zip_longest is not reverse-iteratable because the tuples iterated over
would be different for different length sequences (IMHO for the same
reason neither zip_shortest nor zip_first should be reverse-iteratable;
one can still reverse the ranges individually if that's the expected
behavior).

In contrast to zip_shortest/zip_first, zip_longest tuples contain
rvalues instead of references. This is because llvm::Optional cannot
contain reference types and the value-initialized default does not have
a memory location a reference could point to.

The motivation for these iterators is to use C++ foreach to compare two
lists of ordered attributes in D48100 (SemaOverload.cpp and
ASTReaderDecl.cpp).

Idea by @hfinkel.

This re-commits r348301 which was reverted by r348303.
The compilation error by gcc 5.4 was resolved using make_tuple in the in
the initializer_list.
The compileration error by msvc14 was resolved by splitting
ZipLongestValueType (which already was a workaround for msvc15) into
ZipLongestItemType and ZipLongestTupleType.

Differential Revision: https://reviews.llvm.org/D48348

llvm-svn: 348323
2018-12-05 00:31:54 +00:00
Michael Kruse
1cbc2656f9 Revert "[ADT] Add zip_longest iterators"
This reverts commit r348301.

Compilation fails on buildbots with older versions of gcc and msvc.

llvm-svn: 348303
2018-12-04 21:38:55 +00:00
Michael Kruse
63a060a406 [ADT] Add zip_longest iterators
Like the already existing zip_shortest/zip_first iterators, zip_longest
iterates over multiple iterators at once, but has as many iterations as
the longest sequence.

This means some iterators may reach the end before others do.
zip_longest uses llvm::Optional's None value to mark a
past-the-end value.

zip_longest is not reverse-iteratable because the tuples iterated over
would be different for different length sequences (IMHO for the same
reason neither zip_shortest nor zip_first should be reverse-iteratable;
one can still reverse the ranges individually if that's the expected
behavior).

In contrast to zip_shortest/zip_first, zip_longest tuples contain
rvalues instead of references. This is because llvm::Optional cannot
contain reference types and the value-initialized default does not have
a memory location a reference could point to.

The motivation for these iterators is to use C++ foreach to compare two
lists of ordered attributes in D48100 (SemaOverload.cpp and
ASTReaderDecl.cpp).

Idea by @hfinkel.

Differential Revision: https://reviews.llvm.org/D48348

llvm-svn: 348301
2018-12-04 21:06:16 +00:00
Kristina Brooks
284bf85c95 Add Hurd target to LLVMSupport (1/2)
Add the required target triples to LLVMSupport to support Hurd
in LLVM (formally `pc-hurd-gnu`).

Patch by sthibaul (Samuel Thibault)

Differential Revision: https://reviews.llvm.org/D54378

llvm-svn: 347832
2018-11-29 03:23:01 +00:00
Sanjay Patel
18470cf8db [APInt] Add methods for saturated add and sub
This adds the sadd_sat, uadd_sat, ssub_sat, usub_sat methods for performing saturating additions and subtractions to APInt.

Split out from D54237.

Patch by: nikic (Nikita Popov)

Differential Revision: https://reviews.llvm.org/D54332

llvm-svn: 347324
2018-11-20 16:47:59 +00:00
Tom Stellard
eed954fef0 Re-apply r346985: [ADT] Drop llvm::Optional clang-specific optimization for trivially copyable types
Remove a test case that was added with the optimization we are now
removing.

llvm-svn: 347004
2018-11-16 00:47:24 +00:00
David Blaikie
5ea0bec42a Correctly instantiate iterator_adaptor_base when defining pointer_iterator
The definition of `pointer_iterator` omits what should be a `iterator_traits::<>::iterator_category` parameter from `iterator_adaptor_base`. As a result, iterators based on `pointer_iterator` always have defaulted value types and the wrong iterator category.

The definition of `pointee_iterator` just a few lines above does this correctly.

This resolves [[ https://bugs.llvm.org/show_bug.cgi?id=39617 | bug 39617 ]].

Patch by Dylan MacKenzie!

Reviewers: dblaikie

Differential Revision: https://reviews.llvm.org/D54377

llvm-svn: 346833
2018-11-14 07:19:21 +00:00
Benjamin Kramer
e1a6a783c3 [ADT] Clean up SparseBitVector copying and make it moveable
llvm-svn: 345829
2018-11-01 13:55:59 +00:00
Daniel Sanders
ba18ecd693 [adt] SparseBitVector::test() should be const
Summary:
Re-worked SparseBitVector's most-recently-used-word caching (CurrElementIter)
such that SparseBitVector::test() can be made const. This came up when
attempting to test individual bits in a SparseBitVector which was a member of a
const object.

The cached iterator has no bearing on the externally visible state, it's merely
a performance optimization. Therefore it has been made mutable and
FindLowerBound() has been split into a const and non-const function
(FindLowerBound/FindLowerBoundConst) for the const/non-const
interfaces.

Reviewers: rtereshin

Reviewed By: rtereshin

Subscribers: rtereshin, dexonsmith, kristina, llvm-commits

Differential Revision: https://reviews.llvm.org/D53447

llvm-svn: 345772
2018-10-31 20:05:32 +00:00
Florian Hahn
75395f6f60 [ADT] Remove illegal comparison of singular iterators from SmallSetTest
This removes the assertion that a copy of a moved-from SmallSetIterator
equals the original, which is illegal due to SmallSetIterator including
an instance of a standard `std::set` iterator.

C++ [iterator.requirements.general] states that comparing singular
iterators has undefined result:

> Iterators can also have singular values that are not associated with
> any sequence. [...] Results of most expressions are undefined for
> singular values; the only exceptions are destroying an iterator that
> holds a singular value, the assignment of a non-singular value to an
> iterator that holds a singular value, and, for iterators that satisfy
> the Cpp17DefaultConstructible requirements, using a value-initialized
> iterator as the source of a copy or move operation.

This assertion triggers the following error in the GNU C++ Library in
debug mode under EXPENSIVE_CHECKS:

  /usr/include/c++/8.2.1/debug/safe_iterator.h:518:
  Error: attempt to compare a singular iterator to a singular iterator.

  Objects involved in the operation:
      iterator "lhs" @ 0x0x7fff86420670 {
        state = singular;
      }
      iterator "rhs" @ 0x0x7fff86420640 {
        state = singular;
      }

Patch by Eugene Sharygin.

Reviewers: fhahn, dblaikie, chandlerc

Reviewed By: fhahn, dblaikie

Differential Revision: https://reviews.llvm.org/D53793

llvm-svn: 345712
2018-10-31 11:00:48 +00:00