platform/upstream/llvm.git
2 years ago[X86][FP16] Only generate approximate rsqrt when Reciprocal is true for half type
Phoebe Wang [Thu, 2 Dec 2021 05:11:07 +0000 (13:11 +0800)]
[X86][FP16] Only generate approximate rsqrt when Reciprocal is true for half type

We have reasonable fast sqrt and accurate rsqrt for half type due to the
limited fractions. So neither do we need multi steps refinement for
rsqrt nor replace sqrt by rsqrt.

Reviewed By: RKSimon

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

2 years ago[X86] Insert FMUL for estimated non reciprocal SQRT when `RefinementSteps` = 0
Phoebe Wang [Thu, 2 Dec 2021 05:10:57 +0000 (13:10 +0800)]
[X86] Insert FMUL for estimated non reciprocal SQRT when `RefinementSteps` = 0

Reviewed By: spatel

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

2 years ago[lldb] Skip test_launch_scripted_process_stack_frames with ASan
Jonas Devlieghere [Thu, 2 Dec 2021 05:33:40 +0000 (21:33 -0800)]
[lldb] Skip test_launch_scripted_process_stack_frames with ASan

This test is failing on the sanitized bot because of a
heap-use-after-free. Disabling the test to turn the bot
green again.

rdar://85954489.

2 years ago[ELF] Prevent internalizing used comdat symbol
Igor Kudrin [Thu, 2 Dec 2021 05:10:07 +0000 (12:10 +0700)]
[ELF] Prevent internalizing used comdat symbol

When a comdat symbol is defined in both bitcode and regular object
files, which are contained in the same archive, the linker could lose
the flag that the symbol is used in the regular object file and allow
LTO to internalize it, which led to "error: undefined symbol".

The issue was introduced in D79300.

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

2 years ago[mlir][drr] Simple heuristic to reduce chance of accidental nullptr dereference
Jacques Pienaar [Thu, 2 Dec 2021 04:45:08 +0000 (20:45 -0800)]
[mlir][drr] Simple heuristic to reduce chance of accidental nullptr dereference

When an attribute is optional & is given an additional constraint in
rewrite pattern that could lead to dereferencing null Attribute. Avoid
cases where the constraints checks attribute but has no check if null.

This should be improved to be more uniformly guarded.

2 years ago[AMDGPU] Add a regclass flag for scalar registers
Christudasan Devadasan [Sat, 18 Sep 2021 06:46:02 +0000 (02:46 -0400)]
[AMDGPU] Add a regclass flag for scalar registers

Along with vector RC flags, this scalar flag will
make various regclass queries like `isVGPR` more
accurate.

Regclasses other than vectors are currently set
with the new flag even though certain unallocatable
classes aren't truly scalars. It would be ok as long
as they remain unallocatable.

Reviewed By: rampitec

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

2 years ago[libc++] Implement P1989R2: range constructor for string_view
Joe Loser [Wed, 3 Nov 2021 22:45:04 +0000 (18:45 -0400)]
[libc++] Implement P1989R2: range constructor for string_view

Implement P1989R2 which adds a range constructor for `string_view`.

Adjust `operator/=` in `path` to avoid atomic constraints caching issue
getting provoked from this PR.

Add defaulted template argument to `string_view`'s "sufficient
overloads" to avoid mangling issues in `clang-cl` builds. It is a
MSVC mangling bug that this works around.

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

2 years ago[NFC][sanitizer] Fix "not used" warning in test
Vitaly Buka [Thu, 2 Dec 2021 04:06:31 +0000 (20:06 -0800)]
[NFC][sanitizer] Fix "not used" warning in test

2 years ago[lldb] Fix DYLD_INSERT_LIBRARIES on AS
Jonas Devlieghere [Thu, 2 Dec 2021 04:01:45 +0000 (20:01 -0800)]
[lldb] Fix DYLD_INSERT_LIBRARIES on AS

Don't make DYLD_INSERT_LIBRARIES conditional on the host triple
containing x86.

2 years ago[tests] Precommit tests for writeonly argument attribute inference
Philip Reames [Thu, 2 Dec 2021 03:48:21 +0000 (19:48 -0800)]
[tests] Precommit tests for writeonly argument attribute inference

2 years ago[mlir][linalg][bufferize] Bufferization of tensor.insert
Matthias Springer [Thu, 2 Dec 2021 02:57:26 +0000 (11:57 +0900)]
[mlir][linalg][bufferize] Bufferization of tensor.insert

This is a lightweight operation, useful for writing unit tests. It will be utilized for testing in subsequent commits.

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

2 years agoRevert "[VE] Make VE official"
Kevin Athey [Thu, 2 Dec 2021 00:13:22 +0000 (16:13 -0800)]
Revert "[VE] Make VE official"

Breaks fast buildbot.

This reverts commit a9d1d00b865ab6f6e75dcd649362a7c5cf01d168.

2 years ago[unroll] Fix a functional change in an NFC patch
Daniel Sanders [Thu, 2 Dec 2021 00:15:53 +0000 (16:15 -0800)]
[unroll] Fix a functional change in an NFC patch

5c77aa2b917c [unroll] Use early return in shouldFullUnroll [nfc]
wasn't quite NFC since !(x <= y) is x > y rather than x >= y

Credit to Justin Bogner for spotting the bug

Reviewed By: reames

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

2 years agoRevert "[sanitizer] Add compress_stack_depot flag"
Steven Wan [Thu, 2 Dec 2021 01:20:09 +0000 (20:20 -0500)]
Revert "[sanitizer] Add compress_stack_depot flag"

This is failing on clang-s390x-linux,
https://lab.llvm.org/buildbot/#/builders/94/builds/6748.
This reverts commit bf18253b0ee543f98119e5ab6a5b57d05c24d314.

2 years ago[TSan][Darwin] Prevent inlining of functions in tests
Julian Lettner [Thu, 2 Dec 2021 00:58:36 +0000 (16:58 -0800)]
[TSan][Darwin] Prevent inlining of functions in tests

Prevent inlining of functions so we can FileCheck the generated stack
traces.

2 years ago[lldb] Split TestCxxChar8_t
Jonas Devlieghere [Thu, 2 Dec 2021 00:58:13 +0000 (16:58 -0800)]
[lldb] Split TestCxxChar8_t

Split TestCxxChar8_t into two parts: one that check reading variables
without a process and another part with. This allows us to skip the
former on Apple Silicon, where lack of support for chained fix-ups
causes the test to fail.

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

2 years ago[clang-tidy] Use `hasCanonicalType()` matcher in `bugprone-unused-raii` check
Fabian Wolff [Thu, 2 Dec 2021 00:34:31 +0000 (01:34 +0100)]
[clang-tidy] Use `hasCanonicalType()` matcher in `bugprone-unused-raii` check

Fixes PR#52217.

Reviewed By: simon.giesecke

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

2 years ago[gn build] Port 170783f991fa
LLVM GN Syncbot [Thu, 2 Dec 2021 00:48:10 +0000 (00:48 +0000)]
[gn build] Port 170783f991fa

2 years ago[llvm] [Support] Add HTTP Client Support library.
Noah Shutty [Wed, 1 Dec 2021 23:46:57 +0000 (23:46 +0000)]
[llvm] [Support] Add HTTP Client Support library.

This patch implements a small HTTP client library consisting primarily of the `HTTPRequest`, `HTTPResponseHandler`, and `BufferedHTTPResponseHandler` classes. Unit tests of the `HTTPResponseHandler` and `BufferedHTTPResponseHandler` are included.

Reviewed By: dblaikie

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

2 years ago[TSan][Darwin] Mark test unsupported
Julian Lettner [Wed, 1 Dec 2021 23:49:40 +0000 (15:49 -0800)]
[TSan][Darwin] Mark test unsupported

2 years ago[llvm-reduce] Assert that the number of chunks does not change with reductions
Arthur Eubanks [Sat, 13 Nov 2021 00:05:31 +0000 (16:05 -0800)]
[llvm-reduce] Assert that the number of chunks does not change with reductions

Followup to D113537.

Reviewed By: Meinersbur

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

2 years ago[Cloning] Clone metadata on function declarations
Arthur Eubanks [Fri, 12 Nov 2021 23:48:31 +0000 (15:48 -0800)]
[Cloning] Clone metadata on function declarations

Previously we missed cloning metadata on function declarations because
we don't call CloneFunctionInto() on declarations in CloneModule().

Reviewed By: dexonsmith

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

2 years ago[gn build] Port 7cc2493daaf5
LLVM GN Syncbot [Wed, 1 Dec 2021 23:31:02 +0000 (23:31 +0000)]
[gn build] Port 7cc2493daaf5

2 years agoprofi - a flow-based profile inference algorithm: Part I (out of 3)
spupyrev [Wed, 1 Dec 2021 23:29:35 +0000 (15:29 -0800)]
profi - a flow-based profile inference algorithm: Part I (out of 3)

The benefits of sampling-based PGO crucially depends on the quality of profile
data. This diff implements a flow-based algorithm, called profi, that helps to
overcome the inaccuracies in a profile after it is collected.

Profi is an extended and significantly re-engineered classic MCMF (min-cost
max-flow) approach suggested by Levin, Newman, and Haber [2008, Complementing
missing and inaccurate profiling using a minimum cost circulation algorithm]. It
models profile inference as an optimization problem on a control-flow graph with
the objectives and constraints capturing the desired properties of profile data.
Three important challenges that are being solved by profi:
- "fixing" errors in profiles caused by sampling;
- converting basic block counts to edge frequencies (branch probabilities);
- dealing with "dangling" blocks having no samples in the profile.

The main implementation (and required docs) are in SampleProfileInference.cpp.
The worst-time complexity is quadratic in the number of blocks in a function,
O(|V|^2). However a careful engineering and extensive evaluation shows that
the running time is (slightly) super-linear. In particular, instances with
1000 blocks are solved within 0.1 second.

The algorithm has been extensively tested internally on prod workloads,
significantly improving the quality of generated profile data and providing
speedups in the range from 0% to 5%. For "smaller" benchmarks (SPEC06/17), it
generally improves the performance (with a few outliers) but extra work in
the compiler might be needed to re-tune existing optimization passes relying on
profile counts.

UPD Dec 1st 2021:
- synced the declaration and definition of the option `SampleProfileUseProfi ` to use type `cl::opt<bool`;
- added `inline` for `SampleProfileInference<BT>::findUnlikelyJumps` and `SampleProfileInference<BT>::isExit` to avoid linking problems on windows.

Reviewed By: wenlei, hoy

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

2 years ago[libcxx][test][NFC] Various tests for std::vector
Konstantin Boyarinov [Wed, 1 Dec 2021 23:04:17 +0000 (02:04 +0300)]
[libcxx][test][NFC] Various tests for std::vector

Add missing tests for std::vector funcionality to improve code coverage:

  - Rewrote access tests to check modification of the container using
    the reference returned by the non-const overload
  - Added tests for reverse iterators: rbegin, rend, etc.
  - Added exception test for vector::reserve
  - Extended test cases for vector copy assignment
  - Fixed insert_iter_value.pass.cpp to use insert overload with const
    value_type& (not with value_type&& which is tested in
    iter_rvalue.pass.cpp test)

Reviewed By: Quuxplusone, rarutyun, #libc

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

2 years ago[sanitizer] Implement MprotectReadOnly and MprotectNoAccess
Vitaly Buka [Wed, 1 Dec 2021 22:49:14 +0000 (14:49 -0800)]
[sanitizer] Implement MprotectReadOnly and MprotectNoAccess

MprotectReadOnly for Win and Fuchsia
MprotectNoAccess for Fuchsia

2 years ago[libc++] Make __wrap_iter constexpr
Nikolas Klauser [Tue, 30 Nov 2021 11:02:04 +0000 (12:02 +0100)]
[libc++] Make __wrap_iter constexpr

`__wrap_iter` is currently only constexpr if it's not a debug built, but it isn't used in a constexpr context currently. Making it always constexpr and disabling the debugging utilities at constant evaluation is more usful since it has to be always constexpr to be used in a constexpr context.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[NFC][sanitizer] constexpr in sanitizer_dense_map_info
Vitaly Buka [Wed, 1 Dec 2021 20:35:29 +0000 (12:35 -0800)]
[NFC][sanitizer] constexpr in sanitizer_dense_map_info

2 years ago[mlir] Remove extractVectorTypeFromShapedValue
Kazu Hirata [Wed, 1 Dec 2021 21:43:17 +0000 (13:43 -0800)]
[mlir] Remove extractVectorTypeFromShapedValue

This patch fixes the build by removing
extractVectorTypeFromShapedValue.  The last use was removed Dec 1,
2021 in commit extractVectorTypeFromShapedValue.

2 years ago[flang] Don't close stderr in runtime (fixes STOP output)
Peter Klausler [Wed, 1 Dec 2021 00:21:11 +0000 (16:21 -0800)]
[flang] Don't close stderr in runtime (fixes STOP output)

STOP statement output was sometimes failing to appear because
the runtime flushes and shuts down open Fortran units beforehand.
But when file descriptor 2 was closed, the STOP statement output
was suppressed.  The fix is to not actually close file descriptors
0-2 if they are connected to Fortran units being closed.  This was
already the policy when an OPEN statement was (re-)opening such a
unit, so that logic has been pulled out into a member function and
shared with CLOSE processing.

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

2 years ago[Analyzer][solver] Simplification: Do a fixpoint iteration before the eq class merge
Gabor Marton [Wed, 1 Dec 2021 15:47:22 +0000 (16:47 +0100)]
[Analyzer][solver] Simplification: Do a fixpoint iteration before the eq class merge

This reverts commit f02c5f3478318075d1a469203900e452ba651421 and
addresses the issue mentioned in D114619 differently.

Repeating the issue here:
Currently, during symbol simplification we remove the original member
symbol from the equivalence class (`ClassMembers` trait). However, we
keep the reverse link (`ClassMap` trait), in order to be able the query
the related constraints even for the old member. This asymmetry can lead
to a problem when we merge equivalence classes:
```
ClassA: [a, b]   // ClassMembers trait,
a->a, b->a       // ClassMap trait, a is the representative symbol
```
Now let,s delete `a`:
```
ClassA: [b]
a->a, b->a
```
Let's merge ClassA into the trivial class `c`:
```
ClassA: [c, b]
c->c, b->c, a->a
```
Now, after the merge operation, `c` and `a` are actually in different
equivalence classes, which is inconsistent.

This issue manifests in a test case (added in D103317):
```
void recurring_symbol(int b) {
  if (b * b != b)
    if ((b * b) * b * b != (b * b) * b)
      if (b * b == 1)
}
```
Before the simplification we have these equivalence classes:
```
trivial EQ1: [b * b != b]
trivial EQ2: [(b * b) * b * b != (b * b) * b]
```

During the simplification with `b * b == 1`, EQ1 is merged with `1 != b`
`EQ1: [b * b != b, 1 != b]` and we remove the complex symbol, so
`EQ1: [1 != b]`
Then we start to simplify the only symbol in EQ2:
`(b * b) * b * b != (b * b) * b --> 1 * b * b != 1 * b --> b * b != b`
But `b * b != b` is such a symbol that had been removed previously from
EQ1, thus we reach the above mentioned inconsistency.

This patch addresses the issue by making it impossible to synthesise a
symbol that had been simplified before. We achieve this by simplifying
the given symbol to the absolute simplest form.

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

2 years ago[TLI] Add memset_pattern4, memset_pattern8 lib functions.
Florian Hahn [Wed, 1 Dec 2021 21:18:19 +0000 (21:18 +0000)]
[TLI] Add memset_pattern4, memset_pattern8 lib functions.

Similar to memset_pattern16, memset_pattern4, memset_pattern8 are
available on Darwin platforms.

https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/memset_pattern4.3.html

Reviewed By: ab

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

2 years ago[gn build] Port a0efb1750065
LLVM GN Syncbot [Wed, 1 Dec 2021 20:41:34 +0000 (20:41 +0000)]
[gn build] Port a0efb1750065

2 years ago[libcxx][modularisation] modularises <numeric> header
Christopher Di Bella [Wed, 1 Dec 2021 01:36:32 +0000 (01:36 +0000)]
[libcxx][modularisation] modularises <numeric> header

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

2 years agoAMDGPU/GlobalISel: Fix constant bus restriction errors for med3
Petar Avramovic [Wed, 1 Dec 2021 16:39:39 +0000 (17:39 +0100)]
AMDGPU/GlobalISel: Fix constant bus restriction errors for med3

Detected on targets older then gfx10 (e.g. gfx9) for constants that are
too large to be inlined (constant are sgpr by default).
In med3 combine it is expected that regbankselect maps all operands of
min/max we try to match to vgpr. However constants are mapped to sgpr
and there will be a sgpr-to-vgpr copy. Matchers look through sgpr-to-vgpr
copies and return sgpr and these break constant bus restriction.
Build med3 with all vgpr operands. Use existing sgpr-to-vgpr copies for
matched sgprs. If there is no such copy (not expected) build one.

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

2 years ago[TLI checker] Update for post-commit review comments
Paul Robinson [Tue, 23 Nov 2021 18:24:29 +0000 (10:24 -0800)]
[TLI checker] Update for post-commit review comments

Ignore undefined symbols; other minor code cleanup.
Replace test objects and their asm source with a yaml equivalent.

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

2 years ago[DSE] Add libcall tests for functions only available on Darwin.
Florian Hahn [Wed, 1 Dec 2021 20:30:15 +0000 (20:30 +0000)]
[DSE] Add libcall tests for functions only available on Darwin.

Add a set of tests for memset_pattern{4,8,16} variants.

2 years agoFix false positives in `fuchsia-trailing-return` check involving deduction guides
Fabian Wolff [Wed, 1 Dec 2021 20:28:01 +0000 (15:28 -0500)]
Fix false positives in `fuchsia-trailing-return` check involving deduction guides

Fixes PR#47614. Deduction guides, implicit or user-defined, look like
function declarations in the AST. They aren't really functions, though,
and they always have a trailing return type, so it doesn't make sense
to issue this warning for them.

2 years ago[GlobalOpt] Simplify CleanupConstantGlobalUsers()
Nikita Popov [Sat, 23 Oct 2021 15:23:56 +0000 (17:23 +0200)]
[GlobalOpt] Simplify CleanupConstantGlobalUsers()

This bases the CleanupConstantGlobalUsers() implementation around
the ConstantFoldLoadFromConst() API. The general approach is that
we discover all users while looking through casts, and then
constant fold loads and drop stores and memintrinsics.

This avoids special cases and limitations in the previous
implementation, which is also incompatible with opaque pointers.
The result is a bit more powerful than before, because we now use
more general load folding logic which can for example look through
pointer bitcasts between different sizes. This is where the test
changes come from, as we now fold more loads and can thus remove
more globals.

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

2 years ago[libc++] [test] Refactor string_view comparison tests for comprehensiveness.
Arthur O'Dwyer [Fri, 26 Nov 2021 19:24:36 +0000 (14:24 -0500)]
[libc++] [test] Refactor string_view comparison tests for comprehensiveness.

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

2 years ago[libc++] [test] C++14/17-friendly `TEST_IS_CONSTANT_EVALUATED` macro.
Arthur O'Dwyer [Mon, 29 Nov 2021 19:56:00 +0000 (14:56 -0500)]
[libc++] [test] C++14/17-friendly `TEST_IS_CONSTANT_EVALUATED` macro.

Reviewed as part of D114658.
Ultimately this will probably have to be flipped around and renamed
`TEST_IS_RUNTIME`, and extended with `TEST_IS_RUNTIME_OR_CXX20` (once
constexpr std::string support is added) and so on for every new C++
version. But we don't need that flexibility yet, so we're not adding it.

2 years ago[libc++] [test] C++03-friendly MAKE_STRING macro.
Arthur O'Dwyer [Fri, 26 Nov 2021 20:17:21 +0000 (15:17 -0500)]
[libc++] [test] C++03-friendly MAKE_STRING macro.

Reviewed as part of D114658.

2 years ago[libcxx][NFC] Make sequence containers slightly more SFINAE-friendly during CTAD.
Konstantin Varlamov [Wed, 1 Dec 2021 19:55:46 +0000 (11:55 -0800)]
[libcxx][NFC] Make sequence containers slightly more SFINAE-friendly during CTAD.

Disable the constructors taking `(size_type, const value_type&,
allocator_type)` if `allocator_type` is not a valid allocator.
Otherwise, these constructors are considered when resolving e.g.
`(int*, int*, NotAnAllocator())`, leading to a hard error during
instantiation. A hard error makes the Standard's requirement to not
consider deduction guides of the form `(Iterator, Iterator,
BadAllocator)` during overload resolution essentially non-functional.

The previous approach was to SFINAE away `allocator_traits`. This patch
SFINAEs away the specific constructors instead, for consistency with
`basic_string` -- see [LWG3076](wg21.link/lwg3076) which describes
a very similar problem for strings (note, however, that unlike LWG3076,
no valid constructor call is affected by the bad instantiation).

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

2 years ago[InstrProf][NFC] Refactor ProfileDataMap usage
Ellis Hoag [Wed, 1 Dec 2021 19:46:18 +0000 (11:46 -0800)]
[InstrProf][NFC] Refactor ProfileDataMap usage

Instead of using `DenseMap::find()` and `DenseMap::insert()`, use
`DenseMap::operator[]` to get a reference to the profile data and update
the reference. This simplifies the changes in D114565.

Reviewed By: kyulee

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

2 years ago[RISCV] Add inline expansion for vector ftrunc/fceil/ffloor.
Craig Topper [Wed, 1 Dec 2021 18:46:30 +0000 (10:46 -0800)]
[RISCV] Add inline expansion for vector ftrunc/fceil/ffloor.

This prevents scalarization of fixed vector operations or crashes
on scalable vectors.

We don't have direct support for these operations. To emulate
ftrunc we can convert to the same sized integer and back to fp using
round to zero. We don't need to do a convert if the value is large
enough to have no fractional bits or is a nan.

The ceil and floor lowering would be better if we changed FRM, but
we don't model FRM correctly yet. So I've used the trunc lowering
with a conditional add or subtract with 1.0 if the truncate rounded
in the wrong direction.

There are also missed opportunities to use masked instructions.

Reviewed By: frasercrmck

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

2 years ago[flang] Adjust names in Semantics that imply too much (NFC)
Peter Klausler [Fri, 26 Nov 2021 21:26:50 +0000 (13:26 -0800)]
[flang] Adjust names in Semantics that imply too much (NFC)

Some kinds of Fortran arrays are declared with the same syntax,
and it is impossible to tell from a shape (:, :) or (*) whether
the object is assumed shape, deferred shape, assumed size, implied
shape, or whatever without recourse to more information about the
symbol in question.  This patch softens the names of some predicate
functions (IsAssumedShape to CanBeAssumedShape) and makes others
more reflective of the syntax they represent (isAssumed to isStar)
in an attempt to encourage coders to seek and find definitive
predicate functions whose names deliver what they seem to mean.

Address TODO comments in IsSimplyContiguous() by using the
updated IsAssumedShape() predicate.

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

2 years agoRevert "[sanitizer] Add delta compression stack depot"
Hans Wennborg [Wed, 1 Dec 2021 19:02:51 +0000 (20:02 +0100)]
Revert "[sanitizer] Add delta compression stack depot"

Broke the build on Windows, where MprotectReadOnly() isn't defined, see comment
on the code review.

> Compress by factor 4x, takes about 10ms per 8 MiB block.
>
> Depends on D114498.
>
> Reviewed By: morehouse
>
> Differential Revision: https://reviews.llvm.org/D114503

This reverts commit 1d8f2957591cad2e82d99e2e04830e0faf87707e.

2 years ago[mlir][ods][nfc] fixing test cases
Mogball [Wed, 1 Dec 2021 18:40:36 +0000 (18:40 +0000)]
[mlir][ods][nfc] fixing test cases

2 years ago[Clang] Remove bogus "REQUIRES arm-registered-target" from SVE ACLE tests.
Paul Walker [Wed, 1 Dec 2021 18:06:11 +0000 (18:06 +0000)]
[Clang] Remove bogus "REQUIRES arm-registered-target" from SVE ACLE tests.

Many of the SVE ACLE tests have gained entries as follows:

  REQUIRES: aarch64-registered-target || arm-registered-target

which can cause test failures when only arm-registered-target is
available because only aarch64-registered-target supports SVE.

2 years agoDisable issues / pull requests via templates in preparation with migration
Anton Korobeynikov [Wed, 1 Dec 2021 18:43:22 +0000 (21:43 +0300)]
Disable issues / pull requests via templates in preparation with migration

2 years ago[Support] replace check with assert in known bits of mul calculation; NFC
Sanjay Patel [Wed, 1 Dec 2021 18:39:48 +0000 (13:39 -0500)]
[Support] replace check with assert in known bits of mul calculation; NFC

2 years agoRevert "[lldb] Temporarily skip TestTsanBasic on Darwin"
Jonas Devlieghere [Wed, 1 Dec 2021 18:39:28 +0000 (10:39 -0800)]
Revert "[lldb] Temporarily skip TestTsanBasic on Darwin"

This reverts commit 92a8dc0735cfb3f296f0c487b20d8fa8474e3e40 because
66d4ce7e26a5ab00f7e4946b6e1bac8f805010fa was reverted in 09859113ed23.

2 years ago[NFC][Clang] Fix some comments in clang
Zarko Todorovski [Tue, 30 Nov 2021 18:39:56 +0000 (13:39 -0500)]
[NFC][Clang] Fix some comments in clang

Applying post commit comment suggestions from https://reviews.llvm.org/D114025

2 years ago[mlir][ods][nfc] fix gcc-5 build
Mogball [Wed, 1 Dec 2021 18:12:37 +0000 (18:12 +0000)]
[mlir][ods][nfc] fix gcc-5 build

2 years ago[VE][NFC] Fix use-after-free in VEInstrInfo
Simon Moll [Wed, 1 Dec 2021 17:55:28 +0000 (18:55 +0100)]
[VE][NFC] Fix use-after-free in VEInstrInfo

First call getOperand, then erase the MachineInstr. Not the other way
round.

Expected to fix test/CodeGen/VE/VELIntrinsics/lvm.ll

Detected by asan buildbot:

  sanitizer-x86_64-linux-fast
  (https://lab.llvm.org/buildbot/#/builders/5/builds/15384)

2 years ago[ASan] Fixed include order.
Kirill Stoimenov [Wed, 1 Dec 2021 01:27:22 +0000 (01:27 +0000)]
[ASan] Fixed include order.

Reviewed By: morehouse

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

2 years ago[Clang] Fix nesting of discarded and immediate contexts.
Corentin Jabot [Wed, 1 Dec 2021 17:57:39 +0000 (12:57 -0500)]
[Clang] Fix nesting of discarded and immediate contexts.

In C++23, discarded statements and if consteval statements can nest
arbitrarily. To support that, we keep track of whether the parent of
the current evaluation context is discarded or immediate.

This is done at the construction of an evaluation context
to improve performance.

Fixes https://bugs.llvm.org/show_bug.cgi?id=52231

2 years ago[runtimes] Move WARNING to FATAL_ERROR for folks using FOO_BUILD_32_BITS
Louis Dionne [Wed, 1 Dec 2021 17:57:30 +0000 (12:57 -0500)]
[runtimes] Move WARNING to FATAL_ERROR for folks using FOO_BUILD_32_BITS

2 years ago[runtimes] Remove support for GCC-style 32 bit multilib builds
Louis Dionne [Tue, 23 Nov 2021 21:34:09 +0000 (16:34 -0500)]
[runtimes] Remove support for GCC-style 32 bit multilib builds

This patch removes the ability to build the runtimes in the 32 bit
multilib configuration, i.e. using -m32. Instead of doing this, one
should cross-compile the runtimes for the appropriate target triple,
like we do for all other triples.

As it stands, -m32 has several issues, which all seem to be related to
the fact that it's not well supported by the operating systems that
libc++ support. The simplest path towards fixing this is to remove
support for the configuration, which is also the best course of action
if there is little interest for keeping that configuration. If there
is a desire to keep this configuration around, we'll need to do some
work to figure out the underlying issues and fix them.

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

2 years ago[AArch64] Fix unused variable warning with NDEBUG, NFC
Reid Kleckner [Wed, 1 Dec 2021 17:27:44 +0000 (09:27 -0800)]
[AArch64] Fix unused variable warning with NDEBUG, NFC

2 years ago[Clang][VE] Fix toolchain test when -DCLANG_DEFAULT_LINKER=lld in use
Simon Moll [Wed, 1 Dec 2021 17:03:14 +0000 (18:03 +0100)]
[Clang][VE] Fix toolchain test when -DCLANG_DEFAULT_LINKER=lld in use

The CLANG_DEFAULT_LINKER flag overrides the default toolchain linker.
VE strictly requires 'nld' to be the default linker.  This causes a test
failure in test/Driver/ve-toolchain.cpp when configured with
CLANG_DEFAULT_LINKER!=ld

  Failure in clang-ppc64le-rhel
  (https://lab.llvm.org/buildbot/#/builders/57/builds/12628)

Until default linker selection with CLANG_DEFAULT_LINKER!=ld is fixed
proper, we manually specify '-fuse-ld=ld' (ie the toolchain default
linker) in the ve-toolchain tests.

2 years ago[SelectionDAG] Add pattern to haveNoCommonBitsSet
Omer Aviram [Wed, 1 Dec 2021 17:03:22 +0000 (12:03 -0500)]
[SelectionDAG] Add pattern to haveNoCommonBitsSet

Correctly identify the following pattern, which has no common bits: (X & ~M) op (Y & M).

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

2 years agoRevert "tsan: new runtime (v3)"
Dmitry Vyukov [Wed, 1 Dec 2021 16:55:14 +0000 (17:55 +0100)]
Revert "tsan: new runtime (v3)"

This reverts commit 66d4ce7e26a5ab00f7e4946b6e1bac8f805010fa.

Chromium tests started failing:
https://bugs.chromium.org/p/chromium/issues/detail?id=1275581

2 years ago[mlir][ods] AttrOrTypeGen uses Class
Mogball [Tue, 30 Nov 2021 14:09:00 +0000 (14:09 +0000)]
[mlir][ods] AttrOrTypeGen uses Class

AttrOrType def generator uses `Class` code gen helper,
instead of naked raw_ostream.

Depends on D113714 and D114807

Reviewed By: rriddle

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

2 years ago[llvm][stlextras] Add const methods to concat_range and enumerator
Mogball [Tue, 30 Nov 2021 14:08:40 +0000 (14:08 +0000)]
[llvm][stlextras] Add const methods to concat_range and enumerator

Reviewed By: jpienaar

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

2 years ago[libc++][format][1/6] Reduce binary size.
Mark de Wever [Sat, 4 Sep 2021 11:26:58 +0000 (13:26 +0200)]
[libc++][format][1/6] Reduce binary size.

This removes the `format_args_t` from `<format>` and adjusts the type of
the `format_args` for the `vformat_to` overloads.

The `format_context` uses a `back_insert_iterator<string>` therefore the
new `output_iterator` function uses a `string` as its temporary storage
buffer. This isn't ideal. The next patches in this series will improve
this. These improvements make it easy to also improve `format_to_n` and
`formatted_size`.

This addresses P2216 `6. Binary size`.
P2216 `5. Compile-time checks` are not part of this change.

Implements parts of:
- P2216 std::format improvements

Depends on D103670

Reviewed By: ldionne, #libc

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

2 years ago[mlir][Vector] Thread 0-d vectors through vector.transfer ops
Nicolas Vasilache [Wed, 1 Dec 2021 15:48:17 +0000 (15:48 +0000)]
[mlir][Vector] Thread 0-d vectors through vector.transfer ops

This revision adds 0-d vector support to vector.transfer ops.
In the process, numerous cleanups are applied, in particular around normalizing
and reducing the number of builders.

Reviewed By: ThomasRaoux, springerm

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

2 years ago[OpenMP][FIX] SPMDzation guarding needs to account for all reaching kernels
Joseph Huber [Wed, 1 Dec 2021 14:53:41 +0000 (09:53 -0500)]
[OpenMP][FIX] SPMDzation guarding needs to account for all reaching kernels

If two reaching kernels disagree on the execution mode we cannot guard a
function right now. Ensure we do not as we otherwise will cause a
deadlock.

Reviewed By: JonChesterfield

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

2 years ago[X86] combinePMULH - recognise 'cheap' trunctions via PACKS/PACKUS as well as SEXT...
Simon Pilgrim [Wed, 1 Dec 2021 16:37:39 +0000 (16:37 +0000)]
[X86] combinePMULH - recognise 'cheap' trunctions via PACKS/PACKUS as well as SEXT/ZEXT

combinePMULH currently only truncates vXi32/vXi64 multiplies to PMULHW/PMULUW if the source operands are SEXT/ZEXT instructions for a 'free' truncation.

But we can generalize this to any source operand with sufficient leading sign/zero bits that would allow PACKS/PACKUS to be used as a 'cheap' truncation.

This helps us avoid the wider multiplies, in exchange for truncation on both source operands instead of the result.

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

2 years ago[VE] Remove switch with only default case statement to fix MSVC warning. NFC.
Simon Pilgrim [Wed, 1 Dec 2021 14:36:06 +0000 (14:36 +0000)]
[VE] Remove switch with only default case statement to fix MSVC warning. NFC.

2 years ago[VE][NFC] Use POSIX-compatible stream redirection
Simon Moll [Wed, 1 Dec 2021 16:25:29 +0000 (17:25 +0100)]
[VE][NFC] Use POSIX-compatible stream redirection

Drop Bash-style stream redirect in favor of POSIX stream redirection to
fix spurious test failures on Windows.

Failure:
https://lab.llvm.org/buildbot/#/builders/123/builds/7509/steps/8/logs/stdio

2 years ago[SLP]Improve cost model for the shuffled extracts.
Alexey Bataev [Fri, 12 Nov 2021 17:09:15 +0000 (09:09 -0800)]
[SLP]Improve cost model for the shuffled extracts.

Improved the calculation of the shuffled extracts, where possible. Need
to calculate the cost for the extracted scalars if some users are not
insertelements + improved the total estimation of the shuffled scalars
used in insertelements build vectors.

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

2 years ago[libc++] Fix `uniform_int_distribution` for 128-bit result type
Fabian Wolff [Wed, 1 Dec 2021 16:01:06 +0000 (11:01 -0500)]
[libc++] Fix `uniform_int_distribution` for 128-bit result type

Fixes https://llvm.org/PR51520. The problem is that `uniform_int_distribution`
currently uses an unsigned integer with at most 64 bits internally, which
is then casted to the desired result type. If the result type is `int64_t`,
this will produce a negative number if the most significant bit is set,
but if the result type is `__int128_t`, the value remains non-negative
and will be out of bounds for the example in PR#51520. (The reason why
it also seems to work if the upper or lower bound is changed is
because the branch at [1] will then no longer be taken, and proper
rejection sampling takes place.)

The bigger issue here is probably that `uniform_int_distribution` can be
instantiated with `__int128_t` but will silently produce incorrect results
(only the lowest 64 bits can ever be set). libstdc++ also supports `__int128_t`
as a result type, so I have simply extended the maximum width of the
internal intermediate result type.

[1]: https://github.com/llvm/llvm-project/blob/6d28dffb6/libcxx/include/__random/uniform_int_distribution.h#L266-L267

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

2 years ago[PowerPC][AIX] Add toc-data support for 64-bit AIX small code model.
Yousuf Ali [Tue, 30 Nov 2021 18:43:14 +0000 (13:43 -0500)]
[PowerPC][AIX] Add toc-data support for 64-bit AIX small code model.

The patch expands the existing 32-bit toc-data attribute support to 64-bit.
In both 32-bit and 64-bit it is supported for small code model only.

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

2 years ago[SLP]Introduce isUndefVector function to check for undef vectors.
Alexey Bataev [Wed, 1 Dec 2021 12:58:18 +0000 (04:58 -0800)]
[SLP]Introduce isUndefVector function to check for undef vectors.

Undefined vector might be not only the UndefValue, but also it can be
a constant vector with undef ot poison elements, need to check for this
kind of undef too.

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

2 years ago[AArch64][SVE] Duplicate FP_EXTEND/FP_TRUNC -> LOAD/STORE dag combines
Bradley Smith [Fri, 26 Nov 2021 12:01:22 +0000 (12:01 +0000)]
[AArch64][SVE] Duplicate FP_EXTEND/FP_TRUNC -> LOAD/STORE dag combines

By duplicating these dag combines we can bypass the legality checks that
they do, this allows us to perform these combines on larger than legal
fixed types, which in turn allows us to bring the same benefits D114580
brought but to larger than legal fixed types.

Depends on D114580

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

2 years ago[SLP]Improve vectorization of cmp instructions sequences.
Alexey Bataev [Tue, 16 Nov 2021 19:05:19 +0000 (11:05 -0800)]
[SLP]Improve vectorization of cmp instructions sequences.

Final attempt to vectorize bundles of comptatible cmp instructions after
all other instructions processing.

Metric: SLP.NumVectorInstructions

Program                                                                             results results0 diff
        test-suite :: MultiSource/Benchmarks/mediabench/g721/g721encode/encode.test    1.00    5.00  400.0%
                              test-suite :: MultiSource/Benchmarks/PAQ8p/paq8p.test    8.00   11.00   37.5%
                    test-suite :: MultiSource/Benchmarks/Olden/voronoi/voronoi.test   20.00   26.00   30.0%
                test-suite :: External/SPEC/CINT2017rate/525.x264_r/525.x264_r.test 1344.00 1648.00   22.6%
               test-suite :: External/SPEC/CINT2017speed/625.x264_s/625.x264_s.test 1344.00 1648.00   22.6%
                              test-suite :: MultiSource/Benchmarks/Olden/bh/bh.test  102.00  124.00   21.6%
                test-suite :: MultiSource/Benchmarks/DOE-ProxyApps-C/CoMD/CoMD.test  118.00  133.00   12.7%
          test-suite :: External/SPEC/CFP2017speed/638.imagick_s/638.imagick_s.test 3233.00 3554.00    9.9%
           test-suite :: External/SPEC/CFP2017rate/538.imagick_r/538.imagick_r.test 3233.00 3554.00    9.9%
                        test-suite :: MultiSource/Benchmarks/Olden/power/power.test   64.00   70.00    9.4%
           test-suite :: External/SPEC/CFP2017rate/526.blender_r/526.blender_r.test 7879.00 8604.00    9.2%
           test-suite :: MultiSource/Benchmarks/Prolangs-C/simulator/simulator.test   50.00   54.00    8.0%
                        test-suite :: MultiSource/Applications/sqlite3/sqlite3.test   27.00   29.00    7.4%
             test-suite :: External/SPEC/CFP2017rate/510.parest_r/510.parest_r.test 8345.00 8955.00    7.3%
     test-suite :: MultiSource/Benchmarks/Prolangs-C/TimberWolfMC/timberwolfmc.test  694.00  738.00    6.3%
                        test-suite :: MultiSource/Benchmarks/MallocBench/gs/gs.test  361.00  382.00    5.8%
                      test-suite :: MultiSource/Benchmarks/7zip/7zip-benchmark.test  409.00  430.00    5.1%
     test-suite :: External/SPEC/CINT2017speed/600.perlbench_s/600.perlbench_s.test  140.00  147.00    5.0%
      test-suite :: External/SPEC/CINT2017rate/500.perlbench_r/500.perlbench_r.test  140.00  147.00    5.0%
             test-suite :: External/SPEC/CFP2017rate/511.povray_r/511.povray_r.test 4013.00 4206.00    4.8%
                       test-suite :: MultiSource/Applications/JM/ldecod/ldecod.test  966.00 1011.00    4.7%
                           test-suite :: SingleSource/Benchmarks/Misc/oourafft.test   65.00   68.00    4.6%
                            test-suite :: MultiSource/Benchmarks/Bullet/bullet.test 4219.00 4381.00    3.8%
                    test-suite :: MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.test 1911.00 1973.00    3.2%
      test-suite :: External/SPEC/CINT2017rate/531.deepsjeng_r/531.deepsjeng_r.test   62.00   64.00    3.2%
     test-suite :: External/SPEC/CINT2017speed/631.deepsjeng_s/631.deepsjeng_s.test   62.00   64.00    3.2%
                 test-suite :: External/SPEC/CINT2017speed/602.gcc_s/602.gcc_s.test  852.00  877.00    2.9%
                  test-suite :: External/SPEC/CINT2017rate/502.gcc_r/502.gcc_r.test  852.00  877.00    2.9%
                       test-suite :: MultiSource/Applications/JM/lencod/lencod.test 1624.00 1668.00    2.7%
                         test-suite :: MultiSource/Benchmarks/McCat/18-imp/imp.test   39.00   40.00    2.6%
test-suite :: MultiSource/Benchmarks/MiBench/consumer-typeset/consumer-typeset.test  613.00  624.00    1.8%
      test-suite :: MultiSource/Benchmarks/MiBench/consumer-lame/consumer-lame.test  378.00  383.00    1.3%
      test-suite :: MultiSource/Benchmarks/MiBench/consumer-jpeg/consumer-jpeg.test  293.00  295.00    0.7%
            test-suite :: MultiSource/Benchmarks/mediabench/jpeg/jpeg-6a/cjpeg.test  297.00  299.00    0.7%
      test-suite :: External/SPEC/CINT2017rate/523.xalancbmk_r/523.xalancbmk_r.test 5522.00 5534.00    0.2%
     test-suite :: External/SPEC/CINT2017speed/623.xalancbmk_s/623.xalancbmk_s.test 5522.00 5534.00    0.2%

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

2 years ago[Verifier] Make matrix intrinsic verification compatible with opaque pointers
Nikita Popov [Wed, 1 Dec 2021 15:08:44 +0000 (16:08 +0100)]
[Verifier] Make matrix intrinsic verification compatible with opaque pointers

Don't check the pointer element type for opaque pointers.

2 years ago[mlir][linalg] Disable tensor-matmul test under asan
Stephan Herhut [Wed, 1 Dec 2021 09:38:12 +0000 (10:38 +0100)]
[mlir][linalg] Disable tensor-matmul test under asan

The test is currently leaky. Disabling it to make the bots green.

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

2 years agoRevert "[ARM] Teach getIntImmCostInst about the cost of saturating fp converts"
David Green [Wed, 1 Dec 2021 15:25:19 +0000 (15:25 +0000)]
Revert "[ARM] Teach getIntImmCostInst about the cost of saturating fp converts"

This reverts commit 6d41de380f223c8da02fd4d6a7f7dd1e7a404a24 as the
windows bots are not happy, in a way I do not understand. Revert whilst
we figure out what is wrong.

2 years ago[LV] Move code from vectorizeMemoryInstruction to recipe's execute().
Florian Hahn [Wed, 1 Dec 2021 14:56:51 +0000 (14:56 +0000)]
[LV] Move code from vectorizeMemoryInstruction to recipe's execute().

The code in widenMemoryInstruction has already been transitioned
to only rely on information provided by VPWidenMemoryInstructionRecipe
directly.

Moving the code directly to VPWidenMemoryInstructionRecipe::execute
completes the transition for the recipe.

It provides the following advantages:

1. Less indirection, easier to see what's going on.
2. Removes accesses to fields of ILV.

2) in particular ensures that no dependencies on
fields in ILV for vector code generation are re-introduced.

Reviewed By: Ayal

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

2 years agoRevert "[Flang] Replace notifyMatchFailure with TODO hard failures"
Kiran Chandramohan [Wed, 1 Dec 2021 14:23:48 +0000 (14:23 +0000)]
Revert "[Flang] Replace notifyMatchFailure with TODO hard failures"

This reverts commit 46fd7fd7b342039b59ec534bab8b93fa5d34f6e2.

2 years ago[SLP][NFC]Add a test for inserting into constant undef vector, NFC.
Alexey Bataev [Wed, 1 Dec 2021 14:20:35 +0000 (06:20 -0800)]
[SLP][NFC]Add a test for inserting into constant undef vector, NFC.

2 years ago[BasicAA] Add memset_chk libfunc tests.
Florian Hahn [Wed, 1 Dec 2021 14:15:46 +0000 (14:15 +0000)]
[BasicAA] Add memset_chk libfunc tests.

2 years ago[BasicAA] Add strncpy libfunc tests.
Florian Hahn [Wed, 1 Dec 2021 14:15:40 +0000 (14:15 +0000)]
[BasicAA] Add strncpy libfunc tests.

2 years ago[Dexter] Fix address_printing test by requiring lldb
Stephen Tozer [Wed, 1 Dec 2021 14:03:53 +0000 (14:03 +0000)]
[Dexter] Fix address_printing test by requiring lldb

Fixes a failure on the llvm-clang-x86_64-sie-ubuntu-fast buildbot caused
by the test requiring lldb (with the standard dexter lit config), but
not including a "Requires: lldb" clause.

2 years ago[VE] Make VE official
Simon Moll [Wed, 1 Dec 2021 12:21:39 +0000 (13:21 +0100)]
[VE] Make VE official

Add VE to the list of official targets.

Proposal: https://lists.llvm.org/pipermail/llvm-dev/2021-November/153571.html

Reviewed By: rengolin

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

2 years ago[clang-cl] Set _MSVC_LANG to 202002L with /std:c++20
Nico Weber [Wed, 1 Dec 2021 13:35:32 +0000 (08:35 -0500)]
[clang-cl] Set _MSVC_LANG to 202002L with /std:c++20

MSVC says this should be 202002L for /std:c++20, and of VS16.11
that's indeed the case (older versions warn that they don't
understand /std:c++20, and then cl.exe defaults to C++14 and
sets _MSVC_LANG to 201402 accordingly).

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

2 years ago[gn build] (manually) port 94d5f2afbef0
Nico Weber [Wed, 1 Dec 2021 13:53:49 +0000 (08:53 -0500)]
[gn build] (manually) port 94d5f2afbef0

2 years agoFix a violated precondition in clang-format.
Manuel Klimek [Wed, 1 Dec 2021 13:37:10 +0000 (14:37 +0100)]
Fix a violated precondition in clang-format.

Make sure we do not try to change line comments that are non-regular, i.e. do
not start with "//" or "#". This can for example happen when "//" is
broken into two lines with an escaped newline.

2 years ago[libcxx][test][NFC] Extend get_allocator() testing for containers
Konstantin Boyarinov [Wed, 1 Dec 2021 13:04:59 +0000 (16:04 +0300)]
[libcxx][test][NFC] Extend get_allocator() testing for containers

Add dedicated tests for get_allocator() method for sequence, ordered and
unordered associative containers including constness coverage.

Reviewed by: ldionne, Mordante, rarutyun, #libc

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

2 years ago[Dexter] Add DexDeclareAddress command and address function
Stephen Tozer [Wed, 1 Dec 2021 13:00:22 +0000 (13:00 +0000)]
[Dexter] Add DexDeclareAddress command and address function

This patch adds a new dexter command, DexDeclareAddress, which is used
to test the relative values of pointer variables. The motivation for
adding this command is to allow meaningful assertions to be made about
pointers that go beyond checking variable availability and null
equality.

The full explanation and syntax is in Commands.md.

Reviewed By: Orlando

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

2 years ago[gn build] Port f5f28d5b0ce7
LLVM GN Syncbot [Wed, 1 Dec 2021 12:55:06 +0000 (12:55 +0000)]
[gn build] Port f5f28d5b0ce7

2 years ago[ARM] Implement BTI placement pass for PACBTI-M
Ties Stuij [Wed, 1 Dec 2021 12:44:09 +0000 (12:44 +0000)]
[ARM] Implement BTI placement pass for PACBTI-M

This patch implements a new MachineFunction in the ARM backend for
placing BTI instructions. It is similar to the existing AArch64
aarch64-branch-targets pass.

BTI instructions are inserted into basic blocks that:
- Have their address taken
- Are the entry block of a function, if the function has external
  linkage or has its address taken
- Are mentioned in jump tables
- Are exception/cleanup landing pads

Each BTI instructions is placed in the beginning of a BB after the
so-called meta instructions (e.g. exception handler labels).

Each outlining candidate and the outlined function need to be in agreement about
whether BTI placement is enabled or not. If branch target enforcement is
disabled for a function, the outliner should not covertly enable it by emitting
a call to an outlined function, which begins with BTI.

The cost mode of the outliner is adjusted to account for the extra BTI
instructions in the outlined function.

The ARM Constant Islands pass will maintain the count of the jump tables, which
reference a block. A `BTI` instruction is removed from a block only if the
reference count reaches zero.

PAC instructions in entry blocks are replaced with PACBTI instructions (tests
for this case will be added in a later patch because the compiler currently does
not generate PAC instructions).

The ARM Constant Island pass is adjusted to handle BTI
instructions correctly.

Functions with static linkage that don't have their address taken can
still be called indirectly by linker-generated veneers and thus their
entry points need be marked with BTI or PACBTI.

The changes are tested using "LLVM IR -> assembly" tests, jump tables
also have a MIR test. Unfortunately it is not possible add MIR tests
for exception handling and computed gotos because of MIR parser
limitations.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

The following people contributed to this patch:

- Mikhail Maltsev
- Momchil Velikov
- Ties Stuij

Reviewed By: ostannard

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

2 years agoRevert "[LICM] Hoist LOAD without sinking the STORE"
Djordje Todorovic [Wed, 1 Dec 2021 12:39:26 +0000 (04:39 -0800)]
Revert "[LICM] Hoist LOAD without sinking the STORE"

This reverts commit ecb9d8e4e3c4623c2edcd2c50727103927d31508.

I'll reland this as soon as the failing tests are fixed/updated.

2 years ago[LICM] Hoist LOAD without sinking the STORE
Djordje Todorovic [Wed, 1 Dec 2021 12:21:10 +0000 (04:21 -0800)]
[LICM] Hoist LOAD without sinking the STORE

When doing load/store promotion within LICM, if we
cannot prove that it is safe to sink the store we won't
hoist the load, even though we can prove the load could
be dereferenced and moved outside the loop. This patch
implements the load promotion by moving it in the loop
preheader by inserting proper PHI in the loop. The store
is kept as is in the loop. By doing this, we avoid doing
the load from a memory location in each iteration.

Please consider this small example:

loop {
  var = *ptr;
  if (var) break;
  *ptr= var + 1;
}
After this patch, it will be:

var0 = *ptr;
loop {
  var1 = phi (var0, var2);
  if (var1) break;
  var2 = var1 + 1;
  *ptr = var2;
}
This addresses some problems from [0].

[0] https://bugs.llvm.org/show_bug.cgi?id=51193

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

2 years agoFixed a memory leak in the PDLToPDLInterp RootOrderingTest.
Stanislav Funiak [Wed, 1 Dec 2021 12:10:37 +0000 (17:40 +0530)]
Fixed a memory leak in the PDLToPDLInterp RootOrderingTest.

RootOrderingTest is a low-level unit test that creates values and uses them as vertices in a directed graph. These vertices were created using `builder.create`, but never freed, due to my insufficient understanding of the MLIR infrastructure.

Reviewed By: mehdi_amini, bondhugula, rriddle

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

2 years ago[clang][ARM] removing branch protection error cmdline test
Ties Stuij [Wed, 1 Dec 2021 12:04:08 +0000 (12:04 +0000)]
[clang][ARM] removing branch protection error cmdline test

This test which was just introduced in the PACBTI-M frontend
patch (https://reviews.llvm.org/D112421) is currently failing on some
platforms. Removing temporarily.

2 years ago[X86] Add some basic fptosi/fptoui saturate vector tests
Simon Pilgrim [Wed, 1 Dec 2021 12:03:30 +0000 (12:03 +0000)]
[X86] Add some basic fptosi/fptoui saturate vector tests

2 years ago[LICM] Support opaque pointers in scalar promotion
Nikita Popov [Wed, 1 Dec 2021 11:40:40 +0000 (12:40 +0100)]
[LICM] Support opaque pointers in scalar promotion

Make sure that all pointers have the same load/store access type,
rather than comparing pointer element types.