platform/upstream/llvm.git
2 years ago[clang][OpenMP][DebugInfo] Debug support for private variables inside an OpenMP task...
Alok Kumar Sharma [Wed, 24 Nov 2021 05:08:19 +0000 (10:38 +0530)]
[clang][OpenMP][DebugInfo] Debug support for private variables inside an OpenMP task construct

Currently variables appearing inside private/firstprivate/lastprivate
clause of openmp task construct are not visible inside lldb debugger.
This is because compiler does not generate debug info for it.

Please consider the testcase debug_private.c attached with patch.

```
   28   #pragma omp task shared(res) private(priv1, priv2) firstprivate(fpriv)
   29       {
   30         priv1 = n;
   31         priv2 = n + 2;
   32         printf("Task n=%d,priv1=%d,priv2=%d,fpriv=%d\n",n,priv1,priv2,fpriv);
   33
-> 34         res = priv1 + priv2 + fpriv + foo(n - 1);
   35       }
   36   #pragma omp taskwait
   37       return res;
(lldb) p priv1
error: <user expression 0>:1:1: use of undeclared identifier 'priv1'
priv1
^
(lldb) p priv2
error: <user expression 1>:1:1: use of undeclared identifier 'priv2'
priv2
^
(lldb) p fpriv
error: <user expression 2>:1:1: use of undeclared identifier 'fpriv'
fpriv
^
```

After the current patch, lldb is able to show the variables

```
(lldb) p priv1
(int) $0 = 10
(lldb) p priv2
(int) $1 = 12
(lldb) p fpriv
(int) $2 = 14
```

Reviewed By: djtodoro

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

2 years agoDon't store nullptrs in mlir::FuncOp::getAll*Attrs' result
Tres Popp [Mon, 22 Nov 2021 11:49:00 +0000 (12:49 +0100)]
Don't store nullptrs in mlir::FuncOp::getAll*Attrs' result

These methods for results and arguments would create an ArrayRef full
of nullptrs when there were no argument attributes. This is problematic
because this result could not be passed to the FuncOp::build creator
without causing a segfault. Now the list will have empty attributes.

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

2 years ago[PowerPC/ Regenerate fp128-bitcast-after-operation test checks
Simon Pilgrim [Thu, 25 Nov 2021 13:39:48 +0000 (13:39 +0000)]
[PowerPC/ Regenerate fp128-bitcast-after-operation test checks

2 years agoRevert "[SLP]Improve analysis/emission of vector operands for alternate nodes."
Alexey Bataev [Thu, 25 Nov 2021 13:17:30 +0000 (05:17 -0800)]
Revert "[SLP]Improve analysis/emission of vector operands for alternate nodes."

This reverts commit 496254cf802a21e1967b61dec48017b8ec831574 to fix
compiler crashes reported in D114101#3152982.

2 years ago[MLIR] [docs] Fix misguided examples in memref.subview operation.
seongwon bang [Thu, 25 Nov 2021 12:23:48 +0000 (21:23 +0900)]
[MLIR] [docs] Fix misguided examples in memref.subview operation.

The examples in `memref.subview` operation are misguided in that subview's strides operands mean "memref-rank number of strides that compose multiplicatively with the base memref strides in each dimension.".
So the below examples should be changed from `Strides: [64, 4, 1]` to `Strides: [1, 1, 1]`

Before changes
```
// Subview with constant offsets, sizes and strides.
%1 = memref.subview %0[0, 2, 0][4, 4, 4][64, 4, 1]
  : memref<8x16x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)> to
    memref<4x4x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2 + 8)>
```

After changes
```
// Subview with constant offsets, sizes and strides.
%1 = memref.subview %0[0, 2, 0][4, 4, 4][1, 1, 1]
  : memref<8x16x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)> to
    memref<4x4x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2 + 8)>
```

Also I fixed some syntax issues in docs related with memref layout map and added detailed explanation in subview rank reducing case.

Reviewed By: herhut

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

2 years ago[NFC][llvm] Inclusive language: reword uses of sanity test and check
Zarko Todorovski [Thu, 25 Nov 2021 02:56:49 +0000 (21:56 -0500)]
[NFC][llvm] Inclusive language: reword uses of sanity test and check

Part of continuing work to use more inclusive language. Reworded uses
of sanity check and sanity test in llvm/test/

2 years ago[clangd] Move IncludeCleaner tracer to the actual computation
Kirill Bobyrev [Thu, 25 Nov 2021 12:19:01 +0000 (13:19 +0100)]
[clangd] Move IncludeCleaner tracer to the actual computation

This way we won't get results with 0 ms for all the users with disabled
IncludeCleaner.

2 years ago[clang-format] [C++20] [Module] clang-format couldn't recognize partitions
mydeveloperday [Thu, 25 Nov 2021 11:50:34 +0000 (11:50 +0000)]
[clang-format] [C++20] [Module] clang-format couldn't recognize partitions

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

clang-format is butchering modules, this could easily become a barrier to entry for modules given clang-formats wide spread use.

Prevent the following from adding spaces around the  `:`  (cf was considering the ':' as an InheritanceColon)

Reviewed By: HazardyKnusperkeks, owenpan, ChuanqiXu

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

2 years ago[lldb/gdb-remote] Ignore spurious ACK packets
Pavel Labath [Wed, 24 Nov 2021 10:20:44 +0000 (11:20 +0100)]
[lldb/gdb-remote] Ignore spurious ACK packets

Although I cannot find any mention of this in the specification, both
gdb and lldb agree on sending an initial + packet after establishing the
connection.

OTOH, gdbserver and lldb-server behavior is subtly different. While
lldb-server *expects* the initial ack, and drops the connection if it is
not received, gdbserver will just ignore a spurious ack at _any_ point
in the connection.

This patch changes lldb's behavior to match that of gdb. An ACK packet
is ignored at any point in the connection (except when expecting an ACK
packet, of course). This is inline with the "be strict in what you
generate, and lenient in what you accept" philosophy, and also enables
us to remove some special cases from the server code. I've extended the
same handling to NAK (-) packets, mainly because I don't see a reason to
treat them differently here.

(The background here is that we had a stub which was sending spurious
+ packets. This bug has since been fixed, but I think this change makes
sense nonetheless.)

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

2 years ago[lldb/gdb-remote] Remove initial pipe-draining workaround
Pavel Labath [Wed, 24 Nov 2021 13:11:22 +0000 (14:11 +0100)]
[lldb/gdb-remote] Remove initial pipe-draining workaround

This code, added in rL197579 (Dec 2013) is supposed to work around what
was presumably a qemu bug, where it would send unsolicited stop-reply
packets after the initial connection.

At present, qemu does not exhibit such behavior. Also, the 10ms delay
introduced by this code is sufficient to mask bugs in other stubs, but
it is not sufficient to *reliably* mask those bugs. This resulted in
flakyness in one of our stubs, which was (incorrectly) sending a +
packet at the start of the connection, resulting in a small-but-annoying
number of dropped connections.

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

2 years ago[DAG] SimplifyDemandedBits - simplify rotl/rotr to shl/srl (REAPPLIED)
Simon Pilgrim [Thu, 25 Nov 2021 11:14:06 +0000 (11:14 +0000)]
[DAG] SimplifyDemandedBits - simplify rotl/rotr to shl/srl (REAPPLIED)

If we only demand bits from one half of a rotation pattern, see if we can simplify to a logical shift.

For the ARM/AArch64 rev16/32 patterns, I had to drop a fold to prevent srl(bswap()) -> rotr(bswap) -> srl(bswap) infinite loops. I've replaced this with an isel PatFrag which should do the same task.

Reapplied with fix for AArch64 rev patterns to matching the ARM fix.

https://alive2.llvm.org/ce/z/iroxki (rol -> shl by amt iff demanded bits has at least as many trailing zeros as the shift amount)
https://alive2.llvm.org/ce/z/4ez_U- (ror -> shl by revamt iff demanded bits has at least as many trailing zeros as the reverse shift amount)
https://alive2.llvm.org/ce/z/cD7dR- (ror -> lshr by amt iff demanded bits has at least as many leading zeros as the shift amount)
https://alive2.llvm.org/ce/z/_XGHtQ (rol -> lshr by revamt iff demanded bits has at least as many leading zeros as the reverse shift amount)

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

2 years ago[clang-format]NFC improve the comment to match the code
mydeveloperday [Thu, 25 Nov 2021 11:11:30 +0000 (11:11 +0000)]
[clang-format]NFC improve the comment to match the code

Missing from {D114519}

2 years ago[clang-format] [PR52595] clang-format does not recognize rvalue references to array
mydeveloperday [Thu, 25 Nov 2021 11:04:17 +0000 (11:04 +0000)]
[clang-format] [PR52595] clang-format does not recognize rvalue references to array

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

missing space between `T(&&)` but not between `T (&` due to && being incorrectly thought of as `UnaryOperator`  rather than `PointerOrReference`

```
int operator()(T (&)[N]) { return 0; }
int operator()(T(&&)[N]) { return 1; }
```

Existing Unit tests are changed because actually I think they are originally incorrect, and are inconsistent with the (&) cases that are 4 or 5 lines above them.

Reviewed By: curdeius

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

2 years ago[mlir] Move memref.[tensor_load|buffer_cast|clone] to "bufferization" dialect.
Alexander Belyaev [Thu, 25 Nov 2021 10:42:16 +0000 (11:42 +0100)]
[mlir] Move memref.[tensor_load|buffer_cast|clone] to "bufferization" dialect.

https://llvm.discourse.group/t/rfc-dialect-for-bufferization-related-ops/4712

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

2 years ago[mlir][linalg] Cleanup hoisting test (NFC).
Tobias Gysi [Thu, 25 Nov 2021 10:42:09 +0000 (10:42 +0000)]
[mlir][linalg] Cleanup hoisting test (NFC).

Rename the check prefixes to HOIST21 and HOIST32 to clarify the different flag configurations.

Depends On D114438

Reviewed By: nicolasvasilache

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

2 years ago[mlir][linalg] Perform checks early in hoist padding.
Tobias Gysi [Thu, 25 Nov 2021 10:37:00 +0000 (10:37 +0000)]
[mlir][linalg] Perform checks early in hoist padding.

Instead of checking for unexpected operations (any operation with a region except for scf::For and `padTensorOp` or operations with a memory effect) while cloning the packing loop nest perform the checks early. Update `dropNonIndexDependencies` to check for unexpected operations. Additionally, check all of these operations have index type operands only.

Depends On D114428

Reviewed By: nicolasvasilache

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

2 years ago[mlir][linalg] Limit hoist padding to constant paddings.
Tobias Gysi [Thu, 25 Nov 2021 10:31:19 +0000 (10:31 +0000)]
[mlir][linalg] Limit hoist padding to constant paddings.

Limit hoist padding to pad tensor ops that depend only on a constant value. Supporting arbitrary padding values that depend on computations part of the backward slice to hoist require complex analysis to ensure the computation can be hoisted.

Depends On D114420

Reviewed By: nicolasvasilache

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

2 years ago[mlir][linalg] Add backward slice filtering in hoist padding.
Tobias Gysi [Thu, 25 Nov 2021 10:23:28 +0000 (10:23 +0000)]
[mlir][linalg] Add backward slice filtering in hoist padding.

Adapt hoist padding to filter the backward slice before cloning the packing loop nest. The filtering removes all operations that are not used to index the hoisted pad tensor op and its extract slice op. The filtering is needed to support the more complex loop nests created after fusion. For example, fusing the producer of an output operand can added linalg ops and pad tensor ops to the backward slice. These operations have regions and currently prevent hoisting.

The following example demonstrates the effect of the newly introduced `dropNonIndexDependencies` method that filters the backward slice:
```
%source = linalg.fill(%cst, %arg0)
scf.for %i
  %unrelated = linalg.fill(%cst, %arg1)    // not used to index %source!
  scf.for %j (%arg2 = %unrelated)
    scf.for %k                             // not used to index %source!
      %ubi = affine.min #map(%i)
      %ubj = affine.min #map(%j)
      %slice = tensor.extract_slice %source [%i, %j] [%ubi, %ubj]
      %padded_slice = linalg.pad_tensor %slice
```
dropNonIndexDependencies(%padded_slice, %slice)
removes [scf.for %k, linalg.fill(%cst, %arg1)] from backwardSlice.

Depends On D114175

Reviewed By: nicolasvasilache

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

2 years ago[clangd] Add ObjC method support to prepareCallHierarchy
Sheldon Neuberger [Thu, 25 Nov 2021 10:22:56 +0000 (11:22 +0100)]
[clangd] Add ObjC method support to prepareCallHierarchy

This fixes "textDocument/prepareCallHierarchy" in clangd for ObjC methods. Details at https://github.com/clangd/vscode-clangd/issues/247.

clangd uses Decl::isFunctionOrFunctionTemplate to check if the decl given in a prepareCallHierarchy request is eligible for prepareCallHierarchy. We change to use isFunctionOrMethod which includes functions and ObjC methods.

Reviewed By: kadircet

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

2 years ago[SDAG] Allow Unknown sizes when refining MMO alignments. NFC
David Green [Thu, 25 Nov 2021 10:19:29 +0000 (10:19 +0000)]
[SDAG] Allow Unknown sizes when refining MMO alignments. NFC

The changes in D113888 / 32b6c17b29079e7d altered the memory size of a
masked store, as it will store an unknown number of bytes not the full
vector size. We can have situations where the masked stores is legalized
and then turned to a normal store, as the mask is known to be all ones.
This creates a store with an unknown size MMO that was hitting this
assert.

The store created can be given a better size in a followup patch. This
currently adjusts the assert to handle unknown sizes.

2 years ago[mlir][linalg][bufferize][NFC] Move SCF interface impl to new build target
Matthias Springer [Thu, 25 Nov 2021 08:56:16 +0000 (17:56 +0900)]
[mlir][linalg][bufferize][NFC] Move SCF interface impl to new build target

This makes ComprehensiveBufferize entirely independent of the SCF dialect.

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

2 years agoRevert "[mlir][SCF] Further simplify affine maps during `for-loop-canonicalization`"
Alexander Belyaev [Thu, 25 Nov 2021 09:53:29 +0000 (10:53 +0100)]
Revert "[mlir][SCF] Further simplify affine maps during `for-loop-canonicalization`"

This reverts commit ee1bf186723abb933b2c337e589c5958167f3cbe.

It breaks IREE lowering. Reverting the commit for now while we
investigate what's going on.

2 years ago[clang][driver] Add -fplugin-arg- to pass arguments to plugins
Timm Bäder [Thu, 4 Nov 2021 16:40:51 +0000 (17:40 +0100)]
[clang][driver] Add -fplugin-arg- to pass arguments to plugins

From GCC's manpage:
-fplugin-arg-name-key=value
   Define an argument called key with a value of value for the
   plugin called name.

Since we don't have a key-value pair similar to gcc's plugin_argument
struct, simply accept key=value here anyway and pass it along as-is to
plugins.

This translates to the already existing '-plugin-arg-pluginname arg'
that clang cc1 accepts.

There is an ambiguity here because in clang, both the plugin name
as well as the option name can contain dashes, so when e.g. passing

 -fplugin-arg-foo-bar-foo

it is not clear whether the plugin is foo-bar and the option is foo,
or the plugin is foo and the option is bar-foo. GCC solves this by
interpreting all dashes as part of the option name. So dashes can't be
part of the plugin name in this case.

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

2 years ago[mlir][spirv] arith::RemSIOp OpenCL lowering
Butygin [Thu, 28 Oct 2021 16:04:35 +0000 (19:04 +0300)]
[mlir][spirv] arith::RemSIOp OpenCL lowering

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

2 years ago[clangd] Disable hicpp-invalid-access-moved inside clangd
Kadir Cetinkaya [Thu, 25 Nov 2021 09:27:34 +0000 (10:27 +0100)]
[clangd] Disable hicpp-invalid-access-moved inside clangd

2 years ago[mlir][spirv] Float atomics should not imply Shader
Butygin [Thu, 28 Oct 2021 16:04:35 +0000 (19:04 +0300)]
[mlir][spirv] Float atomics should not imply Shader

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

2 years ago[mlir][interfaces] Add insideMutuallyExclusiveRegions helper
Matthias Springer [Thu, 25 Nov 2021 08:42:08 +0000 (17:42 +0900)]
[mlir][interfaces] Add insideMutuallyExclusiveRegions helper

Add a helper function to ControlFlowInterfaces for checking if two ops
are in mutually exclusive regions according to RegionBranchOpInterface.

Utilize this new helper in Linalg ComprehensiveBufferize. This makes the
analysis independent of the SCF dialect and generalizes it to other ops
that implement RegionBranchOpInterface.

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

2 years ago[clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsO...
mydeveloperday [Thu, 25 Nov 2021 08:30:31 +0000 (08:30 +0000)]
[clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

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

Using the MultiLine setting for BraceWrapping.AfterControlStatement appears to disable AllowShortFunctionsOnASingleLine, even in cases without any control statements

Reviewed By: HazardyKnusperkeks, curdeius

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

2 years agoRevert "[clang][AST] Check context of record in structural equivalence."
Balázs Kéri [Thu, 25 Nov 2021 08:31:41 +0000 (09:31 +0100)]
Revert "[clang][AST] Check context of record in structural equivalence."

Revert commit 6b96b2a0bf65ff838d4dbf909a5120d4d1083e29 because Windows
test failure.

2 years ago[lldb] Fix TestFileHandle.py
Pavel Labath [Thu, 25 Nov 2021 07:56:45 +0000 (08:56 +0100)]
[lldb] Fix TestFileHandle.py

- remove the decorator which is no longer available in main
- remove dependence on revision number, which are not available in all
  builds

2 years ago[ELF] Emit DF_STATIC_TLS only for -shared
Fangrui Song [Thu, 25 Nov 2021 07:17:13 +0000 (23:17 -0800)]
[ELF] Emit DF_STATIC_TLS only for -shared

This matches GNU ld and saves 2 words for executables.

2 years ago[ELF] Rename hasStaticTlsModel to hasTlsIe
Fangrui Song [Thu, 25 Nov 2021 05:06:04 +0000 (21:06 -0800)]
[ELF] Rename hasStaticTlsModel to hasTlsIe

and remove unneeded atomic.

2 years ago[ELF] Remove unneeded DF_STATIC_TLS for EM_386 local-exec TLS
Fangrui Song [Thu, 25 Nov 2021 04:43:58 +0000 (20:43 -0800)]
[ELF] Remove unneeded DF_STATIC_TLS for EM_386 local-exec TLS

which is also untested.

2 years ago[MLIR] Rename test/python/dialects/math.py -> math_dialect.py
Uday Bondhugula [Thu, 25 Nov 2021 03:26:19 +0000 (08:56 +0530)]
[MLIR] Rename test/python/dialects/math.py -> math_dialect.py

Rename test/python/dialects/math.py -> math_dialect.py to avoid a
collision with a Python standard package of the same name. These test
scripts are run by path and are not part of a package. Python apparently
implicitly adds the containing directory to its PYTHONPATH. As such,
test scripts with common names run the risk of conflicting with global
names and resolution of an import for the latter happens to the former.

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

2 years ago[mlir][SCF] Further simplify affine maps during `for-loop-canonicalization`
Matthias Springer [Thu, 25 Nov 2021 03:43:35 +0000 (12:43 +0900)]
[mlir][SCF] Further simplify affine maps during `for-loop-canonicalization`

* Implement `FlatAffineConstraints::getConstantBound(EQ)`.
* Inject a simpler constraint for loops that have at most 1 iteration.
* Taking into account constant EQ bounds of FlatAffineConstraint dims/symbols during canonicalization of the resulting affine map in `canonicalizeMinMaxOp`.

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

2 years ago[mlir][SCF] Fix off-by-one bug in affine analysis
Matthias Springer [Thu, 25 Nov 2021 03:36:12 +0000 (12:36 +0900)]
[mlir][SCF] Fix off-by-one bug in affine analysis

This change is NFC. There were two issues when passing/reading upper bounds into/from FlatAffineConstraints that negate each other, so the bug was not apparent. However, it made debugging harder because some constraints in the FlatAffineConstraints were off by one when dumping all constraints.

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

2 years ago[NFC] Improve debug message in getAsIntegerSet
Uday Bondhugula [Wed, 24 Nov 2021 08:12:20 +0000 (13:42 +0530)]
[NFC] Improve debug message in getAsIntegerSet

Improve debug message in getAsIntegerSet. Add missing trailing new line
and position info.

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

2 years agoGlobalISel: remove assert that memcpy Src and Dst addrspace must be identical
Jameson Nash [Thu, 21 Oct 2021 15:58:02 +0000 (11:58 -0400)]
GlobalISel: remove assert that memcpy Src and Dst addrspace must be identical

The LangRef does not require these arguments to have the same type.

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

2 years ago[mlir][linalg][bufferize][NFC] Move arith interface impl to new build target
Matthias Springer [Thu, 25 Nov 2021 01:06:16 +0000 (10:06 +0900)]
[mlir][linalg][bufferize][NFC] Move arith interface impl to new build target

This makes ComprehensiveBufferize entirely independent of the arith dialect.

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

2 years agoPromote readability by factoring out creation of min/max operation. Remove unnecessar...
bakhtiyar [Thu, 25 Nov 2021 00:11:48 +0000 (16:11 -0800)]
Promote readability by factoring out creation of min/max operation. Remove unnecessary divisions.

Reviewed By: ezhulenev

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

2 years ago[mlir][spirv] Change the return type for {Min|Max}VersionBase
Lei Zhang [Wed, 24 Nov 2021 22:28:58 +0000 (17:28 -0500)]
[mlir][spirv] Change the return type for {Min|Max}VersionBase

For synthesizing an op's implementation of the generated interface
from {Min|Max}Version, we need to define an `initializer` and
`mergeAction`. The `initializer` specifies the initial version,
and `mergeAction` specifies how version specifications from
different parts of the op should be merged to generate a final
version requirements.

Previously we use the specified version enum as the type for both
the initializer and thus the final return type. This means we need
to perform `static_cast` over some hopefully not used number (`~0u`)
as the initializer. This is quite opaque and sort of not guaranteed
to work. Also, there are ops that have an enum attribute where some
values declare version requirements (e.g., enumerant `B` requires
v1.1+) but some not (e.g., enumerant `A` requires nothing). Then a
concrete op instance with `A` will still declare it implements the
version interface (because interface implementation is static for
an op) but actually theirs no requirements for version.

So this commit changes to use an more explicit `llvm::Optional`
to wrap around the returned version enum.  This should make it
more clear.

Reviewed By: jpienaar

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

2 years ago[libc++] Value-initialize unique_ptr's deleter_type
Johan Berg [Wed, 24 Nov 2021 22:30:50 +0000 (17:30 -0500)]
[libc++] Value-initialize unique_ptr's deleter_type

According to the C++ standard, the stored pointer and the stored deleter
should be value-initialized.

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

2 years ago[LLVM][NFC]Inclusive language: remove occurances of sanity check/test from llvm
Zarko Todorovski [Wed, 24 Nov 2021 17:47:59 +0000 (12:47 -0500)]
[LLVM][NFC]Inclusive language: remove occurances of sanity check/test from llvm

Part of work to use more inclusive language in clang/llvm. Rewording
some comments and change function and variable names.

2 years agoDWARFVerifier: Don't parse all units twice
David Blaikie [Wed, 24 Nov 2021 21:47:42 +0000 (13:47 -0800)]
DWARFVerifier: Don't parse all units twice

Introduced/discussed in https://reviews.llvm.org/D38719

The header validation logic was also explicitly building the DWARFUnits
to validate. But then other calls, like "Units.getUnitForOffset" creates
the DWARFUnits again in the DWARFContext proper - so, let's avoid
creating the DWARFUnits twice by walking the DWARFContext's units rather
than building a new list explicitly.

This does reduce some verifier power - it means that any unit with a
header parsing failure won't get further validation, whereas the
verifier-created units were getting some further validation despite
invalid headers. I don't think this is a great loss/seems "right" in
some ways to me that if the header's invalid we should stop there.

Exposing the raw DWARFUnitVectors from DWARFContext feels a bit
sub-optimal, but gave simple access to the getUnitForOffset to keep the
rest of the code fairly similar.

2 years ago[libc++] Fix backdeployment annotations for std::filesystem
Louis Dionne [Tue, 23 Nov 2021 17:26:53 +0000 (12:26 -0500)]
[libc++] Fix backdeployment annotations for std::filesystem

In 1fa27f2a10e8, we made <filesystem>'s iterator types model concepts
from <ranges>, but we forgot to add the appropriate availability
annotations. This broke back-deployment to platforms that don't have
<filesystem> for which we have availability annotations.

For some reason, this wasn't caught by our back-deployment CI.
I believe this is due to the fact that we use a slightly older
compiler in the CI, and perhaps that compiler does not honour
our `#pragma clang attribute push` properly.

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

2 years ago[CVP] Add a cl::opt for canonicalization of signed relational comparisons
Artur Pilipenko [Wed, 24 Nov 2021 21:48:43 +0000 (13:48 -0800)]
[CVP] Add a cl::opt for canonicalization of signed relational comparisons

This canonicalization breaks the ability to discard checks in some cases.
Add a command line option to disable it. This option is on by default,
so the change is NFC.

See for details:
https://reviews.llvm.org/D112895#3149487

2 years ago[libc++] Handle armv7m in two architecture dependent tests
Louis Dionne [Wed, 24 Nov 2021 21:38:55 +0000 (16:38 -0500)]
[libc++] Handle armv7m in two architecture dependent tests

2 years ago[libc++] Fix two tests that were failing in freestanding mode
Louis Dionne [Wed, 24 Nov 2021 21:37:54 +0000 (16:37 -0500)]
[libc++] Fix two tests that were failing in freestanding mode

We were defining `main()` but never returning from it.

2 years ago[ConstraintElimination] Add additional tests.
Florian Hahn [Wed, 24 Nov 2021 21:32:49 +0000 (21:32 +0000)]
[ConstraintElimination] Add additional tests.

2 years agoMove some tests from instcombine to phase ordering. NFC.
Stanislav Mekhanoshin [Wed, 24 Nov 2021 20:17:26 +0000 (12:17 -0800)]
Move some tests from instcombine to phase ordering. NFC.

Tests from D113216 are now handled by Reassociate, GVN and BDCE
passes after D114462. Moving into phase ordering instead of
instcombine.

2 years ago[SLP]Improve analysis/emission of vector operands for alternate nodes.
Alexey Bataev [Wed, 17 Nov 2021 16:42:33 +0000 (08:42 -0800)]
[SLP]Improve analysis/emission of vector operands for alternate nodes.

Compiler has an analysis for perfect diamond matching but it does not
support nodes with main/alternate opcodes. The problem is that the
scalars themselves are different and might not match directly with other
nodes, but operands and main/alternate opcodes might match and compiler
might reuse some previously emitted vector instructions. Need to include
this analysis in the cost model and actual vector instructions emission
process.

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

2 years agoHeaders: exclude `#include_next <stdatomic.h>` on MSVC
Saleem Abdulrasool [Wed, 24 Nov 2021 18:44:38 +0000 (10:44 -0800)]
Headers: exclude `#include_next <stdatomic.h>` on MSVC

The 14.31.30818 toolset has the following in the `stdatomic.h`:
~~~
 #ifndef __cplusplus
 #error <stdatomic.h> is not yet supported when compiling as C, but this is planned for a future release.
 #endif
~~~

This results in clang failing to build existing code which relied on
`stdatomic.h` in C mode on Windows.  Simply fallback to the clang header
until that header is available as a complete implementation.

2 years agocfi: fix more -Wformat warnings
Dimitry Andric [Tue, 23 Nov 2021 20:06:45 +0000 (21:06 +0100)]
cfi: fix more -Wformat warnings

Building cfi with recent clang on a 64-bit system results in the
following warnings:

    compiler-rt/lib/cfi/cfi.cpp:233:64: warning: format specifies type 'void *' but the argument has type '__sanitizer::uptr' (aka 'unsigned long') [-Wformat]
        VReport(1, "Can not handle: symtab > strtab (%p > %zx)\n", symtab, strtab);
                                                     ~~            ^~~~~~
                                                     %lu
    compiler-rt/lib/sanitizer_common/sanitizer_common.h:231:46: note: expanded from macro 'VReport'
        if ((uptr)Verbosity() >= (level)) Report(__VA_ARGS__); \
                                                 ^~~~~~~~~~~
    compiler-rt/lib/cfi/cfi.cpp:253:59: warning: format specifies type 'void *' but the argument has type '__sanitizer::uptr' (aka 'unsigned long') [-Wformat]
        VReport(1, "Can not handle: symtab %p, strtab %zx\n", symtab, strtab);
                                           ~~                 ^~~~~~
                                           %lu
    compiler-rt/lib/sanitizer_common/sanitizer_common.h:231:46: note: expanded from macro 'VReport'
        if ((uptr)Verbosity() >= (level)) Report(__VA_ARGS__); \
                                                 ^~~~~~~~~~~

Since `__sanitizer::uptr` has the same size as `size_t`, consistently
use `%z` as a printf specifier.

Reviewed By: vitalybuka

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

2 years ago[LV] Use OrigLoop instead of induction to get function. (NFC)
Florian Hahn [Wed, 24 Nov 2021 20:17:43 +0000 (20:17 +0000)]
[LV] Use OrigLoop instead of induction to get function. (NFC)

Upcoming changes will result in Induction not being set/used in some
cases. Use OrigLoop to get the function instead.

2 years ago[DebugInfo][InstrRef] Cope with win32 calls changing SP in LiveDebugValues
Jeremy Morse [Wed, 24 Nov 2021 17:32:55 +0000 (17:32 +0000)]
[DebugInfo][InstrRef] Cope with win32 calls changing SP in LiveDebugValues

Almost all of the time, call instructions don't actually lead to SP being
different after they return. An exception is win32's _chkstk, which which
implements stack probes. We need to recognise that as modifying SP, so
that copies of the value are tracked as distinct vla pointers.

This patch adds a target frame-lowering hook to see whether stack probe
functions will modify the stack pointer, store that in an internal flag,
and if it's true then scan CALL instructions to see whether they're a
stack probe. If they are, recognise them as defining a new stack-pointer
value.

The added test exercises this behaviour: two calls to _chkstk should be
considered as producing two different values.

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

2 years ago[mlir][linalg] Simplify padding test (NFC).
Tobias Gysi [Wed, 24 Nov 2021 19:21:18 +0000 (19:21 +0000)]
[mlir][linalg] Simplify padding test (NFC).

The padding tests previously contained the tile loops. This revision removes the tile loops since padding itself does not consider the loops. Instead the induction variables are passed in as function arguments which promotes them to symbols in the affine expressions. Note that the pad-and-hoist.mlir test still exercises padding in the context of the full loop nest.

Depends On D114175

Reviewed By: nicolasvasilache

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

2 years ago[NFC][clang]Inclusive language: remove remaining uses of sanity
Zarko Todorovski [Wed, 24 Nov 2021 19:16:47 +0000 (14:16 -0500)]
[NFC][clang]Inclusive language: remove remaining uses of sanity

Missed some uses of sanity check in previous commits.

2 years ago[mlir][linalg] Add makeComposedPadHighOp.
Tobias Gysi [Wed, 24 Nov 2021 19:12:39 +0000 (19:12 +0000)]
[mlir][linalg] Add makeComposedPadHighOp.

Add the makeComposedPadHighOp method which creates a new PadTensorOp if necessary. If the source to pad is actually the result of a sequence of padded LinalgOps, the method checks if padding is needed or if we can use the padded result of the padded LinalgOp sequence directly.

Example:
```
%0 = tensor.extract_slice %arg0 [%iv0, %iv1] [%sz0, %sz1]
%1 = linalg.pad_tensor %0 low[0, 0] high[...] { linalg.yield %cst }
%2 = linalg.matmul ins(...) outs(%1)
%3 = tensor.extract_slice %2 [0, 0] [%sz0, %sz1]
```
when padding %3 return %2 instead of introducing
```
%4 = linalg.pad_tensor %3 low[0, 0] high[...] { linalg.yield %cst }
```

Depends On D114161

Reviewed By: nicolasvasilache, pifon2a

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

2 years agoRevert "[InstCombine] (~(a | b) & c) | ~(c | (a ^ b)) -> ~((a | b) & (c | (b ^ a)))"
Stanislav Mekhanoshin [Wed, 24 Nov 2021 18:58:05 +0000 (10:58 -0800)]
Revert "[InstCombine] (~(a | b) & c) | ~(c | (a ^ b)) -> ~((a | b) & (c | (b ^ a)))"

This reverts commit c407769f5e6c81d56de0b251aed5750a16a7651c.

2 years ago[mlir][linalg] Update failure conditions for padOperandToSmallestStaticBoundingBox.
Tobias Gysi [Wed, 24 Nov 2021 19:03:41 +0000 (19:03 +0000)]
[mlir][linalg] Update failure conditions for padOperandToSmallestStaticBoundingBox.

Change the failure condition of padOperandToSmallestStaticBoundingBox to never fail if the operand is already statically sized.

In particular:
- if the padding value computation fails -> return failure if the operand shape is dynamic and success if it is static.
- if there is no extract slice op -> return failure if the operand shape is dynamic and success if it is static.

The latter change prevents padding from failure if the output operand passed by iteration argument is statically sized since in this case the extract / insert slice pairs are removed by canonicalization.

Depends On D114153

Reviewed By: nicolasvasilache

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

2 years ago[NFC][Clang][test] Inclusive language: Remove and rephrase uses of sanity test/check...
Zarko Todorovski [Wed, 24 Nov 2021 14:52:01 +0000 (09:52 -0500)]
[NFC][Clang][test] Inclusive language: Remove and rephrase uses of sanity test/check in clang/test

Part of work to use more inclusive terms in clang/llvm.

2 years agoRevert "[ThreadPool] Do not return shared futures."
Florian Hahn [Wed, 24 Nov 2021 19:01:47 +0000 (19:01 +0000)]
Revert "[ThreadPool] Do not return shared futures."

This reverts commit a5fff58781f30ff3fd7a3f56948552cf7b8842bb.

The offending commit broke building with LLVM_ENABLE_THREADS=OFF.

2 years ago[PowerPC] Add missed clang portion of c933c2eb3346
Nemanja Ivanovic [Wed, 24 Nov 2021 18:41:06 +0000 (12:41 -0600)]
[PowerPC] Add missed clang portion of c933c2eb3346

The clang portion of c933c2eb3346 was missed as I made
some kind of mistake squashing the commits with git.
This patch just adds those.

The original review: https://reviews.llvm.org/D114088

2 years ago[mlir][Linalg] Remove alloc/dealloc pair as a callback.
MaheshRavishankar [Wed, 24 Nov 2021 17:26:11 +0000 (09:26 -0800)]
[mlir][Linalg] Remove alloc/dealloc pair as a callback.

The alloc dealloc pair generation callback is really central to the
bufferization algorithm, it modifies the state in a way that affects
correctness. This is not really a configurable option. Moving it to
BufferizationState removes what was probably the reason it was added
as a callback.

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

2 years ago[NFC][AIX]Disable precompiled module file tests on AIX
Steven Wan [Wed, 24 Nov 2021 18:15:52 +0000 (13:15 -0500)]
[NFC][AIX]Disable precompiled module file tests on AIX

The PCH reader looks for `__clangast` section in the precompiled module file, which is not present in the file on AIX, and we don't support writing this custom section in XCOFF yet.

Reviewed By: daltenty

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

2 years ago[ASan] Moved __asan_test_only_reported_buggy_pointer to ReportGenericError, which...
Kirill Stoimenov [Tue, 23 Nov 2021 23:58:17 +0000 (15:58 -0800)]
[ASan] Moved __asan_test_only_reported_buggy_pointer to ReportGenericError, which is needed for shared optimzied callback tests.

Reviewed By: vitalybuka

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

2 years ago[DebugInfo][InstrRef] Ignore SP clobbers on call instructions even more
Jeremy Morse [Wed, 24 Nov 2021 17:21:20 +0000 (17:21 +0000)]
[DebugInfo][InstrRef] Ignore SP clobbers on call instructions even more

Avoid un-necessarily recreating DBG_VALUEs on call instructions.

In LiveDebugvalues we choose to ignore any clobbers of SP by call
instructions, as they're irrelevant to our model of the machine. We
currently do so for tracking register values (MTracker); do the same for
tracking variable locations (TTracker).

Test modified to endure that a duplicate DBG_VALUE is not created after the
call in struction in this test.

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

2 years ago[DebugInfo] Reflect switched variable order from instruction referencing
Jeremy Morse [Wed, 24 Nov 2021 17:05:39 +0000 (17:05 +0000)]
[DebugInfo] Reflect switched variable order from instruction referencing

Enabling instruction referencing causes a few variable locations to switch
order -- i.e., they switch position in the output DWARF, or sometimes the
order of DBG_VALUEs. Update a few tests to reflect this.

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

2 years ago[AArch64] Add regression test for D114354
Simon Pilgrim [Wed, 24 Nov 2021 16:47:42 +0000 (16:47 +0000)]
[AArch64] Add regression test for D114354

2 years ago[NFC][LAA] Precommit tests for forked pointers
Graham Hunter [Thu, 12 Aug 2021 14:38:13 +0000 (15:38 +0100)]
[NFC][LAA] Precommit tests for forked pointers

Precommit for https://reviews.llvm.org/D108699

2 years ago[clang][AST] Check context of record in structural equivalence.
Balázs Kéri [Wed, 24 Nov 2021 15:46:47 +0000 (16:46 +0100)]
[clang][AST] Check context of record in structural equivalence.

The AST structural equivalence check did not differentiate between
a struct and a struct with same name in different namespace. When
type of a member is checked it is possible to encounter such a case
and wrongly decide that the types are similar. This problem is fixed
by check for the namespaces of a record declaration.

Reviewed By: martong

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

2 years agoFixed use of -o and -k in LLDB under Windows when statically compiled with vcruntime.
Levon Ter-Grigoryan [Wed, 24 Nov 2021 16:13:48 +0000 (16:13 +0000)]
Fixed use of -o and -k in LLDB under Windows when statically compiled with vcruntime.

Right now if the LLDB is compiled under the windows with static vcruntime library, the -o and -k commands will not work.

The problem is that the LLDB create FILE* in lldb.exe and pass it to liblldb.dll which is an object from CRT.
Since the CRT is statically linked each of these module has its own copy of the CRT with it's own global state and the LLDB should not share CRT objects between them.

In this change I moved the logic of creating FILE* out of commands stream from Driver class to SBDebugger.
To do this I added new method: SBError SBDebugger::SetInputStream(SBStream &stream)

Command to build the LLDB:
cmake -G Ninja -DLLVM_ENABLE_PROJECTS="clang;lldb;libcxx"  -DLLVM_USE_CRT_RELEASE="MT" -DLLVM_USE_CRT_MINSIZEREL="MT" -DLLVM_USE_CRT_RELWITHDEBINFO="MT" -DP
YTHON_HOME:FILEPATH=C:/Python38 -DCMAKE_C_COMPILER:STRING=cl.exe -DCMAKE_CXX_COMPILER:STRING=cl.exe ../llvm

Command which will fail:
lldb.exe -o help

See discord discussion for more details: https://discord.com/channels/636084430946959380/636732809708306432/854629125398724628
This revision is for the further discussion.

Reviewed By: teemperor

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

2 years agotsan: include internal allocator into deadlock detection
Dmitry Vyukov [Wed, 24 Nov 2021 12:59:42 +0000 (13:59 +0100)]
tsan: include internal allocator into deadlock detection

Now that we lock the internal allocator around fork,
it's possible it will create additional deadlocks.
Add a fake mutex that substitutes the internal allocator
for the purposes of deadlock detection.

Depends on D114531.

Reviewed By: melver

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

2 years agotsan: lock internal allocator around fork
Dmitry Vyukov [Wed, 24 Nov 2021 11:54:06 +0000 (12:54 +0100)]
tsan: lock internal allocator around fork

There is a small chance that the internal allocator is locked
during fork and then the new process is created with locked
internal allocator and any attempts to use it will deadlock.
For example, if detected a suppressed race in the parent during fork
and then another suppressed race after the fork.
This becomes much more likely with the new tsan runtime
as it uses the internal allocator for more things.

Reviewed By: melver

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

2 years ago[mlir][Vector] NFC - Apply some clangd suggested fixes.
Nicolas Vasilache [Wed, 24 Nov 2021 15:54:25 +0000 (15:54 +0000)]
[mlir][Vector] NFC - Apply some clangd suggested fixes.

2 years ago[LoopAccessAnalysis][SVE] Bail out for scalable vectors
Peter Waller [Thu, 18 Nov 2021 13:27:54 +0000 (13:27 +0000)]
[LoopAccessAnalysis][SVE] Bail out for scalable vectors

The supplied test case, reduced from real world code, crashes with a
'Invalid size request on a scalable vector.' error.

Since it's similar in spirit to an existing LAA test, rename the file to
generalize it to both.

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

2 years ago[gn build] Port 3b7244808405
LLVM GN Syncbot [Wed, 24 Nov 2021 15:48:50 +0000 (15:48 +0000)]
[gn build] Port 3b7244808405

2 years ago[clang-tidy] Add unit tests for `DeclRefExprUtils`.
Clement Courbet [Wed, 24 Nov 2021 15:22:54 +0000 (16:22 +0100)]
[clang-tidy] Add unit tests for `DeclRefExprUtils`.

In preparation for D114539.

2 years ago[NFC][X86] Inclusive language: Rename master label in x86-shrink-wrapping.ll
Quinn Pham [Mon, 15 Nov 2021 21:42:04 +0000 (15:42 -0600)]
[NFC][X86] Inclusive language: Rename master label in x86-shrink-wrapping.ll

[NFC] As part of using inclusive language within the llvm project, this patch
renames the master label in `x86-shrink-wrapping.ll` to main.

Reviewed By: ZarkoCA

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

2 years agoHave yaml2obj describe all options in --help
Paul Robinson [Wed, 24 Nov 2021 15:17:58 +0000 (07:17 -0800)]
Have yaml2obj describe all options in --help

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

2 years ago[lldb] Move GetSupportedArchitectureAtIndex to PlatformDarwin
Pavel Labath [Wed, 24 Nov 2021 14:47:20 +0000 (15:47 +0100)]
[lldb] Move GetSupportedArchitectureAtIndex to PlatformDarwin

All other platforms use GetSupportedArchitectures now.

2 years ago[X86][MS] Add test cases to show wrong alignment in vector variable arguments. NFC
Phoebe Wang [Wed, 24 Nov 2021 14:38:20 +0000 (22:38 +0800)]
[X86][MS] Add test cases to show wrong alignment in vector variable arguments. NFC

2 years ago[X86][Costmodel] `getReplicationShuffleCost()`: promote 1 bit-wide elements to 32...
Roman Lebedev [Wed, 24 Nov 2021 14:23:15 +0000 (17:23 +0300)]
[X86][Costmodel] `getReplicationShuffleCost()`: promote 1 bit-wide elements to 32 bit when have AVX512DQ

I believe, this effectively completes `X86TTIImpl::getReplicationShuffleCost()`
for AVX512, other than the question of handling plain AVX512F,
where we end up with some really ugly "shuffles",
but then is there any CPU's that support AVX512, but not AVX512DQ/AVX512BW?

Reviewed By: RKSimon

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

2 years ago[libc] Fix wrong type for load/store of Repeated elements
Guillaume Chatelet [Wed, 24 Nov 2021 14:13:13 +0000 (14:13 +0000)]
[libc] Fix wrong type for load/store of Repeated elements

2 years ago[VPlan] Remove unused VPInstruction constructor. (NFC)
Florian Hahn [Wed, 24 Nov 2021 14:06:00 +0000 (14:06 +0000)]
[VPlan] Remove unused VPInstruction constructor. (NFC)

VPInstruction inherits from VPValue, so the constructor taking
ArrayRef<VPValue*> covers all cases that would be covered by the removed
constructor.

2 years ago[AArch64][SVE] Recognize all ones mask during fixed mask generation
Bradley Smith [Mon, 22 Nov 2021 17:01:08 +0000 (17:01 +0000)]
[AArch64][SVE] Recognize all ones mask during fixed mask generation

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

2 years agoRevert "[DAG] SimplifyDemandedBits - simplify rotl/rotr to shl/srl"
Benjamin Kramer [Wed, 24 Nov 2021 13:42:54 +0000 (14:42 +0100)]
Revert "[DAG] SimplifyDemandedBits - simplify rotl/rotr to shl/srl"

This reverts commit 3cf4a2c6203b5777d56f0c04fb743b85a041d6f9.

It makes llc hang on the following test case.
```
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"

define dso_local void @_PyUnicode_EncodeUTF16() local_unnamed_addr #0 {
entry:
  br label %while.body117.i

while.body117.i:                                  ; preds = %cleanup149.i, %entry
  %out.6269.i = phi i16* [ undef, %cleanup149.i ], [ undef, %entry ]
  %0 = load i16, i16* undef, align 2
  %1 = icmp eq i16 undef, -10240
  br i1 %1, label %fail.i, label %cleanup149.i

cleanup149.i:                                     ; preds = %while.body117.i
  %or130.i = call i16 @llvm.bswap.i16(i16 %0) #2
  store i16 %or130.i, i16* %out.6269.i, align 2
  br label %while.body117.i

fail.i:                                           ; preds = %while.body117.i
  ret void
}

; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
declare i16 @llvm.bswap.i16(i16) #1

attributes #0 = { "target-features"="+neon,+v8a" }
attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
attributes #2 = { mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" }
```

2 years ago[LV] Use patterns in some induction tests, to make more robust. (NFC)
Florian Hahn [Wed, 24 Nov 2021 13:32:24 +0000 (13:32 +0000)]
[LV] Use patterns in some induction tests, to make more robust. (NFC)

2 years ago[X86] Add BMI test coverage for for or-lea with no common bits tests
Simon Pilgrim [Wed, 24 Nov 2021 13:24:27 +0000 (13:24 +0000)]
[X86] Add BMI test coverage for for or-lea with no common bits tests

Ensure D113970 handles andnot patterns as well.

2 years ago[X86] Add D113970 tests cases for or-lea with no common bits.
Omer Aviram [Wed, 24 Nov 2021 13:22:15 +0000 (13:22 +0000)]
[X86] Add D113970 tests cases for or-lea with no common bits.

Added tests are permutations of the pattern: (X & ~M) or (Y & M).

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

2 years ago[InstSimplify] fold xor logic of 2 variables, part 2
Sanjay Patel [Tue, 23 Nov 2021 22:19:12 +0000 (17:19 -0500)]
[InstSimplify] fold xor logic of 2 variables, part 2

(~a & b) ^ (a | b) --> a

This is the swapped and/or (Demorgan?) sibling fold for
the fold added with D114462 ( 892648b18a8c ).

This case is easier to specify because we are returning
a root value, not a 'not':
https://alive2.llvm.org/ce/z/SRzj4f

2 years ago[InstSimplify] add tests for xor logic; NFC
Sanjay Patel [Tue, 23 Nov 2021 22:07:31 +0000 (17:07 -0500)]
[InstSimplify] add tests for xor logic; NFC

2 years ago[llvm-dwarfdump][Statistics] Handle LTO cases with cross CU referencing
Djordje Todorovic [Wed, 24 Nov 2021 12:46:35 +0000 (13:46 +0100)]
[llvm-dwarfdump][Statistics] Handle LTO cases with cross CU referencing

With link-time optimizations enabled, resulting DWARF mayend up containing
cross CU references (through the DW_AT_abstract_origin attribute).
Consider the following example:

// sum.c
__attribute__((always_inline)) int sum(int a, int b)
{
     return a + b;
}
// main.c
extern int sum(int, int);
int main()
{
     int a = 5, b = 10, c = sum(a, b);
     return 0;
}

Compiled as follows:

$ clang -g -flto -fuse-ld=lld main.c sum.c -o main

Results in the following DWARF:

-- sum.c CU: abstract instance tree
...
0x000000b0:   DW_TAG_subprogram
                DW_AT_name ("sum")
                DW_AT_decl_file ("sum.c")
                DW_AT_decl_line (1)
                DW_AT_prototyped (true)
                DW_AT_type (0x000000d3 "int")
                DW_AT_external (true)
                DW_AT_inline (DW_INL_inlined)

0x000000bc:     DW_TAG_formal_parameter
                  DW_AT_name ("a")
                  DW_AT_decl_file ("sum.c")
                  DW_AT_decl_line (1)
                  DW_AT_type (0x000000d3 "int")

0x000000c7:     DW_TAG_formal_parameter
                  DW_AT_name ("b")
                  DW_AT_decl_file ("sum.c")
                  DW_AT_decl_line (1)
                  DW_AT_type (0x000000d3 "int")
...
-- main.c CU: concrete inlined instance tree
...
0x0000006d:     DW_TAG_inlined_subroutine
                  DW_AT_abstract_origin (0x00000000000000b0 "sum")
                  DW_AT_low_pc (0x00000000002016ef)
                  DW_AT_high_pc (0x00000000002016f1)
                  DW_AT_call_file ("main.c")
                  DW_AT_call_line (5)
                  DW_AT_call_column (0x19)

0x00000081:       DW_TAG_formal_parameter
                    DW_AT_location (DW_OP_reg0 RAX)
                    DW_AT_abstract_origin (0x00000000000000bc "a")

0x00000088:       DW_TAG_formal_parameter
                    DW_AT_location (DW_OP_reg2 RCX)
                    DW_AT_abstract_origin (0x00000000000000c7 "b")
...

Note that each entry within the concrete inlined instance tree in
the main.c CU has a DW_AT_abstract_origin attribute which
refers to a corresponding entry within the abstract instance
tree in the sum.c CU.
llvm-dwarfdump --statistics did not properly report
DW_TAG_formal_parameters/DW_TAG_variables from concrete inlined
instance trees which had 0% location coverage and which
referred to a different CU, mainly because information about abstract
instance trees and their parameters/variables was stored
locally - just for the currently processed CU,
rather than globally - for all CUs.
In particular, if the concrete inlined instance tree from
the example above was to look like this
(i.e. parameter b has 0% location coverage, hence why it's missing):

0x0000006d:     DW_TAG_inlined_subroutine
                  DW_AT_abstract_origin (0x00000000000000b0 "sum")
                  DW_AT_low_pc (0x00000000002016ef)
                  DW_AT_high_pc (0x00000000002016f1)
                  DW_AT_call_file ("main.c")
                  DW_AT_call_line (5)
                  DW_AT_call_column (0x19)

0x00000081:       DW_TAG_formal_parameter
                    DW_AT_location (DW_OP_reg0 RAX)
                    DW_AT_abstract_origin (0x00000000000000bc "a")

llvm-dwarfdump --statistics would have not reported b as such.

Patch by Dimitrije Milosevic.

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

2 years ago[PowerPC] Provide XL-compatible vec_round implementation
Nemanja Ivanovic [Wed, 24 Nov 2021 10:34:01 +0000 (04:34 -0600)]
[PowerPC] Provide XL-compatible vec_round implementation

The XL implementation of vec_round for vector double uses
"round-to-nearest, ties to even" just as the vector float
`version does. However clang and gcc use "round-to-nearest-away"
for vector double and "round-to-nearest, ties to even"
for vector float.

The XL behaviour is implemented under the __XL_COMPAT_ALTIVEC__
macro similarly to other instances of incompatibility.

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

2 years ago[DebugInfo] Adjust x86 location-list tests for instruction referencing
Jeremy Morse [Wed, 24 Nov 2021 12:28:15 +0000 (12:28 +0000)]
[DebugInfo] Adjust x86 location-list tests for instruction referencing

This patch updates location lists in various x86 tests to reflect what
instruction referencing produces. There are two flavours of change:
 * Not following a register copy immediately, because instruction
   referencing can make some slightly smarter decisions,
 * Extended ranges, due to having additional information.

The register changes aren't that interesting, it's just a choice between
equally legitimate registers that instr-ref does differently. The extended
ranges are largely due to following stack restores better.

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

2 years agotsan: add another fork deadlock test
Dmitry Vyukov [Wed, 24 Nov 2021 08:44:08 +0000 (09:44 +0100)]
tsan: add another fork deadlock test

The test tries to provoke internal allocator to be locked during fork
and then force the child process to use the internal allocator.
This test sometimes deadlocks with the new tsan runtime.

Depends on D114514.

Reviewed By: melver

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

2 years agosanitizer_common: remove SANITIZER_USE_MALLOC
Dmitry Vyukov [Wed, 24 Nov 2021 08:39:05 +0000 (09:39 +0100)]
sanitizer_common: remove SANITIZER_USE_MALLOC

It was introduced in:
9cffc9550b75 tsan: allow to force use of __libc_malloc in sanitizer_common
and used in:
512a18e51819 tsan: add standalone deadlock detector
and later used for Go support.
But now both uses are gone. Nothing defines SANITIZER_USE_MALLOC.

Reviewed By: melver

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

2 years agoClean up clang-format tech debt.
Manuel Klimek [Wed, 24 Nov 2021 11:17:19 +0000 (12:17 +0100)]
Clean up clang-format tech debt.

Make all code go through FormatTokenSource instead of going around it, which
makes changes to TokenSource brittle.

Add LLVM_DEBUG in FormatTokenSource to be able to follow the token stream.

2 years ago[DebugInfo] Check both instr-ref and DBG_VALUE modes of sdag tests
Jeremy Morse [Wed, 24 Nov 2021 11:45:43 +0000 (11:45 +0000)]
[DebugInfo] Check both instr-ref and DBG_VALUE modes of sdag tests

In these test updates for instruction referencing, I've added specific
instr-ref RUN lines, and kep thte DBG_VALUE-based variable location check
lines too. This is because argument handling is really fiddly, and I figure
it's worth duplicating the testing to ensure it's definitely correct.

There's also dbg-value-superreg-copy2.mir, a dtest for where varaible
locations go when virtual registers are coalesced together. I don't think
there's an instruction referencing specific test for this, so have
duplicated that to for instruction referencing.

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

2 years ago[DAG] SimplifyDemandedBits - simplify rotl/rotr to shl/srl
Simon Pilgrim [Wed, 24 Nov 2021 11:28:28 +0000 (11:28 +0000)]
[DAG] SimplifyDemandedBits - simplify rotl/rotr to shl/srl

If we only demand bits from one half of a rotation pattern, see if we can simplify to a logical shift.

For the ARM rev16 patterns, I had to drop a fold to prevent srl(bswap()) -> rotr(bswap) -> srl(bswap) infinite loops. I've replaced this with an isel PatFrag which should do the same task.

https://alive2.llvm.org/ce/z/iroxki (rol -> shl by amt iff demanded bits has at least as many trailing zeros as the shift amount)
https://alive2.llvm.org/ce/z/4ez_U- (ror -> shl by revamt iff demanded bits has at least as many trailing zeros as the reverse shift amount)
https://alive2.llvm.org/ce/z/cD7dR- (ror -> lshr by amt iff demanded bits has at least as many leading zeros as the shift amount)
https://alive2.llvm.org/ce/z/_XGHtQ (rol -> lshr by revamt iff demanded bits has at least as many leading zeros as the reverse shift amount)

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