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

3277 Commits

Author SHA1 Message Date
Sean Silva
bc224c8fad [SmallVector] Allow SmallVector<T>
This patch adds a capability to SmallVector to decide a number of
inlined elements automatically. The policy is:

- A minimum of 1 inlined elements, with more as long as
sizeof(SmallVector<T>) <= 64.
- If sizeof(T) is "too big", then trigger a static_assert: this dodges
the more pathological cases

This is expected to systematically improve SmallVector use in the
LLVM codebase, which has historically been plagued by semi-arbitrary /
cargo culted N parameters, often leading to bad outcomes due to
excessive sizeof(SmallVector<T, N>). This default also makes
programming more convenient by avoiding edit/rebuild cycles due to
forgetting to type the N parameter.

Differential Revision: https://reviews.llvm.org/D92522
2020-12-03 17:21:44 -08:00
Mehdi Amini
91270b1460 Revert "Switch to std::is_trivially_move_constructible and std::is_trivially_copy_constructible"
This reverts commit c8d406c93c5bb01599990201f78d8428dd29d289.

Builds are broken with some versions of GCC.
2020-12-03 19:58:06 +00:00
Fangrui Song
f6492fea1c Switch to std::is_trivially_move_constructible and std::is_trivially_copy_constructible
Differential Revision: https://reviews.llvm.org/D92543
2020-12-03 09:15:40 -08:00
Ahmed Bougacha
fe6a3c2668 [Triple][MachO] Define "arm64e", an AArch64 subarch for Pointer Auth.
This also teaches MachO writers/readers about the MachO cpu subtype,
beyond the minimal subtype reader support present at the moment.

This also defines a preprocessor macro to allow users to distinguish
__arm64__ from __arm64e__.

arm64e defaults to an "apple-a12" CPU, which supports v8.3a, allowing
pointer-authentication codegen.
It also currently defaults to ios14 and macos11.

Differential Revision: https://reviews.llvm.org/D87095
2020-12-03 07:53:59 -08:00
Tim Northover
a8373fee73 arm64: count Triple::aarch64_32 as an aarch64 target and enable leaf frame pointers 2020-12-03 11:09:44 +00:00
Fangrui Song
649f05aa24 Switch from llvm::is_trivially_copyable to std::is_trivially_copyable
GCC<5 did not support std::is_trivially_copyable. Now LLVM builds require 5.1
we can migrate to std::is_trivially_copyable.

The Optional.h change made MSVC choke
(https://buildkite.com/llvm-project/premerge-checks/builds/18587#cd1bb616-ffdc-4581-9795-b42c284196de)
so I leave it out for now.

Differential Revision: https://reviews.llvm.org/D92514
2020-12-02 22:02:48 -08:00
Duncan P. N. Exon Smith
402de92d98 ADT: Remove redundant alignas from IntervalMap, NFC
`AlignedArrayCharUnion` is now using `alignas`, which is properly
supported now by all the host toolchains we support. As a result, the
extra `alignas` on `IntervalMap` isn't needed anymore.

This is effectively a revert of 379daa29744cd96b0a87ed0d4a010fa4bc47ce73.

Differential Revision: https://reviews.llvm.org/D92509
2020-12-02 14:33:20 -08:00
Reid Kleckner
7c87aeebfe Revert "Use std::is_trivially_copyable", breaks MSVC build
Revert "Delete llvm::is_trivially_copyable and CMake variable HAVE_STD_IS_TRIVIALLY_COPYABLE"

This reverts commit 4d4bd40b578d77b8c5bc349ded405fb58c333c78.

This reverts commit 557b00e0afb2dc1776f50948094ca8cc62d97be4.
2020-12-02 14:30:46 -08:00
Fangrui Song
3effbaa68f Delete llvm::is_trivially_copyable and CMake variable HAVE_STD_IS_TRIVIALLY_COPYABLE
GCC<5 did not support std::is_trivially_copyable. Now LLVM builds
require 5.1 we can delete llvm::is_trivially_copyable after the users
have been migrated to std::is_trivially_copyable.
2020-12-02 09:58:08 -08:00
Fangrui Song
dffdc25f75 Use std::is_trivially_copyable
GCC<5 did not support std::is_trivially_copyable. Now LLVM builds require 5.1
we can migrate to std::is_trivially_copyable.
2020-12-02 09:58:07 -08:00
Arthur O'Dwyer
c383fe5b05 s/instantate/instantiate/ throughout. NFCI.
The static_assert in "libcxx/include/memory" was the main offender here,
but then I figured I might as well `git grep -i instantat` and fix all
the instances I found. One was in user-facing HTML documentation;
the rest were in comments or tests.
2020-12-01 22:13:40 -05:00
Jameson Nash
1c1949a4cb fix some Wundef warnings in public headers
Differential Revision: https://reviews.llvm.org/D91094
2020-11-23 20:17:46 -05:00
Jay Foad
1ac4a188a1 Fix speling in comments. NFC. 2020-11-23 14:43:24 +00:00
Kerry McLaughlin
1a23665577 [APInt] Add the truncOrSelf resizing operator to APInt
Truncates the APInt if the bit width is greater than the width specified,
otherwise do nothing

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D91445
2020-11-23 11:27:30 +00:00
Duncan P. N. Exon Smith
7668c9150a ADT: Split out isSafeToReferenceAfterResize helper to use early returns, NFC
The assertion logic in SmallVector::assertSafeToReferenceAfterResize is
hard to follow; split out SmallVector::isSafeToReferenceAfterResize and
add early returns and comments. No functionality change here.
2020-11-19 17:55:04 -08:00
Duncan P. N. Exon Smith
82e253383a ADT: Use early returns in SmallVector::resize, NFC
Just a simple cleanup, no functionality change here.
2020-11-19 17:28:57 -08:00
Duncan P. N. Exon Smith
8605039d2b ADT: Weaken SmallVector::resize assertion from 5abf76fbe37380874a88cc9aa02164800e4e10f3
There's no need to check for reference invalidation when
`SmallVector::resize` is shrinking; the parameter isn't accessed.

Differential Revision: https://reviews.llvm.org/D91832
2020-11-19 17:25:36 -08:00
Duncan P. N. Exon Smith
b6b630c8ab ADT: Add assertions to SmallVector::insert, etc., for reference invalidation
2c196bbc6bd897b3dcc1d87a3baac28e1e88df41 asserted that
`SmallVector::push_back` doesn't invalidate the parameter when it needs
to grow. Do the same for `resize`, `append`, `assign`, `insert`, and
`emplace_back`.

Differential Revision: https://reviews.llvm.org/D91744
2020-11-18 17:36:28 -08:00
Moritz Sichert
0fadcfd431 Added GDB pretty printer for StringMap
Reviewed By: csigg, dblaikie

Differential Revision: https://reviews.llvm.org/D91183
2020-11-18 16:33:34 -08:00
Duncan P. N. Exon Smith
d59bc177d6 ADT: Share an implementation for single-element insert in SmallVector, NFC
Factor out `SmallVectorImple::insert_one_impl`, a common implementation
for `insert(iterator, T&&)` and `insert(iterator, T const&)`. This is
just a clean up and has no functionality change.

Differential Revision: https://reviews.llvm.org/D91674
2020-11-17 21:20:51 -08:00
Mehdi Amini
738b5c2c48 Add an assertion in SmallVector::push_back()
This assertion ensures the input value isn't part of the vector when
growing is required. In such cases the vector will grow and the input
value is invalidated before being read from.

This found 14 failed Tests.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D84293
2020-11-14 00:55:34 +00:00
Nathan James
0430707986 [clangd] Handle duplicate enum constants in PopulateSwitch tweak
If an enum has different names for the same constant, make sure only the first one declared gets added into the switch. Failing to do so results in a compiler error as 2 case labels can't represent the same value.

```
lang=c
enum Numbers{
One,
Un = One,
Two,
Deux = Two,
Three,
Trois = Three
};

// Old behaviour
switch (<Number>) {
  case One:
  case Un:
  case Two:
  case Duex:
  case Three:
  case Trois: break;
}

// New behaviour
switch (<Number>) {
  case One:
  case Two:
  case Three: break;
}
```

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D90555
2020-11-09 12:14:53 +00:00
Sean Silva
7b66e6757c [STLExtras] Add append_range helper.
This is convenient in a lot of cases, such as when the thing you want
to append is `someReallyLongFunctionName()` that you'd rather not
write twice or assign to a variable for the paired begin/end calls.

Differential Revision: https://reviews.llvm.org/D90894
2020-11-05 16:20:02 -08:00
Nathan James
b80fbad013 [ADT] Add SmallVector::pop_back_n
Adds a method called pop_back_n to SmallVector.
This is more readable and less error prone than the alternatives of using
```lang=c++
Vector.resize(Vector.size() - N);
Vector.erase(Vector.end() - N, Vector.end());
for (unsigned I = 0;I<N;++I) Vector.pop_back();
```

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D90576
2020-11-03 14:57:10 +00:00
Ben Dunbobbin
1b5bdf4e65 [PS4] Support dllimport/export attributes
For PS4 development we support dllimport/export annotations in
source code. This patch enables the dllimport/export attributes
on PS4 by adding a new function to query the triple for whether
dllimport/export are used and using that function to decide
whether these attributes are supported. This replaces the current
method of checking if the target is Windows.

This means we can drop the use of "TargetArch" in the .td file
(which is an improvement as dllimport/export support isn't really
a function of the architecture).

I have included a simple codgen test to show that the attributes
are accepted and have an effect on codegen for PS4. I have also
enabled the DLLExportStaticLocal and DLLImportStaticLocal
attributes, which we support downstream. However, I am unable to
write a test for these attributes until other patches for PS4
dllimport/export handling land upstream. Whilst writing this
patch I noticed that, as these attributes are internal, they do
not need to be target specific (when these attributes are added
internally in Clang the target specific checks have already been
run); however, I think leaving them target specific is fine
because it isn't harmful and they "really are" target specific
even if that has no functional impact.

Differential Revision: https://reviews.llvm.org/D90442
2020-11-02 14:25:34 +00:00
Nathan James
fe6ca64874 [ADT][NFC] Silence some misc-unconventional-assign-operator warnings 2020-10-30 10:57:25 +00:00
Nathan James
21052ba8d6 [ADT] Add methods to SmallString for efficient concatenation
A common pattern when using SmallString is to repeatedly call append to build a larger string.
The issue here is the optimizer can't see through this and often has to check there is enough space in the storage for each string you try to append.
This results in lots of conditional branches and potentially multiple calls to grow needing to be emitted if the buffer wasn't large enough.
By taking an initializer_list of StringRefs, SmallString can preallocate the storage it needs for all of the StringRefs which only need to grow one time at most, then use a fast path of copying all the strings into its storage knowing there is guaranteed to be enough capacity.
By using StringRefs, this also means you can append different string like types in one go as they will all be implicitly converted to a StringRef.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D90386
2020-10-30 10:07:40 +00:00
Adam Balogh
46939502b8 [ADT] Fix for ImmutableMapRef
The `Root` member of `ImmutableMapRef` was changed recently from a plain
pointer to `IntrusiveRefCntPtr`. However, the `Profile` member function
was not adjusted. This results in comilation error whenever the
`Profile` method is used on an `ImmutableMapRef`. This patch fixes this
issue and also adds unit tests for `ImmutableMapRef`.

Differential Revision: https://reviews.llvm.org/D89486
2020-10-29 13:19:51 +01:00
River Riddle
d248b6cfb7 [llvm][StringExtras] Use a lookup table for hexDigitValue
This method is at the core of the conversion from hex to binary, and using a lookup table great improves the compile time of hex conversions.

Context: In MLIR we use hex strings to represent very large constants in the textual format of the IR. These changes lead to a large decrease in compile time when parsing these constants (>1 second -> 350 miliseconds).

Differential Revision: https://reviews.llvm.org/D90320
2020-10-28 16:58:06 -07:00
River Riddle
9da2a4f5d7 [llvm][StringExtras] Add a fail-able version of fromHex
This revision adds a fail-able/checked version of `fromHex` that fails when the input string contains a non-hex character. This removes the need for users to have a separate check for if the string contains all hex digits. This becomes very costly for large hex strings given that checking if a string contains only hex digits is effectively the same as just converting it in the first place.

Context: In MLIR we use hex strings to represent very large constants in the textual format of the IR. These changes lead to a large decrease in compile time when parsing these constants (2 seconds -> 1 second).

Differential Revision: https://reviews.llvm.org/D90265
2020-10-28 16:58:06 -07:00
Mitch Phillips
12ea6caf44 Revert "[ADT] Fix for ImmutableMapRef"
This reverts commit a6336eab0c507b665dda63fa9db1292a2cdee409.

This commit broke check-llvm under ASan:

See http://lab.llvm.org:8011/#/builders/5/builds/446 for more details.
2020-10-27 20:50:46 -07:00
Alex Lorenz
ce5134f423 [driver][arm64] Set target CPU to A12 for compiler invocations that
target Apple Silicon macOS machines

Differential Revision: https://reviews.llvm.org/D82699
2020-10-21 23:35:27 -07:00
Adam Balogh
a4200b92ce [ADT] Fix for ImmutableMapRef
The `Root` member of `ImmutableMapRef` was changed recently from a plain
pointer to `IntrusiveRefCntPtr`. However, the `Profile` member function
was not adjusted. This results in comilation error whenever the
`Profile` method is used on an `ImmutableMapRef`. This patch fixes this
issue and also adds unit tests for `ImmutableMapRef`.

Differential Revision: https://reviews.llvm.org/D89486
2020-10-21 12:13:20 +02:00
Sam McCall
75a854e0a6 [ADT] Avoid use of result_of_t in function_ref
It has bugs on some old libc++ versions and we don't need the power.
See https://reviews.llvm.org/D88977
2020-10-19 14:59:45 +02:00
Reid Kleckner
4b5ed96964 [ADT] Use alignas + sizeof for inline storage, NFC
AlignedCharArrayUnion is really only needed to handle the "union" case
when we need memory of suitable size and alignment for multiple types.
SmallVector only needs storage for one type, so use that directly.
2020-10-14 16:16:02 -07:00
jasonliu
d77cbcb130 [AIX] Turn -fdata-sections on by default in Clang
Summary:

This patch does the following:
1. Make InitTargetOptionsFromCodeGenFlags() accepts Triple as a
 parameter, because some options' default value is triple dependant.
2. DataSections is turned on by default on AIX for llc.
3. Test cases change accordingly because of the default behaviour change.
4. Clang Driver passes in -fdata-sections by default on AIX.

Reviewed By: MaskRay, DiggerLin

Differential Revision: https://reviews.llvm.org/D88737
2020-10-14 15:58:31 +00:00
Bevin Hansson
ad6d96ea4f [Fixed Point] Add floating point methods to APFixedPoint.
This adds methods to APFixedPoint for converting to and from
floating point values.

Differential Revision: https://reviews.llvm.org/D85961
2020-10-09 10:27:42 +02:00
Sam McCall
a23b9aed3d Reapply [ADT] function_ref's constructor is unavailable if the argument is not callable.
This reverts commit 281703e67ffaee8e26efef86e0df3e145477f4cb.

GCC 5.4 bugs are worked around by avoiding use of variable templates.

Differential Revision: https://reviews.llvm.org/D88977
2020-10-07 18:31:12 +02:00
Sam McCall
dc3a1be2c9 Revert "[ADT] function_ref's constructor is unavailable if the argument is not callable."
This reverts commit 4cae6228d129d4c4dfb156c043977bb6b5690031.

Breaks GCC build:
http://lab.llvm.org:8011/#/builders/8/builds/33/steps/6/logs/stdio
2020-10-07 16:37:13 +02:00
Sam McCall
360a9fdce4 [ADT] function_ref's constructor is unavailable if the argument is not callable.
This allows overload sets containing function_ref arguments to work correctly
Otherwise they're ambiguous as anything "could be" converted to a function_ref.

This matches proposed std::function_ref, absl::function_ref, etc.

Differential Revision: https://reviews.llvm.org/D88901
2020-10-07 16:31:09 +02:00
Roman Lebedev
8b5ad85b2f [NFC][APInt] Refactor getMinSignedBits() in terms of getNumSignBits()
This is fully identical to the old implementation, just easier to read.
2020-09-22 21:37:29 +03:00
Simon Pilgrim
ce833bfec3 Revert rGf835779160ec303 "[APFloat] multiplySignificand - always pass IEEEFloat as const reference. NFCI."
This reverts commit f835779160ec30340676918915526615a07e826e while I investigate some buildbot failures
2020-09-22 12:15:23 +01:00
Simon Pilgrim
5c56e1aa26 [APFloat] multiplySignificand - always pass IEEEFloat as const reference. NFCI.
We do this in all other cases.
2020-09-22 11:29:29 +01:00
Serge Pavlov
35714dfbb7 [FPEnv] Use typed accessors in FPOptions
Previously methods `FPOptions::get*` returned unsigned value even if the
corresponding property was represented by specific enumeration type. With
this change such methods return actual type of the property. It also
allows printing value of a property as text rather than integer code.

Differential Revision: https://reviews.llvm.org/D87812
2020-09-18 14:16:43 +07:00
Simon Pilgrim
558faf7f34 APInt.h - return directly from clearUnusedBits in single word cases. NFCI.
Consistently use the same pattern of returning *this from the clearUnusedBits() call to allow us to early out from the isSingleWord() path and avoid an else statement.
2020-09-09 13:22:57 +01:00
Simon Pilgrim
095c0be790 [APFloat] Fix uninitialized variable in IEEEFloat constructors
Some constructors of IEEEFloat do not initialize member variable exponent.
Fix it by initializing exponent with the following values:

For NaNs, the `exponent` is `maxExponent+1`.
For Infinities, the `exponent` is `maxExponent+1`.
For Zeroes, the `exponent` is `maxExponent-1`.

Patch by: @nullptr.cpp (Yang Fan)

Differential Revision: https://reviews.llvm.org/D86997
2020-09-09 11:38:30 +01:00
Benjamin Kramer
c3337b0542 [SmallVector] Move error handling out of line
This reduces duplication and avoids emitting ice cold code into every
instance of grow().
2020-09-06 18:06:44 +02:00
Fangrui Song
7b5b3c5b86 [SmallVector] Include stdexcept if LLVM_ENABLE_EXCEPTIONS
std::length_error needs stdexcept.
2020-09-03 18:06:08 -07:00
Dimitry Andric
79876868be Eliminate the sizing template parameter N from CoalescingBitVector
Since the parameter is not used anywhere, and the default size of 16
apparently causes PR47359, remove it. This ensures that IntervalMap will
automatically determine the optimal size, using its NodeSizer struct.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D87044
2020-09-03 18:15:41 +02:00
Geoffrey Martin-Noble
60cb217dc7 Improve error handling for SmallVector programming errors
This patch changes errors in `SmallVector::grow` that are independent of
memory capacity to be reported using report_fatal_error or
std::length_error instead of report_bad_alloc_error, which falsely signals
an OOM.

It also cleans up a few related things:
- makes report_bad_alloc_error to print the failure reason passed
  to it.
- fixes the documentation to indicate that report_bad_alloc_error
  calls `abort()` not "an assertion"
- uses a consistent name for the size/capacity argument to `grow`
  and `grow_pod`

Reviewed By: mehdi_amini, MaskRay

Differential Revision: https://reviews.llvm.org/D86892
2020-09-02 15:00:26 -07:00
Jay Foad
53df1fb508 [APInt] New member function setBitVal
Differential Revision: https://reviews.llvm.org/D87033
2020-09-02 21:40:31 +01:00
Zi Xuan Wu
ed26c15759 [RFC][Target] Add a new triple called Triple::csky
Before upstream a new target called CSKY, make a new triple of that called Triple::csky.
For now, it's a 32-bit little endian target and the detail can be referred at D86269.

This is the split part of D86269, which add a new target called CSKY.

Differential Revision: https://reviews.llvm.org/D86505
2020-09-02 12:46:09 +08:00
Varun Gandhi
99d53ed697 [ADT] Make Optional a literal type.
This allows returning Optional values from constexpr contexts.

Reviewed By: fhahn, dblaikie, rjmccall

Differential Revision: https://reviews.llvm.org/D86354
2020-09-01 16:13:40 -07:00
Roman Lebedev
5d89fa42b3 [NFC][STLExtras] Add make_first_range(), similar to existing make_second_range()
Having just one of the two seens weird.
I wanted to use it a few times, but it wasn't there.
2020-08-29 09:58:07 +03:00
Yevgeny Rouban
ae25ecf12b [ADT] Allow IsSizeLessThanThresholdT for incomplete types. NFC
If the type T is incomplete then sizeof(T) results in C++ compilation error at line:
  static constexpr bool value = sizeof(T) <= (2 * sizeof(void *));

This patch allows incomplete types in parameters of function. Example:
  using SomeFunc = void(SomeIncompleteType &);
  llvm::unique_function<SomeFuncType> SomeFunc;

Reviewers: DaniilSuchkov, vvereschaka

Differential Revision: https://reviews.llvm.org/D81554
2020-08-21 11:01:57 +07:00
Vitaly Buka
8be4d9ede0 [APInt] Allow self-assignment with libstdc++
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-ubuntu/builds/8256/steps/test-check-all/logs/FAIL%3A%20LLVM%3A%3Athinlto-function-summary-paramaccess.ll

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D86053
2020-08-20 04:14:40 -07:00
Bevin Hansson
9531c6209d [ADT] Move FixedPoint.h from Clang to LLVM.
This patch moves FixedPointSemantics and APFixedPoint
from Clang to LLVM ADT.

This will make it easier to use the fixed-point
classes in LLVM for constructing an IR builder for
fixed-point and for reusing the APFixedPoint class
for constant evaluation purposes.

RFC: http://lists.llvm.org/pipermail/llvm-dev/2020-August/144025.html

Reviewed By: leonardchan, rjmccall

Differential Revision: https://reviews.llvm.org/D85312
2020-08-20 10:29:45 +02:00
Kai Nacke
b0aab57571 [SystemZ/ZOS] Add binary format goff and operating system zos to the triple
Adds the binary format goff and the operating system zos to the triple
class. goff is selected as default binary format if zos is choosen as
operating system. No further functionality is added.

Reviewers: efriedma, tahonermann, hubert.reinterpertcast, MaskRay

Reviewed By: efriedma, tahonermann, hubert.reinterpertcast

Differential Revision: https://reviews.llvm.org/D82081
2020-08-11 05:26:26 -04:00
Shinji Okumura
4e0af248b2 [NFC][APInt][DenseMapInfo] Move DenseMapAPIntKeyInfo into DenseMap.h as DenseMapInfo<APInt>
`DenseMapAPIntKeyInfo` is now located in `lib/IR/LLVMContextImpl.h`.
Moved it into `include/ADT/DenseMapInfo.h` to use it.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D85131
2020-08-03 23:31:13 +09:00
Shinji Okumura
7c6b247bf7 Revert "[Attributor] AAPotentialValues Interface"
The commit cause build failure.
2020-08-02 22:49:52 +09:00
Shinji Okumura
5dd3ff33f5 [Attributor] AAPotentialValues Interface
This is a split patch of D80991.
This patch introduces AAPotentialValues and its interface only.
For more detail of AAPotentialValues abstract attribute, see the original patch.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D83283
2020-08-02 19:12:17 +09:00
Stefanos Baziotis
9255f8a1f0 [ADT][BitVector][NFC] Merge find_first_in() / find_first_unset_in()
We can implement find_first_unset_in() in the same function
if every BitWord we use is first flipped.

Differential Revision: https://reviews.llvm.org/D84717
2020-07-29 04:51:22 +03:00
Jinsong Ji
a3d207d6bc Re-land "[PowerPC] Remove QPX/A2Q BGQ/BGP CNK support"
This reverts commit bf544fa1c3cb80f24d85e84559fb11193846259f.

Fixed the typo in PPCInstrInfo.cpp.
2020-07-28 14:00:11 +00:00
Alina Sbirlea
f4701f9f4b [CFGDiff] Refactor Succ/Pred maps.
Summary:
Refactor Succ/Pred maps to have a single map lookup when constructing
children. The preivous desing made sense when used by GraphTraits.
This more closely matches the previous approach in DomTree.

Reviewers: dblaikie

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D84567
2020-07-27 18:02:52 -07:00
Jinsong Ji
89408b2ab3 Revert "[PowerPC] Remove QPX/A2Q BGQ/BGP CNK support"
This reverts commit adffce71538e219aab4eeb024819baa7687262ff.

This is breaking test-suite, revert while investigation.
2020-07-27 21:07:00 +00:00
Jinsong Ji
2d65e976a4 [PowerPC] Remove QPX/A2Q BGQ/BGP CNK support
Per RFC http://lists.llvm.org/pipermail/llvm-dev/2020-April/141295.html
no one is making use of QPX/A2Q/BGQ/BGP CNK anymore.

This patch remove the support of QPX/A2Q in llvm, BGQ/BGP in clang,
CNK support in openmp/polly.

Reviewed By: hfinkel

Differential Revision: https://reviews.llvm.org/D83915
2020-07-27 19:24:39 +00:00
Nathan James
8b5de07c6a [ADT] Add a range-based version of std::move
Adds a range-based version of `std::move`, the version that moves a range, not the one that creates r-value references.

Reviewed By: dblaikie, gamesh411

Differential Revision: https://reviews.llvm.org/D83902
2020-07-25 10:37:34 +01:00
Fangrui Song
b4f9e0d70d [ADT] Delete unused llvm::pointer_union_detail::AssignableFrom
Noticed by Zhiwei Chen
2020-07-22 09:24:36 -07:00
Nathan James
6fc76c37f5 [ADT] use is_base_of inplace of is_same for random_access_iterator_tag checks
Replace `std::is_same<X, std::random_access_iterator_tag>` with `std::is_base_of<std::random_access_iterator_tag, X>` in STLExtra algos.

This doesn't have too much impact on LLVM internally as no structs derive from it.
However external projects embedding LLVM may use `std::contiguous_iterator_tag` which should be considered by these algorithms.
As well as any other potential tags people want to define derived from `std::random_access_iterator_tag`

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D84141
2020-07-21 09:55:16 +01:00
Yuanfang Chen
8dacd8c600 [NFC] remove unused llvm::deleter 2020-07-20 10:43:29 -07:00
David Blaikie
8ab112dbf4 [llvm] Add contains(KeyType) -> bool methods to StringSet
Matches C++20 API addition.

Differential Revision: https://reviews.llvm.org/D83449
2020-07-17 11:26:27 -07:00
David Blaikie
479337797c [llvm] Add contains(KeyType) -> bool methods to SparseSet
Matches C++20 API addition.

Differential Revision: https://reviews.llvm.org/D83449
2020-07-17 11:26:27 -07:00
David Blaikie
294e3ec1ba [llvm] Add contains(KeyType) -> bool methods to SmallSet
Matches C++20 API addition.

Differential Revision: https://reviews.llvm.org/D83449
2020-07-17 11:26:27 -07:00
David Blaikie
fe6846924a [llvm] Add contains(KeyType) -> bool methods to SmallPtrSet
Matches C++20 API addition.

Differential Revision: https://reviews.llvm.org/D83449
2020-07-17 11:26:27 -07:00
David Blaikie
3cfbc95ca8 [llvm] Add contains(KeyType) -> bool methods to SetVector
Matches C++20 API addition.

Differential Revision: https://reviews.llvm.org/D83449
2020-07-17 11:26:27 -07:00
David Blaikie
f4752de569 [llvm] Add contains(KeyType) -> bool methods to DenseSet
Matches C++20 API addition.

Differential Revision: https://reviews.llvm.org/D83449
2020-07-17 11:26:26 -07:00
Michael Forster
070c7b821a Add hashing support for std::tuple
Summary:
All tuple values are passed directly to hash_combine. This is inspired by the implementation used for Swift:

4a1b4edbe1
845f3829b9

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D83887
2020-07-16 19:01:25 +02:00
Rahul Joshi
b39d7177a6 [NFC] Use appropriate names for for_each and transform template parameters
Differential Revision: https://reviews.llvm.org/D83848
2020-07-16 09:35:16 -07:00
Nikita Popov
addd3a654c [ADT] Specialize std::swap() for SetVector
This is intended to address a compile-time regression from
1eddce4177cfddc86d4696b758904443b0b4f193. A SmallPtrSet was
replaced with a SetVector there, which had an unexpected large
compile-time impact. It turns out that this structure is getting
swapped a lot, and previously this used an optimized std::swap()
specialization for SmallPtrSet. Now it ends up using the default,
triple-move based implementation, which is much more expensive.

This patch (partly) addresses the issue by specializing std::swap()
for SetVector.

Differential Revision: https://reviews.llvm.org/D82230
2020-07-13 23:14:04 +02:00
Pavel Labath
af4f8a5640 [ADT] Make Load(AP)IntFromMemory pointer argument const
The function does not modify this memory.
2020-07-13 17:32:54 +02:00
sstefan1
50ffa1ab38 Reland "[OpenMPOpt] ICV Tracking"
This reverts commit 1d542f0ca83fa1411d6501a8d088450d83abd5b8.

`recollectUses()` is added to prevent looking at dead uses after
Attributor run.

This is the first and most basic ICV Tracking implementation. For this
first version, we only support deduplication within the same BB.

Reviewers: jdoerfert, JonChesterfield, hamax97, jhuber6, uenoku,
baziotis, lebedev.ri

Differential Revision: https://reviews.llvm.org/D81788
2020-07-11 02:25:57 +02:00
David Blaikie
5518644f63 Remove unnecessary/erroneous "static" from function templates in headers
This risks ODR violations in inline functions that call these functions
(if they remain static) & otherwise just causes some object size
increase, potentially, by these functions not being deduplicated by the
linker.
2020-07-10 16:23:33 -07:00
Guillaume Chatelet
a3a41cd01b [Bitfields][NFC] Make sure bitfields are contiguous
Differential Revision: https://reviews.llvm.org/D83202
2020-07-07 14:35:13 +00:00
Bruno Ricci
127992925a [Support][NFC] Fix Wdocumentation warning in ADT/Bitfields.h
\tparam is used for template parameters instead of \param.
2020-07-06 22:41:40 +01:00
Guillaume Chatelet
6e9457fc4d Fix off by one error in Bitfields
Differential Revision: https://reviews.llvm.org/D83192
2020-07-06 08:47:58 +00:00
River Riddle
986143ca63 Add front/back accessors to indexed_accessor_range.
These map to the similar accessors on ArrayRef and other random access containers.

This fixes a compilation error on MLIR ODS for variadic operands/results, which relied on the availability of front in certain situations.
2020-06-29 22:41:15 -07:00
Sam McCall
8554b66076 [ADT] Use more explicit from to initialize member. Appease MSVC?
Or at least get a clearer error message:
http://lab.llvm.org:8011/builders/mlir-windows/builds/3958/steps/build-unified-tree/logs/stdio
2020-06-29 22:22:12 +02:00
Sam McCall
b7a1205c71 Reland [ADT] Support const-qualified unique_functions
This reverts commit 09b6dffb8ed19d624fddc7a57ce886f8be3c45b2.

Now compiles with GCC!
2020-06-29 21:40:16 +02:00
Alex Lorenz
7a66c0870c [darwin][driver] isMacosxVersionLT should check against the minimum supported OS version
This change ensures that the Darwin driver doesn't add unsupported libraries to the link
invocation when linking the Apple Silicon macOS slice.

rdar://61011136

Differential Revision: https://reviews.llvm.org/D82696
2020-06-29 12:21:54 -07:00
Nikita Popov
9640f394fa Revert "[ADT] Support const-qualified unique_functions"
This reverts commit 01bf8cdf5fa9bc71869e15e5e351b2b68c39feb6.

Breaks the build:

llvm/include/llvm/ADT/FunctionExtras.h:223:7: error: explicit template argument list not allowed
  223 |       Callbacks<CallableT, CalledAs, EnableIfTrivial<CallableT>>;
2020-06-29 20:28:10 +02:00
Sam McCall
8618b3d880 [ADT] Support const-qualified unique_functions
Summary:
This technique should extend to rvalue-qualified etc, but I didn't add any.
I removed "volatile" from the future plans, which seems... speculative at best.

While here I moved the callbacks object out of the constructor into a
variable template, which I believe addresses the fixme there about unused
objects.

(I'm not a template guru, so it's always possible the old version was designed
for compile-time performance in a way I'm missing)

Reviewers: kadircet

Subscribers: dexonsmith, llvm-commits, chandlerc

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D82581
2020-06-29 20:13:42 +02:00
Simon Pilgrim
4bf9737876 Fix MSVC truncation of constant value warning. 2020-06-29 16:03:00 +01:00
Guillaume Chatelet
e127592414 [NFC] Fix typos 2020-06-29 13:00:37 +00:00
Guillaume Chatelet
9871a892f8 [ADT] Add Bitfield utilities
Context:
--------
There are places in LLVM where we need to pack typed fields into opaque values.
For instance, the `XXXInst` classes in `llvm/include/llvm/IR/Instructions.h` that extract informations from `Value::SubclassData` via `getSubclassDataFromInstruction()`.
The bit twiddling is done manually: this impairs readability and prevent consistent handling of out of range values (e.g. 435b458ad0/llvm/include/llvm/IR/Instructions.h (L564))
More importantly, the bit pattern is scattered throughout the implementation making it hard to pack additionnal fields or check for overlapping bits.

Design decisions:
-----------------
The Bitfield structs are to be declared together so it is clear which bits are used or not.
The code is designed with simplicity in mind, hence a few limitations:
 - Storage is limited to a single integer,
 - Enum values have to be `unsigned`,
 - Storage type has to be `unsigned`,
 - There are no automatic detection of overlapping fields (packed bitfield declaration should help though),
 - The interface is C like so `storage` needs to be passed in everytime (code is simpler and lifetime considerations more obvious)

RFC: http://lists.llvm.org/pipermail/llvm-dev/2020-June/142196.html

Differential Revision: https://reviews.llvm.org/D81580
2020-06-29 12:48:44 +00:00
Simon Pilgrim
f5fa275b44 Revert rGf0bab7875e78e01c149d12302dcc4b6d4c43e25c - "Triple.h - reduce Twine.h include to forward declarations. NFC."
This causes ICEs on the clang-ppc64be buildbots and I've limited ability to triage the problem.
2020-06-26 14:46:40 +01:00
Simon Pilgrim
efd7ae7bbc Triple.h - reduce Twine.h include to forward declarations. NFC.
Move include down to a number of other files that had an implicit dependency on the Twine class.
2020-06-26 13:06:57 +01:00
Alex Lorenz
a32e5e9698 [Triple] support macOS 11 os version number
macOS goes to 11! This commit adds support for the new version number by ensuring
that existing version comparison routines, and the 'darwin' OS identifier
understands the new numbering scheme. It also adds a new utility method
'getCanonicalVersionForOS', which lets users translate some uses of
macOS 10.16 into macOS 11. This utility method will be used in upcoming
clang and swift commits.

Differential Revision: https://reviews.llvm.org/D82337
2020-06-22 23:03:47 -07:00
Rahul Joshi
099582bd9c - Add hasNItemsOrLess and container variants of hasNItems, hasNItemsOrMore, and hasNItemsOrLess
- Fixed a bug in hasNItems()
- Extend the STLExtras unit test to test hasSingleElement() and hasNItems() and friends.

Differential Revision: https://reviews.llvm.org/D82232
2020-06-22 15:07:36 -07:00
Daniel
ec554713c8 [clang-tidy] remove duplicate fixes of alias checkers
when both a check and its alias are enabled, we should only take the fixes of one of them and not both.
This patch fixes bug 45577
https://bugs.llvm.org/show_bug.cgi?id=45577

Reviewed By: aaron.ballman, njames93

Differential Revision: https://reviews.llvm.org/D80753
2020-06-19 20:40:59 +01:00
Thomas Preud'homme
b66c895a2d [ADT] Fix itostr handling of min int64_t value
Summary:
UBSan buildbot caught an undefined behavior in itostr with INT64_MIN.
The negation cannot be represented in the promoted operand (long long).
Negation is well defined on unsigned value though so this commit does
the negation after the static cast.

Reviewers: jhenderson, chandlerc, lattner

Reviewed By: lattner

Subscribers: dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D82200
2020-06-19 18:38:43 +01:00