platform/upstream/llvm.git
3 years ago[analyzer][NFC] Fix tests failing after a rebase
Valeriy Savchenko [Wed, 28 Apr 2021 15:55:20 +0000 (18:55 +0300)]
[analyzer][NFC] Fix tests failing after a rebase

3 years ago[analyzer] Find better description for tracked symbolic values
Valeriy Savchenko [Wed, 21 Apr 2021 13:01:30 +0000 (16:01 +0300)]
[analyzer] Find better description for tracked symbolic values

When searching for stores and creating corresponding notes, the
analyzer is more specific about the target region of the store
as opposed to the stored value.  While this description was tweaked
for constant and undefined values, it lacked in the most general
case of symbolic values.

This patch tries to find a memory region, where this value is stored,
to use it as a better alias for the value.

rdar://76645710

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

3 years ago[analyzer] Track leaking object through stores
Valeriy Savchenko [Tue, 20 Apr 2021 14:08:55 +0000 (17:08 +0300)]
[analyzer] Track leaking object through stores

Since we can report memory leaks on one variable, while the originally
allocated object was stored into another one, we should explain
how did it get there.

rdar://76645710

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

3 years ago[analyzer] Adjust the reported variable name in retain count checker
Valeriy Savchenko [Fri, 16 Apr 2021 18:10:05 +0000 (21:10 +0300)]
[analyzer] Adjust the reported variable name in retain count checker

When reporting leaks, we try to attach the leaking object to some
variable, so it's easier to understand.  Before the patch, we always
tried to use the first variable that stored the object in question.
This can get very confusing for the user, if that variable doesn't
contain that object at the moment of the actual leak.  In many cases,
the warning is dismissed as false positive and it is effectively a
false positive when we fail to properly explain the warning to the
user.

This patch addresses the bigest issue in cases like this.  Now we
check if the variable still contains the leaking symbolic object.
If not, we look for the last variable to actually hold it and use
that variable instead.

rdar://76645710

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

3 years ago[analyzer][NFC] Remove duplicated work from retain count leak report
Valeriy Savchenko [Fri, 16 Apr 2021 08:22:25 +0000 (11:22 +0300)]
[analyzer][NFC] Remove duplicated work from retain count leak report

Allocation site is the key location for the leak checker.  It is a
uniqueing location for the report and a source of information for
the warning's message.

Before this patch, we calculated and used it twice in bug report and
in bug report visitor.  Such duplication is not only harmful
performance-wise (not much, but still), but also design-wise.  Because
changing something about the end piece of the report should've been
repeated for description as well.

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

3 years ago[ARM][AArch64] Require appropriate features for crypto algorithms
David Candler [Wed, 28 Apr 2021 14:16:01 +0000 (15:16 +0100)]
[ARM][AArch64] Require appropriate features for crypto algorithms

This patch changes the AArch32 crypto instructions (sha2 and aes) to
require the specific sha2 or aes features. These features have
already been implemented and can be controlled through the command
line, but do not have the expected result (i.e. `+noaes` will not
disable aes instructions). The crypto feature retains its existing
meaning of both sha2 and aes.

Several small changes are included due to the knock-on effect this has:

- The AArch32 driver has been modified to ensure sha2/aes is correctly
  set based on arch/cpu/fpu selection and feature ordering.
- Crypto extensions are permitted for AArch32 v8-R profile, but not
  enabled by default.
- ACLE feature macros have been updated with the fine grained crypto
  algorithms. These are also used by AArch64.
- Various tests updated due to the change in feature lists and macros.

Reviewed By: lenary

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

3 years agoRevert "[MLIR][Shape] Concretize broadcast result type if possible"
Frederik Gossen [Wed, 28 Apr 2021 15:16:02 +0000 (17:16 +0200)]
Revert "[MLIR][Shape] Concretize broadcast result type if possible"

This reverts commit dca536103592cf1e92aa8316ed23f33d75da25bc.

3 years ago[mlir][python] Add basic python support for GPU dialect and passes
Nicolas Vasilache [Wed, 28 Apr 2021 13:22:34 +0000 (13:22 +0000)]
[mlir][python] Add basic python support for GPU dialect and passes

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

3 years ago[mlir][python] Add python support for async dialect and passes.
Nicolas Vasilache [Tue, 27 Apr 2021 19:57:56 +0000 (19:57 +0000)]
[mlir][python] Add python support for async dialect and passes.

since the `async` keyword is reserved in python, the dialect is called async_dialect.

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

3 years agoRevert "[SimplifyCFG] Sinking indirect calls - they're already indirect anyways"
Roman Lebedev [Wed, 28 Apr 2021 14:46:59 +0000 (17:46 +0300)]
Revert "[SimplifyCFG] Sinking indirect calls - they're already indirect anyways"

Seems to break indirect call promotion, LTO/Resolution/X86/load-sample-prof-icp.ll fails.

This reverts commit e57cf128b30a88c6dd42e8ef40deeedd0d7f116d.

3 years ago[SimplifyCFG] Sinking indirect calls - they're already indirect anyways
Roman Lebedev [Wed, 28 Apr 2021 14:33:52 +0000 (17:33 +0300)]
[SimplifyCFG] Sinking indirect calls - they're already indirect anyways

3 years ago[NFC][SimplifyCFG] Add test for sinking indirect calls
Roman Lebedev [Wed, 28 Apr 2021 14:32:17 +0000 (17:32 +0300)]
[NFC][SimplifyCFG] Add test for sinking indirect calls

3 years ago[SimplifyLibCalls] Transform printf("%s", str) --> puts(str)/noop
Dawid Jurczak [Wed, 28 Apr 2021 14:21:21 +0000 (10:21 -0400)]
[SimplifyLibCalls] Transform printf("%s", str) --> puts(str)/noop

Before this change LLVM cannot simplify printf in following cases:

printf("%s", "") --> noop
printf("%s", str"\n") --> puts(str)

From the other hand GCC can perform such transformations for many years:
https://godbolt.org/z/7nnqbedfe

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

3 years ago[clang] remove dead code after 2a1332245fc
Nico Weber [Wed, 28 Apr 2021 14:21:31 +0000 (10:21 -0400)]
[clang] remove dead code after 2a1332245fc

Commit 2a1332245fc extracted this code to a new function checkSectionName() and
added a call to it, but didn't remove the original code. The original code
is dead since the checkSectionName() early return would fire when it would
trigger. (If it weren't dead, it'd make clang crash since
err_attribute_section_invalid_for_target now takes two args instead of just the
one that's passed.)

No behavior change.

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

3 years ago[Hexagon] Skip function in Hexagon vector combine if requested
Krzysztof Parzyszek [Wed, 28 Apr 2021 13:57:20 +0000 (08:57 -0500)]
[Hexagon] Skip function in Hexagon vector combine if requested

Add a call to skipFunction().

3 years ago[LoopVectorize][SVE] Fix crash when vectorising FP negation
David Sherwood [Fri, 5 Mar 2021 17:10:09 +0000 (17:10 +0000)]
[LoopVectorize][SVE] Fix crash when vectorising FP negation

This patch fixes a crash encountered when vectorising the following loop:

 void foo(float *dst, float *src, long long n) {
   for (long long i = 0; i < n; i++)
     dst[i] = -src[i];
 }

using scalable vectors. I've added a test to

 Transforms/LoopVectorize/AArch64/sve-basic-vec.ll

as well as cleaned up the other tests in the same file.

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

3 years ago[libc++] [test] Don't assume iterators are class types.
Arthur O'Dwyer [Wed, 28 Apr 2021 01:30:38 +0000 (21:30 -0400)]
[libc++] [test] Don't assume iterators are class types.

In particular, `span<int>::iterator` may be a raw pointer type
and thus have no nested typedef `iterator::value_type`. However,
we already know that the value_type we expect for `span<int>` is just `int`.
Fix up all other iterator_concept_conformance tests in the same way.

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

3 years ago[clangd][ObjC] Improve support for class properties
David Goldman [Tue, 6 Apr 2021 17:31:09 +0000 (13:31 -0400)]
[clangd][ObjC] Improve support for class properties

Class properties are always implicit short-hands for the getter/setter
class methods.

We need to explicitly visit the interface decl `UIColor` in `UIColor.blueColor`,
otherwise we instead show the method decl even while hovering over
`UIColor` in the expression.

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

3 years ago[gn build] (port) 64bc44f5dd and f8de9aaef2f some more
Nico Weber [Wed, 28 Apr 2021 13:58:55 +0000 (09:58 -0400)]
[gn build] (port) 64bc44f5dd and f8de9aaef2f some more

3 years ago[TableGen] Add the !find bang operator
Paul C. Anagnostopoulos [Mon, 26 Apr 2021 13:53:35 +0000 (09:53 -0400)]
[TableGen] Add the !find bang operator

!find searches a source string for a target string and returns the position.

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

3 years agoSilence unused variable warning
Tres Popp [Wed, 28 Apr 2021 13:46:07 +0000 (15:46 +0200)]
Silence unused variable warning

3 years ago[SLP]Try to vectorize tiny trees with shuffled gathers.
Alexey Bataev [Mon, 26 Apr 2021 15:02:06 +0000 (08:02 -0700)]
[SLP]Try to vectorize tiny trees with shuffled gathers.

If the first tree element is vectorize and the second is gather, it
still might be profitable to vectorize it if the gather node contains
less scalars to vectorize than the original tree node. It might be
profitable to use shuffles.

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

3 years ago[NFC][InlineCost] Add tests for D101228
Roman Lebedev [Wed, 28 Apr 2021 13:19:30 +0000 (16:19 +0300)]
[NFC][InlineCost] Add tests for D101228

3 years ago[clangd] Add SymbolID to LocatedSymbol.
Utkarsh Saxena [Tue, 27 Apr 2021 18:36:05 +0000 (20:36 +0200)]
[clangd] Add SymbolID to LocatedSymbol.

This is useful for running in batch mode.
Getting the SymbolID from via getSymbolInfo may give SymbolID
of a symbol different from that located by LocateSymbolAt (they
have different semantics of choosing the symbol.)

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

3 years ago[OpenCL] Introduce new method for validating OpenCL target
Anton Zabaznov [Thu, 22 Apr 2021 16:53:59 +0000 (19:53 +0300)]
[OpenCL] Introduce new method for validating OpenCL target

Language options are not available when a target is being created,
thus, a new method is introduced. Also, some refactoring is done,
such as removing OpenCL feature macros setting from TargetInfo.

Reviewed By: Anastasia

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

3 years ago[mlir] Fix the postsubmit comments in https://reviews.llvm.org/D101445
Alexander Belyaev [Wed, 28 Apr 2021 12:57:50 +0000 (14:57 +0200)]
[mlir] Fix the postsubmit comments in https://reviews.llvm.org/D101445

3 years agoGlobalISel: Relax verification of physical register copy types
Matt Arsenault [Sat, 17 Apr 2021 14:54:56 +0000 (10:54 -0400)]
GlobalISel: Relax verification of physical register copy types

This was picking a concrete size for a physical register, and
enforcing exact match on the virtual register's type size. Some
targets add multiple types to a register class, and some are smaller
than the full bit width. For example x86 adds f32 to 128-bit xmm
registers, and AMDGPU adds i16/f16 to 32-bit registers.

It might be better to represent these cases as a copy of the full
register and an extraction of the subpart, but a lot of code assumes
you can directly copy. This will help fix the current usage of the DAG
calling convention infrastructure which is incompatible with how
GlobalISel is now using it.

The API is somewhat cumbersome here, but I just mirrored the existing
functions, except now with LLTs (and allow returning null on failure,
unlike the MVT version). I think the concept of selecting register
classes based on type is flawed to begin with, but I'm trying to keep
this compatible with the existing handling.

3 years ago[LoopVectorize] Simplify scalar cost calculation in getInstructionCost
David Sherwood [Wed, 10 Mar 2021 08:34:19 +0000 (08:34 +0000)]
[LoopVectorize] Simplify scalar cost calculation in getInstructionCost

This patch simplifies the calculation of certain costs in
getInstructionCost when isScalarAfterVectorization() returns a true value.
There are a few places where we multiply a cost by a number N, i.e.

  unsigned N = isScalarAfterVectorization(I, VF) ? VF.getKnownMinValue() : 1;
  return N * TTI.getArithmeticInstrCost(...

After some investigation it seems that there are only these cases that occur
in practice:

1. VF is a scalar, in which case N = 1.
2. VF is a vector. We can only get here if: a) the instruction is a
GEP/bitcast/PHI with scalar uses, or b) this is an update to an induction
variable that remains scalar.

I have changed the code so that N is assumed to always be 1. For GEPs
the cost is always 0, since this is calculated later on as part of the
load/store cost. PHI nodes are costed separately and were never previously
multiplied by VF. For all other cases I have added an assert that none of
the users needs scalarising, which didn't fire in any unit tests.

Only one test required fixing and I believe the original cost for the scalar
add instruction to have been wrong, since only one copy remains after
vectorisation.

I have also added a new test for the case when a pointer PHI feeds directly
into a store that will be scalarised as we were previously never testing it.

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

3 years ago[OPENMP]Fix PR49098: respect firstprivate of declare target variable.
Alexey Bataev [Mon, 29 Mar 2021 18:39:27 +0000 (11:39 -0700)]
[OPENMP]Fix PR49098: respect firstprivate of declare target variable.

Need to respect mapping/privatization of declare target variables in the
target regions if explicitly specified by the user.

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

3 years ago[mlir] Add folding for tensor inputs and memref.cast in linalg.tiled_loop.
Alexander Belyaev [Wed, 28 Apr 2021 12:16:35 +0000 (14:16 +0200)]
[mlir] Add folding for tensor inputs and memref.cast in linalg.tiled_loop.

Tensor inputs, if not used in the body of TiledLoopOp, can be removed.
memref::CastOp can be folded into TiledLoopOp as well.

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

3 years ago[MLIR] Add ComplexToStandard conversion pass.
Adrian Kuegel [Wed, 28 Apr 2021 10:49:57 +0000 (12:49 +0200)]
[MLIR] Add ComplexToStandard conversion pass.

So far, only a conversion for complex::AbsOp is done, but more will be added.

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

3 years agoRevert "tsan: refactor fork handling"
Tres Popp [Wed, 28 Apr 2021 12:06:57 +0000 (14:06 +0200)]
Revert "tsan: refactor fork handling"

This reverts commit e1021dd1fdfebff77cfb205892ada6b6a900865f.

3 years ago[LV] Calculate max feasible scalable VF.
Sander de Smalen [Tue, 27 Apr 2021 12:18:01 +0000 (13:18 +0100)]
[LV] Calculate max feasible scalable VF.

This patch also refactors the way the feasible max VF is calculated,
although this is NFC for fixed-width vectors.

After this change scalable VF hints are no longer truncated/clamped
to a shorter scalable VF, nor does it drop the 'scalable flag' from
the suggested VF to vectorize with a similar VF that is fixed.

Instead, the hint is ignored which means the vectorizer is free
to find a more suitable VF, using the CostModel to determine the
best possible VF.

Reviewed By: c-rhodes, fhahn

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

3 years ago[llvm-objdump] Fix dumping dynamic relative relocations for SHT_REL
Alex Richardson [Wed, 28 Apr 2021 09:13:27 +0000 (10:13 +0100)]
[llvm-objdump] Fix dumping dynamic relative relocations for SHT_REL

Previously printing R_386_RELATIVE relocations would trigger
`error: can't read an entry at 0x40: it goes past the end of the section (0x40)`
I found this while writing a test case for LLD (D100490).
This also includes some minor cleanup in the elf-dynamic-relcos.test
llvm-objdump test based on the newly added test.

Reviewed By: jhenderson, MaskRay

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

3 years ago[ELF] Update URL for MIPS TLS wiki page
Alex Richardson [Wed, 28 Apr 2021 09:13:17 +0000 (10:13 +0100)]
[ELF] Update URL for MIPS TLS wiki page

The original page no longer works, so use a web.archive.org link instead.

Reviewed By: atanasyan

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

3 years ago[builtins] Fix ABI-incompatibility with GCC for floating-point compare
Alex Richardson [Wed, 21 Apr 2021 11:20:06 +0000 (12:20 +0100)]
[builtins] Fix ABI-incompatibility with GCC for floating-point compare

While implementing support for the float128 routines on x86_64, I noticed
that __builtin_isinf() was returning true for 128-bit floating point
values that are not infinite when compiling with GCC and using the
compiler-rt implementation of the soft-float comparison functions.
After stepping through the assembly, I discovered that this was caused by
GCC assuming a sign-extended 64-bit -1 result, but our implementation
returns an enum (which then has zeroes in the upper bits) and therefore
causes the comparison with -1 to fail.

Fix this by using a CMP_RESULT typedef and add a static_assert that it
matches the GCC soft-float comparison return type when compiling with GCC
(GCC has a __libgcc_cmp_return__ mode that can be used for this purpose).

Also move the 3 copies of the same code to a shared .inc file.

Reviewed By: compnerd

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

3 years ago[update_(llc_)test_checks.py] Support pre-processing commands
Alex Richardson [Wed, 21 Apr 2021 11:19:08 +0000 (12:19 +0100)]
[update_(llc_)test_checks.py] Support pre-processing commands

This has been rather useful in our downstream CHERI target where we want
to run tests both with addrspace(0) and addrspace(200) pointers.
With this patch we can prefix the opt command with
`sed -e 's/addrspace(200)/addrspace(0)/g' -e 's/-A200-P200-G200//g'` to
test both cases using the same IR input.

Reviewed By: jdoerfert

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

3 years ago[lldb] Correct format enum comment (NFC)
David Spickett [Wed, 28 Apr 2021 11:09:01 +0000 (12:09 +0100)]
[lldb] Correct format enum comment (NFC)

'.' is used for unprintable chars (see NON_PRINTABLE_CHAR).

3 years agoRevert "[loop-idiom] Hoist loop memcpys to loop preheader"
Tres Popp [Wed, 28 Apr 2021 11:15:46 +0000 (13:15 +0200)]
Revert "[loop-idiom] Hoist loop memcpys to loop preheader"

This reverts commit 75d6b8bb4056d518d06b72e6411ce3749455e2e3.

The reasoning is mentioned in https://reviews.llvm.org/D97667

3 years ago[NFC][SimplifyCFG] Move sink-common-code.ll into X86
Roman Lebedev [Wed, 28 Apr 2021 11:02:28 +0000 (14:02 +0300)]
[NFC][SimplifyCFG] Move sink-common-code.ll into X86

There are post-commit notest for e4c61d5 that suggest
the test is failing on certain bots. It looks like
the code there isn't being moved, which suggests
cost-model involvement, which suggests that we need to
hardcode the target triple.

Hopefully this helps?

3 years ago[NFC][Verifier] Split token1.ll into two, assert/non-assert versions
Roman Lebedev [Wed, 28 Apr 2021 10:58:22 +0000 (13:58 +0300)]
[NFC][Verifier] Split token1.ll into two, assert/non-assert versions

3 years ago[mlir] Fix typos (NFC)
Lorenzo Chelini [Wed, 28 Apr 2021 10:50:21 +0000 (12:50 +0200)]
[mlir] Fix typos (NFC)

3 years ago[LoopVectorize] Prevent multiple Phis being generated with in-order reductions
Kerry McLaughlin [Tue, 27 Apr 2021 13:50:27 +0000 (14:50 +0100)]
[LoopVectorize] Prevent multiple Phis being generated with in-order reductions

When using the -enable-strict-reductions flag where UF>1 we generate multiple
Phi nodes, though only one of these is used as an input to the vector.reduce.fadd
intrinsics. The unused Phi nodes are removed later by instcombine.

This patch changes widenPHIInstruction/fixReduction to only generate
one Phi, and adds an additional test for unrolling to strict-fadd.ll

Reviewed By: david-arm

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

3 years ago[clang-query] Add check to prevent setting srcloc when no introspection is available.
Nathan James [Wed, 28 Apr 2021 10:21:34 +0000 (11:21 +0100)]
[clang-query] Add check to prevent setting srcloc when no introspection is available.

Checks if introspection support is available set output kind parser.
If it isn't present the auto complete will not suggest `srcloc` and an error query will be reported if a user tries to access it.

Reviewed By: steveire

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

3 years ago[IRCE] Add tests for conservative bound check
Jingu Kang [Tue, 27 Apr 2021 17:24:11 +0000 (18:24 +0100)]
[IRCE] Add tests for conservative bound check

Prevent cases in which the start value of IV is bigger than bound for
increasing.

Prevent cases in which the start value of IV is smaller than bound for
decreasing.

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

3 years ago[ADT] Make TrackingStatistic's ctor constexpr
Benjamin Kramer [Wed, 28 Apr 2021 09:54:00 +0000 (11:54 +0200)]
[ADT] Make TrackingStatistic's ctor constexpr

This lets clang diagnose unused statistics, so remove them.

3 years ago[MLIR][Shape] Concretize broadcast result type if possible
Frederik Gossen [Wed, 28 Apr 2021 09:56:48 +0000 (11:56 +0200)]
[MLIR][Shape] Concretize broadcast result type if possible

As a canonicalization, infer the resulting shape rank if possible.

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

3 years agoTry to fix clang/test/Driver/cl-options.c on non-x86 hosts
Hans Wennborg [Wed, 28 Apr 2021 09:56:58 +0000 (11:56 +0200)]
Try to fix clang/test/Driver/cl-options.c on non-x86 hosts

The /QIntel-jcc-erratum flag only works when targeting x86,
so pass --target to the driver to do that also on non-x86 hosts.

3 years ago[MLIR][Shape] Canonicalize casted extent tensor operands
Frederik Gossen [Wed, 28 Apr 2021 09:50:28 +0000 (11:50 +0200)]
[MLIR][Shape] Canonicalize casted extent tensor operands

Both, `shape.broadcast` and `shape.cstr_broadcastable` accept dynamic and static
extent tensors. If their operands are casted, we can use the original value
instead.

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

3 years ago[PowerPC] Fix SELECT_CC with i64 operand on PPC32
Qiu Chaofan [Wed, 28 Apr 2021 09:39:20 +0000 (17:39 +0800)]
[PowerPC] Fix SELECT_CC with i64 operand on PPC32

This patch fixes the infinite loop in legalization of PPC32 SELECT_CC
with 64-bit operand.

3 years ago[DebugInfo] Drop DBG_VALUE_LISTs with an excessive number of debug operands
Stephen Tozer [Wed, 28 Apr 2021 09:32:08 +0000 (10:32 +0100)]
[DebugInfo] Drop DBG_VALUE_LISTs with an excessive number of debug operands

This patch fixes a crash in LiveDebugVariables for inputs where a
DBG_VALUE_LIST had 64 or more debug operands. This was triggering an
assert, which was added under the assumption that only bad CodeGen would
result in such a limit being hit, but relatively simple source files
that result in these incredibly long debug values have been found, so
this assert has been changed to a condition that drops the debug value
if it is not met.

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

3 years ago[clang-cl] Map /QIntel-jcc-erratum to -mbranches-within-32B-boundaries
Hans Wennborg [Wed, 28 Apr 2021 09:09:50 +0000 (11:09 +0200)]
[clang-cl] Map /QIntel-jcc-erratum to -mbranches-within-32B-boundaries

3 years ago[MLIR][Shape] Derive more concrete type for `shape.shape_of`
Frederik Gossen [Wed, 28 Apr 2021 08:47:32 +0000 (10:47 +0200)]
[MLIR][Shape] Derive more concrete type for `shape.shape_of`

Also create all extent tensor constants with const_shape op.

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

3 years ago[AArch64] Add missing UINT_TO_FP promotions for v16i8
Joe Ellis [Mon, 26 Apr 2021 09:42:18 +0000 (09:42 +0000)]
[AArch64] Add missing UINT_TO_FP promotions for v16i8

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

3 years ago[X86][AMX][NFC] Add more comments and remove unnecessary check found by Clocwork
Wang, Pengfei [Wed, 28 Apr 2021 07:56:17 +0000 (15:56 +0800)]
[X86][AMX][NFC] Add more comments and remove unnecessary check found by Clocwork

3 years agoRequire asserts for llvm/test/Verifier/token1.ll
Hans Wennborg [Wed, 28 Apr 2021 07:56:04 +0000 (09:56 +0200)]
Require asserts for llvm/test/Verifier/token1.ll

The test expects and assert, and that only works in asserts-enabled builds.

3 years ago[flang] Remove interfaces for Character[Min|Max][Val|Loc]. NFC
Diana Picus [Thu, 22 Apr 2021 09:02:40 +0000 (09:02 +0000)]
[flang] Remove interfaces for Character[Min|Max][Val|Loc]. NFC

MAXVAL, MINVAL, MAXLOC and MINLOC are already implemented in extrema.cpp
as MaxvalCharacter, MinvalDim etc. Therefore, the interfaces in
character.h are redundant and should be removed to avoid confusion.

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

3 years ago[RISCV] Remove riscv32 test cases for vector intrinsics.
Hsiangkai Wang [Wed, 28 Apr 2021 07:53:17 +0000 (15:53 +0800)]
[RISCV] Remove riscv32 test cases for vector intrinsics.

3 years ago[mlir][Python][Linalg] Fixing typos (NFC).
Tobias Gysi [Wed, 28 Apr 2021 07:38:36 +0000 (07:38 +0000)]
[mlir][Python][Linalg] Fixing typos (NFC).

3 years ago[libcxx] Fix the libc++abi header path
Petr Hosek [Wed, 28 Apr 2021 06:30:53 +0000 (23:30 -0700)]
[libcxx] Fix the libc++abi header path

This addresses an issue introduced in 775e55462a64.

3 years ago[Driver] Use normalized triples for per-target runtimes
Petr Hosek [Wed, 28 Apr 2021 05:31:36 +0000 (22:31 -0700)]
[Driver] Use normalized triples for per-target runtimes

This is a partial revert of b4537c3f51bc6c011ddd9c10b80043ac4ce16a01
based on the discussion in https://reviews.llvm.org/D101194. Rather
than using the getMultiarchTriple, we use the getTripleString.

3 years ago[MLIR] Add and propagate section attribute for LLVM_GlobalOp
Ranjith Kumar H [Wed, 28 Apr 2021 03:59:11 +0000 (03:59 +0000)]
[MLIR] Add and propagate section attribute for LLVM_GlobalOp

Add a section attribute to LLVM_GlobalOp, during module translation attribute value is propagated to llvm

Reviewed By: sgrechanik, ftynse, mehdi_amini

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

3 years ago[NFC] Refactor how CFI section types are represented in AsmPrinter
RamNalamothu [Wed, 28 Apr 2021 00:27:29 +0000 (05:57 +0530)]
[NFC] Refactor how CFI section types are represented in AsmPrinter

In terms of readability, the `enum CFIMoveType` didn't better document what it
intends to convey i.e. the type of CFI section that gets emitted.

Reviewed By: dblaikie, MaskRay

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

3 years agoFixed Typos
Jennifer Chukwu [Wed, 28 Apr 2021 03:24:03 +0000 (08:54 +0530)]
Fixed Typos

Fixed typo errors in release notes of Polly 13

Reviewed By: Meinersbur

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

3 years ago[lldb] Fix DataLayout reference after 0f1137ba79c0
Jordan Rupprecht [Wed, 28 Apr 2021 03:06:56 +0000 (20:06 -0700)]
[lldb] Fix DataLayout reference after 0f1137ba79c0

3 years ago[clang/Basic] Make TargetInfo.h not use DataLayout again
Nico Weber [Mon, 19 Apr 2021 17:39:20 +0000 (13:39 -0400)]
[clang/Basic] Make TargetInfo.h not use DataLayout again

Reverts parts of https://reviews.llvm.org/D17183, but keeps the
resetDataLayout() API and adds an assert that checks that datalayout string and
user label prefix are in sync.

Approach 1 in https://reviews.llvm.org/D17183#2653279
Reduces number of TUs build for 'clang-format' from 689 to 575.

I also implemented approach 2 in D100764. If someone feels motivated
to make us use DataLayout more, it's easy to revert this change here
and go with D100764 instead. I don't plan on doing more work in this
area though, so I prefer going with the smaller, more self-consistent change.

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

3 years ago[gn build] (manually) port 82d3c0759fa0
Nico Weber [Wed, 28 Apr 2021 02:25:55 +0000 (22:25 -0400)]
[gn build] (manually) port 82d3c0759fa0

3 years ago[mlir] Support setting operand values in C and Python APIs.
Mike Urbach [Sat, 24 Apr 2021 02:27:43 +0000 (20:27 -0600)]
[mlir] Support setting operand values in C and Python APIs.

This adds `mlirOperationSetOperand` to the IR C API, similar to the
function to get an operand.

In the Python API, this adds `operands[index] = value` syntax, similar
to the syntax to get an operand with `operands[index]`.

Reviewed By: mehdi_amini

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

3 years ago[MLIR][Python] Add capsule methods for pybind11 to PyValue.
Mike Urbach [Thu, 22 Apr 2021 06:07:30 +0000 (00:07 -0600)]
[MLIR][Python] Add capsule methods for pybind11 to PyValue.

Add the `getCapsule()` and `createFromCapsule()` methods to the
PyValue class, as well as the necessary interoperability.

Reviewed By: stellaraccident

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

3 years ago[CMake][llvm] add missing include to LLVMCheckLinkerFlag
Jim Radford [Wed, 28 Apr 2021 00:16:57 +0000 (17:16 -0700)]
[CMake][llvm] add missing include to LLVMCheckLinkerFlag

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

3 years ago[scudo] Enable arm32 arch
Vitaly Buka [Wed, 28 Apr 2021 01:33:58 +0000 (18:33 -0700)]
[scudo] Enable arm32 arch

3 years ago[DSE] Eliminate zero memset after calloc
Dávid Bolvanský [Tue, 27 Apr 2021 21:19:44 +0000 (23:19 +0200)]
[DSE] Eliminate zero memset after calloc

Solves PR11896

As noted, this can be improved futher (calloc -> malloc) in some cases. But for know, this is the first step.

Reviewed By: nikic

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

3 years ago[CSSPGO] Fix an AV caused by a block that has only pseudo pseudo instructions.
Hongtao Yu [Wed, 28 Apr 2021 00:16:29 +0000 (17:16 -0700)]
[CSSPGO] Fix an AV caused by a block that has only pseudo pseudo instructions.

Reviewed By: wenlei

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

3 years ago[lld-macho][NFC] define more strings in section_names:: and segment_names::
Greg McGary [Tue, 27 Apr 2021 19:22:44 +0000 (12:22 -0700)]
[lld-macho][NFC] define more strings in section_names:: and segment_names::

As preparation for a subsequent diff that implements builtin section renaming, define more `constexpr` strings in namespaces `lld::macho::segment_names` and `lld::macho::section_names`, and use them to replace string literals.

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

3 years agoHandle the case of tile and pad a subset of the dimensions
Ahmed Taei [Mon, 26 Apr 2021 19:35:12 +0000 (12:35 -0700)]
Handle the case of tile and pad a subset of the dimensions

This is useful in cases such as tile-distribute-and-pad where not all
dims are tiled

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

3 years ago[loop-idiom] Hoist loop memcpys to loop preheader
Han Zhu [Tue, 9 Feb 2021 01:24:25 +0000 (17:24 -0800)]
[loop-idiom] Hoist loop memcpys to loop preheader

For a simple loop like:
```
struct S {
  int x;
  int y;
  char b;
};

unsigned foo(S* __restrict__ a, S* b, int n) {
  for (int i = 0; i < n; i++)
    a[i] = b[i];

  return sizeof(a[0]);
}
```
We could eliminate the loop and convert it to a large memcpy of 12*n bytes. Currently this is not handled. Output of `opt -loop-idiom -S < memcpy_before.ll`
```
%struct.S = type { i32, i32, i8 }

define dso_local i32 @_Z3fooP1SS0_i(%struct.S* noalias nocapture %a, %struct.S* nocapture readonly %b, i32 %n) local_unnamed_addr {
entry:
  %cmp7 = icmp sgt i32 %n, 0
  br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup

for.body.preheader:                               ; preds = %entry
  br label %for.body

for.cond.cleanup.loopexit:                        ; preds = %for.body
  br label %for.cond.cleanup

for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry
  ret i32 12

for.body:                                         ; preds = %for.body, %for.body.preheader
  %i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
  %idxprom = zext i32 %i.08 to i64
  %arrayidx = getelementptr inbounds %struct.S, %struct.S* %b, i64 %idxprom
  %arrayidx2 = getelementptr inbounds %struct.S, %struct.S* %a, i64 %idxprom
  %0 = bitcast %struct.S* %arrayidx2 to i8*
  %1 = bitcast %struct.S* %arrayidx to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 dereferenceable(12) %0, i8* nonnull align 4 dereferenceable(12) %1, i64 12, i1 false)
  %inc = add nuw nsw i32 %i.08, 1
  %cmp = icmp slt i32 %inc, %n
  br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit
}

; Function Attrs: argmemonly nofree nosync nounwind willreturn
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0

attributes #0 = { argmemonly nofree nosync nounwind willreturn }

```
The loop idiom pass currently only handles load and store instructions. Since struct S is too big to fit in a register, the loop body contains a memcpy intrinsic.

With this change, re-run `opt -loop-idiom -S < memcpy_before.ll`. The loop memcpy is promoted to loop preheader. For this trivial case, the loop is dead and will be removed by another pass.
```
%struct.S = type { i32, i32, i8 }

define dso_local i32 @_Z3fooP1SS0_i(%struct.S* noalias nocapture %a, %struct.S* nocapture readonly %b, i32 %n) local_unnamed_addr {
entry:
  %a1 = bitcast %struct.S* %a to i8*
  %b2 = bitcast %struct.S* %b to i8*
  %cmp7 = icmp sgt i32 %n, 0
  br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup

for.body.preheader:                               ; preds = %entry
  %0 = zext i32 %n to i64
  %1 = mul nuw nsw i64 %0, 12
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %a1, i8* align 4 %b2, i64 %1, i1 false)
  br label %for.body

for.cond.cleanup.loopexit:                        ; preds = %for.body
  br label %for.cond.cleanup

for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry
  ret i32 12

for.body:                                         ; preds = %for.body, %for.body.preheader
  %i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
  %idxprom = zext i32 %i.08 to i64
  %arrayidx = getelementptr inbounds %struct.S, %struct.S* %b, i64 %idxprom
  %arrayidx2 = getelementptr inbounds %struct.S, %struct.S* %a, i64 %idxprom
  %2 = bitcast %struct.S* %arrayidx2 to i8*
  %3 = bitcast %struct.S* %arrayidx to i8*
  %inc = add nuw nsw i32 %i.08, 1
  %cmp = icmp slt i32 %inc, %n
  br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit
}

; Function Attrs: argmemonly nofree nosync nounwind willreturn
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0

attributes #0 = { argmemonly nofree nosync nounwind willreturn }
```

Reviewed By: zino

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

3 years ago[AIX] Add %pluginext and update tests to use proper pluginext
David Tenty [Tue, 27 Apr 2021 23:36:45 +0000 (19:36 -0400)]
[AIX] Add %pluginext and update tests to use proper pluginext

As a follow on to D96282, since bug point passes is built as a module the proper file extension to use is LLVM_PLUGIN_EXT, rather than SHLIBEXT. Using SHLIBEXT causes the tests to load a non-existent file on AIX. We also adjust the PluginsTest unittest  to use LLVM_PLUGIN_EXT for similar reasons.

This change should hopefully make little difference to other platforms, since generally `SHLIBEXT=LTDL_SHLIB_EXT=CMAKE_SHARED_LIBRARY_SUFFIX` and `LLVM_PLUGIN_EXT=CMAKE_SHARED_LIBRARY_SUFFIX` on every platform except AIX.

Reviewed By: hubert.reinterpretcast

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

3 years ago[tosa][mlir] Fix FullyConnected to correctly order dimensions
Rob Suderman [Sat, 24 Apr 2021 02:24:49 +0000 (19:24 -0700)]
[tosa][mlir] Fix FullyConnected to correctly order dimensions

MatMul and FullyConnected have transposed dimensions for the weights.
Also, removed uneeded tensor reshape for bias.

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

3 years ago[mlir][tosa] Add tosa.negate lowerings for quantized cases
Rob Suderman [Sat, 24 Apr 2021 05:00:06 +0000 (22:00 -0700)]
[mlir][tosa] Add tosa.negate lowerings for quantized cases

Quantized negation can be performed using higher bits operations.
Minimal bits are picked to perform the operation.

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

3 years ago[CMake][llvm] avoid conflict w/ (and use when available) new builtin check_linker_flag
Jim Radford [Sat, 3 Apr 2021 06:51:17 +0000 (23:51 -0700)]
[CMake][llvm] avoid conflict w/ (and use when available) new builtin check_linker_flag

Match the API for the new check_linker_flag and use it directly when
available, leaving the old code as a fallback.

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

3 years agoRevert "[llvm-objcopy][MachO] Add support for LC_THREAD/LC_UNIXTHREAD"
Alexander Shaposhnikov [Tue, 27 Apr 2021 23:18:12 +0000 (16:18 -0700)]
Revert "[llvm-objcopy][MachO] Add support for LC_THREAD/LC_UNIXTHREAD"

This reverts commit 4dfddf715b94857998601aa79c25e4f327d44dfa
since it breaks some build bots (e.g. clang-ppc64be-linux)

3 years ago[WebAssembly] Error when wasm EH is used with Emscripten EH/SjLj
Heejin Ahn [Tue, 27 Apr 2021 21:59:12 +0000 (14:59 -0700)]
[WebAssembly] Error when wasm EH is used with Emscripten EH/SjLj

- Error out when both Emscripten EH and wasm EH are used together, i.e.,
  both `-enable-emscripten-cxx-exceptions` and `-exception-model=wasm`
  are given together. This will not happen if you use Emscripten, but
  this can happen when you call `llc` manually with wrong set of
  arguments.
- Currently we don't yet support using wasm EH with Emscripten SjLj.
  Unlike `-enable-emscripten-cxx-exceptions` which is turned on only
  when you use `emcc -s DISABLE_EXCEPTION_CATCHING=0`,
  `-enable-emscripten-sjlj` is turned on by Emscripten by default. So we
  error out only when it is turned on and `setjmp` or `longjmp` is
  actually used.

Reviewed By: tlively

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

3 years ago[Driver] Add -print-multiarch
Petr Hosek [Tue, 27 Apr 2021 21:26:55 +0000 (14:26 -0700)]
[Driver] Add -print-multiarch

This is useful in runtimes build for example which currently try to
guess the correct triple where to place libraries in the multiarch
layout.  Using this flag, the build system can get the correct triple
directly by querying Clang.

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

3 years ago[llvm-objcopy][MachO] Add support for LC_THREAD/LC_UNIXTHREAD
Alexander Shaposhnikov [Tue, 27 Apr 2021 22:54:28 +0000 (15:54 -0700)]
[llvm-objcopy][MachO] Add support for LC_THREAD/LC_UNIXTHREAD

Add support for LC_THREAD/LC_UNIXTHREAD
(these load commands can be copied over without any modifications).

Test plan: make check-all

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

3 years ago[OpenMP] Remove legacy pass manager run lines
Joseph Huber [Tue, 27 Apr 2021 22:02:05 +0000 (18:02 -0400)]
[OpenMP] Remove legacy pass manager run lines

Summary:
Two tests in OpenMPOpt currently fail using the legacy pass manager. Remove
these run lines to prevent tests from failing.

3 years ago[lld-macho] Don't put an antivirus test file in reproduce.s
Jez Ng [Tue, 27 Apr 2021 22:02:18 +0000 (18:02 -0400)]
[lld-macho] Don't put an antivirus test file in reproduce.s

It appears that some antivirii do not recognize that "this is a
test": https://reviews.llvm.org/D101218#2720676

Reviewed By: #lld-macho, smeenai

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

3 years ago[lld-macho] std::sort -> llvm::sort
Jez Ng [Mon, 26 Apr 2021 05:23:32 +0000 (01:23 -0400)]
[lld-macho] std::sort -> llvm::sort

3 years ago[SelectionDAG] Use a VTSDNode to store the saturation width for FP_TO_SINT_SAT/FP_TO_...
Craig Topper [Tue, 27 Apr 2021 21:38:40 +0000 (14:38 -0700)]
[SelectionDAG] Use a VTSDNode to store the saturation width for FP_TO_SINT_SAT/FP_TO_UINT_SAT

Previously we used an i32 constant to store the saturation width, but i32 isn't
legal on RISCV64. This wasn't a big deal to fix, but it is extra work for the
type legalizer.

This patch uses a VTSDNode to store the type similar to SEXT_INREG. This makes
it opaque to the type legalizer.

Reviewed By: nikic

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

3 years ago[RISCV] Select 5 bit immediate for VSETIVLI during isel rather than peepholing in...
Craig Topper [Tue, 27 Apr 2021 19:48:44 +0000 (12:48 -0700)]
[RISCV] Select 5 bit immediate for VSETIVLI during isel rather than peepholing in the custom inserter.

This adds a special operand type that is allowed to be either
an immediate or register. By giving it a unique operand type the
machine verifier will ignore it.

This perturbs a lot of tests but mostly it is just slightly different
instruction orders. Something bad did happen to some min/max reduction
tests. We're spilling vector registers when we weren't before.

Reviewed By: khchen

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

3 years ago[NFC][SimplifyCFG] Precommit SimplifyCFG tests from D29428
Reid Kleckner [Tue, 27 Apr 2021 21:32:04 +0000 (00:32 +0300)]
[NFC][SimplifyCFG] Precommit SimplifyCFG tests from D29428

3 years ago[NFC][SimplifyCFG] Autogenerate check lines in few more tests
Roman Lebedev [Tue, 27 Apr 2021 21:24:44 +0000 (00:24 +0300)]
[NFC][SimplifyCFG] Autogenerate check lines in few more tests

3 years ago[mlir] Fix bug in ForwardDataFlowAnalysis solver
River Riddle [Tue, 27 Apr 2021 21:27:08 +0000 (14:27 -0700)]
[mlir] Fix bug in ForwardDataFlowAnalysis solver

Explicitly check for uninitialized to prevent crashes in edge cases where the derived analysis creates a lattice element for a value that hasn't been visited yet.

3 years ago[ConstFold] Use const-folded operands in more places
Arthur Eubanks [Tue, 27 Apr 2021 19:35:25 +0000 (12:35 -0700)]
[ConstFold] Use const-folded operands in more places

Previously we were const folding operands but not passing them.

Reviewed By: nikic

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

3 years ago[OpenMP][CMake] Pass --cuda-path to regression tests.
Michael Kruse [Tue, 27 Apr 2021 21:27:32 +0000 (16:27 -0500)]
[OpenMP][CMake] Pass --cuda-path to regression tests.

The OpenMP runtime can be compiled using a CUDA installed at non-default
location with the -DCUDA_TOOLKIT_ROOT_DIR setting. However, check-openmp
will fail afterwards because Clang needs to know where to find the CUDA
headers.

Fix by passing -cuda-path to Clang using the value of
CUDA_TOOLKIT_ROOT_DIR which has been determined by CMake. Also set
LD_LIBRARY_PATH such that it can find the cuda runtime when executing.
This will ensure that the regression test do not depend on the current
environment, but use the environment it was configured for.

Reviewed By: tianshilei1992

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

3 years ago[DSE] Added testcases for 11896, NFC
Dávid Bolvanský [Tue, 27 Apr 2021 19:25:32 +0000 (21:25 +0200)]
[DSE] Added testcases for 11896, NFC

3 years ago[loop-idiom][NFC] Extract processLoopStoreOfLoopLoad into a helper function
Han Zhu [Tue, 30 Mar 2021 19:56:19 +0000 (12:56 -0700)]
[loop-idiom][NFC] Extract processLoopStoreOfLoopLoad into a helper function

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

3 years ago[SCEV] Handle uge/ugt predicates in applyLoopGuards()
Nikita Popov [Fri, 23 Apr 2021 20:02:27 +0000 (22:02 +0200)]
[SCEV] Handle uge/ugt predicates in applyLoopGuards()

These can be handled the same way as ule/ult, just using umax
instead of umin. This is useful in cases where the umax prevents
the upper bound from overflowing.

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

3 years ago[SLP]Add a test for possibly vectorized tiny tree, NFC.
Alexey Bataev [Tue, 27 Apr 2021 20:38:30 +0000 (13:38 -0700)]
[SLP]Add a test for possibly vectorized tiny tree, NFC.

3 years agotsan: fix build with COMPILER_RT_TSAN_DEBUG_OUTPUT
Dmitry Vyukov [Tue, 27 Apr 2021 18:19:28 +0000 (20:19 +0200)]
tsan: fix build with COMPILER_RT_TSAN_DEBUG_OUTPUT

COMPILER_RT_TSAN_DEBUG_OUTPUT enables TSAN_COLLECT_STATS,
which changes layout of runtime structs (some structs contain
stats when the option is enabled).
It's not OK to build runtime with the define, but tests without it.
The error is detected by build_consistency_stats/nostats.
Fix this by defining TSAN_COLLECT_STATS for tests to match the runtime.

Reviewed By: vitalybuka

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

3 years agotsan: refactor fork handling
Dmitry Vyukov [Fri, 23 Apr 2021 11:10:39 +0000 (13:10 +0200)]
tsan: refactor fork handling

Commit efd254b6362 ("tsan: fix deadlock in pthread_atfork callbacks")
fixed another deadlock related to atfork handling.
But builders with DCHECKs enabled reported failures of
pthread_atfork_deadlock2.c and pthread_atfork_deadlock3.c tests
related to the fact that we hold runtime locks on interceptor exit:
https://lab.llvm.org/buildbot/#/builders/70/builds/6727
This issue is somewhat inherent to the current approach,
we indeed execute user code (atfork callbacks) with runtime lock held.

Refactor fork handling to not run user code (atfork callbacks)
with runtime locks held. This change does this by installing
own atfork callbacks during runtime initialization.
Atfork callbacks run in LIFO order, so the expectation is that
our callbacks run last, right before the actual fork.
This way we lock runtime mutexes around fork, but not around
user callbacks.

Extend tests to also install after fork callbacks just to cover
more scenarios. Some tests also started reporting real races
that we previously suppressed.

Reviewed By: vitalybuka

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