Commit Graph

990 Commits

Author SHA1 Message Date
Jan Korous 79707ecd7d [llvm][ADT][NFC] Add test for makeArrayRef(std::array)
llvm-svn: 371475
2019-09-10 00:29:35 +00:00
Dmitri Gribenko 4fc0d3bd09 [ADT] Removed VariadicFunction
Summary:
It is not used. It uses macro-based unrolling instead of variadic
templates, so it is not idiomatic anymore, and therefore it is a
questionable API to keep "just in case".

Subscribers: mgorny, dmgreen, dexonsmith, llvm-commits

Tags: #llvm

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

llvm-svn: 370441
2019-08-30 08:21:55 +00:00
Benjamin Kramer 57effbdadc [ADT] Make StringRef(const char*) constexpr
This should let us get rid of StringLiteral in the long term and avoid
chasing accidental StringRef globals once and for all.

This requires C++14, I godbolted it on every compiler I know we support
so I hope there won't be much fallout.

llvm-svn: 369961
2019-08-26 20:47:56 +00:00
Sam McCall a451156bb6 reland [gtest] Fix printing of StringRef and SmallString in assert messages.
Renames GTEST_NO_LLVM_RAW_OSTREAM -> GTEST_NO_LLVM_SUPPORT and guards
the new features behind it.

This reverts commit a063bcf3ef5a879adbe9639a3c187d876eee0e66.

llvm-svn: 369527
2019-08-21 13:56:29 +00:00
Sam McCall e7c0356b69 Revert "[gtest] Fix printing of StringRef and SmallString in assert messages."
This reverts commit 4becb2ab4e9f52ce98272d1f5930d6942af5172b.

llvm-svn: 369525
2019-08-21 13:31:44 +00:00
Sam McCall 2fe9ce6064 [gtest] Fix printing of StringRef and SmallString in assert messages.
Summary:
These are detected by gtest as containers, and so previously printed as e.g.
  { '.' (46, 0x2E), 's' (115, 0x73), 'e' (101, 0x65), 'c' (99, 0x63), '0' (48, 0x30) },

gtest itself overloads PrintTo for std::string and friends, we use the same mechanism.

Reviewers: labath

Subscribers: dexonsmith, llvm-commits

Tags: #llvm

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

llvm-svn: 369518
2019-08-21 11:37:06 +00:00
Andrew Trick 861b371e13 Add TinyPtrVector support for general pointer-like things.
In particular, make TinyPtrVector<PtrIntPair<T *, 1>> work. Remove all
unnecessary assumptions that the element type has a formal "null"
representation. The important property to maintain is that
default-constructed element type has the same internal representation
as the default-constructed PointerUnion (all zero bits).

Remove the incorrect recursive behavior from
PointerUnion::isNull. This was never generally correct because it only
recursed over the first type parameter. With variadic templates it's
completely unnecessary.

llvm-svn: 369473
2019-08-20 23:29:28 +00:00
Jonas Devlieghere 7e106445ef [ADT] Remove llvm::make_unique utility.
All uses of llvm::make_unique should have been replaced with
std::make_unique. This patch represents the last part of the migration
and removes the utility from LLVM.

Differential revision: https://reviews.llvm.org/D66259

llvm-svn: 369130
2019-08-16 17:19:57 +00:00
Jonas Devlieghere 0eaee545ee [llvm] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

llvm-svn: 369013
2019-08-15 15:54:37 +00:00
Russell Gallop 2601cdd3ae Revert rL368939 "Remove LVALUE / RVALUE workarounds"
This reverts commit cad8356d69.

To unbreak Windows bots

llvm-svn: 368985
2019-08-15 10:12:11 +00:00
JF Bastien cad8356d69 Remove LVALUE / RVALUE workarounds
Summary: LLVM_HAS_RVALUE_REFERENCE_THIS and LLVM_LVALUE_FUNCTION shouldn't be needed anymore because the minimum compiler versions support them.

Subscribers: jkorous, dexonsmith, cfe-commits, llvm-commits, hans, thakis, chandlerc, rnk

Tags: #clang, #llvm

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

llvm-svn: 368939
2019-08-14 22:48:12 +00:00
David Blaikie 42ad452c1e Fix build when both gtest death tests and LLVM_NODISCARD are available.
(matching r367495)

llvm-svn: 367899
2019-08-05 18:12:50 +00:00
Jinsong Ji 490292c3e0 [PowerPC][NFC] Enable ADT BitVectorTest
Test on ppc64le passed.
This fix https://bugs.llvm.org/show_bug.cgi?id=42702

llvm-svn: 367713
2019-08-02 19:58:00 +00:00
Sam Elliott 1fc2a47f0b Add support for openSUSE RISC-V triple
Reviewers: asb

Reviewed By: asb

Subscribers: lenary, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lebedev.ri, kito-cheng, shiva0217, rogfer01, dexonsmith, rkruppe, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Patch by Andreas Schwab (schwab)

llvm-svn: 367565
2019-08-01 14:23:56 +00:00
Richard Smith a8cf379826 Fix build when both gtest death tests and LLVM_NODISCARD are available.
llvm-svn: 367495
2019-07-31 23:37:24 +00:00
Roman Lebedev 6606815993 [APInt] Introduce clearLowBits()
Summary: Equivalent to `x & -2^K`.

Reviewers: RKSimon, craig.topper

Reviewed By: RKSimon, craig.topper

Subscribers: dexonsmith, llvm-commits

Tags: #llvm

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

llvm-svn: 367287
2019-07-30 07:09:41 +00:00
Whitney Tsang 8b288c7d11 [DDG] DirectedGraph as a base class for various dependence graphs such
as DDG and PDG.
Summary:
This is an implementation of a directed graph base class with explicit
representation of both nodes and edges. This implementation makes the
edges explicit because we expect to assign various attributes (such as
dependence type, distribution interference weight, etc) to the edges in
the derived classes such as DDG and DIG. The DirectedGraph consists of a
list of DGNode's. Each node consists of a (possibly empty) list of
outgoing edges to other nodes in the graph. A DGEdge contains a
reference to a single target node. Note that nodes do not know about
their incoming edges so the DirectedGraph class provides a function to
find all incoming edges to a given node.

This is the first patch in a series of patches that we are planning to
contribute upstream in order to implement Data Dependence Graph and
Program Dependence Graph.

More information about the proposed design can be found here:
https://ibm.ent.box.com/v/directed-graph-and-ddg
Authored By: bmahjour
Reviewer: Meinersbur, myhsum hfinkel, fhahn, jdoerfert, kbarton
Reviewed By: Meinersbur
Subscribers: mgorny, wuzish, jsji, lebedev.ri, dexonsmith, kristina,
llvm-commits, Whitney, etiotto
Tag: LLVM
Differential Revision: https://reviews.llvm.org/D64088

llvm-svn: 367043
2019-07-25 18:23:22 +00:00
Simon Pilgrim 630be14ac6 [SmallBitVector] Fix bug in find_next_unset for small types with indices >=32
We were creating a bitmask from a shift of unsigned instead of uintptr_t, meaning we couldn't create masks for indices above 31.

Noticed due to a MSVC analyzer warning.

llvm-svn: 366657
2019-07-21 16:06:26 +00:00
Simon Pilgrim d050e45631 [ADT] Remove MSVC-only "no two-phase name lookup" typename path.
Now that we've dropped VS2015 support (D64326) we can use the regular codepath as VS2017+ correctly handles it

llvm-svn: 365502
2019-07-09 15:24:19 +00:00
Simon Pilgrim e995ce5498 [ADT] Enable ArrayRef/StringRef is_assignable tests on MSVC
Now that we've dropped VS2015 support (D64326) we can enable these static_asserts on MSVC builds as VS2017+ correctly handles them

llvm-svn: 365471
2019-07-09 12:20:04 +00:00
Reid Kleckner 2f07c2e9d9 Standardize on MSVC behavior for triples with no environment
Summary:
This makes it so that IR files using triples without an environment work
out of the box, without normalizing them.

Typically, the MSVC behavior is more desirable. For example, it tends to
enable things like constant merging, use of associative comdats, etc.

Addresses PR42491

Reviewers: compnerd

Subscribers: hiraditya, dexonsmith, llvm-commits

Tags: #llvm

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

llvm-svn: 365387
2019-07-08 21:05:20 +00:00
Alex Bradbury c5f552d705 [Triple] Add isRISCV function
This matches isARM, isThumb, isAArch64 and similar helpers. Future commits
which clean-up code that currently checks for Triple::riscv32 ||
Triple::riscv64.

Differential Revision: https://reviews.llvm.org/D54215
Patch by Simon Cook.
Test case added by Alex Bradbury.

llvm-svn: 365327
2019-07-08 14:52:36 +00:00
Alex Lorenz 3dbdbbec84 [triple] Use 'macabi' environment name for the Mac Catalyst triples
The 'macabi' environment name is preferred instead of 'maccatalyst'.

llvm-svn: 364988
2019-07-03 01:02:43 +00:00
Alex Lorenz 31dee6d6ed [triple] add 'macCatalyst' environment type
Mac Catalyst is a new deployment platform in macOS Catalina.

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

llvm-svn: 364971
2019-07-02 21:37:00 +00:00
Roman Lebedev 1a5ebe1fb1 [APIntTest] multiplicativeInverse(): clarify test
Clarify that multiplicative inverse exists for all odd numbers,
and does not exist for all even numbers (including 0).

llvm-svn: 364920
2019-07-02 13:21:17 +00:00
Fangrui Song 78ee2fbf98 Cleanup: llvm::bsearch -> llvm::partition_point after r364719
llvm-svn: 364720
2019-06-30 11:19:56 +00:00
Fangrui Song 2d2cb77e45 [ADT] Implement llvm::bsearch() with std::partition_point()
Summary:
Delete the begin-end form because the standard std::partition_point
can be easily used as a replacement.

The ranges-style llvm::bsearch will be renamed to llvm::partition_point
in the next clean-up patch.

The name "bsearch" doesn't meet people's expectation because in C:

> If two or more members compare equal, which member is returned is unspecified.

Reviewed By: sammccall

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

llvm-svn: 364719
2019-06-30 09:17:59 +00:00
Dmitry Venikov 9e9eb62f9f [APInt] Fix getBitsNeeded for INT_MIN values
Summary: This patch fixes behaviour of APInt::getBitsNeeded for INT_MIN 10 bits values.

Reviewers: regehr, RKSimon

Reviewed By: RKSimon

Subscribers: grandinj, dexonsmith, kristina, llvm-commits

Tags: #llvm

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

llvm-svn: 364710
2019-06-29 11:38:12 +00:00
Mikael Holmen 2adab5a142 Silence gcc warning in testcase [NFC]
Without the fix gcc (7.4.0) complains with

../unittests/ADT/APIntTest.cpp: In member function 'virtual void {anonymous}::APIntTest_MultiplicativeInverseExaustive_Test::TestBody()':
../unittests/ADT/APIntTest.cpp:2510:36: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
     for (unsigned Value = 0; Value < (1 << BitWidth); ++Value) {
                              ~~~~~~^~~~~~~~~~~~~~~~~

llvm-svn: 364624
2019-06-28 06:45:20 +00:00
Roman Lebedev a59cf87822 [NFC][APInt] Add (exhaustive) test for multiplicativeInverse()
Else there is no direct test coverage at all.
The function should either return '0' or precise answer.

llvm-svn: 364599
2019-06-27 21:51:54 +00:00
Michael Pozulp 31650eaa02 [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 d8e3d0dab8 Revert "[ADT] Enable set_difference() to be used on StringSet"
This reverts commit 0bddef7901, 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 0bddef7901 [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 a881ffeae4 [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 a9a92653a3 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 9b92875bbd 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 3588a7462b 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 8e7a05a456 [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 3234887fe2 [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 51389aad98 [ADT] Avoid warning in bsearch testcase
llvm-svn: 358811
2019-04-20 11:48:11 +00:00
Fangrui Song acc7641bcb [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 6b44291b5c [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 67c29e2294 [ADT] Fix OwningArrayRef's move ctor
llvm-svn: 358332
2019-04-13 13:52:11 +00:00
Eli Friedman 3dd72ea810 [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 78e21bac99 [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 a03ae73c29 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 9e302c6231 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 6e0b562bf6 [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 099cbc3e46 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 98b4fd82b7 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