platform/upstream/llvm.git
3 years ago[libunwind] Compile with -Wunused-but-set-variable
Daniel Kiss [Wed, 11 Aug 2021 08:11:31 +0000 (10:11 +0200)]
[libunwind] Compile with -Wunused-but-set-variable

-Wunused-but-set-variable triggers a warning even the block of code is effectively dead.

Reviewed By: MaskRay

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

3 years ago[Arm][Unwind][libc++abi] Add _Unwind_ForcedUnwind to EHABI.
Daniel Kiss [Wed, 11 Aug 2021 08:11:30 +0000 (10:11 +0200)]
[Arm][Unwind][libc++abi] Add _Unwind_ForcedUnwind to EHABI.

_Unwind_ForcedUnwind is not mandated by the EHABI but for compatibilty
reasons adding so the interface to higher layers would be the same.
Dropping EHABI specific _Unwind_Stop_Fn definition since it is not defined by EHABI.

Reviewed By: MaskRay

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

3 years ago[Unwind] Split unwind.h
Daniel Kiss [Wed, 11 Aug 2021 08:11:27 +0000 (10:11 +0200)]
[Unwind] Split unwind.h

Moving Itanium and ArmEHABI specific implementations to dedicated files.
This is a NFC patch.

Reviewed By: MaskRay

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

3 years agoRevert "Bufferization for tiled loop."
Alexander Belyaev [Wed, 11 Aug 2021 08:04:12 +0000 (10:04 +0200)]
Revert "Bufferization for tiled loop."

This reverts commit edaffebcb2a62b0195e23fe7d4ead005822865c3.

3 years agoRevert "[mlir] Change the pattern for TiledLoopOp bufferization."
Alexander Belyaev [Wed, 11 Aug 2021 08:01:36 +0000 (10:01 +0200)]
Revert "[mlir] Change the pattern for TiledLoopOp bufferization."

This reverts commit 2f946eaa9d2648b883b2a1e567b23fff307f13d9.

3 years ago[AArch64][SME] Support ptrue(s) in streaming mode
Cullen Rhodes [Wed, 11 Aug 2021 07:07:32 +0000 (07:07 +0000)]
[AArch64][SME] Support ptrue(s) in streaming mode

The ptrue and ptrues instructions are legal in streaming mode, missed in
D106272.

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2021-06/SVE-Instructions

Reviewed By: paulwalker-arm

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

3 years ago[ELF] Don't emit SHF_GNU_RETAIN on Solaris
Rainer Orth [Wed, 11 Aug 2021 07:27:51 +0000 (09:27 +0200)]
[ELF] Don't emit SHF_GNU_RETAIN on Solaris

The introduction of `SHF_GNU_RETAIN` has caused massive problems on Solaris.

Initially, as reported in Bug 49437, it caused dozens of testsuite failures
on both sparc and x86.  The objects were marked as `ELFOSABI_NONE`, but
`SHF_GNU_RETAIN` is a GNU extension. In the native Solaris ABI, that flag
(in the range for OS-specific values) is `SHF_SUNW_ABSENT` with a
completely different semantics, which confuses Solaris `ld` very much.

Later, the objects became (correctly) marked `ELFOSABI_GNU`, which Solaris
`ld` doesn't support, causing it to SEGV and break the build.  The linker
is currently being hardened to not accept non-native OS ABIs to avoid this.

The need for linker support is already documented in
`clang/include/clang/Basic/AttrDocs.td`, but not currently checked.

This patch avoids all this by not emitting `SHF_GNU_RETAIN` on Solaris at all.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

3 years ago[mlir][Analysis][NFC] Remove code duplication around getFlattenedAffineExprs
Matthias Springer [Wed, 11 Aug 2021 06:59:43 +0000 (15:59 +0900)]
[mlir][Analysis][NFC] Remove code duplication around getFlattenedAffineExprs

Remove code duplication in `addLowerOrUpperBound` and `composeMatchingMap`.

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

3 years ago[mlir][Analysis][NFC] Reimplement FlatAffineConstraints::composeMap
Matthias Springer [Wed, 11 Aug 2021 06:48:21 +0000 (15:48 +0900)]
[mlir][Analysis][NFC] Reimplement FlatAffineConstraints::composeMap

Reimplement this function in terms of `composeMatchingMap`.

Also fix a bug in `composeMatchingMap` where local dims of `this` could be missing in `localCst`.

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

3 years ago[DAG] Reword comment for EnforceNodeIdInvariant and InvalidateNodeId. NFC.
madhur13490 [Tue, 10 Aug 2021 17:22:29 +0000 (22:52 +0530)]
[DAG] Reword comment for EnforceNodeIdInvariant and InvalidateNodeId. NFC.

Reviewed By: niravd

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

3 years ago[lld] Add lto-pgo-warn-mismatch option
Yolanda Chen [Wed, 11 Aug 2021 05:22:36 +0000 (13:22 +0800)]
[lld] Add lto-pgo-warn-mismatch option

When enable CSPGO for ThinLTO, there are profile cfg mismatch warnings that will cause lld-link errors (with /WX).
To disable it we have to use an internal "/mllvm:-no-pgo-warn-mismatch" option.
In contrast clang uses option ”-Wno-backend-plugin“ to avoid such warnings and gcc has an explicit "-Wno-coverage-mismatch" option.

Add this "lto-pgo-warn-mismatch" option to lld to help turn on/off the profile mismatch warnings explicitly when build with ThinLTO and CSPGO.

Reviewed By: tejohnson

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

3 years ago[mlir][Analysis][NFC] Reimplement FlatAffineConstraints::addLowerOrUpperBound
Matthias Springer [Wed, 11 Aug 2021 06:15:30 +0000 (15:15 +0900)]
[mlir][Analysis][NFC] Reimplement FlatAffineConstraints::addLowerOrUpperBound

Reimplement this function in terms of the function variant without Value semantics.

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

3 years ago[InstrProfiling] Generate runtime hook for Fuchsia
Petr Hosek [Tue, 10 Aug 2021 18:03:07 +0000 (11:03 -0700)]
[InstrProfiling] Generate runtime hook for Fuchsia

When none of the translation units in the binary have been instrumented
we shouldn't need to link the profile runtime. However, because we pass
-u__llvm_profile_runtime on Linux and Fuchsia, the runtime would still
be pulled in and incur some overhead. On Fuchsia which uses runtime
counter relocation, it also means that we cannot reference the bias
variable unconditionally.

This change modifies the InstrProfiling pass to pull in the profile
runtime only when needed by declaring the __llvm_profile_runtime symbol
in the translation unit only when needed. For now we restrict this only
for Fuchsia, but this can be later expanded to other platforms. This
approach was already used prior to 9a041a75221ca, but we changed it
to always generate the __llvm_profile_runtime due to a TAPI limitation,
but that limitation may no longer apply, and it certainly doesn't apply
on platforms like Fuchsia.

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

3 years agoRevert "[InstrProfiling] Emit bias variable eagerly"
Petr Hosek [Tue, 10 Aug 2021 18:23:50 +0000 (11:23 -0700)]
Revert "[InstrProfiling] Emit bias variable eagerly"

This reverts commit 6660cec568504df47d9becb0c552c20577880df8 since
it was superseded by https://reviews.llvm.org/D98061.

3 years ago[mlir][Analysis] Add FlatAffineConstraints::addLowerOrUpperBound
Matthias Springer [Wed, 11 Aug 2021 06:08:02 +0000 (15:08 +0900)]
[mlir][Analysis] Add FlatAffineConstraints::addLowerOrUpperBound

This function overload is similar to the existing `FlatAffineConstraints::addLowerOrUpperBound`. It constrains a dimension based on an affine map. However, in contrast to the other overloading, it does not attempt to align dimensions/symbols of the affine map with the dimensions/symbols of the constraint set. Instead, dimensions/symbols are expected to already be aligned.

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

3 years ago[Attributor][NFC] Try to make the windows build bots happy
Johannes Doerfert [Wed, 11 Aug 2021 06:10:13 +0000 (01:10 -0500)]
[Attributor][NFC] Try to make the windows build bots happy

Failed for some reason, potentially because of the inner type
declaration in combination with the `using`. This might help.

Failure:
https://lab.llvm.org/buildbot/#/builders/127/builds/15432

3 years ago[mlir][Analysis] Add alignAffineMapWithValues
Matthias Springer [Wed, 11 Aug 2021 05:55:22 +0000 (14:55 +0900)]
[mlir][Analysis] Add alignAffineMapWithValues

This function aligns an affine map (and operands) with given dims and syms SSA values.

This is useful in conjunction with `FlatAffineConstraints::addLowerOrUpperBound`, which requires the `boundMap` to be aligned with the constraint set's dims and syms.

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

3 years ago[Attributor][FIX] Handle recurrences (PHIs) in AAPointerInfo explicitly
Johannes Doerfert [Tue, 10 Aug 2021 09:06:59 +0000 (04:06 -0500)]
[Attributor][FIX] Handle recurrences (PHIs) in AAPointerInfo explicitly

PHI nodes are not pass through but change their value, we have to
account for that to avoid missing stores.

Follow up for D107798 to fix PR51249 for good.

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

3 years ago[Attributor][FIX] Only avoid visiting PHI uses multiple times (PR51249)
Johannes Doerfert [Tue, 10 Aug 2021 03:22:49 +0000 (22:22 -0500)]
[Attributor][FIX] Only avoid visiting PHI uses multiple times (PR51249)

AAPointerInfoFloating needs to visit all uses and some multiple times if
we go through PHI nodes. Attributor::checkForAllUses keeps a visited set
so we don't recurs endlessly. We now allow recursion for non-phi uses so
we track all pointer offsets via PHI nodes properly without endless
recursion.

This replaces the first attempt D107579.

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

3 years ago[Attributor][NFC] Precommit reproducer for PR51249
Johannes Doerfert [Tue, 10 Aug 2021 03:27:45 +0000 (22:27 -0500)]
[Attributor][NFC] Precommit reproducer for PR51249

The bulk of the changes come from attributes but only the @phi_store
function is effectively added.

3 years ago[OpenMP][FIX] Disabled optimizations have to be made known
Johannes Doerfert [Tue, 10 Aug 2021 18:24:34 +0000 (13:24 -0500)]
[OpenMP][FIX] Disabled optimizations have to be made known

To avoid simplification with wrong constants we need to make sure we
know that we won't perform specific optimizations based on the users
request. The non-SPMDzation and non-CustomStateMachine flags did only
prevent the final transformation but allowed to value simplification
to go ahead.

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

3 years ago[SelectionDAGBuilder] Save iterator to avoid second DenseMap lookup. NFC
Craig Topper [Wed, 11 Aug 2021 05:32:18 +0000 (22:32 -0700)]
[SelectionDAGBuilder] Save iterator to avoid second DenseMap lookup. NFC

We were calling find and then using operator[]. Instead keep the
iterator from find and use it to get the value.

Just happened to notice while investigating how we decide what extends
to use between basic blocks.

3 years ago[NFC][MLGO] 'Use' variable used for asserts
Mircea Trofin [Wed, 11 Aug 2021 02:46:04 +0000 (19:46 -0700)]
[NFC][MLGO] 'Use' variable used for asserts

3 years ago[llvm][clang][NFC] updates inline licence info
Christopher Di Bella [Thu, 5 Aug 2021 03:16:17 +0000 (03:16 +0000)]
[llvm][clang][NFC] updates inline licence info

Some files still contained the old University of Illinois Open Source
Licence header. This patch replaces that with the Apache 2 with LLVM
Exception licence.

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

3 years ago[gn build] Port 58915667d0b9
LLVM GN Syncbot [Wed, 11 Aug 2021 02:07:04 +0000 (02:07 +0000)]
[gn build] Port 58915667d0b9

3 years ago[CSSPGO] Additional cleanup as a follow-up to D107838
Hongtao Yu [Wed, 11 Aug 2021 02:00:33 +0000 (19:00 -0700)]
[CSSPGO] Additional cleanup as a follow-up to D107838

3 years ago[libc++] IWYU to fix Modules complaints in <__ranges/reverse_view.h>.
Arthur O'Dwyer [Wed, 11 Aug 2021 02:01:19 +0000 (22:01 -0400)]
[libc++] IWYU to fix Modules complaints in <__ranges/reverse_view.h>.

And now we can use granular concepts headers!

3 years ago[libc++][modularisation] Split up <concepts> into granular headers.
Arthur O'Dwyer [Thu, 29 Jul 2021 05:08:30 +0000 (01:08 -0400)]
[libc++][modularisation] Split up <concepts> into granular headers.

This is the complete split of <concepts>, with nothing left in the main header.

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

3 years ago[RISCV][test] Add new tests for mul optimization in the zba extension with SH*ADD
Ben Shi [Tue, 10 Aug 2021 11:56:19 +0000 (19:56 +0800)]
[RISCV][test] Add new tests for mul optimization in the zba extension with SH*ADD

Reviewed By: craig.topper

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

3 years ago[CSSPGO] Do not use getCanonicalFnName in pseudo probe descriptor decoding
Hongtao Yu [Tue, 10 Aug 2021 15:59:01 +0000 (08:59 -0700)]
[CSSPGO] Do not use getCanonicalFnName in pseudo probe descriptor decoding

Pseudo probe descriptors are created very early in the pipeline where function names just come from the front end and are not yet decorated. So calling getCanonicalFnName on the function names in probe desc is basically a no-op, which also addes a depenency from MC to ProfileData unnessesarily.

Reviewed By: wenlei, wlei

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

3 years ago[gn build] Port f9e58f35e905
LLVM GN Syncbot [Tue, 10 Aug 2021 23:45:53 +0000 (23:45 +0000)]
[gn build] Port f9e58f35e905

3 years ago[libcxx][ranges] Add `views::counted` CPO.
zoecarver [Tue, 27 Jul 2021 22:44:33 +0000 (15:44 -0700)]
[libcxx][ranges] Add `views::counted` CPO.

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

3 years ago[AArch64][GlobalISel] Relax oneuse restriction for PTR_ADD chain combining to check...
Amara Emerson [Tue, 10 Aug 2021 23:11:56 +0000 (16:11 -0700)]
[AArch64][GlobalISel] Relax oneuse restriction for PTR_ADD chain combining to check addressing legality.

With contributions by Sebastian Neubauer

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

3 years ago[M68k][GloballSel] RegBankSelect implementation
Sushma Unnibhavi [Tue, 10 Aug 2021 06:36:16 +0000 (23:36 -0700)]
[M68k][GloballSel] RegBankSelect implementation

Implementation of RegBankSelect for the M68k backend.

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

3 years agoSimplify coro::salvageDebugInfo() (NFC-ish)
Adrian Prantl [Tue, 10 Aug 2021 22:02:25 +0000 (15:02 -0700)]
Simplify coro::salvageDebugInfo() (NFC-ish)

This patch removes the hand-rolled implementation of salvageDebugInfo
for cast and GEPs and replaces it with a call into
llvm::salvageDebugInfoImpl().

A side-effect of this is that additional redundant convert operations
are introduced, but those don't have any negative effect on the
resulting DWARF expression.

rdar://80227769

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

3 years agoStreamline the API of salvageDebugInfoImpl (NFC)
Adrian Prantl [Mon, 2 Aug 2021 23:59:45 +0000 (16:59 -0700)]
Streamline the API of salvageDebugInfoImpl (NFC)

This patch refactors / simplifies salvageDebugInfoImpl(). The goal
here is to simplify the implementation of coro::salvageDebugInfo() in
a followup patch.

  1. Change the return value to I.getOperand(0). Currently users of
     salvageDebugInfoImpl() assume that the first operand is
     I.getOperand(0). This patch makes this information explicit. A
     nice side-effect of this change is that it allows us to salvage
     expressions such as add i8 1, %a in the future.

  2. Factor out the creation of a DIExpression and return an array of
     DIExpression operations instead. This change allows users that
     call salvageDebugInfoImpl() in a loop to avoid the costly
     creation of temporary DIExpressions and to defer the creation of
     a DIExpression until the end.

This patch does not change any functionality.

rdar://80227769

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

3 years ago[lld][WebAssembly] Prefer objdump -d over obj2yaml for tests. NFC
Sam Clegg [Tue, 27 Jul 2021 18:06:03 +0000 (11:06 -0700)]
[lld][WebAssembly] Prefer objdump -d over obj2yaml for tests. NFC

Now that we have https://reviews.llvm.org/D105539 we can
use objdump -d to actually check for instruction sequences
rather than binary blobs.

This is just an example of how to do that we should followup
with a wider ranging conversion of existing tests.

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

3 years ago[mlir][tosa] Add folders for trivial tosa operation cases
Rob Suderman [Tue, 10 Aug 2021 21:42:56 +0000 (14:42 -0700)]
[mlir][tosa] Add folders for trivial tosa operation cases

Some folding cases are trivial to fold away, specifically no-op cases where
an operation's input and output are the same. Canonicalizing these away
removes unneeded operations.

The current version includes tensor cast operations to resolve shape
discreprencies that occur when an operation's result type differs from the
input type. These are resolved during a tosa shape propagation pass.

Reviewed By: NatashaKnk

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

3 years ago[mlir][tosa] Add dilation to tosa.transpose_conv2d lowering
Rob Suderman [Tue, 10 Aug 2021 21:36:08 +0000 (14:36 -0700)]
[mlir][tosa] Add dilation to tosa.transpose_conv2d lowering

Dilation only requires increasing the padding on the left/right side of the
input, and including dilation in the convolution. This implementation still
lacks support for strided convolutions.

Reviewed By: NatashaKnk

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

3 years ago[mlir][tosa] Add quantized and unquantized versions for tosa.depthwise_conv2d lowering
natashaknk [Tue, 10 Aug 2021 21:29:15 +0000 (14:29 -0700)]
[mlir][tosa] Add quantized and unquantized versions for tosa.depthwise_conv2d lowering

Reviewed By: rsuderman

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

3 years ago[analyzer] Cleanup a FIXME in SValBuilder.cpp
Vince Bridgers [Sun, 8 Aug 2021 20:36:37 +0000 (15:36 -0500)]
[analyzer] Cleanup a FIXME in SValBuilder.cpp

This change follows up on a FIXME submitted with D105974. This change simply let's the reference case fall through to return a concrete 'true'
instead of a nonloc pointer of appropriate length set to NULL.

Reviewed By: NoQ

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

3 years ago[Sema] Include full range of the switch condition in -Wswitch diagnostic
Sam McCall [Tue, 10 Aug 2021 20:49:49 +0000 (22:49 +0200)]
[Sema] Include full range of the switch condition in -Wswitch diagnostic

3 years ago[RISCV] Remove stale TODO from test. NFC
Craig Topper [Tue, 10 Aug 2021 20:13:44 +0000 (13:13 -0700)]
[RISCV] Remove stale TODO from test. NFC

3 years ago[mlir][drr] Improve error message for unexpected attribute (NFC)
Jacques Pienaar [Tue, 10 Aug 2021 20:03:52 +0000 (13:03 -0700)]
[mlir][drr] Improve error message for unexpected attribute (NFC)

When using an attribute where a value is expected previously this would fail
complaining about unbound symbol. Instead make error clear and mention common
failure reason.

3 years ago[docs] Clarify variable-width integer (VBR) encoding example.
Volodymyr Sapsai [Tue, 10 Aug 2021 01:42:26 +0000 (18:42 -0700)]
[docs] Clarify variable-width integer (VBR) encoding example.

Show that the bit chunks are placed starting at the least significant
bit. Select a different number, so the bit chunks have different values
and it is more obvious where they are in the encoded result.

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

3 years ago[mlir] Support normalizing memrefs with MemRef_ReinterpretCastOp
Haruki Imai [Tue, 10 Aug 2021 19:45:07 +0000 (01:15 +0530)]
[mlir] Support normalizing memrefs with MemRef_ReinterpretCastOp

This patch enables normalizing memrefs with MemRef_ReinterpretCastOp by
adding MemRefsNormalizable trait in the Op definition.

Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Reviewed By: bondhugula

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

3 years ago[MemCpyOpt] Optimize MemoryDef insertion
Nikita Popov [Sat, 7 Aug 2021 21:09:09 +0000 (23:09 +0200)]
[MemCpyOpt] Optimize MemoryDef insertion

When converting a store into a memset, we currently insert the new
MemoryDef after the store MemoryDef, which requires all uses to be
renamed to the new def using a whole block scan. Instead, we can
insert the new MemoryDef before the store and not rename uses,
because we know that the location is immediately overwritten, so
all uses should still refer to the old MemoryDef. Those uses will
get renamed when the old MemoryDef is actually dropped, which is
efficient.

I expect something similar can be done for some of the other MSSA
updates in MemCpyOpt. This is an alternative to D107513, at least
for this particular case.

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

3 years ago[mlir] Change the pattern for TiledLoopOp bufferization.
Alexander Belyaev [Tue, 10 Aug 2021 19:08:10 +0000 (21:08 +0200)]
[mlir] Change the pattern for TiledLoopOp bufferization.

This version is does not affect the patterns for Extract/InsertSliceOp and
LinalgOps.

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

3 years ago[ARC] Add codegen for count trailing zeros intrinsic for the ARC backend
Thomas Johnson [Sat, 7 Aug 2021 19:05:59 +0000 (21:05 +0200)]
[ARC] Add codegen for count trailing zeros intrinsic for the ARC backend

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

3 years ago[InlineAdvisor] Add single quotes around caller/callee names
Fangrui Song [Tue, 10 Aug 2021 18:51:31 +0000 (11:51 -0700)]
[InlineAdvisor] Add single quotes around caller/callee names

Clang diagnostics refer to identifier names in quotes.
This patch makes inline remarks conform to the convention.
New behavior:

```
% clang -O2 -Rpass=inline -Rpass-missed=inline -S a.c
a.c:4:25: remark: 'foo' inlined into 'bar' with (cost=-30, threshold=337) at callsite bar:0:25; [-Rpass=inline]
int bar(int a) { return foo(a); }
                        ^
```

Reviewed By: hoy

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

3 years ago[mlir] Enable specifying querying function in ValueShapeRange
Jacques Pienaar [Tue, 10 Aug 2021 18:44:20 +0000 (11:44 -0700)]
[mlir] Enable specifying querying function in ValueShapeRange

This enables querying shapes/values as shapes without mutating the IR
directly (e.g., towards enabling doing inference in analysis &
application steps, inferring function shape with constant from callsite,
...). Add a new ShapeAdaptor that abstracts over whether shape is from
Type or ShapedTypeComponents or DenseIntElementsAttribute. This adds new
accessors to ValueShapeRange to get Shape and value as shape, but
doesn't restrict or remove the previous way of accessing Type via the
Value for now, that does mean a less refined shape could be accidentally
queried and will be restricted in follow up.

Currently restricted Value query to what can be represented as Shape. So
only supports cases where constant subgraph evaluation's output is a
shape. I had considered making it more general, but without TBD extern
attribute concept or some such a user cannot today uniformly avoid
overhead.

Update TOSA ops and also the shape inference pass.

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

3 years ago[nfc] [lldb] Assertions for D106270 - [DWARF5] Fix offset check when using .debug_names
Jan Kratochvil [Tue, 10 Aug 2021 18:39:40 +0000 (20:39 +0200)]
[nfc] [lldb] Assertions for D106270 - [DWARF5] Fix offset check when using .debug_names

Skeleton vs. DWO units mismatch has been fixed in D106270. As they both
have type DWARFUnit it is a bit difficult to debug. So it is better to
make it safe against future changes.

Reviewed By: kimanh, clayborg

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

3 years ago[InstCombine] avoid infinite loops from min/max canonicalization
Sanjay Patel [Tue, 10 Aug 2021 18:30:43 +0000 (14:30 -0400)]
[InstCombine] avoid infinite loops from min/max canonicalization

The intrinsics have an extra chunk of known bits logic
compared to the normal cmp+select idiom. That allows
folding the icmp in each case to something better, but
that then opposes the canonical form of min/max that
we try to form for a select.

I'm carving out a narrow exception to preserve all
existing regression tests while avoiding the inf-loop.
It seems unlikely that this is the only bug like this
left, but this should fix:
https://llvm.org/PR51419

3 years ago[OpenMP] AlwaysInline __kmpc_parallel_51 to improve inlining hueristics
Joseph Huber [Tue, 10 Aug 2021 16:08:17 +0000 (12:08 -0400)]
[OpenMP] AlwaysInline __kmpc_parallel_51 to improve inlining hueristics

This patch adds the `AlwaysInline` attribute to the `__kmpc_parallel_51`
device runtime call. This improves inlining heuristics which encourages
the indirect function pointer arguemnt to also be inlined. This greatly
improves performance for a few applications whose outlined regions were
not inlined otherwise.

Reviewed By: jdoerfert

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

3 years agotsan: add notion of compressed addresses
Dmitry Vyukov [Sat, 7 Aug 2021 19:05:59 +0000 (21:05 +0200)]
tsan: add notion of compressed addresses

New tsan runtime will need to compress addresses/PCs to fewer bits.
Add CompressAddr/RestoreAddr functions that compress/restore
addresses to 44 bits.

Depends on D107744.

Reviewed By: melver

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

3 years agotsan: rename mapping field selectors
Dmitry Vyukov [Sat, 7 Aug 2021 18:18:37 +0000 (20:18 +0200)]
tsan: rename mapping field selectors

Rename mapping field selectors according to the code style.
Reuse the actual field names, there is no need to invent
second set of names.

Depends on D107743.

Reviewed By: melver

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

3 years agotsan: remove indirection when selecting the active mapping
Dmitry Vyukov [Sat, 7 Aug 2021 18:10:54 +0000 (20:10 +0200)]
tsan: remove indirection when selecting the active mapping

Currently there are 2 levels when selecting the active mapping:
the branchy ifdef tree + another ifdef tree in SelectMapping.
Moreover, there is an additional indirection for some platforms
via HAS_48_BIT_ADDRESS_SPACE define. This makes already complex
logic even more complex and almost impossible to read.
Remove one level of indirection and define the active mapping
in SelectMapping.

Depends on D107742.

Reviewed By: melver

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

3 years agotsan: remove dependencies on HAS_48_BIT_ADDRESS_SPACE and Mapping
Dmitry Vyukov [Sun, 8 Aug 2021 10:20:48 +0000 (12:20 +0200)]
tsan: remove dependencies on HAS_48_BIT_ADDRESS_SPACE and Mapping

Remove direct uses of Mapping in preperation for removing Mapping type
(which we already don't have for all platforms).
Remove dependence on HAS_48_BIT_ADDRESS_SPACE in preparation for removing it.
As far as I see for Apple/Mac platforms !HAS_48_BIT_ADDRESS_SPACE
simply means SANITIZER_IOS.

Depends on D107741.

Reviewed By: melver

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

3 years agotsan: unit-test all mappings
Dmitry Vyukov [Sat, 7 Aug 2021 11:07:00 +0000 (13:07 +0200)]
tsan: unit-test all mappings

Move the mapping checking logic from startup to unit tests
and test all mapping instead of just the active one.
This makes it much more feasible to make any global changes
to the mappings since we have 17 of them.

Depends on D107740.

Reviewed By: vitalybuka, melver

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

3 years agotsan: unify all shadow mappings
Dmitry Vyukov [Sat, 7 Aug 2021 14:05:15 +0000 (16:05 +0200)]
tsan: unify all shadow mappings

Currently we have ifdef's for Go/C++ and Windows/non-Windows
in MemToShadow, MemToMeta, ShadowToMem. This does not allow
to test all mappings on a single platform.
Make all these functions support a superset of mappings for
all platforms by defining missing mapping consts to 0.
E.g. we always do ^A+B, but if A and B are defined to 0,
then these operations become no-op.

Depends on D107739.

Reviewed By: melver

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

3 years agotsan: define all fields for all mappings
Dmitry Vyukov [Sat, 7 Aug 2021 12:19:17 +0000 (14:19 +0200)]
tsan: define all fields for all mappings

Define all fields to 0 for all mappings.
This allows to write portable code and tests.
For all existing cases 0 values work out of the box
because we check if an address belongs to the range
and nothing belongs to [0, 0] range.

Depends on D107738.

Reviewed By: melver

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

3 years agotsan: rename kAppMemBeg to kLoAppMemBeg
Dmitry Vyukov [Sat, 7 Aug 2021 12:06:43 +0000 (14:06 +0200)]
tsan: rename kAppMemBeg to kLoAppMemBeg

Unify Go mapping naming with C++ naming to allow
writing portable code/tests that can work for both C++ and Go.
No functional changes.

Depends on D107737.

Reviewed By: melver

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

3 years agotsan: remove TSAN_MID_APP_RANGE macro
Dmitry Vyukov [Sat, 7 Aug 2021 11:39:58 +0000 (13:39 +0200)]
tsan: remove TSAN_MID_APP_RANGE macro

First, the define conflicts with definition/testing of all mappings,
since it's not a global property anymore. Second, macros/ifdefs are bad.
Define kMidAppMemBeg/End to 0 to denote that there is no "mid" range instead.

Depends on D107736.

Reviewed By: melver

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

3 years agosanitizer_common: add FALLTHROUGH macro
Dmitry Vyukov [Sat, 7 Aug 2021 11:56:48 +0000 (13:56 +0200)]
sanitizer_common: add FALLTHROUGH macro

Add FALLTHROUGH portably defined to [[clang::fallthrough]].
We have -Wimplicit-fallthrough already enabled, and currently
it's not possible to fix the warning.

Depends on D107735.

Reviewed By: melver

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

3 years agotsan: deduplicate mapping selection
Dmitry Vyukov [Sat, 7 Aug 2021 10:57:24 +0000 (12:57 +0200)]
tsan: deduplicate mapping selection

Currently we have mapping selection duplicated 9 times.
Deduplicate it. No functional changes.

Depends on D107734.

Reviewed By: melver

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

3 years agotsan: make all memory mappings testable
Dmitry Vyukov [Sat, 7 Aug 2021 10:03:24 +0000 (12:03 +0200)]
tsan: make all memory mappings testable

Currently we define/compile the mapping for a platform
only on that platform. This makes it impossible to unit-test
them on a single platform, and even to build test.
We have 17 of them and the Go mappings will be tested
only after a manual episodic update of the Go runtime.

Define all mappings always with unique names.
This will allow to unit-test them.
No functional changes.

Reviewed By: melver

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

3 years agosanitizers: turn thread-safety errors into warnings
Dmitry Vyukov [Tue, 10 Aug 2021 14:16:32 +0000 (16:16 +0200)]
sanitizers: turn thread-safety errors into warnings

There were 2 issues reported on https://reviews.llvm.org/D105716:
1. FreeBSD phtread.h is annotated with thread-safety attributes
and this causes errors in gtest headers.
2. If sanitizers are compiled with an older versions of clang
(which supports the annotations, but has some false positives
in analysis not present in later versions of clang), compilation
fails with errors.

Switch the errors to warnings by default.
Some CI bots enable COMPILER_RT_ENABLE_WERROR, which should
turn these warnings back into errors.

Reviewed By: nikic

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

3 years agosanitizer_common: optimize Mutex for high contention
Dmitry Vyukov [Tue, 10 Aug 2021 13:48:12 +0000 (15:48 +0200)]
sanitizer_common: optimize Mutex for high contention

After switching tsan from the old mutex to the new sanitizer_common mutex,
we've observed a significant degradation of performance on a test.
The test effectively stresses a lock-free stack with 4 threads
with a mix of atomic_compare_exchange and atomic_load operations.
The former takes write lock, while the latter takes read lock.
It turned out the new mutex performs worse because readers don't
use active spinning, which results in significant amount of thread
blocking/unblocking. The old tsan mutex used active spinning
for both writers and readers.

Add active spinning for readers.
Don't hand off the mutex to readers, and instread make them
compete for the mutex after wake up again.
This makes readers and writers almost symmetric.

Reviewed By: melver

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

3 years agoSystemZ: Tidy up a mir test
Matt Arsenault [Fri, 6 Aug 2021 16:42:54 +0000 (12:42 -0400)]
SystemZ: Tidy up a mir test

3 years agolibunwind: add missing break statements in EHABI
Saleem Abdulrasool [Tue, 10 Aug 2021 17:45:31 +0000 (17:45 +0000)]
libunwind: add missing break statements in EHABI

Add missing break statements identified by static analysis tools.

Patch by Andrii Kurdiumov!

Reviewed By: compnerd, danielkiss

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

3 years ago[clang][cache] Update Fuchsia-stage2.cmake to create hwasan multilibs
Leonard Chan [Tue, 10 Aug 2021 17:50:06 +0000 (10:50 -0700)]
[clang][cache] Update Fuchsia-stage2.cmake to create hwasan multilibs

This is a reland of commit a9d1970384aa3908adbf6f50f110c375def58947.

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

3 years ago[AIX] Don't crash on unimplemented lowerRelativeReference
Jinsong Ji [Tue, 10 Aug 2021 17:43:05 +0000 (17:43 +0000)]
[AIX] Don't crash on unimplemented lowerRelativeReference

We may call lowerRelativeReference in MC to determine whether target
supports this lowering. We should return nullptr instead of crashing
when we haven't implemented the real lowering.

Reviewed By: hubert.reinterpretcast

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

3 years ago[flang] Fix the extent calculation when upper bounds are less than lower bounds
Peter Steinfeld [Tue, 10 Aug 2021 15:20:30 +0000 (08:20 -0700)]
[flang] Fix the extent calculation when upper bounds are less than lower bounds

When the upper bound is less than the lower bound, the extent is zero.  This is
specified in section 8.5.8.2, paragraph 3.

Note that similar problems exist in the lowering code.  This change only fixes
the problem for the front end.

I also added a test.

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

3 years agoAMDGPU: Add alloc priority to global ranges
Matt Arsenault [Tue, 3 Aug 2021 23:09:44 +0000 (19:09 -0400)]
AMDGPU: Add alloc priority to global ranges

The requested register class priorities weren't respected
globally. Not sure why this is a target option, and not just the
expected behavior (recently added in
1a6dc92be7d68611077f0fb0b723b361817c950c). This avoids an allocation
failure when many wide tuple spills are introduced. I think this is a
workaround since I would not expect the allocation priority to be
required, and only a performance hint. The allocator should be smarter
about when only a subregister needs to be spilled and restored.

This does regress a couple of degenerate store stress lit tests which
shouldn't be too important.

3 years agoAMDGPU: Add baseline register allocation failure test
Matt Arsenault [Mon, 2 Aug 2021 21:11:59 +0000 (17:11 -0400)]
AMDGPU: Add baseline register allocation failure test

3 years agoRegAllocGreedy: Add spaces between registers in debug message
Matt Arsenault [Tue, 3 Aug 2021 01:12:21 +0000 (21:12 -0400)]
RegAllocGreedy: Add spaces between registers in debug message

3 years ago[AIX] Define __HOS_AIX__ macro only for AIX target
Jake Egan [Tue, 10 Aug 2021 15:38:48 +0000 (11:38 -0400)]
[AIX] Define __HOS_AIX__ macro only for AIX target

%%%
This patch defines the macro __HOS_AIX__ when the target is AIX and without any dependency on the host. The macro indicates that the host is AIX. Defining the macro will help minimize porting pain for existing code compiled with xlc/xlC. xlC never shipped cross-compiling support, so the difference is not observable anyway.
%%%
This is a follow up to the discussion in https://reviews.llvm.org/D107242.

Reviewed By: cebowleratibm, joerg

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

3 years ago[libcxx] Remove _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
Mark de Wever [Sun, 1 Aug 2021 18:01:51 +0000 (20:01 +0200)]
[libcxx] Remove _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED

All supported compilers should support
_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED so this can be removed.

Reviewed By: ldionne, #libc, Quuxplusone

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

3 years ago[Security] Replace Josh Eads with Tim Penge as a Sony rep
Paul Robinson [Wed, 28 Jul 2021 14:47:06 +0000 (10:47 -0400)]
[Security] Replace Josh Eads with Tim Penge as a Sony rep

3 years ago[libomptarget][NFC] Fix compilation issue with GCC
George Rokos [Tue, 10 Aug 2021 16:36:43 +0000 (09:36 -0700)]
[libomptarget][NFC] Fix compilation issue with GCC

Removed redundant assignment from condition which causes gcc to emit the following error:

error: operation on ‘MoveData’ may be undefined [-Werror=sequence-point]

3 years agoabseil-string-find-str-contains should not propose an edit for the three-parameter...
Tom Lokovic [Tue, 10 Aug 2021 16:26:02 +0000 (16:26 +0000)]
abseil-string-find-str-contains should not propose an edit for the three-parameter version of find().

std::string, std::string_view, and absl::string_view all have a three-parameter version of find()
which has a "count" (or "n") paremeter limiting the size of the substring to search.  We don't want
to propose changing to absl::StrContains in those cases.  This change fixes that and adds unit tests
to confirm.

Reviewed By: ymandel

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

3 years ago[OpenMP][NFC] Simplify targetDataEnd conditions for CopyMember
Joel E. Denny [Tue, 10 Aug 2021 16:23:15 +0000 (12:23 -0400)]
[OpenMP][NFC] Simplify targetDataEnd conditions for CopyMember

targetDataEnd and targetDataBegin compute CopyMember/copy differently,
and I don't see why they should.  This patch eliminates one of those
differences by making a simplifying NFC change to targetDataEnd.

The change is NFC as follows.  The change only affects the case when
`!UNIFIED_SHARED_MEMORY || HasCloseModifier`.  In that case, the
following points are always true:

* The value of CopyMember is relevant later only if DelEntry = false.
* DelEntry = false only if one of the following is true:
    * IsLast = false.  In this case, it's always true that CopyMember
      = false = IsLast.
    * `MEMBER_OF && !PTR_AND_OBJ` is true.  In this case, CopyMember =
      IsLast.
* Thus, if CopyMember is relevant, CopyMember = IsLast.

Reviewed By: grokos

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

3 years agorevert test commit
Denys Petrov [Tue, 10 Aug 2021 16:19:27 +0000 (19:19 +0300)]
revert test commit

3 years ago[analyzer] Move test case to existing test file and remove duplicated test file.
Denys Petrov [Mon, 19 Jul 2021 13:30:24 +0000 (16:30 +0300)]
[analyzer] Move test case to existing test file and remove duplicated test file.

Summary: Move the test case to existing test file. Remove test file as duplicated. The file was mistakenly added due to concerns of a hidden bug (see https://reviews.llvm.org/D104381). After it turned out, that the bug was already fixed with another revision (https://reviews.llvm.org/D85817) and corresponding test was added as well, we can remove this file.

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

3 years agotest commit
Denys Petrov [Tue, 10 Aug 2021 16:06:37 +0000 (19:06 +0300)]
test commit

3 years ago[RISCV] Fold (add (select lhs, rhs, cc, 0, y), x) -> (select lhs, rhs, cc, x, (add...
Craig Topper [Tue, 10 Aug 2021 15:27:34 +0000 (08:27 -0700)]
[RISCV] Fold (add (select lhs, rhs, cc, 0, y), x) -> (select lhs, rhs, cc, x, (add x, y))

Similar for sub except sub isn't commutative.

Modify the existing and/or/xor folds to also work on ISD::SELECT
and not just RISCVISD::SELECT_CC. This is needed to make sure
we do this transform before type legalization turns i32 add/sub
into add/sub+sign_extend_inreg on RV64. If we don't do this before
that, the sign_extend_inreg will still be after the select.

Reviewed By: frasercrmck

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

3 years ago[libc++][NFC] Simplify tests for bind_front
Louis Dionne [Tue, 10 Aug 2021 15:56:03 +0000 (11:56 -0400)]
[libc++][NFC] Simplify tests for bind_front

3 years ago[clang] Implement P0692R1 from C++20 (access checking on specializations and instanti...
Alex Orlov [Tue, 10 Aug 2021 15:20:50 +0000 (19:20 +0400)]
[clang] Implement P0692R1 from C++20 (access checking on specializations and instantiations)

This patch implements paper P0692R1 from the C++20 standard. Disable usual access checking rules to template argument names in a declaration of partial specializations, explicit instantiation or explicit specialization (C++20 13.7.5/10, 13.9.1/6).
Fixes: https://llvm.org/PR37424
This patch also implements option *A* from this paper P0692R1 from the C++20 standard.
This patch follows the @rsmith suggestion from D78404.

Reviewed By: krisb

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

3 years ago[InstSimplify] fold min/max with limit constant
Sanjay Patel [Tue, 10 Aug 2021 14:57:25 +0000 (10:57 -0400)]
[InstSimplify] fold min/max with limit constant

This is already done within InstCombine:
https://alive2.llvm.org/ce/z/MiGE22

...but leaving it out of analysis makes it
harder to avoid infinite loops there.

3 years agoRevert "[InstSimplify] fold min/max with limit constant; NFC"
Sanjay Patel [Tue, 10 Aug 2021 14:50:09 +0000 (10:50 -0400)]
Revert "[InstSimplify] fold min/max with limit constant; NFC"

This reverts commit f43859b4370f978d2bc625643ccbe03775b99713.
This is not NFC, so I'll try again without that mistake in the commit message.

3 years ago[InstSimplify] fold min/max with limit constant; NFC
Sanjay Patel [Tue, 10 Aug 2021 14:41:23 +0000 (10:41 -0400)]
[InstSimplify] fold min/max with limit constant; NFC

This is already done within InstCombine:
https://alive2.llvm.org/ce/z/MiGE22

...but leaving it out of analysis makes it
harder to avoid infinite loops there.

3 years ago[InstSimplify] add tests for min/max idioms; NFC
Sanjay Patel [Tue, 10 Aug 2021 13:39:01 +0000 (09:39 -0400)]
[InstSimplify] add tests for min/max idioms; NFC

3 years agoProblem with realpath interceptor
Dmitry Vyukov [Tue, 10 Aug 2021 14:27:49 +0000 (16:27 +0200)]
Problem with realpath interceptor

tsan in some cases (e.g. after fork from multithreaded program, which arguably is problematic) increments ignore_interceptors and in that case runs just the intercepted functions and not their wrappers.
For realpath the interceptor handles the resolved_path == nullptr case though and so when ignore_interceptors is non-zero, realpath (".", nullptr) will fail instead of succeeding.
This patch uses instead the COMMON_INTERCEPT_FUNCTION_GLIBC_VER_MIN macro to use realpath@@GLIBC_2.3 whenever possible (if not, then it is likely a glibc architecture
with more recent oldest symbol version than 2.3, for which any realpath in glibc will DTRT, or unsupported glibc older than 2.3), which never supported NULL as second argument.

Reviewed By: dvyukov

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

3 years ago[DWARF] Remove isInlinedCStr (NFC)
Kazu Hirata [Tue, 10 Aug 2021 14:24:46 +0000 (07:24 -0700)]
[DWARF] Remove isInlinedCStr (NFC)

The last use was removed on Oct 28, 2013 in commit
48cbda5850264671e982ecdd834c1587b1732c15.

3 years ago[lldb][NFC] Fix inversed documentation of Process::GetID/SetID
Raphael Isemann [Tue, 10 Aug 2021 14:15:57 +0000 (16:15 +0200)]
[lldb][NFC] Fix inversed documentation of Process::GetID/SetID

3 years ago[lldb][NFC] Add a FIXME for NameSearchContext::AddFunDecl's missing addDecl
Raphael Isemann [Tue, 10 Aug 2021 14:14:27 +0000 (16:14 +0200)]
[lldb][NFC] Add a FIXME for NameSearchContext::AddFunDecl's missing addDecl

3 years agoSet supported target for asan-use-callbacks test
Thomas Preud'homme [Fri, 6 Aug 2021 10:09:40 +0000 (11:09 +0100)]
Set supported target for asan-use-callbacks test

Explicitely set x86_64-linux-gnu as a target for asan-use-callbacks
clang test since some target do not support -fsanitize=address (e.g.
i386-pc-openbsd). Also remove redundant -fsanitize=address and move
-emit-llvm right after -S.

Reviewed By: vitalybuka

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

3 years ago[NFC] Add extra RUN line to strict reduction tests
David Sherwood [Tue, 10 Aug 2021 13:42:47 +0000 (14:42 +0100)]
[NFC] Add extra RUN line to strict reduction tests

I have added RUN lines to both:

  Transforms/LoopVectorize/AArch64/strict-fadd.ll
  Transforms/LoopVectorize/AArch64/scalable-strict-fadd.ll

to show the default behaviour is to not vectorise when the following
flag is unset:

  -force-ordered-reductions

3 years ago[clang] [hexagon] Add resource include dir
Brian Cain [Tue, 10 Aug 2021 04:03:06 +0000 (23:03 -0500)]
[clang] [hexagon] Add resource include dir

3 years agoRevert "[clangd] Support `#pragma mark` in the outline"
Florian Mayer [Tue, 10 Aug 2021 13:25:52 +0000 (14:25 +0100)]
Revert "[clangd] Support `#pragma mark` in the outline"

This reverts commit ba06ac8b45ca2ad047131fb9cc9af922cb913ea1.