platform/upstream/llvm.git
3 years ago[clang-tidy] Add options to describe individual core increments to readability-functi...
Jens Massberg [Thu, 4 Mar 2021 20:02:26 +0000 (21:02 +0100)]
[clang-tidy] Add options to describe individual core increments to readability-function-cognitive-complexity check.

Often you are only interested in the overall cognitive complexity of a
function and not every individual increment. Thus the flag
'DescribeBasicIncrements' is added. If it is set to 'true', each increment
is flagged. Otherwise, only the complexity of function with complexity
of at least the threshold are flagged.

By default 'DescribeBasisIncrements' is set to 'true', which is the original behavior of the check.

Added a new test for different flag combinations.

(The option to ignore macros which was original part of this patch will be added in another path)

Reviewed By: lebedev.ri

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

3 years ago[mlir] Add a DialectAsmParser::getChecked method
River Riddle [Thu, 4 Mar 2021 19:52:14 +0000 (11:52 -0800)]
[mlir] Add a DialectAsmParser::getChecked method

This function simplifies calling the getChecked methods on Attributes and Types from within the parser, and removes any need to use `getEncodedSourceLocation` for these methods (by using an SMLoc instead). This is much more efficient than using an mlir::Location, as the encoding process to produce an mlir::Location is inefficient and undesirable for parsing (locations used during parsing should not persist afterwards unless otherwise necessary).

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

3 years agoRevert "Revert "[Coverage] Emit gap region between statements if first statements...
Zequan Wu [Thu, 4 Mar 2021 19:50:31 +0000 (11:50 -0800)]
Revert "Revert "[Coverage] Emit gap region between statements if first statements contains terminate statements.""

Reland with update on test case ContinuousSyncmode/basic.c.

This reverts commit fe5c2c3ca682b140dd5e640e75948363b6b25ef9.

3 years ago[lld-macho] Include install name in error messages for dylibs from TBDs
Jez Ng [Thu, 4 Mar 2021 19:36:49 +0000 (14:36 -0500)]
[lld-macho] Include install name in error messages for dylibs from TBDs

Since multiple dylibs can be defined in one TBD, this is
necessary to avoid confusion.

Reviewed By: #lld-macho, oontvoo

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

3 years ago[lld-macho] Filter TAPI re-exports by target
Jez Ng [Thu, 4 Mar 2021 19:36:47 +0000 (14:36 -0500)]
[lld-macho] Filter TAPI re-exports by target

Previously, we were loading re-exports without checking whether
they were compatible with our target. Prior to {D97209}, it meant that
we were defining dylib symbols that were invalid -- usually a silent
failure unless our binary actually used them. D97209 exposed this as an
explicit error.

Along the way, I've extended our TAPI compatibility check to cover the
platform as well, instead of just checking the arch. To this end, I've
replaced MachO::Architecture with MachO::Target in our Config struct.

Reviewed By: #lld-macho, oontvoo

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

3 years ago[lld-macho] Fix & fold reexport-nested-libs test into stub-link.s
Jez Ng [Thu, 4 Mar 2021 19:36:46 +0000 (14:36 -0500)]
[lld-macho] Fix & fold reexport-nested-libs test into stub-link.s

The reexport-nested-libs test added in D97438 was a bit wonky.

First, it was linking against libReexportSystem.tbd which targets the
iOS simulator, and which in turn attempted to re-export the iOS
simulator's libSystem. However, due to the way `-syslibroot` works, it
was actually re-exporting the macOS libSystem.

As a result, the test was not actually able to resolve the symbols in
the desired libSystem. I'm guessing that @oontvoo was confused by this
and therefore included those symbols in libReexportSystem.tbd itself.
But this means that the test wasn't actually testing the resolution of
re-exported symbols (though it did at least verify that the re-exported
libraries could be located).

After some consideration, I figured that stub-link.s could be extended
to cover what reexport-nested-libs.s was attempting to do. The test
targets macOS, so we only have one `-syslibroot` and no chance of
confusion.

Reviewed By: #lld-macho, oontvoo

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

3 years ago[lld-macho] Bind re-exported symbols directly to implicitly-linked umbrellas
Jez Ng [Thu, 4 Mar 2021 19:36:44 +0000 (14:36 -0500)]
[lld-macho] Bind re-exported symbols directly to implicitly-linked umbrellas

Suppose we are linking against libFoo, which re-exports the
implicitly-bound libSystem, which in turn re-exports some
non-explicitly-bound library like `/usr/lib/system/libsystem_c.dylib`.
Then any bindings we have to a symbol in libsystem_c should use
libSystem (and not libFoo) as the umbrella library.

Reviewed By: #lld-macho, smeenai

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

3 years ago[llvm-ifs] Add option to use InterfaceStub library
Haowei Wu [Sat, 9 Jan 2021 00:26:32 +0000 (16:26 -0800)]
[llvm-ifs] Add option to use InterfaceStub library

This change adds '-use-interfacestub' option to allow llvm-ifs
to use InterfaceStub lib when generating ELF binary.

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

3 years ago[libc][NFC] Make few fenv functions work with fexcept_t from other libcs.
Siva Chandra Reddy [Thu, 4 Mar 2021 19:16:26 +0000 (11:16 -0800)]
[libc][NFC] Make few fenv functions work with fexcept_t from other libcs.

3 years ago[lldb/Interpreter] Make OptionGroupPythonClassWithDict options non-required
Med Ismail Bennani [Thu, 4 Mar 2021 19:23:56 +0000 (19:23 +0000)]
[lldb/Interpreter] Make OptionGroupPythonClassWithDict options non-required

When using `OptionGroupPythonClassWithDict` options in an `OptionGroup`
with other `Options`, it can happen that the combinaison of some options
of each group makes the command invalid.

To solve that issue, this patch adds a bitmask argument to the
`OptionGroupPythonClassWithDict` constuctor that is used to mark each
option as required (or not).

If the `required_options` bitmask isn't passed to the constructor, the
class will keep its default behaviour, making the `--script-class` and
`--python-function` required.

rdar://65508855

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
3 years ago[ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of
Akira Hatanaka [Wed, 10 Feb 2021 22:47:06 +0000 (14:47 -0800)]
[ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of
explicitly emitting retainRV or claimRV calls in the IR

This reapplies ed4718eccb12bd42214ca4fb17d196d49561c0c7, which was reverted
because it was causing a miscompile. The bug that was causing the miscompile
has been fixed in 75805dce5ff874676f3559c069fcd6737838f5c0.

Original commit message:

Background:

This fixes a longstanding problem where llvm breaks ARC's autorelease
optimization (see the link below) by separating calls from the marker
instructions or retainRV/claimRV calls. The backend changes are in
https://reviews.llvm.org/D92569.

https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-autoreleasereturnvalue

What this patch does to fix the problem:

- The front-end adds operand bundle "clang.arc.attachedcall" to calls,
  which indicates the call is implicitly followed by a marker
  instruction and an implicit retainRV/claimRV call that consumes the
  call result. In addition, it emits a call to
  @llvm.objc.clang.arc.noop.use, which consumes the call result, to
  prevent the middle-end passes from changing the return type of the
  called function. This is currently done only when the target is arm64
  and the optimization level is higher than -O0.

- ARC optimizer temporarily emits retainRV/claimRV calls after the calls
  with the operand bundle in the IR and removes the inserted calls after
  processing the function.

- ARC contract pass emits retainRV/claimRV calls after the call with the
  operand bundle. It doesn't remove the operand bundle on the call since
  the backend needs it to emit the marker instruction. The retainRV and
  claimRV calls are emitted late in the pipeline to prevent optimization
  passes from transforming the IR in a way that makes it harder for the
  ARC middle-end passes to figure out the def-use relationship between
  the call and the retainRV/claimRV calls (which is the cause of
  PR31925).

- The function inliner removes an autoreleaseRV call in the callee if
  nothing in the callee prevents it from being paired up with the
  retainRV/claimRV call in the caller. It then inserts a release call if
  claimRV is attached to the call since autoreleaseRV+claimRV is
  equivalent to a release. If it cannot find an autoreleaseRV call, it
  tries to transfer the operand bundle to a function call in the callee.
  This is important since the ARC optimizer can remove the autoreleaseRV
  returning the callee result, which makes it impossible to pair it up
  with the retainRV/claimRV call in the caller. If that fails, it simply
  emits a retain call in the IR if retainRV is attached to the call and
  does nothing if claimRV is attached to it.

- SCCP refrains from replacing the return value of a call with a
  constant value if the call has the operand bundle. This ensures the
  call always has at least one user (the call to
  @llvm.objc.clang.arc.noop.use).

- This patch also fixes a bug in replaceUsesOfNonProtoConstant where
  multiple operand bundles of the same kind were being added to a call.

Future work:

- Use the operand bundle on x86-64.

- Fix the auto upgrader to convert call+retainRV/claimRV pairs into
  calls with the operand bundles.

rdar://71443534

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

3 years ago[Support] Add raw_ostream_iterator: ostream_iterator for raw_ostream
Nicolas Guillemot [Thu, 4 Mar 2021 17:58:16 +0000 (09:58 -0800)]
[Support] Add raw_ostream_iterator: ostream_iterator for raw_ostream

Adds a class `raw_ostream_iterator` that behaves like
std::ostream_iterator, but can be used with raw_ostream.
This is useful for using raw_ostream with std algorithms.

For example, it can be used to output std containers as follows:

```
std::vector<int> V = { 1, 2, 3 };
std::copy(V.begin(), V.end(), raw_ostream_iterator<int>(outs(), ", "));
// Output: "1, 2, 3, "
```

The API tries to follow std::ostream_iterator as closely as is
practically possible.

Reviewed By: dblaikie, mkitzan

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

3 years agoImprove the debug info for coro-split .resume functions
Adrian Prantl [Fri, 26 Feb 2021 01:25:34 +0000 (17:25 -0800)]
Improve the debug info for coro-split .resume functions

This patch updates the scope line to point to the suspend point. This
makes the first address in the function point to the first source line
in the resume function rather than the function declaration. Without
this the line table "jumps" from the beginning of the function to the
suspend point at the beginning.

rdar://73386346

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

3 years ago[clang-tidy] Extend LoopConvert on array with `!=` comparison
Nathan James [Thu, 4 Mar 2021 18:58:42 +0000 (18:58 +0000)]
[clang-tidy] Extend LoopConvert on array with `!=` comparison

Enables transforming loops of the form:
```
for (int i = 0; I != container.size(); ++I) { container[I]...; }
for (int i = 0; I != N; ++I) { FixedArrSizeN[I]...; }
```

Reviewed By: aaron.ballman

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

3 years ago[CostModel][SVE] Add cost model for shuffle reverse with i1 and scalable vector
Caroline Concatto [Mon, 15 Feb 2021 17:46:21 +0000 (17:46 +0000)]
[CostModel][SVE]  Add cost model for shuffle reverse with i1 and scalable vector

This patch adds the cost model for experimental.vector.reverse
with scalable vector types: nxv16i1, nxv8i1, nxv4i1 and nxv2i1.
These types are missing from the previous cost model patch D95603.

The cost model for experimental.vector.reverse with 1 bit mask is used by
loop vectorization in the patch D95363

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

3 years ago[TableGen] Fix warning when compiling generated MCCodeEmitter
Jay Foad [Thu, 4 Mar 2021 13:53:51 +0000 (13:53 +0000)]
[TableGen] Fix warning when compiling generated MCCodeEmitter

This fixes an instance of:
warning: cast from 'const unsigned long *' to 'unsigned char *' drops const qualifier [-Wcast-qual]
when compiling the generated MCCodeEmitter for an out-of-tree target
that uses the optional support for instruction widths > 64 bits.

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

3 years ago[mir] Fix confusing MIR when MMO's value is nullptr but offset is non-zero
Daniel Sanders [Tue, 2 Mar 2021 22:59:06 +0000 (14:59 -0800)]
[mir] Fix confusing MIR when MMO's value is nullptr but offset is non-zero

:: (store 1 + 4, addrspace 1)
->
:: (store 1 into undef + 4, addrspace 1)

An offset without a base isn't terribly useful but it's convenient to update
the offset without checking the value. For example, when breaking apart
stores into smaller units

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

3 years ago[PowerPC][PC Rel] Implement option to omit Power10 instructions from stubs
Albion Fung [Thu, 4 Mar 2021 18:17:40 +0000 (13:17 -0500)]
[PowerPC][PC Rel] Implement option to omit Power10 instructions from stubs

Implemented the option to omit Power10 instructions from save stubs via the
option --no-power10-stubs or --power10-stubs=no on lld. --power10-stubs= will
override the other option. --power10-stubs=auto also exists to use the default
behaviour (ie allow Power10 instructions in stubs).

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

3 years ago[cgp] Defer lazy domtree usage to last possible point
Philip Reames [Thu, 4 Mar 2021 18:18:10 +0000 (10:18 -0800)]
[cgp] Defer lazy domtree usage to last possible point

This is a compile time optimization for d9e93e8e5. Not sure this matters or not, but why not do it just in case.

This does involve querying TLI with a potentially invalid addressing mode for the using instruction, but since we don't actually pass the using instruction to the TLI callback, that should be fine.

3 years agoFold full-size subview of static shapes.
Ahmed Taei [Thu, 25 Feb 2021 01:24:14 +0000 (17:24 -0800)]
Fold full-size subview of static shapes.

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

3 years ago[mlir] Tighten the rules around folding TensorLoadOp
Nicolas Vasilache [Thu, 4 Mar 2021 17:36:56 +0000 (17:36 +0000)]
[mlir] Tighten the rules around folding TensorLoadOp

`tensor_load(tensor_to_memref(x)) -> x` is an incorrect folding because it ignores potential aliasing.

This revision approximates no-aliasing by restricting the folding to occur only when tensor_to_memref
is immediately preceded by tensor_load in the same block. This is a conservative step back towards
correctness until better alias analysis becomes available.

Context: https://llvm.discourse.group/t/properly-using-bufferization-related-passes/2913/6

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

3 years ago[FileCheck][NFC] Move -dump-input tests to a subdirectory
Joel E. Denny [Thu, 4 Mar 2021 17:43:48 +0000 (12:43 -0500)]
[FileCheck][NFC] Move -dump-input tests to a subdirectory

Just to make them easier to find.

Reviewed By: jhenderson

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

3 years ago[CGP] Lazily compute domtree only when needed during address matching
Philip Reames [Thu, 4 Mar 2021 17:31:02 +0000 (09:31 -0800)]
[CGP] Lazily compute domtree only when needed during address matching

This is a compile time optimization for d9e93e8e5.  As pointed out in post dommit review on the original review (D96399), there was a moderately large compile time regression with this patch and the eager computation of domtree on matcher construction is the first obvious candidate for why.

3 years ago[mlir] Add an AccessGroup attribute to load/store LLVM dialect ops and generate the...
Arpith C. Jacob [Thu, 4 Mar 2021 17:12:56 +0000 (18:12 +0100)]
[mlir] Add an AccessGroup attribute to load/store LLVM dialect ops and generate the access_group LLVM metadata.

This also includes LLVM dialect ops created from intrinsics.

Reviewed By: ftynse

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

3 years ago[OpenMP] Encapsulate more in checkDeviceAndCtors
Joel E. Denny [Thu, 4 Mar 2021 16:19:13 +0000 (11:19 -0500)]
[OpenMP] Encapsulate more in checkDeviceAndCtors

This patch just encapsulates some repeated code.  To do so, it
relocates some functions from interface.cpp to omptarget.cpp.  It also
adjusts them to the LLVM coding style.

This patch is almost NFC except some `DP` messages are a bit
different.  For example, messages like "Entering target region" are
now emitted even if offload is disabled, but a subsequent "Offload is
disabled" is then emitted.

Reviewed By: jdoerfert, grokos

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

3 years ago[OpenMP] Fix lone target exit data
Joel E. Denny [Thu, 4 Mar 2021 16:18:13 +0000 (11:18 -0500)]
[OpenMP] Fix lone target exit data

Without this patch, an `omp target exit data` before the runtime is
initialized produces a runtime error.  This patch fixes that by
changing `__tgt_target_data_end_mapper` to call `CheckDeviceAndCtors`
like many other runtime routines.

Discussed at
<https://lists.llvm.org/pipermail/openmp-dev/2021-March/003920.html>.

Reviewed By: grokos

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

3 years ago[OpenMP] Fix support for device as host
Joel E. Denny [Thu, 4 Mar 2021 16:15:58 +0000 (11:15 -0500)]
[OpenMP] Fix support for device as host

Without this patch, when the offload device is set to
`omp_get_initial_device()`, the runtime fails with an error diagnostic
when entering target regions or target data regions.

However, OpenMP 5.1, sec. 2.14.5 "target Construct", "Restrictions",
p. 203, L3-5 states:

> The device clause expression must evaluate to a non-negative integer
> value that is less than or equal to the value of
> omp_get_num_devices().

Sec. 3.7.7 "omp_get_initial_device", p. 412, L2-3 states:

> The value of the device number is the value returned by the
> omp_get_num_devices routine.

Similarly, OpenMP 5.0, sec. 2.12.5 "target Construct", "Restrictions",
p. 174 L30-32 states:

> The device clause expression must evaluate to a non-negative integer
> value less than the value of omp_get_num_devices() or to the value
> of omp_get_initial_device().

This patch fixes this behavior by changing the runtime to behave as if
offloading is disabled whenever it finds the offload device (either
from a `device` clause or the default device) is set to the host
device.  In the case of mandatory offloading when
`omp_get_num_devices() == 0`, it incorporates the behavior proposed
for OpenMP 5.2 in OpenMP spec github issue 2669.

Reviewed By: grokos, RaviNarayanaswamy

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

3 years ago[clang] removes check against integral-to-pointer conversion...
Christopher Di Bella [Fri, 26 Feb 2021 00:11:25 +0000 (00:11 +0000)]
[clang] removes check against integral-to-pointer conversion...

... unless it's a literal

D94640 was a bit too aggressive in its analysis, considering integers
representing valid addresses as invalid. This change rolls back some of
the check, so that only the most obvious case is still flagged.

Before:

```cpp
free((void*)1000);   // literal converted to `void*`: warning good
free((void*)an_int); // `int` object converted to `void*`: warning might
                     //  be a false positive
```

After

```cpp
free((void*)1000);   // literal converted to `void*`: warning good
free((void*)an_int); // doesn't warn
```

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

3 years ago[dfsan] add a missing zero origin at atomic commands
Jianzhou Zhao [Thu, 4 Mar 2021 16:48:06 +0000 (16:48 +0000)]
[dfsan] add a missing zero origin at atomic commands

3 years agoRevert "[llvm-exegesis] Disable the LBR check on AMD"
Nico Weber [Thu, 4 Mar 2021 16:48:33 +0000 (11:48 -0500)]
Revert "[llvm-exegesis] Disable the LBR check on AMD"

This reverts commit 293e8fa13d3f05e993771577a4c022deee5cbf6e.
Breaks build on non-intel hosts, see e.g.
http://45.33.8.238/macm1/4600/step_3.txt

3 years ago[gn build] port e9f9ec837d447857
Nico Weber [Thu, 4 Mar 2021 16:40:12 +0000 (11:40 -0500)]
[gn build] port e9f9ec837d447857

3 years ago[CMake][AIX] Adjust plugin library extension used on AIX
Xiangling Liao [Thu, 4 Mar 2021 14:52:04 +0000 (09:52 -0500)]
[CMake][AIX] Adjust plugin library extension used on AIX

As stated in the CMake manual, we are supposed to use MODULE rules to generate
plugin libraries:

"MODULE libraries are plugins that are not linked into other targets but may be
loaded dynamically at runtime using dlopen-like functionality"

Besides, LLVM's plugin infrastructure fits with the AIX treatment of .so
shared objects more than it fits with the AIX treatment of .a library archives
(which may contain shared objects).

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

3 years ago[llvm-exegesis] Disable the LBR check on AMD
Vy Nguyen [Thu, 25 Feb 2021 22:40:38 +0000 (17:40 -0500)]
[llvm-exegesis] Disable the LBR check on AMD

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

The bug reported a hang (or very very slow runtime) on a Zen2. Unfortunately, we don't have the hardware right now to debug it and I was not able to reproduce the bug on a HSW.
Theory we've got is that the lbr-checking code could be confused on AMD.

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

3 years ago[Instcombiner]Improve emission of logical or/and reductions.
Alexey Bataev [Mon, 22 Feb 2021 20:56:09 +0000 (12:56 -0800)]
[Instcombiner]Improve emission of logical or/and reductions.

For logical or/and reductions we emit regular intrinsics @llvm.vector.reduce.or/and.vxi1 calls.
These intrinsics are not effective for the logical or/and reductions,
especially if the optimizer is able to emit short circuit versions of
the scalar or/and instructions and vector code gets less effective than
the scalar version.
Instead, or reduction for i1 can be represented as:
```
%val = bitcast <ReduxWidth x i1> to iReduxWidth
%res = cmp ne iReduxWidth %val, 0
```
and reduction for i1 can be represented as:
```
%val = bitcast <ReduxWidth x i1> to iReduxWidth
%res = cmp eq iReduxWidth %val, 11111
```
This improves perfromance of the vector code significantly and make it
to outperform short circuit scalar code.

Part of D57059.

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

3 years ago[PowerPC][AIX] Handle variadic vector formal arguments.
Sean Fertile [Thu, 4 Mar 2021 15:56:53 +0000 (10:56 -0500)]
[PowerPC][AIX] Handle variadic vector formal arguments.

Patch adds support for passing vector arguments to variadic functions.
Arguments which are fixed shadow GPRs and stack space even when they are
passed in vector registers, while arguments passed through ellipses are
passed in(properly aligned GPRs if available and on the stack once all
GPR arguments registers are consumed.

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

3 years ago[Analysis][LoopVectorize] rename "Unsafe" variables/methods; NFC
Sanjay Patel [Thu, 4 Mar 2021 15:06:24 +0000 (10:06 -0500)]
[Analysis][LoopVectorize] rename "Unsafe" variables/methods; NFC

Similar to b3a33553aec7, but this shows a TODO and a potential
miscompile is already present.

We are tracking an FP instruction that does *not* have FMF (reassoc)
properties, so calling that "Unsafe" seems opposite of the common
reading.

I also removed one getter method by rolling the null check into
the access. Further simplification may be possible.

The motivation is to clean up the interactions between FMF and
function-level attributes in these classes and their callers.

The new test shows that there is an existing bug somewhere in
the callers. We assumed that the original code was fully 'fast'
and so we produced IR with 'fast' even though it was just 'reassoc'.

3 years ago[OPENMP]Fix PR48759: "fatal error" when compile with preprocessed file.
Alexey Bataev [Thu, 4 Mar 2021 14:03:53 +0000 (06:03 -0800)]
[OPENMP]Fix PR48759:  "fatal error" when compile with preprocessed file.

If the file in line directive does not exist on the system we need, to
use the original file to get its file id.

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

3 years ago[SystemZ][z/OS] Missing non-posix functions libc++
Muiez Ahmed [Thu, 4 Mar 2021 15:21:23 +0000 (15:21 +0000)]
[SystemZ][z/OS] Missing non-posix functions libc++

The aim is to add missing non-posix functions for z/OS libc++ (strtod_l and strtof_l).

Reviewed By: #libc, ldionne

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

3 years agoRevert "AMDGPU/GlobalISel: Combine zext(trunc x) to x after RegBankSelect"
Nico Weber [Thu, 4 Mar 2021 15:16:11 +0000 (10:16 -0500)]
Revert "AMDGPU/GlobalISel: Combine zext(trunc x) to x after RegBankSelect"

This reverts commit bf5a5826504754788a8f1e3fec7a7dc95cda5782.
Also depends on now-reverted 4c8fb7ddd6fa49258e0e9427e7345fb56ba522d4

3 years agoRevert "[GlobalISel] Combine zext(trunc x) to x"
Nico Weber [Thu, 4 Mar 2021 15:11:31 +0000 (10:11 -0500)]
Revert "[GlobalISel] Combine zext(trunc x) to x"

This reverts commit 4112299ee761a9b6a309c8ff4a7e75f8c8d8851b.
Seems to depend on 4c8fb7ddd6fa49258e0e9427e7345fb56ba522d4 which
is being reverted.

3 years agoRevert "[GlobalISel] Start using vectors in GISelKnownBits"
Nico Weber [Thu, 4 Mar 2021 15:08:37 +0000 (10:08 -0500)]
Revert "[GlobalISel] Start using vectors in GISelKnownBits"

This reverts commit 4c8fb7ddd6fa49258e0e9427e7345fb56ba522d4.
Breaks check-llvm everywhere, see https://reviews.llvm.org/D96122

3 years ago[mlir][linalg] Add suffix "Op" to pooling TC ops.
Hanhan Wang [Thu, 4 Mar 2021 15:08:19 +0000 (07:08 -0800)]
[mlir][linalg] Add suffix "Op" to pooling TC ops.

Reviewed By: antiagainst

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

3 years ago[pstl] A hot fix for
Mikhail Dvorskiy [Thu, 4 Mar 2021 14:39:52 +0000 (17:39 +0300)]
[pstl] A hot fix for

Commit 5856f202
by Mikhail Dvorskiy, 02/13/2021 08:28 PM
parent f515ca89

Iterator types renaming: ForwardIterator -> RandomAccessIterator; for parallel patterns/bricks

https://reviews.llvm.org/D96266

3 years ago[mlir][Vector] Add folding of vector transfers from/into tensor producing ops.
Nicolas Vasilache [Thu, 4 Mar 2021 14:09:54 +0000 (14:09 +0000)]
[mlir][Vector] Add folding of vector transfers from/into tensor producing ops.

Add a folder to rewrite a sequence such as:

```
   %t1 = ...
   %v = vector.transfer_read %t0[%c0...], {masked = [false...]} :
     tensor<static_sizesxf32>, vector<static_sizesxf32>
  %t2 = vector.transfer_write %v, %t1[%c0...] {masked = [false...]} :
     vector<static_sizesxf32>, tensor<static_sizesxf32>
```

into:

```
   %t0
```

The producer of t1 may or may not be DCE'd depending on whether it is a
block argument or has side effects.

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

3 years ago[AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member
Gabor Marton [Wed, 3 Mar 2021 12:35:13 +0000 (13:35 +0100)]
[AST][PCH][ASTImporter] Fix UB caused by uninited SwitchStmt member

The SwitchStmt::FirstCase member is not initialized when the AST is
built by the ASTStmtReader. See the below code of
ASTStmtReader::VisitSwitchStmt in the case where the for loop does not
have any iterations:
```
    // ... more code ...
    SwitchCase *PrevSC = nullptr;
    for (auto E = Record.size(); Record.getIdx() != E; ) {
      SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
      if (PrevSC)
        PrevSC->setNextSwitchCase(SC);
      else
        S->setSwitchCaseList(SC); // Sets FirstCase !!!

      PrevSC = SC;
    }
  } // return
```
Later, in ASTNodeImporter::VisitSwitchStmt,
we have a condition that depends on this uninited value:
```
  for (SwitchCase *SC = S->getSwitchCaseList(); SC != nullptr;
       SC = SC->getNextSwitchCase()) {
       // ... more code ...
  }

```
This is clearly an UB. This causes non-deterministic crashes when
ClangSA analyzes some code with CTU. See the below report by valgrind
(the whole valgrind output is attached):
```
==31019== Conditional jump or move depends on uninitialised value(s)
==31019==    at 0x12ED1983: clang::ASTNodeImporter::VisitSwitchStmt(clang::SwitchStmt*) (ASTImporter.cpp:6195)
==31019==    by 0x12F1D509: clang::StmtVisitorBase<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Stmt*>>::Visit(clang::Stmt*) (StmtNodes.inc:591)
==31019==    by 0x12EE4FDF: clang::ASTImporter::Import(clang::Stmt*) (ASTImporter.cpp:8484)
==31019==    by 0x12F09498: llvm::Expected<clang::Stmt*> clang::ASTNodeImporter::import<clang::Stmt>(clang::Stmt*) (ASTImporter.cpp:164)
==31019==    by 0x12F3A1F5: llvm::Error clang::ASTNodeImporter::ImportArrayChecked<clang::Stmt**, clang::Stmt**>(clang::Stmt**, clang::Stmt**, clang::Stmt**) (ASTImporter.cpp:653)
==31019==    by 0x12F13152: llvm::Error clang::ASTNodeImporter::ImportContainerChecked<llvm::iterator_range<clang::Stmt**>, llvm::SmallVector<clang::Stmt*, 8u> >(llvm::iterator_range<clang::Stmt**> const&, llvm::SmallVector<clang::Stmt*, 8u>&) (ASTImporter.cpp:669)
==31019==    by 0x12ED099F: clang::ASTNodeImporter::VisitCompoundStmt(clang::CompoundStmt*) (ASTImporter.cpp:6077)
==31019==    by 0x12F1CC2D: clang::StmtVisitorBase<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Stmt*>>::Visit(clang::Stmt*) (StmtNodes.inc:73)
==31019==    by 0x12EE4FDF: clang::ASTImporter::Import(clang::Stmt*) (ASTImporter.cpp:8484)
==31019==    by 0x12F09498: llvm::Expected<clang::Stmt*> clang::ASTNodeImporter::import<clang::Stmt>(clang::Stmt*) (ASTImporter.cpp:164)
==31019==    by 0x12F13275: clang::Stmt* clang::ASTNodeImporter::importChecked<clang::Stmt*>(llvm::Error&, clang::Stmt* const&) (ASTImporter.cpp:197)
==31019==    by 0x12ED0CE6: clang::ASTNodeImporter::VisitCaseStmt(clang::CaseStmt*) (ASTImporter.cpp:6098)
```

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

3 years agoAMDGPU/GlobalISel: Combine zext(trunc x) to x after RegBankSelect
Petar Avramovic [Thu, 4 Mar 2021 13:40:31 +0000 (14:40 +0100)]
AMDGPU/GlobalISel: Combine zext(trunc x) to x after RegBankSelect

RegBankSelect creates zext and trunc when it selects banks for uniform i1.
Add zext_trunc_fold from generic combiner to post RegBankSelect combiner.

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

3 years ago[GlobalISel] Combine zext(trunc x) to x
Petar Avramovic [Thu, 4 Mar 2021 13:34:21 +0000 (14:34 +0100)]
[GlobalISel] Combine zext(trunc x) to x

Combine zext(trunc x) to x when truncated bits are known to be zero.

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

3 years ago[GlobalISel] Start using vectors in GISelKnownBits
Petar Avramovic [Thu, 4 Mar 2021 13:27:39 +0000 (14:27 +0100)]
[GlobalISel] Start using vectors in GISelKnownBits

For vectors we consider a bit as known if it is the same for all demanded
vector elements (all elements by default). KnownBits BitWidth for vector
type is size of vector element. Add support for G_BUILD_VECTOR.
This allows combines of urem_pow2_to_mask in pre-legalizer combiner.

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

3 years agoRevert "[Coverage] Emit gap region between statements if first statements contains...
Nico Weber [Thu, 4 Mar 2021 13:52:29 +0000 (08:52 -0500)]
Revert "[Coverage] Emit gap region between statements if first statements contains terminate statements."

This reverts commit 2d7374a0c680f96bdcdb3d05034a93bf145d140f.
Breaks ContinuousSyncMode/basic.c in check-profile on macOS.

3 years ago[Analysis][LoopVectorize] rename "Unsafe" variables/methods; NFC
Sanjay Patel [Thu, 4 Mar 2021 13:47:46 +0000 (08:47 -0500)]
[Analysis][LoopVectorize] rename "Unsafe" variables/methods; NFC

We are tracking an FP instruction that does *not* have FMF (reassoc)
properties, so calling that "Unsafe" seems opposite of the common
reading.

I also removed one getter method by rolling the null check into
the access. Further simplification seems possible.

The motivation is to clean up the interactions between FMF and
function-level attributes in these classes and their callers.

3 years ago[CodeGenPrepare] Eliminate llvm.expect before removing empty blocks
Jann Horn [Thu, 4 Mar 2021 13:39:21 +0000 (14:39 +0100)]
[CodeGenPrepare] Eliminate llvm.expect before removing empty blocks

CodeGenPrepare currently first removes empty blocks, then in a loop
performs other optimizations. One of those optimizations is the removal
of call instructions that invoke @llvm.assume, which can create new
empty blocks.

This means that when a branch only contains a call to __builtin_assume(),
the empty branch will survive into MIR, and will then only be
half-removed by MIR-level optimizations (e.g. removing the branch but
leaving the condition intact).

Fix it by eliminating @llvm.expect builtin calls before removing empty
blocks.

Reviewed By: bkramer

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

3 years ago[lldb] Apply gdb-remote timeout to platform connections as well
Pavel Labath [Tue, 2 Mar 2021 14:43:11 +0000 (15:43 +0100)]
[lldb] Apply gdb-remote timeout to platform connections as well

We have a plugin.process.gdb-remote.packet-timeout setting, which can be
used to control how long the lldb client is willing to wait before
declaring the server side dead. Our test suite makes use of this
feature, and sets the setting value fairly high, as the low default
value can cause flaky tests, particularly on slower bots.

After fixing TestPlatformConnect (one of the few tests exercising the
remote platform capabilities of lldb) in 4b284b9ca, it immediately
started being flaky on the arm bots. It turns out this is because the
packet-timeout setting is not being applied to platform connections.

This patch makes the platform connections also respect the value of this
setting. It also adds a test which checks that the timeout value is
being honored.

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

3 years ago[mlir][Linalg] Add folding of linalg.copy that are in fact identities.
Nicolas Vasilache [Thu, 4 Mar 2021 13:08:21 +0000 (13:08 +0000)]
[mlir][Linalg] Add folding of linalg.copy that are in fact identities.

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

3 years ago[flang][driver] Add options for -fdefault* and -flarge-sizes
Arnamoy Bhattacharyya [Wed, 3 Mar 2021 16:28:11 +0000 (16:28 +0000)]
[flang][driver] Add options for -fdefault* and -flarge-sizes

Add support for the following Fortran dialect options:
  - -default*
  - -flarge-sizes

It also adds two test cases:
  # For checking whether `flang-new` is passing options correctly to `flang-new -fc1`.
  # For checking if `fdefault-` arguments are processed properly.

Also moves the Dialect related option parsing to a dedicated function
and adds a member `defaultKinds()` to `CompilerInvocation`

Depends on: D96032

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

3 years ago[AVR] Fix lifeness issues in the AVR backend
Ayke van Laethem [Mon, 22 Feb 2021 00:36:26 +0000 (01:36 +0100)]
[AVR] Fix lifeness issues in the AVR backend

This patch is a large number of small changes that should hopefully not
affect the generated machine code but are still important to get right
so that the machine verifier won't complain about them.

The llvm/test/CodeGen/AVR/pseudo/*.mir changes are also necessary
because without the liveins the used registers are considered undefined
by the machine verifier and it will complain about them.

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

3 years agoAdd __builtin_isnan(__fp16) testcase
Thomas Preud'homme [Tue, 2 Mar 2021 17:04:34 +0000 (17:04 +0000)]
Add __builtin_isnan(__fp16) testcase

Reviewed By: rjmccall

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

3 years ago[mlir] NFC - Add runner util functions to only print MemRef metadata.
Nicolas Vasilache [Thu, 4 Mar 2021 12:35:01 +0000 (12:35 +0000)]
[mlir] NFC - Add runner util functions to only print MemRef metadata.

These are useful to debug execution, without having to print the whole
content of a memref.

3 years ago[mlir][Linalg] NFC - Add isOutputTensor to LinalgInterfaces.td
Nicolas Vasilache [Thu, 4 Mar 2021 12:19:44 +0000 (12:19 +0000)]
[mlir][Linalg] NFC - Add isOutputTensor to LinalgInterfaces.td

3 years ago[clang-tidy][NFC] Update docs for bugprone-use-after-move
martinboehme [Fri, 19 Feb 2021 10:49:25 +0000 (11:49 +0100)]
[clang-tidy][NFC] Update docs for bugprone-use-after-move

- Create a separate section on silencing erroneous warnings and add more material to it
- Add note that the check is flow-sensitive but not path-sensitive

3 years agoRevert "Add __builtin_isnan(__fp16) testcase"
Thomas Preud'homme [Thu, 4 Mar 2021 12:17:09 +0000 (12:17 +0000)]
Revert "Add __builtin_isnan(__fp16) testcase"

This reverts commit e77b5c40d57633a66842e75410585696895ecf4d because it
fails without 1b6eb56aa0ea2931866455a21a138fc09c08e905.

3 years ago[DAG] TargetLowering::BuildUDIV - use APInt as const ref. NFCI.
Simon Pilgrim [Thu, 4 Mar 2021 12:14:55 +0000 (12:14 +0000)]
[DAG] TargetLowering::BuildUDIV - use APInt as const ref. NFCI.

Fixes clang-tidy warning.

3 years ago[X86] X86TargetLowering::isSafeMemOpType - break if-else chain. NFCI.
Simon Pilgrim [Thu, 4 Mar 2021 11:36:22 +0000 (11:36 +0000)]
[X86] X86TargetLowering::isSafeMemOpType - break if-else chain. NFCI.

All if-else blocks return - fixes clang-tidy warning.

3 years ago[mlir] Initialize CUDA context lazily.
Christian Sigg [Wed, 3 Mar 2021 16:35:02 +0000 (17:35 +0100)]
[mlir] Initialize CUDA context lazily.

So we can remove the ignore-warning pragma again.

Reviewed By: herhut

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

3 years agoRevert "Stop traping on sNaN in __builtin_isinf"
Thomas Preud'homme [Thu, 4 Mar 2021 12:03:20 +0000 (12:03 +0000)]
Revert "Stop traping on sNaN in __builtin_isinf"

This reverts commit 1b6eb56aa0ea2931866455a21a138fc09c08e905 because the
invert logic for isfinite is incorrect.

3 years agoRevert "[DebugInfo] Add new instruction and DIExpression operator for variadic debug...
Stephen Tozer [Thu, 4 Mar 2021 11:59:21 +0000 (11:59 +0000)]
Revert "[DebugInfo] Add new instruction and DIExpression operator for variadic debug values"

This reverts commit d07f106f4a48b6e941266525b6f7177834d7b74e.

3 years ago[DebugInfo] Add new instruction and DIExpression operator for variadic debug values
gbtozers [Fri, 11 Sep 2020 14:58:01 +0000 (15:58 +0100)]
[DebugInfo] Add new instruction and DIExpression operator for variadic debug values

This patch adds a new instruction that can represent variadic debug values,
DBG_VALUE_VAR. This patch alone covers the addition of the instruction and a set
of basic code changes in MachineInstr and a few adjacent areas, but does not
correctly handle variadic debug values outside of these areas, nor does it
generate them at any point.

The new instruction is similar to the existing DBG_VALUE instruction, with the
following differences: the operands are in a different order, any number of
values may be used in the instruction following the Variable and Expression
operands (these are referred to in code as “debug operands”) and are indexed
from 0 so that getDebugOperand(X) == getOperand(X+2), and the Expression in a
DBG_VALUE_VAR must use the DW_OP_LLVM_arg operator to pass arguments into the
expression.

The new DW_OP_LLVM_arg operator is only valid in expressions appearing in a
DBG_VALUE_VAR; it takes a single argument and pushes the debug operand at the
index given by the argument onto the Expression stack. For example the
sub-expression `DW_OP_LLVM_arg, 0` has the meaning “Push the debug operand at
index 0 onto the expression stack.”

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

3 years ago[llvm-objcopy][llvm-strip][test] Improve testing
James Henderson [Mon, 22 Feb 2021 14:30:15 +0000 (14:30 +0000)]
[llvm-objcopy][llvm-strip][test] Improve testing

This patch adds a number of new test cases that cover various
llvm-objcopy and llvm-strip features that had missing test coverage of
various descriptions:
* --add-section - checked the shdr properties, not just the content.
* Dedicated test case for --add-symbol when there are many sections.
* Show that --change-start accepts negative values without overflow.
  This was previously present but got lost between review versions.
* --dump-section - show that multiple sections can be dumped
  simultaneously to different files, and that an error is reported when
  a section cannot be found.
* --globalize-symbol(s) - show that symbols that are not mentioned are
  not globalized, if they would otherwise be, and that missing symbols
  from the list do not cause problems.
* --keep-global-symbol - show that the --regex option can be used in
  conjunction with this option.
* --keep-symbol - show that the --regex option can be used in
  conjunction with this option.
* --localize-symbol(s) - show that symbols that are not mentioned are
  not localized, if they would otherwise be, and that missing symbols
  from the list do not cause problems.
* --prefix-alloc-sections - show the behaviour of an empty string
  argument and multiple arguments.
* --prefix-symbols - show the behaviour of an empty string argument and
  multiple arguments. Also show the option applies to undefined symbols.
* --redefine-symbol - show that symbols with no name can be renamed,
  that it is not an error if a symbol is not specified, and that the
  option doesn't chain (i.e. --redefine-sym a=b --redefine-sym b=c does
  not redefine a as c).
* --rename-section - show that all section flags are preserved if none
  are specified. Also show that the option does not chain.
* --set-section-alignment - show that only specified sections have
  their alignments changed.
* --set-section-flags - show which section flags are preserved when this
  option is used. Also show that unspecified sections are not affected.
* --preserve-dates - show that -p is an alias of --preserve-dates.
* --strip-symbol - show that --regex works with this option for
  llvm-objcopy as well as llvm-strip.
* --strip-unneeded-symbol(s) - show more clearly that needed symbols are
  not stripped even if requested by this option.
* --allow-broken-links - show the sh_link of a symbol table is set to 0
  when its string table has been removed when this option is specified.
* --weaken-symbol(s) - show that symbols that are not mentioned are not
  weakened, if they would otherwise be, and that missing symbols from
  the list do not cause problems.
* --wildcard - show the wildcard behaviour for several options that were
  previously unchecked.

Reviewed by: alexshap

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

3 years agoRevert "[darwin] switch blocking mutex from osspinlock to os_unfair_lock"
Hans Wennborg [Thu, 4 Mar 2021 11:15:42 +0000 (12:15 +0100)]
Revert "[darwin] switch blocking mutex from osspinlock to os_unfair_lock"

> OSSpinLock is deprecated, so we are switching to `os_unfair_lock`. However, `os_unfair_lock` isn't available on older OSs, so we keep `OSSpinLock` as fallback.
>
> Also change runtime assumption check to static since they only ever check constant values.
>
> rdar://69588111
>
> Reviewed By: delcypher, yln
>
> Differential Revision: https://reviews.llvm.org/D97509

This reverts commit 71ef54337d5e83c6767e4816227ef340caa337fc.

3 years ago[gn build] Port d791695cb517
LLVM GN Syncbot [Thu, 4 Mar 2021 11:17:51 +0000 (11:17 +0000)]
[gn build] Port d791695cb517

3 years ago[objdump][ARM] Use correct offset when printing ARM/Thumb branch targets
Oliver Stannard [Tue, 2 Mar 2021 13:49:14 +0000 (13:49 +0000)]
[objdump][ARM] Use correct offset when printing ARM/Thumb branch targets

llvm-objdump only uses one MCInstrAnalysis object, so if ARM and Thumb
code is mixed in one object, or if an object is disassembled without
explicitly setting the triple to match the ISA used, then branch and
call targets will be printed incorrectly.

This could be fixed by creating two MCInstrAnalysis objects in
llvm-objdump, like we currently do for SubtargetInfo. However, I don't
think there's any reason we need two separate sub-classes of
MCInstrAnalysis, so instead these can be merged into one, and the ISA
determined by checking the opcode of the instruction.

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

3 years ago[MCA] Add support for in-order CPUs
Andrew Savonichev [Tue, 29 Dec 2020 16:49:09 +0000 (19:49 +0300)]
[MCA] Add support for in-order CPUs

This patch adds a pipeline to support in-order CPUs such as ARM
Cortex-A55.

In-order pipeline implements a simplified version of Dispatch,
Scheduler and Execute stages as a single stage. Entry and Retire
stages are common for both in-order and out-of-order pipelines.

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

3 years ago[X86] canonicalizeShuffleWithBinOps - handle general unaryshuffle(binop(x,c)) pattern...
Simon Pilgrim [Thu, 4 Mar 2021 10:44:23 +0000 (10:44 +0000)]
[X86] canonicalizeShuffleWithBinOps - handle general unaryshuffle(binop(x,c)) patterns not just xor(x,-1)

Generalize the shuffle(not(x)) -> not(shuffle(x)) fold to handle any binop with 0/-1.

Hopefully we can further generalize to help push target unary/binary shuffles through binops similar to what we do in DAGCombiner::visitVECTOR_SHUFFLE

3 years ago[NFC] Fix typos in CallingConvLower.h
Fraser Cormack [Thu, 4 Mar 2021 10:23:12 +0000 (10:23 +0000)]
[NFC] Fix typos in CallingConvLower.h

3 years ago[llvm-objcopy][llvm-strip] Improve --discard-all documentation and help
James Henderson [Tue, 23 Feb 2021 13:55:48 +0000 (13:55 +0000)]
[llvm-objcopy][llvm-strip] Improve --discard-all documentation and help

The help text and documentation for the --discard-all option failed to
mention that the option also causes the removal of debug sections. This
change fixes both for both llvm-objcopy and llvm-strip.

Reviewed by: MaskRay

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

3 years ago[llvm-objcopy/strip] Fix off-by-one error in SYMTAB_SHNDX need check
James Henderson [Fri, 26 Feb 2021 13:44:48 +0000 (13:44 +0000)]
[llvm-objcopy/strip] Fix off-by-one error in SYMTAB_SHNDX need check

The check for whether an extended symbol index table was required
dropped the first SHN_LORESERVE sections from the sections array before
checking whether the remaining sections had symbols. Unfortunately, the
null section header is not present in this list, so the check was
skipping the first section that might be important. If that section
contained a symbol, and no subsequent ones did, the .symtab_shndx
section would not be emitted, leading to a corrupt object.

Also consolidate and expand test coverage in the area to cover this bug
and other aspects of the SYMTAB_SHNDX section.

Reviewed by: alexshap, MaskRay

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

3 years ago[libcxx] Move Linaro AArch64 buildbots to buildkite
David Spickett [Mon, 8 Feb 2021 10:43:21 +0000 (10:43 +0000)]
[libcxx] Move Linaro AArch64 buildbots to buildkite

Reviewed By: #libc, ldionne

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

3 years ago[clangd] Introduce client state invalidation
Kadir Cetinkaya [Fri, 26 Feb 2021 13:44:01 +0000 (14:44 +0100)]
[clangd] Introduce client state invalidation

Clangd can invalidate client state of features like semantic higlighting
without client explicitly triggering, for example after a preamble build
caused by an onSave notification on a different file.

This patch introduces a mechanism to let client know of such actions,
and also calls the workspace/semanticTokens/refresh request to
demonstrate the situation after each preamble build.

Fixes https://github.com/clangd/clangd/issues/699.

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

3 years ago[ARM] Remove new ARMSelectionDAGTest unittest.
David Green [Thu, 4 Mar 2021 10:14:35 +0000 (10:14 +0000)]
[ARM] Remove new ARMSelectionDAGTest unittest.

This removes the unit test from a968e7b82eac as it reportedly causes
some link problems. It can be reinstated once the issues are understood
and sorted out.

3 years ago[Polly][Codegen] Emit access group metadata.
Michael Kruse [Thu, 4 Mar 2021 09:46:29 +0000 (03:46 -0600)]
[Polly][Codegen] Emit access group metadata.

Emit llvm.loop.parallel_accesses metadata instead of
llvm.mem.parallel_loop_access. The latter is deprecated because it
assumes that LoopIDs are persistent, which they are not.
We also emit parallel access metadata for all surrounding parallel
loops, not just the innermost parallel.

3 years ago[mlir] ODS: change OpBuilderDAG to OpBuilder
Alex Zinenko [Wed, 3 Mar 2021 14:53:09 +0000 (15:53 +0100)]
[mlir] ODS: change OpBuilderDAG to OpBuilder

We no longer have the non-DAG version.

Reviewed By: rriddle

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

3 years ago[X86][CodeGenPrepare] Try to reuse IV's incremented value instead of adding the offse...
Max Kazantsev [Thu, 4 Mar 2021 08:41:22 +0000 (15:41 +0700)]
[X86][CodeGenPrepare] Try to reuse IV's incremented value instead of adding the offset, part 2

This patch enables the case where we do not completely eliminate offset.
Supposedly in this case we reduce live range overlap that never harms, but
since there are doubts this is true, this goes as a separate change.

Differential Revision: https://reviews.llvm.org/D96399
Reviewed By: reames

3 years ago[llvm-objcopy][test] Improve many-sections object and test case
James Henderson [Wed, 17 Feb 2021 13:53:01 +0000 (13:53 +0000)]
[llvm-objcopy][test] Improve many-sections object and test case

Additionally do some test tidy-ups and improve coverage of symbol
section indexes where the logical section index >= SHN_LORESERVE.

The symbol and section names in the many-section input object were
mostly shared. This patch changes them to be distinct, enabling
different operations such as --add-symbol, to be more targeted, when
using the object. It also makes the test less confusing and removes some
oddness in the symbol table order, presumably caused by the duplicate
names.

The input object was built from assembly that was of the form:
.section s1
sym1:
.section s2
sym2:
...
with a total of 65536 such occurrences. llvm-objcopy was then used to
remove the empty .text section automatically generated by MC, and
incidentally to move .strtab to the end of the object. This ensured that
the section/symbol indexes matched their name (i.e. section index 1 was
s1, section index 2 was s2 etc, and sym1 was in s1, sym2 in s2 etc).

Reviewed by: MaskRay

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

3 years ago[RISCV] Fix crash when inserting large fixed-length subvectors
Fraser Cormack [Wed, 3 Mar 2021 16:39:43 +0000 (16:39 +0000)]
[RISCV] Fix crash when inserting large fixed-length subvectors

This patch addresses a compiler crash resulting from passing a
fixed-length type to one that expects scalable vector types. An
assertion was added to prevent this regressing in the future.

Reviewed By: craig.topper

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

3 years ago[RISCV] Preserve fixed-length VL on insert_vector_elt in more cases
Fraser Cormack [Wed, 3 Mar 2021 07:50:49 +0000 (07:50 +0000)]
[RISCV] Preserve fixed-length VL on insert_vector_elt in more cases

This patch fixes up one case where the fixed-length-vector VL was
dropped (falling back to VLMAX) when inserting vector elements, as the
code would lower via ISD::INSERT_VECTOR_ELT (at index 0) which loses the
fixed-length vector information.

To this end, a custom node, VMV_S_XF_VL, was introduced to carry the VL
operand through to the final instruction. This node wraps the RVV
vmv.s.x and vmv.s.f instructions, which were being selected by
insert_vector_elt anyway.

There should be no observable difference in scalable-vector codegen.

There is still one outstanding drop from fixed-length VL to VLMAX, when
an i64 element is inserted into a vector on RV32; the splat (which is
custom legalized) has no notion of the original fixed-length vector
type.

Reviewed By: craig.topper

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

3 years ago[ARM] Fix linking of the new unittest from a968e7b82eac
Martin Storsjö [Thu, 4 Mar 2021 09:03:44 +0000 (11:03 +0200)]
[ARM] Fix linking of the new unittest from a968e7b82eac

3 years agoRevert "[XRay][x86_64] Fix CFI directives in assembly trampolines"
Petr Hosek [Thu, 4 Mar 2021 09:03:04 +0000 (01:03 -0800)]
Revert "[XRay][x86_64] Fix CFI directives in assembly trampolines"

This reverts commit 9ee61cf3f67b9fdcee7c2dd650321264376bc0f2 since
it's failing to compile on Darwin.

3 years ago[ARM] KnownBits for CSINC/CSNEG/CSINV
David Green [Thu, 4 Mar 2021 08:40:20 +0000 (08:40 +0000)]
[ARM] KnownBits for CSINC/CSNEG/CSINV

This adds some simple known bits handling for the three CSINC/NEG/INV
instructions. From the operands known bits we can compute the common
bits of the first operand and incremented/negated/inverted second
operand. The first, especially CSINC ZR, ZR, comes up fair amount in the
tests. The others are more rare so a unit test for them is added.

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

3 years ago[lld][WebAssembly] -Bsymbolic creates indirect function table if needed
Andy Wingo [Wed, 3 Mar 2021 10:13:25 +0000 (11:13 +0100)]
[lld][WebAssembly] -Bsymbolic creates indirect function table if needed

It can be that while processing relocations, we realize that in the end
we need an indirect function table.  Ensure that one is present, in that
case, to avoid writing invalid object files.

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

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

3 years ago[X86][CodeGenPrepare] Try to reuse IV's incremented value instead of adding the offse...
Max Kazantsev [Thu, 4 Mar 2021 05:01:39 +0000 (12:01 +0700)]
[X86][CodeGenPrepare] Try to reuse IV's incremented value instead of adding the offset, part 1

While optimizing the memory instruction, we sometimes need to add
offset to the value of `IV`. We could avoid doing so if the `IV.next` is
already defined at the point of interest. In this case, we may get two
possible advantages from this:

- If the `IV` step happens to match with the offset, we don't need to add
  the offset at all;
- We reduce overlap of live ranges of `IV` and `IV.next`. They may stop overlapping
  and it will lead to better register allocation. Even if the overlap will preserve,
  we are not introducing a new overlap, so it should be a neutral transform (Disabled
  this patch, will come with follow-up).

Currently I've only added support for IVs that get decremented using `usub`
intrinsic. We could also support `AddInstr`, however there is some weird
interaction with some other transform that may lead to infinite compilation
in this case (seems like same transform is done and undone over and over).
I need to investigate why it happens, but generally we could do that too.

The first part only handles case where this reuse fully elimiates the offset.

Differential Revision: https://reviews.llvm.org/D96399
Reviewed By: reames

3 years ago[LangRef] remove links to lifetime since use marker intro already has a link
Juneyoung Lee [Thu, 4 Mar 2021 08:19:08 +0000 (17:19 +0900)]
[LangRef] remove links to lifetime since use marker intro already has a link

3 years ago[mlir] make implementations of translation to LLVM IR interfaces private
Alex Zinenko [Wed, 3 Mar 2021 13:08:30 +0000 (14:08 +0100)]
[mlir] make implementations of translation to LLVM IR interfaces private

There is no need for the interface implementations to be exposed, opaque
registration functions are sufficient for all users, similarly to passes.

Reviewed By: mehdi_amini

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

3 years ago[LangRef] fix more undefined label errors
Juneyoung Lee [Thu, 4 Mar 2021 08:09:03 +0000 (17:09 +0900)]
[LangRef] fix more undefined label errors

3 years ago[mlir] Add loop codegen options to some LLVM dialect ops.
Arpith C. Jacob [Thu, 4 Mar 2021 08:00:18 +0000 (09:00 +0100)]
[mlir] Add loop codegen options to some LLVM dialect ops.

Add a Loop Option attribute and generate llvm metadata attached to
branch instructions to control code generation.

Reviewed By: ftynse, mehdi_amini

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

3 years ago[LegalizeVectorTypes] Remove a tautological compare.
Craig Topper [Thu, 4 Mar 2021 07:25:46 +0000 (23:25 -0800)]
[LegalizeVectorTypes] Remove a tautological compare.

3 years ago[debugserver] Fix more compiler warnings on arm64
Jonas Devlieghere [Thu, 4 Mar 2021 07:09:58 +0000 (23:09 -0800)]
[debugserver] Fix more compiler warnings on arm64

This fixes the following two warnings in code that's only compiled on
arm64:

 - warning: cast from 'const void *' to 'unsigned char *' drops const
   qualifier [-Wcast-qual]
 - warning: embedding a directive within macro arguments has undefined
   behavior [-Wembedded-directive]

3 years ago[libcxx] Don't use dllimport for a static member in a template
Martin Storsjö [Sun, 21 Feb 2021 23:13:13 +0000 (01:13 +0200)]
[libcxx] Don't use dllimport for a static member in a template

This fixes clang warnings (that are treated as errors when running
the test suite):

libcxx/include/string:4409:59: error: definition of dllimport static field [-Werror,-Wdllimport-static-field-def]
               basic_string<_CharT, _Traits, _Allocator>::npos;

The warning is normally not visible as long as the libc++ headers
are treated as system headers.

The same construct is always an error in MSVC.

(One _LIBCPP_FUNC_VIS was added in
2d8f23f571635c1fb983b40c4c2548716a5b65b6, which broke DLL builds.
59919c4d6b6370da7133bbca0d31844e21646bb1 fixed this by adding another
_LIBCPP_FUNC_VIS on the declaration for consistency, but the underlying
issue remained, that one can't use dllimport here.)

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

3 years ago[CSSPGO] Deduplicating dangling pseudo probes.
Hongtao Yu [Thu, 25 Feb 2021 07:47:29 +0000 (23:47 -0800)]
[CSSPGO] Deduplicating dangling pseudo probes.

Same dangling probes are redundant since they all have the same semantic that is to rely on the counts inference tool to get reasonable count for the same original block. Therefore, there's no need to keep multiple copies of them. I've seen jump threading created tons of redundant dangling probes that slowed down the compiler dramatically. Other optimization passes can also result in redundant probes though without an observed impact so far.

This change removes block-wise redundant dangling probes specifically introduced by jump threading. To support removing redundant dangling probes caused by all other passes, a final function-wise deduplication is also added.

An 18% size win of the .pseudo_probe section was seen for SPEC2017. No performance difference was observed.

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

3 years ago[CSSPGO] Unblocking optimizations by dangling pseudo probes.
Hongtao Yu [Thu, 25 Feb 2021 08:52:58 +0000 (00:52 -0800)]
[CSSPGO] Unblocking optimizations by dangling pseudo probes.

This change fixes a couple places where the pseudo probe intrinsic blocks optimizations because they are not naturally removable. To unblock those optimizations, the blocking pseudo probes are moved out of the original blocks and tagged dangling, instead of allowing pseudo probes to be literally removed. The reason is that when the original block is removed, we won't be able to sample it. Instead of assigning it a zero weight, moving all its pseudo probes into another block and marking them dangling should allow the counts inference a chance to assign them a more reasonable weight. We have not seen counts quality degradation from our experiments.

The optimizations being unblocked are:

1. Removing conditional probes for if-converted branches. Conditional probes are tagged dangling when their homing branch arms are folded so that they will not be over-counted.
2. Unblocking jump threading from removing empty blocks. Pseudo probe prevents jump threading from removing logically empty blocks that only has one unconditional jump instructions.
3. Unblocking SimplifyCFG and MIR tail duplicate to thread empty blocks and blocks with redundant branch checks.

Since dangling probes are logically deleted, they should not consume any samples in LTO postLink. This can be achieved by setting their distribution factors to zero when dangled.

Reviewed By: wmi

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

3 years ago[CSSPGO] Introducing dangling pseudo probes.
Hongtao Yu [Thu, 25 Feb 2021 08:43:17 +0000 (00:43 -0800)]
[CSSPGO] Introducing dangling pseudo probes.

Dangling probes are the probes associated to an empty block. This usually happens when all real instructions are optimized away from the block. There is a problem with dangling probes during the offline counts processing. The way the sample profiler works is that samples collected on the first physical instruction following a probe will be counted towards the probe. This logically equals to treating the instruction next to a probe as if it is from the same block of the probe. In the dangling probe case, the real instruction following a dangling probe actually starts a new block, and samples collected on the new block may cause issues when counted towards the empty block.

To mitigate this issue, we first try to move around a dangling probe inside its owning block. If there are still native instructions preceding the probe in the same block, we can then use them as a place holder to collect samples for the probe. A pass is added to walk each block backwards looking for probes not followed by any real instruction and moving them before the first real instruction. This is done right before the object emission.

If we are unlucky to find such in-block preceding instructions for a probe, the solution we are taking is to tag such probe as dangling so that the samples reported for them will not be trusted by the compiler. We leave it up to the counts inference algorithm to get such probes a reasonable count. The number `UINT64_MAX` is used to mark sample count as collected for a dangling probe.

Reviewed By: wmi

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

3 years ago[libcxx] adds concept `std::assignable_from`
Christopher Di Bella [Thu, 4 Mar 2021 06:27:21 +0000 (22:27 -0800)]
[libcxx] adds concept `std::assignable_from`

Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96660

Reviewed By: ldionne, #libc

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