platform/upstream/llvm.git
3 years ago[gn build] Port d53b4bee0cc
LLVM GN Syncbot [Thu, 1 Oct 2020 12:55:59 +0000 (12:55 +0000)]
[gn build] Port d53b4bee0cc

3 years ago[LoopFlatten] Add a loop-flattening pass
Sjoerd Meijer [Wed, 30 Sep 2020 10:16:22 +0000 (11:16 +0100)]
[LoopFlatten] Add a loop-flattening pass

This is a simple pass that flattens nested loops.  The intention is to optimise
loop nests like this, which together access an array linearly:

  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j)
      f(A[i*M+j]);

into one loop:

  for (int i = 0; i < (N*M); ++i)
    f(A[i]);

It can also flatten loops where the induction variables are not used in the
loop. This can help with codesize and runtime, especially on simple cpus
without advanced branch prediction.

This is only worth flattening if the induction variables are only used in an
expression like i*M+j. If they had any other uses, we would have to insert a
div/mod to reconstruct the original values, so this wouldn't be profitable.

This partially fixes PR40581 as this pass triggers on one of the two cases. I
will follow up on this to learn LoopFlatten a few more (small) tricks. Please
note that LoopFlatten is not yet enabled by default.

Patch by Oliver Stannard, with minor tweaks from Dave Green and myself.

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

3 years ago[NFC][ARM] LowOverheadLoop DEBUG statements
Sam Parker [Thu, 1 Oct 2020 12:37:47 +0000 (13:37 +0100)]
[NFC][ARM] LowOverheadLoop DEBUG statements

3 years ago[lldb] Add missing import for LLDB test decorators to TestStopHookScripted
Raphael Isemann [Thu, 1 Oct 2020 12:32:02 +0000 (14:32 +0200)]
[lldb] Add missing import for LLDB test decorators to TestStopHookScripted

This test wasn't using decorators before and was missing the import, so my
previous commit broke the test.

3 years ago[libc++] Simplify how we re-export symbols from libc++abi
Louis Dionne [Wed, 30 Sep 2020 23:17:16 +0000 (19:17 -0400)]
[libc++] Simplify how we re-export symbols from libc++abi

Instead of managing two copies of the symbol lists, reuse the same list
in libc++abi and libc++.

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

3 years ago[lldb] Skip the flakey part of TestStopHookScripted on Linux
Raphael Isemann [Thu, 1 Oct 2020 12:23:45 +0000 (14:23 +0200)]
[lldb] Skip the flakey part of TestStopHookScripted on Linux

This test seems to randomly fail on Linux machines. It's only one part of the
test failing randomly, so let's just skip it instead of reverting the whole
patch (again).

3 years ago[InstCombine] collectBitParts - use APInt directly to check for out of range bit...
Simon Pilgrim [Thu, 1 Oct 2020 11:49:59 +0000 (12:49 +0100)]
[InstCombine] collectBitParts - use APInt directly to check for out of range bit shifts. NFCI.

3 years ago[CFGuard] Add address-taken IAT tables and delay-load support
Andrew Paverd [Thu, 1 Oct 2020 09:07:40 +0000 (10:07 +0100)]
[CFGuard] Add address-taken IAT tables and delay-load support

This patch adds support for creating Guard Address-Taken IAT Entry Tables (.giats$y sections) in object files, matching the behavior of MSVC. These contain lists of address-taken imported functions, which are used by the linker to create the final GIATS table.
Additionally, if any DLLs are delay-loaded, the linker must look through the .giats tables and add the respective load thunks of address-taken imports to the GFIDS table, as these are also valid call targets.

Reviewed By: rnk

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

3 years ago[SVE][CodeGen] Lower scalable fp_extend & fp_round operations
Kerry McLaughlin [Thu, 1 Oct 2020 10:06:55 +0000 (11:06 +0100)]
[SVE][CodeGen] Lower scalable fp_extend & fp_round operations

This patch adds FP_EXTEND_MERGE_PASSTHRU & FP_ROUND_MERGE_PASSTHRU
ISD nodes, used to lower scalable vector fp_extend/fp_round operations.
fp_round has an additional argument, the 'trunc' flag, which is an integer of zero or one.

This also fixes a warning introduced by the new tests added to sve-split-fcvt.ll,
resulting from an implicit TypeSize -> uint64_t cast in SplitVecOp_FP_ROUND.

Reviewed By: sdesmalen, paulwalker-arm

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

3 years ago[mlir][Linalg] Fix ASAN bug
Nicolas Vasilache [Thu, 1 Oct 2020 10:57:35 +0000 (06:57 -0400)]
[mlir][Linalg] Fix ASAN bug

```
 LinalgTilingOptions &setTileSizes(ValueRange ts)
```
makes it all too easy to create stack-use-after-return errors.

In particular, c694588fc52a8845174fee06ad0bcfa338e87816 introduced one such issue.

Instead just take a copy in the lambda and be done with it.

3 years ago[SCEV] Prove implicaitons via AddRec start
Max Kazantsev [Thu, 1 Oct 2020 08:58:31 +0000 (15:58 +0700)]
[SCEV] Prove implicaitons via AddRec start

If we know that some predicate is true for AddRec and an invariant
(w.r.t. this AddRec's loop), this fact is, in particular, true on the first
iteration. We can try to prove the facts we need using the start value.

The motivating example is proving things like
```
  isImpliedCondOperands(>=, X, 0, {X,+,-1}, 0}
```

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

3 years ago[ARM][LowOverheadLoops] Adjust Start insertion.
Sam Parker [Thu, 1 Oct 2020 09:47:02 +0000 (10:47 +0100)]
[ARM][LowOverheadLoops] Adjust Start insertion.

Try to move the insertion point to become the terminator of the
block, usually the preheader.

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

3 years ago[SVE][CodeGen] Legalisation of integer -> floating point conversions
Kerry McLaughlin [Wed, 30 Sep 2020 09:55:51 +0000 (10:55 +0100)]
[SVE][CodeGen] Legalisation of integer -> floating point conversions

Splitting the operand of a scalable [S|U]INT_TO_FP results in a
concat_vectors operation where the operands are unpacked FP
scalable vectors (e.g. nxv2f32).
This patch adds custom lowering of concat_vectors which
checks that the number of operands is 2, and isel patterns
to match concat_vectors of scalable FP types with uzp1.

Reviewed By: efriedma, paulwalker-arm

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

3 years ago[NFC] Iterate across an explicit list of scalable MVTs when driving setOperationAction.
Paul Walker [Fri, 25 Sep 2020 12:37:03 +0000 (13:37 +0100)]
[NFC] Iterate across an explicit list of scalable MVTs when driving setOperationAction.

Iterating across all of integer_scalable_vector_valuetypes seems
wasteful when there's only a handful we care about.

Also removes some rouge whitespace.

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

3 years ago[ARM][LowOverheadLoops] Iteration count liveness
Sam Parker [Wed, 30 Sep 2020 10:10:49 +0000 (11:10 +0100)]
[ARM][LowOverheadLoops] Iteration count liveness

Before deciding to insert a [W|D]LSTP, check that defining LR with
the element count won't affect any other instructions that should be
taking the iteration count.

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

3 years ago[ARM][LowOverheadLoops] Start insertion point
Sam Parker [Wed, 30 Sep 2020 09:42:08 +0000 (10:42 +0100)]
[ARM][LowOverheadLoops] Start insertion point

If possible, try not to move the start position earlier than it
already is.

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

3 years ago[ORC][examples] Temporarily remove LLJITWithChildProcess until ORC TPC lands
Stefan Gränitz [Thu, 1 Oct 2020 08:25:06 +0000 (10:25 +0200)]
[ORC][examples] Temporarily remove LLJITWithChildProcess until ORC TPC lands

This solves a phase ordering problem: OrcV2 remote process support depends on OrcV2 removable code, OrcV2 removable code depends on OrcV1 removal, OrcV1 removal depends on LLJITWithChildProcess migration, and LLJITWithChildProcess migration depends on OrcV2 TargetProcessControl support.

3 years ago[ORC][examples] Remove ThinLtoJIT example after LLJITWithThinLTOSummaries landed...
Stefan Gränitz [Thu, 1 Oct 2020 08:03:58 +0000 (10:03 +0200)]
[ORC][examples] Remove ThinLtoJIT example after LLJITWithThinLTOSummaries landed in OrcV2Examples

The ThinLtoJIT example was aiming to utilize ThinLTO summaries and concurrency in ORC for speculative compilation. The latter is heavily dependent on asynchronous task scheduling which is probably done better out-of-tree with a mature library like Boost-ASIO. The pure utilization of ThinLTO summaries in ORC is demonstrated in OrcV2Examples/LLJITWithThinLTOSummaries.

3 years ago[sanitizer] Fix SymbolizedStack leak
Vitaly Buka [Thu, 1 Oct 2020 07:49:09 +0000 (00:49 -0700)]
[sanitizer] Fix SymbolizedStack leak

3 years ago[ARM][LowOverheadLoops] Use iterator for InsertPt.
Sam Parker [Wed, 30 Sep 2020 14:15:42 +0000 (15:15 +0100)]
[ARM][LowOverheadLoops] Use iterator for InsertPt.

Use a MachineBasicBlock::iterator instead of a MachineInstr* for the
position of our LoopStart instruction. NFCish, as it change debug
info.

3 years ago[MC] Inline MCExpr::printVariantKind & remove UseParensForSymbolVariantBit
Fangrui Song [Thu, 1 Oct 2020 07:05:15 +0000 (00:05 -0700)]
[MC] Inline MCExpr::printVariantKind & remove UseParensForSymbolVariantBit

Note, MAI may be nullptr in -show-encoding.

3 years ago[AArch64][GlobalISel] Select all-zero G_BUILD_VECTOR into a zero mov.
Amara Emerson [Fri, 18 Sep 2020 18:33:16 +0000 (11:33 -0700)]
[AArch64][GlobalISel] Select all-zero G_BUILD_VECTOR into a zero mov.

Unfortunately the leaf SDAG patterns aren't supported yet so we need to do
this manually, but it's not a significant amount of code anyway.

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

3 years ago[AVR] fix interrupt stack pointer restoration
Andrew Dona-Couch [Thu, 1 Oct 2020 05:49:12 +0000 (18:49 +1300)]
[AVR] fix interrupt stack pointer restoration

This patch fixes a corruption of the stack pointer and several registers in any AVR interrupt with non-empty stack frame.  Previously, the callee-saved registers were popped before restoring the stack pointer, causing the pointer math to use the wrong base value while also corrupting the caller's register.  This change fixes the code to restore the stack pointer last before exiting the interrupt service routine.

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

Reviewed By: dylanmckay

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

Patch by Andrew Dona-Couch.

3 years agoWe don't need two different ways to get commit access, just simplify
Chris Lattner [Thu, 1 Oct 2020 05:36:44 +0000 (22:36 -0700)]
We don't need two different ways to get commit access, just simplify
the policy here so that old SVN users and new contributors do the same
thing.

3 years ago[LLDB] Remove AArch64/Linux xfail decorator from TestGuiBasicDebug
Muhammad Omair Javaid [Thu, 1 Oct 2020 05:20:16 +0000 (10:20 +0500)]
[LLDB] Remove AArch64/Linux xfail decorator from TestGuiBasicDebug

This test now passes on AArch64/Linux after following change by Jonas:
d689570d7dcb16ee241676e22324dc456837eb23

3 years ago[RISCV][ASAN] implementation for previous/next pc routines for riscv64
Igor Chervatyuk [Thu, 24 Sep 2020 07:23:45 +0000 (10:23 +0300)]
[RISCV][ASAN] implementation for previous/next pc routines  for riscv64

[7/11] patch series to port ASAN for riscv64

Depends On D87575

Reviewed By: eugenis, vitalybuka, luismarques

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

3 years ago[SCEV][NFC] Introduce isKnownPredicateAt method
Max Kazantsev [Thu, 1 Oct 2020 05:11:24 +0000 (12:11 +0700)]
[SCEV][NFC] Introduce isKnownPredicateAt method

We can query known predicates in different points, respecting
their dominating conditions.

3 years agoRevert "[llvm-exegesis] Add option to check the hardware support for a given feature...
Michael Liao [Thu, 1 Oct 2020 03:15:35 +0000 (23:15 -0400)]
Revert "[llvm-exegesis] Add option to check the hardware support for a given feature before benchmarking."

This reverts commit 4fcd1a8e6528ca42fe656f2745e15d2b7f5de495 as
`llvm/test/tools/llvm-exegesis/X86/lbr/mov-add.s` failed on hosts
without LBR supported if the build has LIBPFM enabled. On that host,
`perf_event_open` fails with `EOPNOTSUPP` on LBR config. That change's
basic assumption

> If this is run on a non-supported hardware, it will produce all zeroes for latency.

could not stand as `perf_event_open` system call will fail if the
underlying hardware really don't have LBR supported.

3 years ago[ELF] --wrap: don't unnecessarily expose __real_
Fangrui Song [Thu, 1 Oct 2020 03:09:25 +0000 (20:09 -0700)]
[ELF] --wrap: don't unnecessarily expose __real_

The routing rules are:

sym -> __wrap_sym
__real_sym -> sym

__wrap_sym and sym are routing targets, so they need to be exposed to the symbol
table. __real_sym is not and can be eliminated if not used by regular object.

3 years ago[APFloat] Improve asserts in isSignificandAllOnes and isSignificandAllZeros so they...
Craig Topper [Thu, 1 Oct 2020 02:31:08 +0000 (19:31 -0700)]
[APFloat] Improve asserts in isSignificandAllOnes and isSignificandAllZeros so they protect shift operations from undefined behavior.

For example, the assert in isSignificandAllZeros allowed NumHighBits
to be integerPartWidth. But since it is used directly as a shift amount
it must be less than integerPartWidth.

3 years ago[flang][msvc] Workaround 'forgotten' symbols in FoldOperation. NFC.
Michael Kruse [Thu, 1 Oct 2020 01:55:44 +0000 (20:55 -0500)]
[flang][msvc] Workaround 'forgotten' symbols in FoldOperation. NFC.

This resolves an issue where the Microsoft compiler 'forgets' symbols when using constexpr in a lambda in a templated function. The symbols are:

1. The implicit lambda captures `context` and `convert`. Fix by making them explicit captures. The error message was:
```
fold-implementation.h(1220): error C2065: 'convert': undeclared identifier
```

2. The function template argument FROMCAT. Fix by storing it in a temporary constexpr variable inside the function. The error message was:
```
fold-implementation.h(1216): error C2065: 'FROMCAT': undeclared identifier
```

This patch is part of the series to make flang compilable with MS Visual Studio <http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html>.

Reviewed By: klausler

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

3 years ago[WebAssembly] New-style command support
Dan Gohman [Thu, 1 Oct 2020 00:21:57 +0000 (17:21 -0700)]
[WebAssembly] New-style command support

This adds support for new-style command support. In this mode, all exports
are considered command entrypoints, and the linker inserts calls to
`__wasm_call_ctors` and `__wasm_call_dtors` for all such entrypoints.

This enables support for:

 - Command entrypoints taking arguments other than strings and return values
   other than `int`.
 - Multicall executables without requiring on the use of string-based
   command-line arguments.

This new behavior is disabled when the input has an explicit call to
`__wasm_call_ctors`, indicating code not expecting new-style command
support.

This change does mean that wasm-ld no longer supports DCE-ing the
`__wasm_call_ctors` function when there are no calls to it. If there are no
calls to it, and there are ctors present, we assume it's wasm-ld's job to
insert the calls. This seems ok though, because if there are ctors present,
the program is expecting them to be called. This change affects the
init-fini-gc.ll test.

3 years ago[flang][msvc] Avoid ReferenceVariantBase ctor ambiguity. NFC.
Michael Kruse [Wed, 30 Sep 2020 21:14:12 +0000 (16:14 -0500)]
[flang][msvc] Avoid ReferenceVariantBase ctor ambiguity. NFC.

Msvc reports the following error when a ReferenceVariantBase is constructed using an r-value reference or instantiated as std::vector template parameter.  The error message is:
```
PFTBuilder.h(59,1): error C2665: 'std::variant<...>::variant': none of the 2 overloads could convert all the argument types
variant(1248,1): message : could be 'std::variant<...>::variant(std::variant<...> &&) noexcept(false)'
variant(1248,1): message : or       'std::variant<...>::variant(const std::variant<...> &) noexcept(false)'
PFTBuilder.h(59,1): message : while trying to match the argument list '(common::Reference<lower::pft::ReferenceVariantBase<false,...>>)'
```

Work around the ambiguity by only taking `common::Reference` arguments in the constructor. That is, conversion to common::Reference has to be done be the caller instead of being done inside the ctor. Unfortunately, with this change clang/gcc (but not msvc) insist on that the ReferenceVariantBase is stored in a `std::initializer_list`-initialized variable before being used, like being passed to a function or returned.

This patch is part of the series to make flang compilable with MS Visual Studio <http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html>.

Reviewed By: DavidTruby

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

3 years ago[AArch64][GlobalISel] Clamp oversize FP arithmetic vectors.
Amara Emerson [Thu, 1 Oct 2020 01:03:02 +0000 (18:03 -0700)]
[AArch64][GlobalISel] Clamp oversize FP arithmetic vectors.

3 years ago[mlir] Split Dialect::addOperations into two functions
River Riddle [Thu, 1 Oct 2020 00:23:11 +0000 (17:23 -0700)]
[mlir] Split Dialect::addOperations into two functions

The current implementation uses a fold expression to add all of the operations at once. This is really nice, but apparently the lifetime of each of the AbstractOperation instances is for the entire expression which may lead to a stack overflow for large numbers of operations. This splits the method in two to allow for the lifetime of the AbstractOperation to be properly scoped.

3 years ago[flang] Fix Gw.d format output
peter klausler [Wed, 30 Sep 2020 22:04:43 +0000 (15:04 -0700)]
[flang] Fix Gw.d format output

The estimation of the decimal exponent needs to allow for all
'd' of the requested significant digits.

Also accept a plus sign on a "+kP" scaling factor in a format.

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

3 years agoRemove `Ops` suffix from dialect library names
Geoffrey Martin-Noble [Thu, 1 Oct 2020 00:47:25 +0000 (17:47 -0700)]
Remove `Ops` suffix from dialect library names

Dialects include more than just ops, so this suffix is outdated. Follows
discussion in
https://llvm.discourse.group/t/rfc-canonical-file-paths-to-dialects/621

Reviewed By: stellaraccident

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

3 years ago[lld][WebAssembly] Allow exporting of mutable globals
Sam Clegg [Fri, 31 Jul 2020 00:44:32 +0000 (17:44 -0700)]
[lld][WebAssembly] Allow exporting of mutable globals

In particular allow explict exporting of `__stack_pointer` but
exclud this from `--export-all` to avoid requiring the mutable
globals feature whenenve `--export-all` is used.

This uncovered a bug in populateTargetFeatures regarding checking
if the mutable-globals feature is allowed.

See: https://github.com/WebAssembly/binaryen/issues/2934

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

3 years agoTry to fix build. May have used a C++ feature too new/not supported on all platforms.
Amara Emerson [Thu, 1 Oct 2020 00:35:53 +0000 (17:35 -0700)]
Try to fix build. May have used a C++ feature too new/not supported on all platforms.

3 years ago[WholeProgramDevirt][NewPM] Add NPM testing path to match legacy pass
Arthur Eubanks [Wed, 30 Sep 2020 16:22:18 +0000 (09:22 -0700)]
[WholeProgramDevirt][NewPM] Add NPM testing path to match legacy pass

The legacy pass's default constructor sets UseCommandLine = true and
goes down a separate testing route. Match that in the NPM pass.

This fixes all tests in llvm/test/Transforms/WholeProgramDevirt under NPM.

Reviewed By: ychen

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

3 years ago[AArch64][GlobalISel] Add some more legal types for G_PHI, G_IMPLICIT_DEF, G_FREEZE.
Amara Emerson [Thu, 1 Oct 2020 00:20:57 +0000 (17:20 -0700)]
[AArch64][GlobalISel] Add some more legal types for G_PHI, G_IMPLICIT_DEF, G_FREEZE.

Also use this opportunity start to clean up the mess of vector type lists we
have in the LegalizerInfo. Unfortunately since the legalizer rule builders require
std::initializer_list objects as parameters we can't programmatically generate the
type lists.

3 years ago[flang] Allow record advancement in external formatted sequential READ
peter klausler [Wed, 30 Sep 2020 19:53:00 +0000 (12:53 -0700)]
[flang] Allow record advancement in external formatted sequential READ

The '/' control edit descriptor causes a runtime crash for an
external formatted sequential READ because the AdvanceRecord()
member function for external units implemented only the tasks
to finish reading the current record.  Split those out into
a new FinishReadingRecord() member function, call that instead
from EndIoStatement(), and change AdvanceRecord() to both
finish reading the current record and to begin reading the next
one.

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

3 years ago[lldb] Make TestGuiBasicDebug more lenient
Jonas Devlieghere [Thu, 1 Oct 2020 00:01:27 +0000 (17:01 -0700)]
[lldb] Make TestGuiBasicDebug more lenient

Matt's change to the register allocator in 89baeaef2fa9 changed where we
end up after the `finish`. Before we'd end up on line 4.

* thread #1, queue = 'com.apple.main-thread', stop reason = step out
Return value: (int) $0 = 1
    frame #0: 0x0000000100003f7d a.out`main(argc=1, argv=0x00007ffeefbff630) at main.c:4:3
   1    extern int func();
   2
   3    int main(int argc, char **argv) {
-> 4      func(); // Break here
   5      func(); // Second
   6      return 0;
   7    }

Now, we end up on line 5.

* thread #1, queue = 'com.apple.main-thread', stop reason = step out
Return value: (int) $0 = 1

    frame #0: 0x0000000100003f8d a.out`main(argc=1, argv=0x00007ffeefbff630) at main.c:5:3
   2
   3    int main(int argc, char **argv) {
   4      func(); // Break here
-> 5      func(); // Second
   6      return 0;
   7    }

Given that this is not expected stable to be stable I've made the test a
bit more lenient to accept both scenarios.

3 years ago[AArch64][GlobalISel] NFC: Refactor G_FCMP selection code
Jessica Paquette [Wed, 30 Sep 2020 01:23:02 +0000 (18:23 -0700)]
[AArch64][GlobalISel] NFC: Refactor G_FCMP selection code

Refactor this so it's similar to the existing integer comparison code.

Also add some missing 64-bit testcases to select-fcmp.mir.

Refactoring to prep for improving selection for G_FCMP-related conditional
branches etc.

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

3 years ago[ARM] Add missing target for Arm neon test case.
Ranjeet Singh [Wed, 30 Sep 2020 23:30:36 +0000 (00:30 +0100)]
[ARM] Add missing target for Arm neon test case.

This is a follow-up from https://reviews.llvm.org/D61717. Where Richard
described the issue with compiling arm_neon.h under
-flax-vector-conversions=none. It looks like the example reproducer does
actually work but what was missing was a test entry for that target.

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

3 years ago[OpenMP][libarcher] Allow all possible argument separators in TSAN_OPTIONS
Joachim Protze [Wed, 30 Sep 2020 23:01:09 +0000 (01:01 +0200)]
[OpenMP][libarcher] Allow all possible argument separators in TSAN_OPTIONS

Currently, the parser used to tokenize the TSAN_OPTIONS in libomp uses
only spaces as separators, even though TSAN in compiler-rt supports
other separators like ':' or ','.
CTest uses ':' to separate sanitizer options by default.
The documentation for other sanitizers mentions ':' as separator,
but TSAN only lists spaces, which is probably where this mismatch originated.

Patch provided by  upsj

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

3 years agoPatch IEEEFloat::isSignificandAllZeros and IEEEFloat::isSignificandAllOnes (bug 34579)
Craig Topper [Wed, 30 Sep 2020 20:55:01 +0000 (13:55 -0700)]
Patch IEEEFloat::isSignificandAllZeros and IEEEFloat::isSignificandAllOnes (bug 34579)

Patch IEEEFloat::isSignificandAllZeros and IEEEFloat::isSignificandAllOnes to behave correctly in the case that the size of the significand is a multiple of the width of the integerParts making up the significand.

The patch to IEEEFloat::isSignificandAllOnes fixes bug 34579, and the patch to IEEE:Float:isSignificandAllZeros fixes the unit test "APFloatTest.x87Next" I added here. I have included both in this diff since the changes are very similar.

Patch by Andrew Briand

3 years ago[PowerPC] Add outer product instructions for MMA
Ahsan Saghir [Tue, 29 Sep 2020 14:40:38 +0000 (09:40 -0500)]
[PowerPC] Add outer product instructions for MMA

This patch adds outer product instructions for MMA, including related infrastructure, and their tests.

Depends on D84968.

Reviewed By: #powerpc, bsaleil, amyk

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

3 years agoHandle unknown OSes in DarwinTargetInfo::getExnObjectAlignment
Akira Hatanaka [Wed, 30 Sep 2020 23:05:17 +0000 (16:05 -0700)]
Handle unknown OSes in DarwinTargetInfo::getExnObjectAlignment

rdar://problem/69727650

3 years ago[OpenMP][OMPT] Update OMPT tests for newly added GOMP interface patches
Joachim Protze [Wed, 30 Sep 2020 22:53:41 +0000 (00:53 +0200)]
[OpenMP][OMPT] Update OMPT tests for newly added GOMP interface patches

This patch updates the expected results for the GOMP interface patches: D87267, D87269, and D87271.
The taskwait-depend test is changed to really use taskwait-depend and copied to an task_if0-depend test.

To pass the tests, the handling of the return address was fixed.

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

3 years ago[OpenMP][libomptarget] make omp_get_initial_device 5.1 compliant
Joachim Protze [Wed, 30 Sep 2020 08:40:51 +0000 (10:40 +0200)]
[OpenMP][libomptarget] make omp_get_initial_device 5.1 compliant

OpenMP 5.1 defines omp_get_initial_device to return the same value as omp_get_num_devices.
Since this change is also 5.0 compliant, no versioning is needed.

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

3 years ago[flang] Semantic analysis for FINAL subroutines
peter klausler [Wed, 30 Sep 2020 20:34:23 +0000 (13:34 -0700)]
[flang] Semantic analysis for FINAL subroutines

Represent FINAL subroutines in the symbol table entries of
derived types.  Enforce constraints.  Update tests that have
inadvertent violations or modified messages.  Added a test.

The specific procedure distinguishability checking code for generics
was used to enforce distinguishability of FINAL procedures.
(Also cleaned up some confusion and redundancy noticed in the
type compatibility infrastructure while digging into that area.)

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

3 years agoRe-land "[PDB] Merge types in parallel when using ghashing"
Reid Kleckner [Wed, 30 Sep 2020 21:55:51 +0000 (14:55 -0700)]
Re-land "[PDB] Merge types in parallel when using ghashing"

Stored Error objects have to be checked, even if they are success
values.

This reverts commit 8d250ac3cd48d0f17f9314685a85e77895c05351.
Relands commit 49b3459930655d879b2dc190ff8fe11c38a8be5f..

Original commit message:
-----------------------------------------

This makes type merging much faster (-24% on chrome.dll) when multiple
threads are available, but it slightly increases the time to link (+10%)
when /threads:1 is passed. With only one more thread, the new type
merging is faster (-11%). The output PDB should be identical to what it
was before this change.

To give an idea, here is the /time output placed side by side:
                              BEFORE    | AFTER
  Input File Reading:           956 ms  |  968 ms
  Code Layout:                  258 ms  |  190 ms
  Commit Output File:             6 ms  |    7 ms
  PDB Emission (Cumulative):   6691 ms  | 4253 ms
    Add Objects:               4341 ms  | 2927 ms
      Type Merging:            2814 ms  | 1269 ms  -55%!
      Symbol Merging:          1509 ms  | 1645 ms
    Publics Stream Layout:      111 ms  |  112 ms
    TPI Stream Layout:          764 ms  |   26 ms  trivial
    Commit to Disk:            1322 ms  | 1036 ms  -300ms
----------------------------------------- --------
Total Link Time:               8416 ms    5882 ms  -30% overall

The main source of the additional overhead in the single-threaded case
is the need to iterate all .debug$T sections up front to check which
type records should go in the IPI stream. See fillIsItemIndexFromDebugT.
With changes to the .debug$H section, we could pre-calculate this info
and eliminate the need to do this walk up front. That should restore
single-threaded performance back to what it was before this change.

This change will cause LLD to be much more parallel than it used to, and
for users who do multiple links in parallel, it could regress
performance. However, when the user is only doing one link, it's a huge
improvement. In the future, we can use NT worker threads to avoid
oversaturating the machine with work, but for now, this is such an
improvement for the single-link use case that I think we should land
this as is.

Algorithm
----------

Before this change, we essentially used a
DenseMap<GloballyHashedType, TypeIndex> to check if a type has already
been seen, and if it hasn't been seen, insert it now and use the next
available type index for it in the destination type stream. DenseMap
does not support concurrent insertion, and even if it did, the linker
must be deterministic: it cannot produce different PDBs by using
different numbers of threads. The output type stream must be in the same
order regardless of the order of hash table insertions.

In order to create a hash table that supports concurrent insertion, the
table cells must be small enough that they can be updated atomically.
The algorithm I used for updating the table using linear probing is
described in this paper, "Concurrent Hash Tables: Fast and General(?)!":
https://dl.acm.org/doi/10.1145/3309206

The GHashCell in this change is essentially a pair of 32-bit integer
indices: <sourceIndex, typeIndex>. The sourceIndex is the index of the
TpiSource object, and it represents an input type stream. The typeIndex
is the index of the type in the stream. Together, we have something like
a ragged 2D array of ghashes, which can be looked up as:
  tpiSources[tpiSrcIndex]->ghashes[typeIndex]

By using these side tables, we can omit the key data from the hash
table, and keep the table cell small. There is a cost to this: resolving
hash table collisions requires many more loads than simply looking at
the key in the same cache line as the insertion position. However, most
supported platforms should have a 64-bit CAS operation to update the
cell atomically.

To make the result of concurrent insertion deterministic, the cell
payloads must have a priority function. Defining one is pretty
straightforward: compare the two 32-bit numbers as a combined 64-bit
number. This means that types coming from inputs earlier on the command
line have a higher priority and are more likely to appear earlier in the
final PDB type stream than types from an input appearing later on the
link line.

After table insertion, the non-empty cells in the table can be copied
out of the main table and sorted by priority to determine the ordering
of the final type index stream. At this point, item and type records
must be separated, either by sorting or by splitting into two arrays,
and I chose sorting. This is why the GHashCell must contain the isItem
bit.

Once the final PDB TPI stream ordering is known, we need to compute a
mapping from source type index to PDB type index. To avoid starting over
from scratch and looking up every type again by its ghash, we save the
insertion position of every hash table insertion during the first
insertion phase. Because the table does not support rehashing, the
insertion position is stable. Using the array of insertion positions
indexed by source type index, we can replace the source type indices in
the ghash table cells with the PDB type indices.

Once the table cells have been updated to contain PDB type indices, the
mapping for each type source can be computed in parallel. Simply iterate
the list of cell positions and replace them with the PDB type index,
since the insertion positions are no longer needed.

Once we have a source to destination type index mapping for every type
source, there are no more data dependencies. We know which type records
are "unique" (not duplicates), and what their final type indices will
be. We can do the remapping in parallel, and accumulate type sizes and
type hashes in parallel by type source.

Lastly, TPI stream layout must be done serially. Accumulate all the type
records, sizes, and hashes, and add them to the PDB.

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

3 years ago[AMDGPU] Reorganize VOP3P encoding
Stanislav Mekhanoshin [Wed, 30 Sep 2020 22:01:33 +0000 (15:01 -0700)]
[AMDGPU] Reorganize VOP3P encoding

This changes width of encoding and opcode fields to match the
documentation.

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

3 years ago[Msan] Add ptsname, ptsname_r interceptors
Vitaly Buka [Wed, 30 Sep 2020 10:02:41 +0000 (03:02 -0700)]
[Msan] Add ptsname, ptsname_r interceptors

Reviewed By: eugenis, MaskRay

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

3 years ago[mlir][Linalg] Add pattern to tile and fuse Linalg operations on buffers.
MaheshRavishankar [Wed, 30 Sep 2020 21:55:59 +0000 (14:55 -0700)]
[mlir][Linalg] Add pattern to tile and fuse Linalg operations on buffers.

The pattern is structured similar to other patterns like
LinalgTilingPattern. The fusion patterns takes options that allows you
to fuse with producers of multiple operands at once.
- The pattern fuses only at the level that is known to be legal, i.e
  if a reduction loop in the consumer is tiled, then fusion should
  happen "before" this loop. Some refactoring of the fusion code is
  needed to fuse only where it is legal.
- Since the fusion on buffers uses the LinalgDependenceGraph that is
  not mutable in place the fusion pattern keeps the original
  operations in the IR, but are tagged with a marker that can be later
  used to find the original operations.

This change also fixes an issue with tiling and
distribution/interchange where if the tile size of a loop were 0 it
wasnt account for in these.

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

3 years agoRevert "[PDB] Merge types in parallel when using ghashing"
Reid Kleckner [Wed, 30 Sep 2020 21:55:32 +0000 (14:55 -0700)]
Revert "[PDB] Merge types in parallel when using ghashing"

This reverts commit 49b3459930655d879b2dc190ff8fe11c38a8be5f.

3 years ago[PDB] Merge types in parallel when using ghashing
Reid Kleckner [Thu, 14 May 2020 21:02:36 +0000 (14:02 -0700)]
[PDB] Merge types in parallel when using ghashing

This makes type merging much faster (-24% on chrome.dll) when multiple
threads are available, but it slightly increases the time to link (+10%)
when /threads:1 is passed. With only one more thread, the new type
merging is faster (-11%). The output PDB should be identical to what it
was before this change.

To give an idea, here is the /time output placed side by side:
                              BEFORE    | AFTER
  Input File Reading:           956 ms  |  968 ms
  Code Layout:                  258 ms  |  190 ms
  Commit Output File:             6 ms  |    7 ms
  PDB Emission (Cumulative):   6691 ms  | 4253 ms
    Add Objects:               4341 ms  | 2927 ms
      Type Merging:            2814 ms  | 1269 ms  -55%!
      Symbol Merging:          1509 ms  | 1645 ms
    Publics Stream Layout:      111 ms  |  112 ms
    TPI Stream Layout:          764 ms  |   26 ms  trivial
    Commit to Disk:            1322 ms  | 1036 ms  -300ms
----------------------------------------- --------
Total Link Time:               8416 ms    5882 ms  -30% overall

The main source of the additional overhead in the single-threaded case
is the need to iterate all .debug$T sections up front to check which
type records should go in the IPI stream. See fillIsItemIndexFromDebugT.
With changes to the .debug$H section, we could pre-calculate this info
and eliminate the need to do this walk up front. That should restore
single-threaded performance back to what it was before this change.

This change will cause LLD to be much more parallel than it used to, and
for users who do multiple links in parallel, it could regress
performance. However, when the user is only doing one link, it's a huge
improvement. In the future, we can use NT worker threads to avoid
oversaturating the machine with work, but for now, this is such an
improvement for the single-link use case that I think we should land
this as is.

Algorithm
----------

Before this change, we essentially used a
DenseMap<GloballyHashedType, TypeIndex> to check if a type has already
been seen, and if it hasn't been seen, insert it now and use the next
available type index for it in the destination type stream. DenseMap
does not support concurrent insertion, and even if it did, the linker
must be deterministic: it cannot produce different PDBs by using
different numbers of threads. The output type stream must be in the same
order regardless of the order of hash table insertions.

In order to create a hash table that supports concurrent insertion, the
table cells must be small enough that they can be updated atomically.
The algorithm I used for updating the table using linear probing is
described in this paper, "Concurrent Hash Tables: Fast and General(?)!":
https://dl.acm.org/doi/10.1145/3309206

The GHashCell in this change is essentially a pair of 32-bit integer
indices: <sourceIndex, typeIndex>. The sourceIndex is the index of the
TpiSource object, and it represents an input type stream. The typeIndex
is the index of the type in the stream. Together, we have something like
a ragged 2D array of ghashes, which can be looked up as:
  tpiSources[tpiSrcIndex]->ghashes[typeIndex]

By using these side tables, we can omit the key data from the hash
table, and keep the table cell small. There is a cost to this: resolving
hash table collisions requires many more loads than simply looking at
the key in the same cache line as the insertion position. However, most
supported platforms should have a 64-bit CAS operation to update the
cell atomically.

To make the result of concurrent insertion deterministic, the cell
payloads must have a priority function. Defining one is pretty
straightforward: compare the two 32-bit numbers as a combined 64-bit
number. This means that types coming from inputs earlier on the command
line have a higher priority and are more likely to appear earlier in the
final PDB type stream than types from an input appearing later on the
link line.

After table insertion, the non-empty cells in the table can be copied
out of the main table and sorted by priority to determine the ordering
of the final type index stream. At this point, item and type records
must be separated, either by sorting or by splitting into two arrays,
and I chose sorting. This is why the GHashCell must contain the isItem
bit.

Once the final PDB TPI stream ordering is known, we need to compute a
mapping from source type index to PDB type index. To avoid starting over
from scratch and looking up every type again by its ghash, we save the
insertion position of every hash table insertion during the first
insertion phase. Because the table does not support rehashing, the
insertion position is stable. Using the array of insertion positions
indexed by source type index, we can replace the source type indices in
the ghash table cells with the PDB type indices.

Once the table cells have been updated to contain PDB type indices, the
mapping for each type source can be computed in parallel. Simply iterate
the list of cell positions and replace them with the PDB type index,
since the insertion positions are no longer needed.

Once we have a source to destination type index mapping for every type
source, there are no more data dependencies. We know which type records
are "unique" (not duplicates), and what their final type indices will
be. We can do the remapping in parallel, and accumulate type sizes and
type hashes in parallel by type source.

Lastly, TPI stream layout must be done serially. Accumulate all the type
records, sizes, and hashes, and add them to the PDB.

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

3 years ago[clangd] Remove dead variable. NFC
Sam McCall [Wed, 30 Sep 2020 21:19:08 +0000 (23:19 +0200)]
[clangd] Remove dead variable. NFC

3 years ago[flang] Fix descriptor-based array data item I/O for list-directed CHARACTER & LOGICAL
peter klausler [Wed, 30 Sep 2020 19:43:21 +0000 (12:43 -0700)]
[flang] Fix descriptor-based array data item I/O for list-directed CHARACTER & LOGICAL

These types have to distinguish list-directed I/O from formatted I/O,
and the subscript incrementation call was in the formatted branch
of the if() rather than after the if().

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

3 years ago[NFC] Fix spacing in clang/test/Driver/aix-ld.c
Hubert Tong [Wed, 30 Sep 2020 20:58:48 +0000 (16:58 -0400)]
[NFC] Fix spacing in clang/test/Driver/aix-ld.c

Fix one line with mismatch in indentation after afc277b0ed0d.

3 years ago[asan][test] XFAIL Posix/no_asan_gen_globals.c on Solaris
Rainer Orth [Wed, 30 Sep 2020 20:58:07 +0000 (22:58 +0200)]
[asan][test] XFAIL Posix/no_asan_gen_globals.c on Solaris

`Posix/no_asan_gen_globals.c` currently `FAIL`s on Solaris:

  $ nm no_asan_gen_globals.c.tmp.exe | grep ___asan_gen_
  0809696a r .L___asan_gen_.1
  0809a4cd r .L___asan_gen_.2
  080908e2 r .L___asan_gen_.4
  0809a4cd r .L___asan_gen_.5
  0809a529 r .L___asan_gen_.7
  0809a4cd r .L___asan_gen_.8

As detailed in Bug 47607, there are two factors here:

- `clang` plays games by emitting some local labels into the symbol
  table.  When instead one uses `-fno-integrated-as` to have `gas` create
  the object files, they don't land in the objects in the first place.
- Unlike GNU `ld`, the Solaris `ld` doesn't support support
  `-X`/`--discard-locals` but instead relies on the assembler to follow its
  specification and not emit local labels.

Therefore this patch `XFAIL`s the test on Solaris.

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

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

3 years ago[X86] Canonicalize (x > 1) ? x : 1 -> (x >= 1) ? x : 1 for sign and unsigned to enabl...
Craig Topper [Wed, 30 Sep 2020 19:36:28 +0000 (12:36 -0700)]
[X86] Canonicalize (x > 1) ? x : 1 -> (x >= 1) ? x : 1 for sign and unsigned to enable the use of test instructions for the compare.

This will be further canonicalized to a compare involving 0
which will enable the use of test instructions. Either using
cmovg for signed for cmovne for unsigned.

Fixes more case for PR47049

3 years ago[NPM] Add target specific hook to add passes for New Pass Manager
Arthur Eubanks [Wed, 30 Sep 2020 20:23:21 +0000 (13:23 -0700)]
[NPM] Add target specific hook to add passes for New Pass Manager

The patch adds a new TargetMachine member "registerPassBuilderCallbacks" for targets to add passes to the pass pipeline using the New Pass Manager (similar to adjustPassManager for the Legacy Pass Manager).

Reviewed By: aeubanks

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

3 years ago[mlir][vector] First step of vector distribution transformation
Thomas Raoux [Wed, 30 Sep 2020 19:58:24 +0000 (12:58 -0700)]
[mlir][vector] First step of vector distribution transformation

This is the first of several steps to support distributing large vectors. This
adds instructions extract_map and insert_map that allow us to do incremental
lowering. Right now the transformation only apply to simple pointwise operation
with a vector size matching the multiplicity of the IDs used to distribute the
vector.
This can be used to distribute large vectors to loops or SPMD.

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

3 years agoAdd GDB prettyprinters for a few more MLIR types.
Christian Sigg [Tue, 29 Sep 2020 13:19:54 +0000 (15:19 +0200)]
Add GDB prettyprinters for a few more MLIR types.

Reviewed By: dblaikie, jpienaar

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

3 years agoRevert "[OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def"
Joseph Huber [Wed, 30 Sep 2020 19:11:51 +0000 (15:11 -0400)]
Revert "[OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def"

Failing tests on Arm due to the tests automatically populating
incomatible pointer width architectures. Reverting until the tests are
updated. Failing tests:

OpenMP/distribute_parallel_for_num_threads_codegen.cpp
OpenMP/distribute_parallel_for_if_codegen.cpp
OpenMP/distribute_parallel_for_simd_if_codegen.cpp
OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
OpenMP/teams_distribute_parallel_for_if_codegen.cpp
OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp

This reverts commit 90eaedda9b8ef46e2c0c1b8bce33e98a3adbb68c.

3 years ago[CodeGen] improve coverage for float (32-bit) type of NAN; NFC
Sanjay Patel [Wed, 30 Sep 2020 19:09:21 +0000 (15:09 -0400)]
[CodeGen] improve coverage for float (32-bit) type of NAN; NFC

Goes with D88238

3 years agoRevert "[OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload"
Joseph Huber [Wed, 30 Sep 2020 19:02:16 +0000 (15:02 -0400)]
Revert "[OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload"

Failing tests on Arm due to the tests automatically populating
incomatible pointer width architectures. Reverting until the tests are
updated. Failing tests:

OpenMP/distribute_parallel_for_num_threads_codegen.cpp
OpenMP/distribute_parallel_for_if_codegen.cpp
OpenMP/distribute_parallel_for_simd_if_codegen.cpp
OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
OpenMP/teams_distribute_parallel_for_if_codegen.cpp
OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp

This reverts commit 9d2378b59150f6f1cb5c9cf42ea06b0bb57029a1.

3 years ago[libc++] Make sure we don't attempt to run check-cxx-abilist when libc++ doesn't...
Louis Dionne [Wed, 30 Sep 2020 18:58:17 +0000 (14:58 -0400)]
[libc++] Make sure we don't attempt to run check-cxx-abilist when libc++ doesn't define new/delete

That would make the test fail spuriously because we don't generate
an ABI list for that configuration.

3 years ago[test][NewPM][SampleProfile] Fix more tests under NPM
Arthur Eubanks [Wed, 30 Sep 2020 18:49:58 +0000 (11:49 -0700)]
[test][NewPM][SampleProfile] Fix more tests under NPM

These all have separate legacy and new PM RUN lines.

3 years agoFix crash in SBStructuredData::GetDescription() when there's no StructuredDataPlugin.
Jim Ingham [Wed, 30 Sep 2020 18:46:59 +0000 (11:46 -0700)]
Fix crash in SBStructuredData::GetDescription() when there's no StructuredDataPlugin.

Also, use the StructuredData::Dump method to print the StructuredData if there
is no plugin, rather than just returning an error.

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

3 years ago[lldb-vscode] Allow an empty 'breakpoints' field to clear breakpoints.
Jordan Rupprecht [Wed, 30 Sep 2020 18:24:10 +0000 (11:24 -0700)]
[lldb-vscode] Allow an empty 'breakpoints' field to clear breakpoints.

Per the DAP spec for SetBreakpoints [1], the way to clear breakpoints is: `To clear all breakpoint for a source, specify an empty array.`

However, leaving the breakpoints field unset is also a well formed request (note the `breakpoints?:` in the `SetBreakpointsArguments` definition). If it's unset, we have a couple choices:

1. Crash (current behavior)
2. Clear breakpoints
3. Return an error response that the breakpoints field is missing.

I propose we do (2) instead of (1), and treat an unset breakpoints field the same as an empty breakpoints field.

[1] https://microsoft.github.io/debug-adapter-protocol/specification#Requests_SetBreakpoints

Reviewed By: wallace, labath

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

3 years ago[MLIR] Add async.value type to Async dialect
Eugene Zhulenev [Tue, 29 Sep 2020 20:55:33 +0000 (13:55 -0700)]
[MLIR] Add async.value type to Async dialect

Return values from async regions as !async.value<...>.

Reviewed By: mehdi_amini, csigg

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

3 years ago[lldb/ipv6] Support running lldb tests in an ipv6-only environment.
Jordan Rupprecht [Wed, 30 Sep 2020 17:47:48 +0000 (10:47 -0700)]
[lldb/ipv6] Support running lldb tests in an ipv6-only environment.

When running in an ipv6-only environment where `AF_INET` sockets are not available, many lldb tests (mostly gdb remote tests) fail because things like `127.0.0.1` don't work there.

Use `localhost` instead of `127.0.0.1` whenever possible, or include a fallback of creating `AF_INET6` sockets when `AF_INET` fails.

Reviewed By: labath

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

3 years agoException support for basic block sections
Rahman Lavaee [Wed, 30 Sep 2020 17:37:00 +0000 (10:37 -0700)]
Exception support for basic block sections

This is part of the Propeller framework to do post link code layout optimizations. Please see the RFC here: https://groups.google.com/forum/#!msg/llvm-dev/ef3mKzAdJ7U/1shV64BYBAAJ and the detailed RFC doc here: https://github.com/google/llvm-propeller/blob/plo-dev/Propeller_RFC.pdf

This patch provides exception support for basic block sections by splitting the call-site table into call-site ranges corresponding to different basic block sections. Still all landing pads must reside in the same basic block section (which is guaranteed by the the core basic block section patch D73674 (ExceptionSection) ). Each call-site table will refer to the landing pad fragment by explicitly specifying @LPstart (which is omitted in the normal non-basic-block section case). All these call-site tables will share their action and type tables.

The C++ ABI somehow assumes that no landing pads point directly to LPStart (which works in the normal case since the function begin is never a landing pad), and uses LP.offset = 0 to specify no landing pad. In the case of basic block section where one section contains all the landing pads, the landing pad offset relative to LPStart could actually be zero. Thus, we avoid zero-offset landing pads by inserting a **nop** operation as the first non-CFI instruction in the exception section.

**Background on Exception Handling in C++ ABI**
https://github.com/itanium-cxx-abi/cxx-abi/blob/master/exceptions.pdf

Compiler emits an exception table for every function. When an exception is thrown, the stack unwinding library queries the unwind table (which includes the start and end of each function) to locate the exception table for that function.

The exception table includes a call site table for the function, which is used to guide the exception handling runtime to take the appropriate action upon an exception. Each call site record in this table is structured as follows:

| CallSite                       |  -->  Position of the call site (relative to the function entry)
| CallSite length           |  -->  Length of the call site.
| Landing Pad               |  -->  Position of the landing pad (relative to the landing pad fragment’s begin label)
| Action record offset  |  -->  Position of the first action record

The call site records partition a function into different pieces and describe what action must be taken for each callsite. The callsite fields are relative to the start of the function (as captured in the unwind table).

The landing pad entry is a reference into the function and corresponds roughly to the catch block of a try/catch statement. When execution resumes at a landing pad, it receives an exception structure and a selector value corresponding to the type of the exception thrown, and executes similar to a switch-case statement. The landing pad field is relative to the beginning of the procedure fragment which includes all the landing pads (@LPStart). The C++ ABI requires all landing pads to be in the same fragment. Nonetheless, without basic block sections, @LPStart is the same as the function @Start (found in the unwind table) and can be omitted.

The action record offset is an index into the action table which includes information about which exception types are caught.

**C++ Exceptions with Basic Block Sections**
Basic block sections break the contiguity of a function fragment. Therefore, call sites must be specified relative to the beginning of the basic block section. Furthermore, the unwinding library should be able to find the corresponding callsites for each section. To do so, the .cfi_lsda directive for a section must point to the range of call-sites for that section.
This patch introduces a new **CallSiteRange** structure which specifies the range of call-sites which correspond to every section:

  `struct CallSiteRange {
    // Symbol marking the beginning of the precedure fragment.
    MCSymbol *FragmentBeginLabel = nullptr;
    // Symbol marking the end of the procedure fragment.
    MCSymbol *FragmentEndLabel = nullptr;
    // LSDA symbol for this call-site range.
    MCSymbol *ExceptionLabel = nullptr;
    // Index of the first call-site entry in the call-site table which
    // belongs to this range.
    size_t CallSiteBeginIdx = 0;
    // Index just after the last call-site entry in the call-site table which
    // belongs to this range.
    size_t CallSiteEndIdx = 0;
    // Whether this is the call-site range containing all the landing pads.
    bool IsLPRange = false;
  };`

With N basic-block-sections, the call-site table is partitioned into N call-site ranges.

Conceptually, we emit the call-site ranges for sections sequentially in the exception table as if each section has its own exception table. In the example below, two sections result in the two call site ranges (denoted by LSDA1 and LSDA2) placed next to each other. However, their call-sites will refer to records in the shared Action Table. We also emit the header fields (@LPStart and CallSite Table Length) for each call site range in order to place the call site ranges in separate LSDAs. We note that with -basic-block-sections, The CallSiteTableLength will not actually represent the length of the call site table, but rather the reference to the action table. Since the only purpose of this field is to locate the action table, correctness is guaranteed.

Finally, every call site range has one @LPStart pointer so the landing pads of each section must all reside in one section (not necessarily the same section). To make this easier, we decide to place all landing pads of the function in one section (hence the `IsLPRange` field in CallSiteRange).

|  @LPStart                   |  --->  Landing pad fragment     ( LSDA1 points here)
| CallSite Table Length | ---> Used to find the action table.
| CallSites                     |
| …                                 |
| …                                 |
| @LPStart                    |  --->  Landing pad fragment ( LSDA2 points here)
| CallSite Table Length |
| CallSites                     |
| …                                 |
| …                                 |


|      Action Table          |
|      Types Table           |

Reviewed By: MaskRay

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

3 years ago[AIX][Clang][Driver] Link libm in c++ mode
David Tenty [Tue, 29 Sep 2020 15:30:28 +0000 (11:30 -0400)]
[AIX][Clang][Driver] Link libm in c++ mode

since that is the normal behaviour of other compilers on the platform.

Reviewed By: hubert.reinterpretcast

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

3 years ago[OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def
Joseph Huber [Mon, 28 Sep 2020 14:23:14 +0000 (10:23 -0400)]
[OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

Summary:
Replace the OpenMP Runtime Library functions used in CGOpenMPRuntimeGPU
for OpenMP device code generation with ones in OMPKinds.def and use
OMPIRBuilder for generating runtime calls. This allows us to consolidate
more OpenMP code generation into the OMPIRBuilder. This patch also
invalidates specifying target architectures with conflicting pointer
sizes.

Reviewers: jdoerfert

Subscribers: aaron.ballman cfe-commits guansong llvm-commits sstefan1 yaxunl

Tags: #OpenMP #Clang #LLVM

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

3 years ago[OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload
Joseph Huber [Wed, 30 Sep 2020 17:10:32 +0000 (13:10 -0400)]
[OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload

Summary:
This patch adds an error to Clang that detects if OpenMP offloading is used
between two architectures with incompatible pointer sizes. This ensures that
the data mapping can be done correctly and solves an issue in code generation
generating the wrong size pointer.

Reviewer: jdoerfert

Subscribers:

Tags: #OpenMP #Clang

Differential Revision:

3 years agoFix interaction of `constinit` and `weak`.
Richard Smith [Wed, 30 Sep 2020 17:48:00 +0000 (10:48 -0700)]
Fix interaction of `constinit` and `weak`.

We previously took a shortcut and said that weak variables never have
constant initializers (because those initializers are never correct to
use outside the variable). We now say that weak variables can have
constant initializers, but are never usable in constant expressions.

3 years ago[Sema] Support Comma operator for fp16 vectors.
Alexandre Rames [Wed, 30 Sep 2020 17:11:14 +0000 (18:11 +0100)]
[Sema] Support Comma operator for fp16 vectors.

The current half vector was enforcing an assert expecting
 "(LHS is half vector) == (RHS is half vector)"
for comma.

Reviewed By: ahatanak, fhahn

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

3 years ago[CodeGen] add test for NAN creation; NFC
Sanjay Patel [Wed, 30 Sep 2020 17:18:42 +0000 (13:18 -0400)]
[CodeGen] add test for NAN creation; NFC

This goes with the APFloat change proposed in
D88238.
This is copied from the MIPS-specific test in
builtin-nan-legacy.c to verify that the normal
behavior is correct on other targets without the
complication of an inverted quiet bit.

3 years ago[AArch64] Avoid pairing loads when the base reg is modified
Congzhe Cao [Wed, 30 Sep 2020 17:03:14 +0000 (13:03 -0400)]
[AArch64] Avoid pairing loads when the base reg is modified

When pairing loads, we should check if in between the two loads the
base register has been modified. If that is the case then avoid pairing
them because the second load actually loads from a different address.

Reviewed By: fhahn

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

3 years ago[asan][test] Several Posix/unpoison-alternate-stack.cpp fixes
Rainer Orth [Wed, 30 Sep 2020 16:56:52 +0000 (18:56 +0200)]
[asan][test] Several Posix/unpoison-alternate-stack.cpp fixes

`Posix/unpoison-alternate-stack.cpp` currently `FAIL`s on Solaris/i386.
Some of the problems are generic:

- `clang` warns compiling the testcase:

  compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp:83:7: warning: nested designators are a C99 extension [-Wc99-designator]
        .sa_sigaction = signalHandler,
        ^~~~~~~~~~~~~
  compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp:84:7: warning: ISO C++ requires field designators to be specified in declaration order; field '_funcptr' will be initialized after field 'sa_flags' [-Wreorder-init-list]
        .sa_flags = SA_SIGINFO | SA_NODEFER | SA_ONSTACK,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  and some more instances.  This can all easily be avoided by initializing
  each field separately.

- The test `SEGV`s in `__asan_memcpy`.  The default Solaris/i386 stack size
  is only 4 kB, while `__asan_memcpy` tries to allocate either 5436
  (32-bit) or 10688 bytes (64-bit) on the stack.  This patch avoids this by
  requiring at least 16 kB stack size.

- Even without `-fsanitize=address` I get an assertion failure:

  Assertion failed: !isOnSignalStack(), file compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp, line 117

  The fundamental problem with this testcase is that `longjmp` from a
  signal handler is highly unportable; XPG7 strongly warns against it and
  it is thus unspecified which stack is used when `longjmp`ing from a
  signal handler running on an alternative stack.

  So I'm `XFAIL`ing this testcase on Solaris.

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

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

3 years ago[test][SampleProfile][NewPM] Fix some tests under NPM
Arthur Eubanks [Wed, 30 Sep 2020 16:42:49 +0000 (09:42 -0700)]
[test][SampleProfile][NewPM] Fix some tests under NPM

3 years agoscudo: Make it thread-safe to set some runtime configuration flags.
Peter Collingbourne [Fri, 25 Sep 2020 00:01:24 +0000 (17:01 -0700)]
scudo: Make it thread-safe to set some runtime configuration flags.

Move some of the flags previously in Options, as well as the
UseMemoryTagging flag previously in the primary allocator, into an
atomic variable so that it can be updated while other threads are
running. Relaxed accesses are used because we only have the requirement
that the other threads see the new value eventually.

The code is set up so that the variable is generally loaded once per
allocation function call with the exception of some rarely used code
such as error handlers. The flag bits can generally stay in a register
during the execution of the allocation function which means that they
can be branched on with minimal overhead (e.g. TBZ on aarch64).

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

3 years ago[llvm-exegesis] Add option to check the hardware support for a given feature before...
Vy Nguyen [Tue, 4 Aug 2020 22:34:22 +0000 (18:34 -0400)]
[llvm-exegesis] Add option to check the hardware support for a given feature before benchmarking.

This is mostly for the benefit of the LBR latency mode.
Right now, it performs no checking. If this is run on non-supported hardware, it will produce all zeroes for latency.

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

3 years ago[mlir][openacc] Remove -allow-unregistred-dialect from ops and invalid tests
Valentin Clement [Wed, 30 Sep 2020 16:23:06 +0000 (12:23 -0400)]
[mlir][openacc] Remove -allow-unregistred-dialect from ops and invalid tests

Switch to a dummy op in the test dialect so we can remove the -allow-unregistred-dialect
on ops.mlir and invalid.mlir. Change after comment on D88272.

Reviewed By: mehdi_amini

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

3 years ago[ObjCARCAA][NewPM] Add already ported objc-arc-aa to PassRegistry.def
Arthur Eubanks [Sat, 26 Sep 2020 07:18:42 +0000 (00:18 -0700)]
[ObjCARCAA][NewPM] Add already ported objc-arc-aa to PassRegistry.def

Also add missing AnalysisKey definition.

3 years ago[VE] Support TargetBlockAddress
Kazushi (Jam) Marukawa [Mon, 21 Sep 2020 08:15:26 +0000 (17:15 +0900)]
[VE] Support TargetBlockAddress

Change to handle TargetBlockAddress and add a regression test for it.

Reviewed By: simoll

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

3 years ago[DA][SDA] SyncDependenceAnalysis re-write
Simon Moll [Wed, 30 Sep 2020 15:10:44 +0000 (17:10 +0200)]
[DA][SDA] SyncDependenceAnalysis re-write

This patch achieves two things:
1. It breaks up the `join_blocks` interface between the SDA to the DA to
   return two separate sets for divergent loops exits and divergent,
disjoint path joins.
2. It updates the SDA algorithm to run in O(n) time and improves the
   precision on divergent loop exits.

This fixes `https://bugs.llvm.org/show_bug.cgi?id=46372` (by virtue of
the improved `join_blocks` interface) and revealed an imprecise expected
result in the `Analysis/DivergenceAnalysis/AMDGPU/hidden_loopdiverge.ll`
test.

Reviewed By: sameerds

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

3 years ago[NFC][regalloc] Make VirtRegAuxInfo part of allocator state
Mircea Trofin [Tue, 29 Sep 2020 16:09:25 +0000 (09:09 -0700)]
[NFC][regalloc] Make VirtRegAuxInfo part of allocator state

All the state of VRAI is allocator-wide, so we can avoid creating it
every time we need it. In addition, the normalization function is
allocator-specific. In a next change, we can simplify that design in
favor of just having it as a virtual member.

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

3 years ago[InstCombine] Add tests for 'partial' bswap patterns
Simon Pilgrim [Wed, 30 Sep 2020 15:08:52 +0000 (16:08 +0100)]
[InstCombine] Add tests for 'partial' bswap patterns

As mentioned on PR47191, if we're bswap'ing some bytes and the zero'ing the remainder we can perform this as a bswap+mask which helps us match 'partial' bswaps as a first step towards folding into a more complex bswap pattern.

3 years ago[PPC] Do not emit extswsli in 32BIT mode when using -mcpu=pwr9
Zarko Todorovski [Wed, 30 Sep 2020 15:03:03 +0000 (11:03 -0400)]
[PPC] Do not emit extswsli in 32BIT mode when using -mcpu=pwr9

It looks like in some circumstances when compiling with `-mcpu=pwr9` we create an EXTSWSLI node when which causes llc to fail. No such error occurs in pwr8 or lower.

This occurs in 32BIT AIX and BE Linux. the cause seems to be that the default return in combineSHL is to create an EXTSWSLI node.  Adding a check for whether we are in PPC64 before that fixes the issue.

Reviewed By: #powerpc, nemanjai

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

3 years ago[PowerPC] Avoid unused variable warning in Release builds
Benjamin Kramer [Wed, 30 Sep 2020 15:01:14 +0000 (17:01 +0200)]
[PowerPC] Avoid unused variable warning in Release builds

PPCFrameLowering.cpp:632:8: warning: unused variable 'isAIXABI' [-Wunused-variable]

3 years ago[InstCombine] Fix bswap(trunc(bswap(x))) -> trunc(lshr(x, c)) vector support
Simon Pilgrim [Wed, 30 Sep 2020 14:51:54 +0000 (15:51 +0100)]
[InstCombine] Fix bswap(trunc(bswap(x))) -> trunc(lshr(x, c)) vector support

Use getScalarSizeInBits not getPrimitiveSizeInBits to determine the shift value at the element level.

3 years ago[InstCombine] Add bswap(trunc(bswap(x))) -> trunc(lshr(x, c)) vector tests
Simon Pilgrim [Wed, 30 Sep 2020 14:42:53 +0000 (15:42 +0100)]
[InstCombine] Add bswap(trunc(bswap(x))) -> trunc(lshr(x, c)) vector tests

Add tests showing failure to correctly fold vector bswap(trunc(bswap(x))) intrinsic patterns

3 years ago[mlir][Linalg] Generalize the logic to compute reassociation maps
Mahesh Ravishankar [Tue, 29 Sep 2020 23:14:49 +0000 (16:14 -0700)]
[mlir][Linalg] Generalize the logic to compute reassociation maps
while folding tensor_reshape op.

While folding reshapes that introduce unit extent dims, the logic to
compute the reassociation maps can be generalized to handle some
corner cases, for example, when the folded shape still has unit-extent
dims but corresponds to folded unit extent dims of the expanded shape.

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

3 years ago[FE] Use preferred alignment instead of ABI alignment for complete object when applicable
Xiangling Liao [Wed, 30 Sep 2020 14:35:00 +0000 (10:35 -0400)]
[FE] Use preferred alignment instead of ABI alignment for complete object when applicable

On some targets, preferred alignment is larger than ABI alignment in some cases. For example,
on AIX we have special power alignment rules which would cause that. Previously, to support
those cases, we added a “PreferredAlignment” field in the `RecordLayout` to store the AIX
special alignment values in “PreferredAlignment” as the community suggested.

However, that patch alone is not enough. There are places in the Clang where `PreferredAlignment`
should have been used instead of ABI-specified alignment. This patch is aimed at fixing those
spots.

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

3 years ago[InstCombine] Remove %tmp variable names from bswap-fold tests
Simon Pilgrim [Wed, 30 Sep 2020 14:32:57 +0000 (15:32 +0100)]
[InstCombine] Remove %tmp variable names from bswap-fold tests

Appease update_test_checks script that was complaining about potential %TMP clashes