platform/upstream/llvm.git
3 years ago[NFC] Remove unused variable
Vitaly Buka [Mon, 14 Jun 2021 17:56:40 +0000 (10:56 -0700)]
[NFC] Remove unused variable

To fix 'set but not used' warning on sanitizer-x86_64-linux-android bot.

3 years ago[OpaquePtr] Remove existing support for forward compatibility
Arthur Eubanks [Wed, 26 May 2021 03:04:00 +0000 (20:04 -0700)]
[OpaquePtr] Remove existing support for forward compatibility

It assumes that PointerType will keep having an optional pointee type,
but we'd like to remove the pointee type in PointerType at some point.

I feel like the current implementation could be simplified anyway,
although perhaps I'm underestimating the amount of work needed
throughout BitcodeReader.

We will still need a side table to keep track of pointee types. This
will be reimplemented at some point.

This is essentially a revert of a4771e9d (which doesn't look like it was
reviewed anyway).

Reviewed By: dblaikie

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

3 years ago[lld-macho] Fix "shift exponent too large" UBSAN error
Jez Ng [Mon, 14 Jun 2021 03:20:30 +0000 (23:20 -0400)]
[lld-macho] Fix "shift exponent too large" UBSAN error

UBSAN seems to have added this check somewhere along the way...

This might also fix the PPC buildbot, which is failing on the same test

3 years ago[lld-macho] Reword comment for clarity
Jez Ng [Sat, 12 Jun 2021 00:30:12 +0000 (20:30 -0400)]
[lld-macho] Reword comment for clarity

3 years ago[OpenMP] Fix C-only clang assert on parsing use_allocator clause of target directive
Alexey Bataev [Mon, 14 Jun 2021 17:04:59 +0000 (10:04 -0700)]
[OpenMP] Fix C-only clang assert on parsing use_allocator clause of target directive

The parser code assumes building with C++ compiler and asserts when using clang (not clang++) on C file. I made the code dependent on input language. This shows up for amdgpu target.

Reviewed By: ABataev

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

3 years ago[CSSPGO] Aggregation by the last K context frames for cold profiles
wlei [Fri, 11 Jun 2021 07:35:45 +0000 (00:35 -0700)]
[CSSPGO] Aggregation by the last K context frames for cold profiles

This change provides the option to merge and aggregate cold context by the last k frames instead of context-less name. By default K = 1 means the context-less one.

This is for better perf tuning. The more selective merging and trimming will rely on llvm-profgen's preinliner.

Reviewed By: wenlei, hoy

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

3 years ago[Clang] Test case for -Wunused-but-set-variable, warn for volatile.
Michael Benfield [Mon, 14 Jun 2021 17:15:55 +0000 (10:15 -0700)]
[Clang] Test case for -Wunused-but-set-variable, warn for volatile.

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

3 years ago[RISCV] Transform unaligned RVV vector loads/stores to aligned ones
Fraser Cormack [Wed, 9 Jun 2021 14:17:21 +0000 (15:17 +0100)]
[RISCV] Transform unaligned RVV vector loads/stores to aligned ones

This patch adds support for loading and storing unaligned vectors via an
equivalently-sized i8 vector type, which has support in the RVV
specification for byte-aligned access.

This offers a more optimal path for handling of unaligned fixed-length
vector accesses, which are currently scalarized. It also prevents
crashing when `LegalizeDAG` sees an unaligned scalable-vector load/store
operation.

Future work could be to investigate loading/storing via the largest
vector element type for the given alignment, in case that would be more
optimal on hardware. For instance, a 4-byte-aligned nxv2i64 vector load
could loaded as nxv4i32 instead of as nxv16i8.

Reviewed By: craig.topper

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

3 years ago[flang] Move buffer runtime test to GTest
Asher Mancinelli [Mon, 14 Jun 2021 16:16:46 +0000 (09:16 -0700)]
[flang] Move buffer runtime test to GTest

Move buffer unit test from Runtime directory to RuntimeGtest
directory and use GTest. Test coverage is only maintained.

Differential Revision: https://reviews.llvm.org/D102335
Reviewed By: awarzynski, klausler

3 years ago[Verifier] Parallelize verification and dom checking. NFC.
Chris Lattner [Mon, 14 Jun 2021 04:42:06 +0000 (21:42 -0700)]
[Verifier] Parallelize verification and dom checking.  NFC.

This changes the outer verification loop to not recurse into
IsolatedFromAbove operations - instead return them up to a place
where a parallel for loop can process them all in parallel.  This
also changes Dominance checking to happen on IsolatedFromAbove
chunks of the region tree, which makes it easy to fold operation
and dominance verification into a single simple parallel regime.

This speeds up firtool in CIRCT from ~40s to 31s on a large
testcase in -verify-each mode (the default).  The .fir parser and
module passes in particular benefit from this - FModule passes
(roughly analogous to function passes) were already running the
verifier in parallel as part of the pass manager.  This allows
the whole-module passes to verify their enclosed functions /
FModules in parallel.

-verify-each mode is still faster (26.3s on the same testcase),
but we do expect the verifier to take *some* time.

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

3 years ago[InstCombine] add DeMorgan folds for logical ops in select form
Sanjay Patel [Mon, 14 Jun 2021 16:10:48 +0000 (12:10 -0400)]
[InstCombine] add DeMorgan folds for logical ops in select form

We canonicalized to these select patterns (poison-safe logic)
with D101191, so we need to reduce 'not' ops when possible
as we would with 'and'/'or' instructions.

This is shown in a secondary example in:
https://llvm.org/PR50389

https://alive2.llvm.org/ce/z/BvsESh

3 years ago[InstCombine] add tests for logical and/or with not ops; NFC
Sanjay Patel [Mon, 14 Jun 2021 14:47:36 +0000 (10:47 -0400)]
[InstCombine] add tests for logical and/or with not ops; NFC

3 years ago[LoopDeletion] Add test with irreducible control flow in loop.
Florian Hahn [Mon, 14 Jun 2021 16:15:32 +0000 (17:15 +0100)]
[LoopDeletion] Add test with irreducible control flow in loop.

Currently the irreducible cycles in the loops are ignored. The
irreducible cycle may loop infinitely in
irreducible_subloop_no_mustprogress, which is allowed and the loop
should not be removed.

Discussed in D103382.

3 years ago[mlir] Mark gpu dialect illegal in gpu-to-llvm conversion
Christian Sigg [Mon, 14 Jun 2021 07:14:30 +0000 (09:14 +0200)]
[mlir] Mark gpu dialect illegal in gpu-to-llvm conversion

Reviewed By: herhut, bondhugula

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

3 years ago[VectorCombine] Limit scalarization to non-poison indices for now.
Florian Hahn [Mon, 14 Jun 2021 15:38:27 +0000 (16:38 +0100)]
[VectorCombine] Limit scalarization to non-poison indices for now.

As Eli mentioned post-commit in D103378, the result of the freeze may
still be out-of-range according to Alive2. So for now, just limit the
transform to indices that are non-poison.

3 years agoSelectionDAG: repair the Windows build
Saleem Abdulrasool [Mon, 14 Jun 2021 15:23:51 +0000 (08:23 -0700)]
SelectionDAG: repair the Windows build

6e5628354e22f3ca40b04295bac540843b8e6482 regressed the Windows build as
the return type no longer matched in both branches for the return value
type deduction.  This uses a bit more compiler magic to deal with that.

3 years ago[AIX][XCOFF] emit vector info of traceback table.
zhijian [Mon, 14 Jun 2021 15:15:22 +0000 (11:15 -0400)]
[AIX][XCOFF] emit vector info of traceback table.

Summary:

emit vector info of traceback table.

Reviewers: Jason Liu,Hubert Tong
Differential Revision: https://reviews.llvm.org/D93659

3 years ago[ADT] Use unnamed argument for unused arg in StringMapEntryStorage.
Florian Hahn [Mon, 14 Jun 2021 14:27:22 +0000 (15:27 +0100)]
[ADT] Use unnamed argument for unused arg in StringMapEntryStorage.

This silences an 'unsused argument' warning.

Similar to c2006f857d80f54b90ed7d911d3e7acf4f46001b.

3 years ago[AArch64] Improve SAD pattern
Jingu Kang [Thu, 10 Jun 2021 15:02:57 +0000 (16:02 +0100)]
[AArch64] Improve SAD pattern

Given a vecreduce_add node, detect the below pattern and convert it to the node
sequence with UABDL, [S|U]ADB and UADDLP.

i32 vecreduce_add(
 v16i32 abs(
   v16i32 sub(
    v16i32 [sign|zero]_extend(v16i8 a), v16i32 [sign|zero]_extend(v16i8 b))))
=================>
i32 vecreduce_add(
  v4i32 UADDLP(
    v8i16 add(
      v8i16 zext(
        v8i8 [S|U]ABD low8:v16i8 a, low8:v16i8 b
      v8i16 zext(
        v8i8 [S|U]ABD high8:v16i8 a, high8:v16i8 b

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

3 years agoRevert "[clang] NRVO: Improvements and handling of more cases."
Hans Wennborg [Mon, 14 Jun 2021 14:39:32 +0000 (16:39 +0200)]
Revert "[clang] NRVO: Improvements and handling of more cases."

This change caused build errors related to move-only __block variables,
see discussion on https://reviews.llvm.org/D99696

> This expands NRVO propagation for more cases:
>
> Parse analysis improvement:
> * Lambdas and Blocks with dependent return type can have their variables
>   marked as NRVO Candidates.
>
> Variable instantiation improvements:
> * Fixes crash when instantiating NRVO variables in Blocks.
> * Functions, Lambdas, and Blocks which have auto return type have their
>   variables' NRVO status propagated. For Blocks with non-auto return type,
>   as a limitation, this propagation does not consider the actual return
>   type.
>
> This also implements exclusion of VarDecls which are references to
> dependent types.
>
> Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
>
> Reviewed By: Quuxplusone
>
> Differential Revision: https://reviews.llvm.org/D99696

This also reverts the follow-on change which was hard to tease apart
form the one above:

> "[clang] Implement P2266 Simpler implicit move"
>
> This Implements [[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2266r1.html|P2266 Simpler implicit move]].
>
> Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
>
> Reviewed By: Quuxplusone
>
> Differential Revision: https://reviews.llvm.org/D99005

This reverts commits 1e50c3d785f4563873ab1ce86559f2a1285b5678 and
bf20631782183cd19e0bb7219e908c2bbb01a75f.

3 years ago[gn build] Port c820b494d6e1
LLVM GN Syncbot [Mon, 14 Jun 2021 14:41:33 +0000 (14:41 +0000)]
[gn build] Port c820b494d6e1

3 years ago[libcxx][ranges] Implement views::all.
zoecarver [Thu, 6 May 2021 22:31:45 +0000 (15:31 -0700)]
[libcxx][ranges] Implement views::all.

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

3 years ago[lldb][docs] Add the missing rst anchors to the Python enum docs
Raphael Isemann [Mon, 14 Jun 2021 14:31:28 +0000 (16:31 +0200)]
[lldb][docs] Add the missing rst anchors to the Python enum docs

3 years ago[lldb][docs] Fix section name for InputReaderGranularity
Raphael Isemann [Mon, 14 Jun 2021 14:21:27 +0000 (16:21 +0200)]
[lldb][docs] Fix section name for InputReaderGranularity

3 years ago[libc++] [test] No longer rely on std::hash<T>::argument_type.
Arthur O'Dwyer [Sat, 12 Jun 2021 01:05:17 +0000 (21:05 -0400)]
[libc++] [test] No longer rely on std::hash<T>::argument_type.

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

3 years agoAdd AutomaticAllocationScope to memref.alloca_scope
Denys Shabalin [Mon, 14 Jun 2021 14:07:40 +0000 (16:07 +0200)]
Add AutomaticAllocationScope to memref.alloca_scope

This change adds `AutomaticAllocationScope` to the
memref.alloca_scope op. Additionally, it also clarifies
that alloca_scope is is conceptually a passthrough operation.

Reviewed By: ftynse, bondhugula

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

3 years ago[flang] Fix compilation problem with rename of "MemRefDataFlow"
Peter Steinfeld [Mon, 14 Jun 2021 13:21:37 +0000 (06:21 -0700)]
[flang] Fix compilation problem with rename of "MemRefDataFlow"

Revision https://reviews.llvm.org/D104190 renamed MemRefDataFlow -> AffineScalarReplacement.  After this rename, mlir failed to build.  With this change, all of clang, mlir, and flang build and test correctly.

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

3 years agoReland "[lldb] Set return status to failed when adding a command error"
David Spickett [Mon, 14 Jun 2021 12:11:58 +0000 (13:11 +0100)]
Reland "[lldb] Set return status to failed when adding a command error"

This reverts commit ac031c8db2ce454a9b08f23192ce698e8bde4447.

SB API usage has been corrected.

3 years ago[NFC][DAGCombine] Extract getFirstIndexOf() lambda back into a function
Roman Lebedev [Mon, 14 Jun 2021 13:25:59 +0000 (16:25 +0300)]
[NFC][DAGCombine] Extract getFirstIndexOf() lambda back into a function

Not all supported compilers like such lambdas, at least one buildbot is unhappy.

3 years ago[DAGCombine] reduceBuildVecToShuffle(): sort input vectors by decreasing size
Roman Lebedev [Mon, 14 Jun 2021 12:59:03 +0000 (15:59 +0300)]
[DAGCombine] reduceBuildVecToShuffle(): sort input vectors by decreasing size

The sorting, obviously, must be stable, else we will have random assembly fluctuations.

Apparently there was no test coverage that would benefit from that,
so i've added one test.

The sorting consists of two parts - just sort the input vectors,
and recompute the shuffle mask -> input vector mapping.
I don't believe we need to do anything else.

Reviewed By: RKSimon

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

3 years ago[clang][deps] NFC: Stop using moved-from object
Jan Svoboda [Mon, 14 Jun 2021 13:08:02 +0000 (15:08 +0200)]
[clang][deps] NFC: Stop using moved-from object

The dependency scanning worker uses `std::move` to "reset" `DependencyOutputOptions` in the `CompilerInstance` that performs the implicit build. It's probably preferable to replace the object with value-initialized instance, rather than depending on the behavior of a moved-from object.

Reviewed By: dexonsmith

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

3 years ago[clang][deps] NFC: Handle `DependencyOutputOptions` only once
Jan Svoboda [Mon, 14 Jun 2021 13:06:13 +0000 (15:06 +0200)]
[clang][deps] NFC: Handle `DependencyOutputOptions` only once

There's no need to pass `DependencyOutputOptions` to each call of `handleFileDependency`, since the options don't ever change.

This patch adds new `handleDependencyOutputOpts` method to the `DependencyConsumer` interface and the dependency scanner uses it to report the options only once.

Reviewed By: dexonsmith

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

3 years agoIntrinsic::getName: require a Module argument
Jeroen Dobbelaere [Mon, 14 Jun 2021 12:52:29 +0000 (14:52 +0200)]
Intrinsic::getName: require a Module argument

Ensure that we provide a `Module` when checking if a rename of an intrinsic is necessary.

This fixes the issue that was detected by https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32288
(as mentioned by @fhahn), after committing D91250.

Note that the `LLVMIntrinsicCopyOverloadedName` is being deprecated in favor of `LLVMIntrinsicCopyOverloadedName2`.

Reviewed By: nikic

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

3 years ago[libc++] NFC: More refactoring in the prev/next/advance tests per review comments
Louis Dionne [Mon, 14 Jun 2021 12:41:56 +0000 (08:41 -0400)]
[libc++] NFC: More refactoring in the prev/next/advance tests per review comments

3 years ago[clang][deps] NFC: Fix an XFAIL test on Windows
Jan Svoboda [Fri, 11 Jun 2021 11:52:38 +0000 (13:52 +0200)]
[clang][deps] NFC: Fix an XFAIL test on Windows

The `sed` command ensures Windows-specific path separators (single and double backslashes) are replaced by forward slashes in the output file. FileCheck can continue using forward slashes in paths this way.

3 years ago[MLIR][NFC] Rename MemRefDataFlow -> AffineScalarReplacement
Uday Bondhugula [Sat, 12 Jun 2021 23:19:20 +0000 (04:49 +0530)]
[MLIR][NFC] Rename MemRefDataFlow -> AffineScalarReplacement

NFC. Rename MemRefDataFlow -> AffineScalarReplacement and move to
AffineTransforms library. Pass command line rename: -memref-dataflow-opt
-> affine-scalrep. Update outdated pass documentation.

Rationale:
https://llvm.discourse.group/t/move-and-rename-memref-dataflow-opt-lib-transforms-lib-affine-dialect-transforms/3640

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

3 years ago[libc++] Refactor the tests for std::prev, next and advance
Louis Dionne [Thu, 27 May 2021 18:15:11 +0000 (14:15 -0400)]
[libc++] Refactor the tests for std::prev, next and advance

This started as an attempt to fix a GCC 11 warning of misplaced parentheses.
I then noticed that trying to fix the parentheses warning actually triggered
errors in the tests, showing that we were incorrectly assuming that the
implementation of ranges::advance was using operator+= or operator-=.

This commit fixes that issue and makes the tests easier to follow by
localizing the assertions it makes.

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

3 years agoRevert "[lldb] Set return status to failed when adding a command error" (and fixups)
David Spickett [Mon, 14 Jun 2021 12:08:40 +0000 (12:08 +0000)]
Revert "[lldb] Set return status to failed when adding a command error" (and fixups)

This reverts commit f583029da3d6dbabe82f48b160227eb0120abd33,
0f94d68a2e15d50796439f20bcb508b95931d2ae and
a2363c0cf9b6a9a81c76ac652da667f73845d38b.

Due to test failures from incorrect SB API usage.

3 years ago[clang][deps] Prevent unintended modifications of the original TU command-line
Jan Svoboda [Mon, 14 Jun 2021 10:24:54 +0000 (12:24 +0200)]
[clang][deps] Prevent unintended modifications of the original TU command-line

One of the goals of the dependency scanner is to generate command-lines that can be used to explicitly build modular dependencies of a translation unit. The only modifications to these command-lines should be for the purposes of explicit modular build.

However, the current version of dependency scanner leaks its implementation details into the command-lines.

The first problem is that the `clang-scan-deps` tool adjusts the original textual command-line (adding `-Eonly -M -MT <target> -sys-header-deps -Wno-error -o /dev/null `, removing `--serialize-diagnostics`) in order to set up the `DependencyScanning` library. This has been addressed in D103461, D104012, D104030, D104031, D104033. With these patches, the `DependencyScanning` library receives the unmodified `CompilerInvocation`, sets it up and uses it for the implicit modular build.

Finally, to prevent leaking the implementation details to the resulting command-lines, this patch generates them from the **original** unmodified `CompilerInvocation` rather than from the one that drives the implicit build.

Reviewed By: dexonsmith

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

3 years ago[clang][deps] NFC: Check the correct context hashes in tests
Jan Svoboda [Thu, 10 Jun 2021 12:13:25 +0000 (14:13 +0200)]
[clang][deps] NFC: Check the correct context hashes in tests

The `clang-scan-deps` tests for the full output format were written under the assumption that most TUs/modules have the same context hash. This is no longer true, since we're changing the original compilation options. This patch updates the tests, which no longer conflate multiple context hashes into a single FileCheck variable.

3 years ago[lldb][docs] Document SBType
Raphael Isemann [Mon, 14 Jun 2021 11:03:02 +0000 (13:03 +0200)]
[lldb][docs] Document SBType

This documents the behaviour of the different SBType functions with notes for
the language-specific behaviour for C/C++/Objective-C. All of this reflects the
current behaviour of LLDB (even though that also means some functions behave
kinda weird but at least they are now documented to be weird)

Reviewed By: #lldb, mib

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

3 years ago[clang][deps] Fix failing modules.cpp test
Jan Svoboda [Mon, 14 Jun 2021 10:55:32 +0000 (12:55 +0200)]
[clang][deps] Fix failing modules.cpp test

Commit d8bab69ead22a10dc4cdb2e36f6ea6fdfe774e2e updated the ClangScanDeps/modules.cpp test. The new `{{.*}}` regex is supposed to only match `modules_cdb_input.o`, `a.o` or `b.o`. However, due to non-determinism, this can sometimes also match `modules_cdb_input2.o`, causing match failure on the next line. This commit changes the regex to only match one of the three valid cases.

Buildbot failure: https://lab.llvm.org/buildbot/#/builders/109/builds/16675

3 years ago[VPlan] Add additional tests for region merging.
Florian Hahn [Sun, 13 Jun 2021 15:29:18 +0000 (16:29 +0100)]
[VPlan] Add additional tests for region merging.

Add additional tests suggested in D100260.

Also drop the unneeded `indvars.` prefix from induction phi name.

3 years ago[clang][deps] Move enabling system header deps from `clang-scan-deps` to `DependencyS...
Jan Svoboda [Mon, 14 Jun 2021 10:12:23 +0000 (12:12 +0200)]
[clang][deps] Move enabling system header deps from `clang-scan-deps` to `DependencyScanning` library

This patch moves enabling system header deps from `clang-scan-deps` into the `DependencyScanning` library. This will make it easier to preserve semantics of the original TU command-line for modular dependencies (see D104036).

Reviewed By: arphaman

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

3 years ago[clang][deps] Move injection of `-Wno-error` from `clang-scan-deps` to `DependencySca...
Jan Svoboda [Mon, 14 Jun 2021 10:09:54 +0000 (12:09 +0200)]
[clang][deps] Move injection of `-Wno-error` from `clang-scan-deps` to `DependencyScanning` library

This moves another piece of logic specific to `clang-scan-deps` into the `DependencyScanning` library. This makes it easier to check how the original command-line looked like in the library and will enable the library to stop inventing `-Wno-error` for modular dependencies (see D104036).

Reviewed By: arphaman

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

3 years ago[clang][deps] Move invocation adjustments from `clang-scan-deps` to `DependencyScanni...
Jan Svoboda [Mon, 14 Jun 2021 10:06:08 +0000 (12:06 +0200)]
[clang][deps] Move invocation adjustments from `clang-scan-deps` to `DependencyScanning` library

The `clang-scan-deps` tool has some logic that parses and modifies the original Clang command-line. The goal is to setup `DependencyOutputOptions` by injecting `-M -MT <target>` and prevent the creation of output files.

This patch moves the logic into the `DependencyScanning` library, and uses the parsed `CompilerInvocation` instead of the raw command-line. The code simpler and can be used from the C++ API as well.

The `-o /dev/null` arguments are not necessary, since the `DependencyScanning` library only runs a preprocessing action, so there's no way it'll produce an actual object file.

Related: The `-M` argument implies `-w`, which would appear on the command-line of modular dependencies even though it was not on the original TU command line (see D104036).

Some related tests were updated.

Reviewed By: arphaman

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

3 years ago[clang][deps] Move stripping of diagnostic serialization from `clang-scan-deps` to...
Jan Svoboda [Mon, 14 Jun 2021 10:02:19 +0000 (12:02 +0200)]
[clang][deps] Move stripping of diagnostic serialization from `clang-scan-deps` to `DependencyScanning` library

To prevent the creation of diagnostics file, `clang-scan-deps` strips the corresponding command-line argument. This behavior is useful even when using the C++ `DependencyScanner` library.

This patch transforms stripping of command-line in `clang-scan-deps` into stripping of `CompilerInvocation` in `DependencyScanning`.

AFAIK, the `clang-cl` driver doesn't even accept `--serialize-diagnostics`, so I've removed the test. (It would fail with an unknown command-line argument otherwise.)

Note: Since we're generating command-lines for modular dependencies from `CompilerInvocation`, the `--serialize-diagnostics` will be dropped. This was already happening in `clang-scan-deps` before this patch, but it will now happen also when using `DependencyScanning` library directly. This is resolved in D104036.

Reviewed By: dexonsmith, arphaman

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

3 years ago[Analyzer][solver] Simplify existing eq classes and constraints when a new constraint...
Gabor Marton [Fri, 28 May 2021 13:18:28 +0000 (15:18 +0200)]
[Analyzer][solver] Simplify existing eq classes and constraints when a new constraint is added

Update `setConstraint` to simplify existing equivalence classes when a
new constraint is added. In this patch we iterate over all existing
equivalence classes and constraints and try to simplfy them with
simplifySVal. This solves problematic cases where we have two symbols in
the tree, e.g.:
```
int test_rhs_further_constrained(int x, int y) {
  if (x + y != 0)
    return 0;
  if (y != 0)
    return 0;
  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
  clang_analyzer_eval(y == 0);     // expected-warning{{TRUE}}
  return 0;
}
```

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

3 years ago[clang][deps] Handle modular dependencies present in PCH
Jan Svoboda [Mon, 14 Jun 2021 09:30:26 +0000 (11:30 +0200)]
[clang][deps] Handle modular dependencies present in PCH

When a translation unit uses a PCH and imports the same modules as the PCH, we'd prefer to resolve to those modules instead of inventing new modules and reporting them as modular dependencies. Since the PCH modules have already been built nudge the compiler to reuse them when deciding whether to build a new module and don't report them as regular modular dependencies.

Depends on D103524 & D103802.

Reviewed By: dexonsmith

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

3 years agoFix -Wswitch warning after 092c303955cd18be6c0b923b1c0a1b96e2c91893.
Haojian Wu [Mon, 14 Jun 2021 09:51:00 +0000 (11:51 +0200)]
Fix -Wswitch warning after 092c303955cd18be6c0b923b1c0a1b96e2c91893.

3 years ago[flang] Add POSIX implementation for CPU_TIME
Diana Picus [Wed, 9 Jun 2021 09:47:10 +0000 (09:47 +0000)]
[flang] Add POSIX implementation for CPU_TIME

Add an implementation for CPU_TIME using the POSIX function
clock_gettime. I think on most POSIX systems this will be included for
free via <ctime>, which corresponds to "time.h" (YMMV, we can fix the
code if the need arises).

Detecting that clock_gettime is available is tricky. For instance, commit
827407a86aa07 used the following incantation in f18-parse-demo.cpp:

  #if _POSIX_C_SOURCE >= 199309L && _POSIX_TIMERS > 0 && _POSIX_CPUTIME && \
    defined CLOCK_PROCESS_CPUTIME_ID

This doesn't work on my AArch64 Ubuntu system, which provides
clock_gettime but doesn't define _POSIX_TIMERS. Since finding the right
combination of macros requires infinite time, patience and access to
sundry POSIX systems, we should probably try a different approach.

This patch attempts to use SFINAE instead of the preprocessor to choose
an implementation for CPU_TIME. We define a helper function template
which helps us check if clock_gettime is available (and has the
interface we expect). I hope the comments explain it well enough.

This approach has the advantage that it keeps the detection of
clock_gettime close to the code that uses it. An alternative would be to
use CMake to check for the symbol (I personally haven't used this before
so I don't know if there are any quirks).

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

3 years ago[lldb] Correct "else if" to "elif" in TestRegisters
David Spickett [Mon, 14 Jun 2021 09:35:14 +0000 (09:35 +0000)]
[lldb] Correct "else if" to "elif" in TestRegisters

3 years agoRevert "[libc] Add a set of elementary operations"
Guillaume Chatelet [Mon, 14 Jun 2021 09:33:39 +0000 (09:33 +0000)]
Revert "[libc] Add a set of elementary operations"

This reverts commit e63f27a3cf8129cb66b8350ad50bf19633554a6b.

3 years ago[clang][deps] Handle precompiled headers' AST files
Jan Svoboda [Mon, 14 Jun 2021 09:15:03 +0000 (11:15 +0200)]
[clang][deps] Handle precompiled headers' AST files

The `PreprocessOnlyAction` doesn't support loading the AST file of a precompiled header. This is problematic for dependency scanning, since the `#include` manufactured for the PCH is treated as textual. This means the PCH contents get scanned with each TU, which is redundant. Moreover, dependencies of the PCH end up being considered dependency of the TU.

To handle AST file of PCH properly, this patch creates new `FrontendAction` that behaves the same way `PreprocessorOnlyAction` does, but treats the manufactured PCH `#include` as a normal compilation would (by not claiming it only uses a preprocessor and creating the default AST consumer).

The AST file is now reported as a file dependency of the TU.

Depends on D103519.

Reviewed By: Bigcheese

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

3 years ago[lldb] Add missing changes to a2363c0cf9b6a9a81c76ac652da667f73845d38b
David Spickett [Mon, 14 Jun 2021 09:23:05 +0000 (09:23 +0000)]
[lldb] Add missing changes to a2363c0cf9b6a9a81c76ac652da667f73845d38b

Completely forgot to actually update the change before relanding it.
This adds the Darwin AVX changes.

3 years agoReland "[lldb] Set return status to failed when adding a command error"
David Spickett [Mon, 14 Jun 2021 09:19:25 +0000 (09:19 +0000)]
Reland "[lldb] Set return status to failed when adding a command error"

This reverts commit db93e4e70aa453e5ba04ba0d9e01f581882b6c81.

This modifies TestRegsters.py to account for Darwin showing
AVX registers as part of "Floating Point Registers" instead
of in a separate "Advanced Vector Extensions" category.

3 years ago[clang][modules][pch] Allow loading PCH with different modules cache path
Jan Svoboda [Mon, 14 Jun 2021 08:51:04 +0000 (10:51 +0200)]
[clang][modules][pch] Allow loading PCH with different modules cache path

It's useful to be able to load explicitly-built PCH files into an implicit build (e.g. during dependency scanning). That's currently impossible, since the explicitly-built PCH has an empty modules cache path, while the current compilation has (and needs to have) a valid path, triggering an error in the `PCHValidator`.

This patch adds a preprocessor option and command-line flag that can be used to omit this check.

Reviewed By: dexonsmith

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

3 years ago[libc] Add a set of elementary operations
Guillaume Chatelet [Mon, 14 Jun 2021 09:01:06 +0000 (09:01 +0000)]
[libc] Add a set of elementary operations

Each of these elementary operations can be assembled to support higher order constructs (Overlapping access, Loop, Aligned Loop).
The patch does not compile yet as it depends on other ones (D100571, D100631) but it allows to get the conversation started.

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

3 years ago[clang][deps] NFC: Preserve the original frontend action
Jan Svoboda [Mon, 14 Jun 2021 08:32:48 +0000 (10:32 +0200)]
[clang][deps] NFC: Preserve the original frontend action

This patch stops adjusting the frontend action when `clang-scan-deps` is configured to use the full output format.

In a future patch, the dependency scanner needs to check whether the original compiler invocation builds a PCH. That's impossible when `-Eonly` et al. override `-emit-pch`.

The `-Eonly` flag is not needed - the dependency scanner explicitly sets up its own frontend action anyways.

Reviewed By: dexonsmith

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

3 years ago[llvm] remove Sequence::asSmallVector()
Guillaume Chatelet [Mon, 14 Jun 2021 08:27:41 +0000 (08:27 +0000)]
[llvm] remove Sequence::asSmallVector()

There's no need for `toSmallVector()` as `SmallVector.h` already provides a `to_vector` free function that takes a range.

Reviewed By: Quuxplusone

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

3 years ago[flang] Add initial implementation for CPU_TIME
Diana Picus [Wed, 9 Jun 2021 08:19:43 +0000 (08:19 +0000)]
[flang] Add initial implementation for CPU_TIME

Add an implementation for CPU_TIME based on std::clock(), which should
be available on all the platforms that we support.

Also add a test that's basically just a sanity check to make sure we
return positive values and that the value returned at the start of some
amount of work is larger than the one returned after the end.

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

3 years ago[VP] Binary floating-point intrinsics.
Simon Moll [Mon, 14 Jun 2021 06:51:24 +0000 (08:51 +0200)]
[VP] Binary floating-point intrinsics.

This patch implements vector-predicated intrinsics on IR level for fadd,
fsub, fmul, fdiv and frem.  There operate in the default floating-point
environment. We will use constrained fp operand bundles for constrained
vector-predicated fp math (D93455).

Reviewed By: craig.topper

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

3 years ago[mlir] Remove traits that require vector type support from ops in Complex dialect.
Adrian Kuegel [Fri, 11 Jun 2021 10:24:40 +0000 (12:24 +0200)]
[mlir] Remove traits that require vector type support from ops in Complex dialect.

Actually, no vector types are supported so far. We should add the traits once
the vector types are supported (e.g. ElementwiseMappable.traits).
Instead add Elementwise trait to each op.

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

3 years ago[mlir][linalg] Add support for scalar input operands.
Tobias Gysi [Mon, 14 Jun 2021 05:59:33 +0000 (05:59 +0000)]
[mlir][linalg] Add support for scalar input operands.

Up to now all structured op operands are assumed to be shaped. The patch relaxes this assumption and allows scalar input operands. In contrast to shaped operands scalar operands are not indexed and directly forwarded to the body of the operation. As all other operands, scalar operands are associated to an indexing map that in case of a scalar or a 0D-operand has an empty range.

We will use scalar operands as a replacement for the capture mechanism. In contrast to captures, the approach ensures we can generate the function signature from the operand list and it prevents outdated capture values in case a transformation updates only the capture operand but not the hidden body of a named operation.

Removing captures and updating existing operations such as linalg.fill is left for a later patch.

The patch depends on https://reviews.llvm.org/D103891 and https://reviews.llvm.org/D103890.

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

3 years ago[mlir][linalg] Lower PadTensorOps with non-constant pad value
Matthias Springer [Mon, 14 Jun 2021 06:00:30 +0000 (15:00 +0900)]
[mlir][linalg] Lower PadTensorOps with non-constant pad value

The padding of such ops is not generated in a vectorized way. Instead, emit a tensor::GenerateOp.

We may vectorize GenerateOps in the future.

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

3 years ago[mlir] Add ExpOp to Complex dialect.
Adrian Kuegel [Fri, 11 Jun 2021 11:37:51 +0000 (13:37 +0200)]
[mlir] Add ExpOp to Complex dialect.

Also add a conversion pattern from Complex to Standard/Math dialect.

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

3 years agoOnly consider built-in compound assignment operators for -Wunused-but-set-*
Stephan Bergmann [Mon, 14 Jun 2021 05:57:22 +0000 (07:57 +0200)]
Only consider built-in compound assignment operators for -Wunused-but-set-*

At least LibreOffice has, for mainly historic reasons that would be hard to
change now, a class Any with an overloaded operator >>= that semantically does
not assign to the LHS but rather extracts into the (by-reference) RHS.  Which
thus caused false positive -Wunused-but-set-parameter and
-Wunused-but-set-variable after those have been introduced recently.

This change is more conservative about the assumed semantics of overloaded
operators, excluding compound assignment operators but keeping plain operator =
ones.  At least for LibreOffice, that strikes a good balance of not producing
false positives but still finding lots of true ones.

(The change to the BinaryOperator case in MaybeDecrementCount is necessary
because e.g. the template f4 test code in warn-unused-but-set-variables-cpp.cpp
turns the += into a BinaryOperator.)

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

3 years ago[LoopVectorize] precommit pr50686.ll for D104148
Mindong Chen [Mon, 14 Jun 2021 05:55:14 +0000 (13:55 +0800)]
[LoopVectorize] precommit pr50686.ll for D104148

3 years ago[mlir][linalg] Vectorize linalg.pad_op source copying (improved)
Matthias Springer [Mon, 14 Jun 2021 05:41:07 +0000 (14:41 +0900)]
[mlir][linalg] Vectorize linalg.pad_op source copying (improved)

Vectorize linalg.pad_op source copying if source or result shape are static.

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

3 years ago[mlir][linalg] Vectorize linalg.pad_op source copying (static source shape)
Matthias Springer [Mon, 14 Jun 2021 05:30:02 +0000 (14:30 +0900)]
[mlir][linalg] Vectorize linalg.pad_op source copying (static source shape)

If the source operand of a linalg.pad_op operation has static shape, vectorize the copying of the source.

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

3 years ago[mlir][linalg] Lower PadTensorOp to InitTensorOp + FillOp + SubTensorInitOp
Matthias Springer [Mon, 14 Jun 2021 05:20:11 +0000 (14:20 +0900)]
[mlir][linalg] Lower PadTensorOp to InitTensorOp + FillOp + SubTensorInitOp

Currently limited to constant pad values. Any combination of dynamic/static tensor sizes and padding sizes is supported.

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

3 years agoAMD k8 family does not support SSE4.x which are required by x86-64-v2+
serge-sans-paille [Fri, 11 Jun 2021 13:42:26 +0000 (15:42 +0200)]
AMD k8 family does not support SSE4.x which are required by x86-64-v2+

So don't define __tune__k8__ for these micro architecture.

SSE, SSE2 and SSE3 appear in https://www.amd.com/system/files/TechDocs/25112.PDF
but not SSE4.x.

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

3 years ago[LLParser] Remove outdated deplibs
Xuanda Yang [Mon, 14 Jun 2021 04:46:12 +0000 (12:46 +0800)]
[LLParser] Remove outdated deplibs

The comment mentions deplibs should be removed in 4.0. Removing it in this patch.

Reviewed By: compnerd, dexonsmith, lattner

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

3 years ago[Testsuite] Change these tests to only have a single verification error, NFC.
Chris Lattner [Mon, 14 Jun 2021 04:35:24 +0000 (21:35 -0700)]
[Testsuite] Change these tests to only have a single verification error, NFC.

These are testing for various verification failures, but have missing returns
at the end of their function.  Add the returns to focus the tests better.

3 years ago[lld-macho] Try to fix MSAN "uninitialized memory" error
Jez Ng [Mon, 14 Jun 2021 03:30:33 +0000 (23:30 -0400)]
[lld-macho] Try to fix MSAN "uninitialized memory" error

I *think* this is the fix, with the regression being introduced by
D104199. Not 100% sure since MSAN isn't supported on my Mac machine, and
it'll take some time to spin up a Linux box... will look at the
buildbots for answers

3 years agoImplement DW_CFA_LLVM_* for Heterogeneous Debugging
RamNalamothu [Mon, 14 Jun 2021 01:27:58 +0000 (06:57 +0530)]
Implement DW_CFA_LLVM_* for Heterogeneous Debugging

Add support in MC/MIR for writing/parsing, and DebugInfo.

This is part of the Extensions for Heterogeneous Debugging defined at
https://llvm.org/docs/AMDGPUDwarfExtensionsForHeterogeneousDebugging.html

Specifically the CFI instructions implemented here are defined at
https://llvm.org/docs/AMDGPUDwarfExtensionsForHeterogeneousDebugging.html#cfa-definition-instructions

Reviewed By: clayborg

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

3 years agoCalculate getTerminator only when necessary
Aditya Kumar [Sun, 13 Jun 2021 18:32:28 +0000 (11:32 -0700)]
Calculate getTerminator only when necessary

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

3 years ago[ORC-RT] Fix an error check.
Lang Hames [Mon, 14 Jun 2021 00:35:20 +0000 (10:35 +1000)]
[ORC-RT] Fix an error check.

3 years ago[mlir][linalg] Remove generic PadTensorOp vectorization pattern
Matthias Springer [Mon, 14 Jun 2021 01:40:50 +0000 (10:40 +0900)]
[mlir][linalg] Remove generic PadTensorOp vectorization pattern

The generic vectorization pattern handles only those cases, where
low and high padding is zero. This is already handled by a
canonicalization pattern.

Also add a new canonicalization test case to ensure that tensor cast ops
are properly inserted.

A more general vectorization pattern will be added in a subsequent commit.

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

3 years ago[DominanceInfo] Make the ctor take a defaulted value for the operand. NFC.
Chris Lattner [Mon, 14 Jun 2021 01:24:53 +0000 (18:24 -0700)]
[DominanceInfo] Make the ctor take a defaulted value for the operand. NFC.

This allows it to be default constructible, which makes sense given it
ignores the operand.

3 years ago[mlir] Vectorize linalg.pad_tensor consumed by transfer_write
Matthias Springer [Mon, 14 Jun 2021 01:16:22 +0000 (10:16 +0900)]
[mlir] Vectorize linalg.pad_tensor consumed by transfer_write

Vectorize linalg.pad_tensor without generating a linalg.init_tensor when consumed by a transfer_write.

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

3 years ago[mlir] Vectorize linalg.pad_tensor consumed by subtensor_insert
Matthias Springer [Mon, 14 Jun 2021 00:58:26 +0000 (09:58 +0900)]
[mlir] Vectorize linalg.pad_tensor consumed by subtensor_insert

Vectorize linalg.pad_tensor without generating a linalg.init_tensor when consumed by a subtensor_insert.

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

3 years ago[mlir] Vectorize linalg.pad_tensor consumed by transfer_read
Matthias Springer [Mon, 14 Jun 2021 00:51:50 +0000 (09:51 +0900)]
[mlir] Vectorize linalg.pad_tensor consumed by transfer_read

Vectorize linalg.pad_tensor without generating a linalg.init_tensor when consumed by a transfer_read.

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

3 years ago[mlir][linalg] Add constant padding helper to PadTensorOp
Matthias Springer [Mon, 14 Jun 2021 00:43:02 +0000 (09:43 +0900)]
[mlir][linalg] Add constant padding helper to PadTensorOp

* Add a helper function that returns the constant padding value (if applicable).
* Remove existing getConstantYieldValueFromBlock function, which does almost the same.
* Adapted from D103243.

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

3 years ago[Utils] Add missing freeze and poison keyword highlights
Juneyoung Lee [Mon, 14 Jun 2021 00:21:01 +0000 (09:21 +0900)]
[Utils] Add missing freeze and poison keyword highlights

This patch adds missing keyword highlights for freeze and poison

Reviewed By: MaskRay, porglezomp

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

3 years ago[lld-macho][nfc] Add `final` to classes where possible
Jez Ng [Sun, 13 Jun 2021 23:43:37 +0000 (19:43 -0400)]
[lld-macho][nfc] Add `final` to classes where possible

I wanted to see if we would get any perf wins out of this, but
it doesn't seem to be the case. But it still seems worth committing.

Reviewed By: MaskRay

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

3 years ago[lld-macho][nfc] Represent the image loader cache with a ConcatInputSection
Jez Ng [Sun, 13 Jun 2021 23:43:36 +0000 (19:43 -0400)]
[lld-macho][nfc] Represent the image loader cache with a ConcatInputSection

We don't need to define any special behavior for this section,
so creating a subclass for it is redundant.

Reviewed By: #lld-macho, thakis

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

3 years ago[lld-macho][nfc] Remove InputSection::outSecFileOff
Jez Ng [Sun, 13 Jun 2021 23:43:34 +0000 (19:43 -0400)]
[lld-macho][nfc] Remove InputSection::outSecFileOff

`outSecFileOff` and the associated `getFileOffset()` accessors were
unnecessary.

For all the cases we care about, `outSecFileOff` is the same as
`outSecOff`. The only time they deviate is if there are zerofill
sections within a given segment. But since zerofill sections are always
at the end of a segment, the only sections where the two values deviate
are zerofill sections themselves. And we never actually query the
outSecFileOff of zerofill sections.

As for `getFileOffset()`, the only place it was being used was to
calculate the offset of the entry symbol. However, we can compute that
value by just taking the difference between the address of the entry
symbol and the address of the Mach-O header. In fact, this appears to be
what ld64 itself does. This difference is the same as the file offset as
long as there are no intervening zerofill sections, but since `__text`
is the first section in `__TEXT`, this never happens, so our previous
use of `getFileOffset()` was not wrong -- just inefficient.

Reviewed By: #lld-macho, thakis

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

3 years ago[ms] [llvm-ml] When parsing MASM, "jmp short" instructions are case insensitive
Eric Astor [Sun, 13 Jun 2021 22:35:51 +0000 (18:35 -0400)]
[ms] [llvm-ml] When parsing MASM, "jmp short" instructions are case insensitive

Handle "short" in a case-insensitive fashion in MASM.

Required to correctly parse z_Windows_NT-586_asm.asm from the OpenMP runtime.

Reviewed By: thakis

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

3 years ago[ms] [llvm-ml] Fix capitalization of the ignored CPU directives
Eric Astor [Sun, 13 Jun 2021 22:27:06 +0000 (18:27 -0400)]
[ms] [llvm-ml] Fix capitalization of the ignored CPU directives

These directives are matched in lowercase, so make sure to use lowercase for their P suffix.

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

3 years agoFix misspelled instruction in X86 assembly parser
Eric Astor [Sun, 13 Jun 2021 22:33:55 +0000 (18:33 -0400)]
Fix misspelled instruction in X86 assembly parser

Did not correctly handle "jecxz short <address>".

Discovered while working on LLVM-ML; shows up in z_Windows_NT-586_asm.asm from the OpenMP runtime

Reviewed By: MaskRay

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

3 years agounwind: allow building with GCC
Saleem Abdulrasool [Sun, 13 Jun 2021 21:28:43 +0000 (14:28 -0700)]
unwind: allow building with GCC

This was regressed in adf1561d6ce8.  Since gcc does not support
`__has_feature`, this adjusts the build to use the
`__SANITIZE_ADDRESS__` macro which GCC defines to identify if ASAN is
enabled (similar to `__has_feature`).  This allows building libunwind
with gcc again.

Patch by Daniel Levin!

Reviewed By: compnerd

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

3 years ago[DSE] Extra multiblock loop tests, NFC.
David Green [Sun, 13 Jun 2021 21:30:42 +0000 (22:30 +0100)]
[DSE] Extra multiblock loop tests, NFC.

Some of these can be DSE'd, some of which cannot. Useful in D100464.

3 years agoIntroduce tensor.insert op to Tensor dialect.
Hanhan Wang [Sun, 13 Jun 2021 20:45:33 +0000 (13:45 -0700)]
Introduce tensor.insert op to Tensor dialect.

Add `tensor.insert` op to make `tensor.extract`/`tensor.insert` work in pairs
for `scalar` domain. Like `subtensor`/`subtensor_insert` work in pairs in
`tensor` domain, and `vector.transfer_read`/`vector.transfer_write` work in
pairs in `vector` domain.

Reviewed By: silvas

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

3 years ago[ELF] Add OVERWRITE_SECTIONS command
Fangrui Song [Sun, 13 Jun 2021 19:41:11 +0000 (12:41 -0700)]
[ELF] Add OVERWRITE_SECTIONS command

This implements https://sourceware.org/bugzilla/show_bug.cgi?id=26404

An `OVERWRITE_SECTIONS` command is a `SECTIONS` variant which contains several
output section descriptions. The output sections do not have specify an order.
Similar to `INSERT [BEFORE|AFTER]`, `LinkerScript::hasSectionsCommand` is not
set, so the built-in rules (see `docs/ELF/linker_script.rst`) still apply.
`OVERWRITE_SECTIONS` can be more convenient than `INSERT` because it does not
need an anchor section.

The initial syntax is intentionally narrow to facilitate backward compatible
extensions in the future. Symbol assignments cannot be used.

This feature is versatile. To list a few usage:

* Use `section : { KEEP(...) }` to retain input sections under GC
* Define encapsulation symbols (start/end) for an output section
* Use `section : ALIGN(...) : { ... }` to overalign an output section (similar to ld64 `-sectalign`)

When an output section is specified by both `OVERWRITE_SECTIONS` and
`INSERT`, `INSERT` is processed after overwrite sections. To make this work,
this patch changes `InsertCommand` to use name based matching instead of pointer
based matching. (This may cause a difference when `INSERT` moves one output
section more than once. Such duplicate commands should not be used in practice
(seems that in GNU ld the output sections may just disappear).)

A linker script can be used without -T/--script. The traditional `SECTIONS`
commands are concatenated, so a wrong rule can be more noticeable from the
section order. This feature if misused can be less noticeable, just like
`INSERT`.

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

3 years ago[fuzzer] Fix build on musl
Khem Raj [Sun, 13 Jun 2021 19:32:07 +0000 (12:32 -0700)]
[fuzzer] Fix build on musl

cstddef is needed for size_t definition.
(Multiple headers can provide size_t but none of them exists.)

Reviewed By: MaskRay

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

3 years ago[clang-format] Adds a formatter for aligning arrays of structs
Fred Grim [Sun, 13 Jun 2021 14:36:42 +0000 (16:36 +0200)]
[clang-format] Adds a formatter for aligning arrays of structs

This adds a new formatter to arrange array of struct initializers into
neat columns.

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

3 years ago[SPARC] Legalize truncation and extension between fp128 and half
LemonBoy [Sun, 13 Jun 2021 18:03:42 +0000 (20:03 +0200)]
[SPARC] Legalize truncation and extension between fp128 and half

Lower truncations and expansions between fp128 and half values into libcalls.
Expand truncating stores into two separate truncation and a store operations.

Reviewed By: jrtc27

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

3 years agoDirectoryWatcher: also wait for the notifier thread
Saleem Abdulrasool [Sun, 13 Jun 2021 17:52:27 +0000 (10:52 -0700)]
DirectoryWatcher: also wait for the notifier thread

Ultimately the DirectoryWatcher is not ready until the notifier thread
is also active.  Failure to wait for the notifier thread may result in
loss of events.  While this is not catastrophic in practice, the tests
are sensitive to this as depending on the thread scheduler, the thread
may fail to being execution before the operations are completed by the
fixture.  Running this in a tight loop shows no regressions locally as
previously, but this failure mode was been sighted once on a builder.

3 years ago[lld/mac] clarify comment
Nico Weber [Sun, 13 Jun 2021 17:30:05 +0000 (13:30 -0400)]
[lld/mac] clarify comment

This is a "we should do X in the future" fixme, not an "X might go wrong"
fixme.