platform/upstream/llvm.git
3 years ago[mlir][sparse] scalarize reductions in for-loops during sparse codegen
Aart Bik [Thu, 17 Dec 2020 23:42:23 +0000 (15:42 -0800)]
[mlir][sparse] scalarize reductions in for-loops during sparse codegen

Reductions in innermost loops become harder for the backend to disambiguate
after bufferization into memrefs, resulting in less efficient load-update-store
cycles. By scalarizing innermost reductions, the backend is more likely to assign
a register to perform the reduction (also prepares vectorization). Even though
we could scalarize reductions for more outer loops and while-loops as well,
currently scalarization is only done for chains of innermost for-loops, where
it matters most, to avoid complicating codegen unnecessary (viz. adding lots
of yield instructions).

This CL also refactors condition simplification into the merger class,
where it belongs, so that conditions are simplified only once per loop
nest and not repeatedly as was currently done. This CL also fixes a few
minor bugs, some layout issues, and comments.

Reviewed By: penpornk

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

3 years agoRemove unneeded header include (NFC)
Mehdi Amini [Fri, 18 Dec 2020 00:09:51 +0000 (00:09 +0000)]
Remove unneeded header include (NFC)

3 years ago[mlir] Move `std.tensor_cast` -> `tensor.cast`.
Sean Silva [Wed, 16 Dec 2020 00:47:19 +0000 (16:47 -0800)]
[mlir] Move `std.tensor_cast` -> `tensor.cast`.

This is almost entirely mechanical.

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

3 years agoWorkaround around clang 5.0 bug by including SmallVector.h in LLVM.h (PR41549)
Mehdi Amini [Thu, 17 Dec 2020 23:53:19 +0000 (23:53 +0000)]
Workaround around clang 5.0 bug by including SmallVector.h in LLVM.h (PR41549)

The forward declaration for SmallVector does not play well with clang-5.

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

3 years ago[mlir][Linalg] Define a linalg.init_tensor operation.
MaheshRavishankar [Thu, 17 Dec 2020 22:42:40 +0000 (14:42 -0800)]
[mlir][Linalg] Define a linalg.init_tensor operation.

This operation is used to materialize a tensor of a particular
shape. The shape could be specified as a mix of static and dynamic
values.

The use of this operation is to be an `init` tensor for Linalg
structured operation on tensors where the bounds of the computation
depends on the shape of the output of the linalg operation. The result
of this operation will be used as the `init` tensor of such Linalg
operations. To note,

1) The values in the tensor materialized is not used. Any operation to
   which this is an init tensor is expected to overwrite the entire
   tensor.
2) The tensor is materialized only for the shape of the output and to
   make the loop bounds depend only on operands of the structured
   operation.

Based on (1) and (2) it is assumed that these operations eventually go
away since they are only used in `dim` operations that can be
canonicalized to make this operation dead. Such canonicalization are
added here too.

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

3 years ago[mlir] Add canonicalization from `tensor_cast` to `dim` op.
MaheshRavishankar [Thu, 17 Dec 2020 22:42:33 +0000 (14:42 -0800)]
[mlir] Add canonicalization from `tensor_cast` to `dim` op.

Fold a `tensor_cast` -> `dim` to take the `dim` of the original tensor.

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

3 years ago[DSE] Add test for potential caching bug (NFC)
Nikita Popov [Thu, 17 Dec 2020 22:31:31 +0000 (23:31 +0100)]
[DSE] Add test for potential caching bug (NFC)

This one would miscompile if read-clobber checks switched to using
the EarlierAccess location, but the read cache was retained.

3 years agoCodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)
Tom Stellard [Thu, 17 Dec 2020 18:43:00 +0000 (10:43 -0800)]
CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)

Add a special case for handling __builtin_mul_overflow with unsigned
inputs and a signed output to avoid emitting the __muloti4 library
call on x86_64.  __muloti4 is not implemented in libgcc, so avoiding
this call fixes compilation of some programs that call
__builtin_mul_overflow with these arguments.

For example, this fixes the build of cpio with clang, which includes code from
gnulib that calls __builtin_mul_overflow with these argument types.

Reviewed By: vsk

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

3 years ago[VectorCombine] add tests for gep load with cast; NFC
Sanjay Patel [Thu, 17 Dec 2020 17:03:55 +0000 (12:03 -0500)]
[VectorCombine] add tests for gep load with cast; NFC

3 years ago[SimplifyCFG] Teach simplifyUnreachable() to preserve DomTree
Roman Lebedev [Thu, 17 Dec 2020 18:30:37 +0000 (21:30 +0300)]
[SimplifyCFG] Teach simplifyUnreachable() to preserve DomTree

Pretty boring, removeUnwindEdge() already known how to update DomTree,
so if we are to call it, we must first flush our own pending updates;
otherwise, we just stop predecessors from branching to us,
and for certain predecessors, stop their predecessors from
branching to them also.

3 years ago[SimplifyCFG] ConstantFoldTerminator() already knows how to preserve DomTree
Roman Lebedev [Thu, 17 Dec 2020 17:13:03 +0000 (20:13 +0300)]
[SimplifyCFG] ConstantFoldTerminator() already knows how to preserve DomTree

... so just ensure that we pass DomTreeUpdater it into it.

Fixes DomTree preservation for a number of tests,
all of which are marked as such so that they do not regress.

3 years ago[SimplifyCFG] DeleteDeadBlock() already knows how to preserve DomTree
Roman Lebedev [Thu, 17 Dec 2020 16:57:42 +0000 (19:57 +0300)]
[SimplifyCFG] DeleteDeadBlock() already knows how to preserve DomTree

... so just ensure that we pass DomTreeUpdater it into it.

Fixes DomTree preservation for a large number of tests,
all of which are marked as such so that they do not regress.

3 years agoFix -Wno-error= parsing in clang-format.
Joachim Meyer [Thu, 17 Dec 2020 15:06:56 +0000 (16:06 +0100)]
Fix -Wno-error= parsing in clang-format.

As noted in https://reviews.llvm.org/D86137#2460135 parsing of
the clang-format parameter -Wno-error=unknown fails.
This currently is done by having `-Wno-error=unknown` as an option.
In this patch this is changed to make `-Wno-error=` parse an enum into a bit set.
This way the parsing is fixed and also we can possibly add new options easily.

Reviewed By: MyDeveloperDay

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

3 years ago[libc++] Fix extern C for __sanitizer_annotate_contiguous_container() (for gcc)
Azat Khuzhin [Thu, 17 Dec 2020 21:19:50 +0000 (16:19 -0500)]
[libc++] Fix extern C for __sanitizer_annotate_contiguous_container() (for gcc)

gcc supports it only at the beginning:

    $ g++ -o /dev/null -c /tmp/test_extern.cpp
    $ cat /tmp/test_extern.cpp
    extern "C" __attribute__ ((__visibility__("default"))) int foo();

Otherwise:

    $ g++ -o /dev/null -c /tmp/test_extern.cpp
    /tmp/test_extern.cpp:1:52: error: expected unqualified-id before string constant
        1 | __attribute__ ((__visibility__("default"))) extern "C" int foo();
          |                                                    ^~~
    $ cat /tmp/test_extern.cpp
    __attribute__ ((__visibility__("default"))) extern "C" int foo();

Reviewed By: #libc, ldionne

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

3 years agolld: Replace some lld::outs()s with message()
Nico Weber [Thu, 17 Dec 2020 21:19:06 +0000 (16:19 -0500)]
lld: Replace some lld::outs()s with message()

No behavior change.

3 years ago[mlir][IR][NFC] Move context/location parameters of builtin Type::get methods to...
River Riddle [Thu, 17 Dec 2020 20:24:45 +0000 (12:24 -0800)]
[mlir][IR][NFC] Move context/location parameters of builtin Type::get methods to the start of the parameter list

This better matches the rest of the infrastructure, is much simpler, and makes it easier to move these types to being declaratively specified.

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

3 years agoRevert "Ensure SplitEdge to return the new block between the two given blocks"
Bangtian Liu [Thu, 17 Dec 2020 21:00:20 +0000 (21:00 +0000)]
Revert "Ensure SplitEdge to return the new block between the two given blocks"

This reverts commit d20e0c3444ad9ada550d9d6d1d56fd72948ae444.

3 years ago[mlir] Partially update the conversion-to-llvm document
Alex Zinenko [Thu, 17 Dec 2020 20:38:15 +0000 (21:38 +0100)]
[mlir] Partially update the conversion-to-llvm document

This document was not updated after the LLVM dialect type system had been
reimplemented and was using an outdated syntax. Rewrite the part of the
document that concerns type conversion and prepare the ground for splitting it
into a document that explains how built-in types are converted and a separate
document that explains how standard types and functions are converted, which
will better correspond to the fact that built-in types do not belong to the
standard dialect.

Reviewed By: rriddle

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

3 years agoclang-cl: Remove /Zd flag
Nico Weber [Thu, 17 Dec 2020 14:23:02 +0000 (09:23 -0500)]
clang-cl: Remove /Zd flag

cl.exe doesn't understand Zd (in either MSVC 2017 or 2019), so neiter
should we. It used to do the same as `-gline-tables-only` which is
exposed as clang-cl flag as well, so if you want this behavior, use
`gline-tables-only`. That makes it clear that it's a clang-cl-only flag
that won't work with cl.exe.

Motivated by the discussion in D92958.

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

3 years ago[gn build] Link with -Wl,--gdb-index when linking with LLD
Nico Weber [Tue, 8 Dec 2020 14:35:58 +0000 (09:35 -0500)]
[gn build] Link with -Wl,--gdb-index when linking with LLD

For full-debug-info (is_debug=true / symbol_level=2 builds), this makes
linking 15% slower, but gdb startup 1500% faster (for lld: link time
3.9s->4.4s, gdb load time >30s->2s).

For link time, I ran

    bench.py -o {noindex,index}.txt \
        sh -c 'rm out/gn/bin/lld && ninja -C out/gn lld'

and then `ministat noindex.txt index.txt`:

```
x noindex.txt
+ index.txt
    N           Min           Max        Median           Avg        Stddev
x   5      3.784461     4.0200169     3.8452811     3.8754988   0.089902595
+   5       4.32496     4.6058481     4.3361208     4.4141198    0.12288267
Difference at 95.0% confidence
0.538621 +/- 0.15702
13.8981% +/- 4.05161%
(Student's t, pooled s = 0.107663)
```

For gdb load time I loaded the crash in PR48392 with

    gdb -ex r --args ../out/gn/bin/ld64.lld.darwinnew @response.txt

and just stopped the time until the crash got displayed with a stopwatch
a few times. So the speedup there is less precise, but it's so
pronounced that that's ok (loads ~instantly with the patch, takes a very
long time without it).

Only doing this for LLD because I haven't tried it with other linkers.

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

3 years ago[OpenMP][NFC] Provide a new remark and documentation
Johannes Doerfert [Thu, 17 Dec 2020 02:29:26 +0000 (20:29 -0600)]
[OpenMP][NFC] Provide a new remark and documentation

If a GPU function is externally reachable we give up trying to find the
(unique) kernel it is called from. This can hinder optimizations. Emit a
remark and explain mitigation strategies.

Reviewed By: tianshilei1992

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

3 years ago[AttrDocs] document always_inline
Nick Desaulniers [Thu, 17 Dec 2020 20:34:01 +0000 (12:34 -0800)]
[AttrDocs] document always_inline

GNU documentaion for always_inline:
https://gcc.gnu.org/onlinedocs/gcc/Inline.html

GNU documentation for function attributes:
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

Microsoft documentation for __force_inline:
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp

Reviewed By: ojeda

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

3 years ago[mlir][ArmSVE] Add documentation generation
Javier Setoain [Thu, 17 Dec 2020 20:15:41 +0000 (12:15 -0800)]
[mlir][ArmSVE] Add documentation generation

Adds missing cmake command to generate documentation for ArmSVE
Dialect.

Reviewed By: aartbik

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

3 years ago[gn build] (manually) merge f4c8b8031800
Nico Weber [Thu, 17 Dec 2020 20:09:51 +0000 (15:09 -0500)]
[gn build] (manually) merge f4c8b8031800

3 years ago[DSE] Add more tests for read clobber location (NFC)
Nikita Popov [Thu, 17 Dec 2020 19:39:46 +0000 (20:39 +0100)]
[DSE] Add more tests for read clobber location (NFC)

3 years ago[test] Factor out creation of copy of SCC Nodes into function
Arthur Eubanks [Thu, 17 Dec 2020 01:14:13 +0000 (17:14 -0800)]
[test] Factor out creation of copy of SCC Nodes into function

Reviewed By: rnk

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

3 years agoFix NDEBUG build after https://reviews.llvm.org/D93005.
Christian Sigg [Thu, 17 Dec 2020 19:35:48 +0000 (20:35 +0100)]
Fix NDEBUG build after https://reviews.llvm.org/D93005.

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

3 years ago[NFC][AMDGPU] Reorganize description of scratch handling
Tony [Thu, 17 Dec 2020 02:45:47 +0000 (02:45 +0000)]
[NFC][AMDGPU] Reorganize description of scratch handling

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

3 years ago[mlir][LLVMIR] Add 'llvm.switch' op
Brian Gesiak [Thu, 10 Dec 2020 03:37:20 +0000 (22:37 -0500)]
[mlir][LLVMIR] Add 'llvm.switch' op

The LLVM IR 'switch' instruction allows control flow to be transferred
to one of any number of branches depending on an integer control value,
or a default value if the control does not match any branch values. This patch
adds `llvm.switch` to the MLIR LLVMIR dialect, as well as translation routines
for lowering it to LLVM IR.

To store a variable number of operands for a variable number of branch
destinations, the new op makes use of the `AttrSizedOperandSegments`
trait. It stores its default branch operands as one segment, and all
remaining case branches' operands as another. It also stores pairs of
begin and end offset values to delineate the sub-range of each case branch's
operands. There's probably a better way to implement this, since the
offset computation complicates several parts of the op definition. This is the
approach I settled on because in doing so I was able to delegate to the default
op builder member functions. However, it may be preferable to instead specify
`skipDefaultBuilders` in the op's ODS, or use a completely separate
approach; feedback is welcome!

Another contentious part of this patch may be the custom printer and
parser functions for the op. Ideally I would have liked the MLIR to be
printed in this way:

```
llvm.switch %0, ^bb1(%1 : !llvm.i32) [
  1: ^bb2,
  2: ^bb3(%2, %3 : !llvm.i32, !llvm.i32)
]
```

The above would resemble how LLVM IR is formatted for the 'switch'
instruction. But I found it difficult to print and parse something like
this, whether I used the declarative assembly format or custom functions.
I also was not sure a multi-line format would be welcome -- it seems
like most MLIR ops do not use newlines. Again, I'd be happy to hear any
feedback here as well, or on any other aspect of the patch.

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

3 years ago[openmp] Remove clause from OMPKinds.def and use OMP.td info
Valentin Clement [Thu, 17 Dec 2020 19:07:29 +0000 (14:07 -0500)]
[openmp] Remove clause from OMPKinds.def and use OMP.td info

Remove the OpenMP clause information from the OMPKinds.def file and use the
information from the new OMP.td file. There is now a single source of truth for the
directives and clauses.

To avoid generate lots of specific small code from tablegen, the macros previously
used in OMPKinds.def are generated almost as identical. This can be polished and
possibly removed in a further patch.

Reviewed By: jdoerfert

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

3 years ago[WebAssembly][lld] Don't mark a file live from an undefine symbol
Derek Schuff [Thu, 17 Dec 2020 18:25:11 +0000 (10:25 -0800)]
[WebAssembly][lld] Don't mark a file live from an undefine symbol

Live symbols should only cause the files in which they are defined
to become live.

For now this is only tested in emscripten: we're continuing
to work on reducing the test case further for an lld-style
unit test.

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

3 years ago[OpenMP] Add definitions for 5.1 interop to omp.h
Hansang Bae [Thu, 17 Dec 2020 00:18:12 +0000 (18:18 -0600)]
[OpenMP] Add definitions for 5.1 interop to omp.h

3 years agoscudo: Adjust test to use correct check for primary allocations.
Peter Collingbourne [Wed, 16 Dec 2020 19:24:30 +0000 (11:24 -0800)]
scudo: Adjust test to use correct check for primary allocations.

canAllocate() does not take into account the header size so it does
not return the right answer in borderline cases. There was already
code handling this correctly in isTaggedAllocation() so split it out
into a separate function and call it from the test.

Furthermore the test was incorrect when MTE is enabled because MTE
does not pattern fill primary allocations. Fix it.

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

3 years agoAdd brief description of dialects doc section.
Richard Uhler [Thu, 17 Dec 2020 18:37:26 +0000 (18:37 +0000)]
Add brief description of dialects doc section.

Reviewed By: jpienaar

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

3 years ago[PowerPC] Rename the vector pair intrinsics and builtins to replace the _mma_ prefix...
Baptiste Saleil [Thu, 17 Dec 2020 18:18:43 +0000 (13:18 -0500)]
[PowerPC] Rename the vector pair intrinsics and builtins to replace the _mma_ prefix by _vsx_

On PPC, the vector pair instructions are independent from MMA.
This patch renames the vector pair LLVM intrinsics and Clang builtins to replace the _mma_ prefix by _vsx_ in their names.
We also move the vector pair type/intrinsic/builtin tests to their own files.

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

3 years ago[scudo][standalone] Allow the release of smaller sizes
Kostya Kortchinsky [Fri, 11 Dec 2020 22:04:47 +0000 (14:04 -0800)]
[scudo][standalone] Allow the release of smaller sizes

Initially we were avoiding the release of smaller size classes due to
the fact that it was an expensive operation, particularly on 32-bit
platforms. With a lot of batches, and given that there are a lot of
blocks per page, this was a lengthy operation with little results.

There has been some improvements since then to the 32-bit release,
and we still have some criterias preventing us from wasting time
(eg, 9x% free blocks in the class size, etc).

Allowing to release blocks < 128 bytes helps in situations where a lot
of small chunks would not have been reclaimed if not for a forced
reclaiming.

Additionally change some `CHECK` to `DCHECK` and rearrange a bit the
code.

I didn't experience any regressions in my benchmarks.

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

3 years agoAdd call site location getter to C API
George [Thu, 17 Dec 2020 17:27:17 +0000 (09:27 -0800)]
Add call site location getter to C API

Reviewed By: ftynse

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

3 years ago[gn build] Port dae34463e3e
LLVM GN Syncbot [Thu, 17 Dec 2020 17:28:45 +0000 (17:28 +0000)]
[gn build] Port dae34463e3e

3 years ago[IRSim][IROutliner] Adding the extraction basics for the IROutliner.
Andrew Litteken [Tue, 15 Sep 2020 23:05:38 +0000 (18:05 -0500)]
[IRSim][IROutliner] Adding the extraction basics for the IROutliner.

Extracting the similar regions is the first step in the IROutliner.

Using the IRSimilarityIdentifier, we collect the SimilarityGroups and
sort them by how many instructions will be removed.  Each
IRSimilarityCandidate is used to define an OutlinableRegion.  Each
region is ordered by their occurrence in the Module and the regions that
are not compatible with previously outlined regions are discarded.

Each region is then extracted with the CodeExtractor into its own
function.

We test that correctly extract in:
test/Transforms/IROutliner/extraction.ll
test/Transforms/IROutliner/address-taken.ll
test/Transforms/IROutliner/outlining-same-globals.ll
test/Transforms/IROutliner/outlining-same-constants.ll
test/Transforms/IROutliner/outlining-different-structure.ll

Recommit of bf899e891387d07dfd12de195ce2a16f62afd5e0 fixing memory
leaks.

Reviewers: paquette, jroelofs, yroux

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

3 years ago[gn build] Add symbol_level to adjust debug info level
Arthur Eubanks [Wed, 9 Dec 2020 19:51:00 +0000 (11:51 -0800)]
[gn build] Add symbol_level to adjust debug info level

is_debug by default makes symbol_level = 2 and !is_debug means by
default symbol_level = 0.

Reviewed By: thakis

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

3 years ago[LangRef] Update new ssp/sspstrong/sspreq semantics after D91816
Fangrui Song [Thu, 17 Dec 2020 17:16:37 +0000 (09:16 -0800)]
[LangRef] Update new ssp/sspstrong/sspreq semantics after D91816

Reviewed By: nickdesaulniers

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

3 years ago[libc][Obvious] Fix typo is wrappergen unittest.
Siva Chandra Reddy [Thu, 17 Dec 2020 17:12:51 +0000 (09:12 -0800)]
[libc][Obvious] Fix typo is wrappergen unittest.

3 years ago[lldb] [Process/FreeBSDRemote] Use RegSetKind consistently [NFC]
Michał Górny [Thu, 17 Dec 2020 12:12:24 +0000 (13:12 +0100)]
[lldb] [Process/FreeBSDRemote] Use RegSetKind consistently [NFC]

Use RegSetKind enum for register sets everything, rather than int.
Always spell it as 'RegSetKind', without unnecessary 'enum'.  Add
missing switch case.  While at it, use uint32_t for regnums
consistently.

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

3 years ago[lldb] [Process/FreeBSDRemote] Replace GetRegisterSetCount()
Michał Górny [Wed, 16 Dec 2020 14:51:04 +0000 (15:51 +0100)]
[lldb] [Process/FreeBSDRemote] Replace GetRegisterSetCount()

Replace the wrong code in GetRegisterSetCount() with a constant return.
The original code passed register index in place of register set index,
effectively getting always true.  Correcting the code to check for
register set existence is not possible as LLDB supports only eliminating
last register sets.  Just return the full number for now which should
be NFC.

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

3 years ago[libc] Add python3 to libc buildbot depedencies.
Paula Toth [Thu, 17 Dec 2020 16:56:15 +0000 (08:56 -0800)]
[libc] Add python3 to libc buildbot depedencies.

Reviewed By: sivachandra

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

3 years ago[libc] Refactor WrapperGen to make the flow cleaner.
Siva Chandra Reddy [Wed, 16 Dec 2020 19:30:37 +0000 (11:30 -0800)]
[libc] Refactor WrapperGen to make the flow cleaner.

Reviewed By: michaelrj

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

3 years agoRevert "[lldb] Make CommandInterpreter's execution context the same as debugger's...
Pavel Labath [Thu, 17 Dec 2020 16:10:17 +0000 (17:10 +0100)]
Revert "[lldb] Make CommandInterpreter's execution context the same as debugger's one."

This reverts commit a01b26fb51c710a3a8ef88cc83b0701461f5b9ab, because it
breaks the "finish" command in some way -- the command does not
terminate after it steps out, but continues running the target. The
exact blast radius is not clear, but it at least affects the usage of
the "finish" command in TestGuiBasicDebug.py. The error is *not*
gui-related, as the same issue can be reproduced by running the same
steps outside of the gui.

There is some kind of a race going on, as the test fails only 20% of the
time on the buildbot.

3 years agoDetect section type conflicts between functions and variables
Tomas Matheson [Thu, 17 Dec 2020 16:42:32 +0000 (11:42 -0500)]
Detect section type conflicts between functions and variables

If two variables are declared with __attribute__((section(name))) and
the implicit section types (e.g. read only vs writeable) conflict, an
error is raised. Extend this mechanism so that an error is raised if the
section type implied by a function's __attribute__((section)) conflicts
with that of another variable.

3 years ago[flang][openacc] Enforce restriction on routine directive and clauses
Valentin Clement [Thu, 17 Dec 2020 16:32:52 +0000 (11:32 -0500)]
[flang][openacc] Enforce restriction on routine directive and clauses

This patch add some checks for the restriction on the routine directive
and fix several issue at the same time.

Validity tests have been added in a separate file than acc-clause-validity.f90 since this one
became quite large. I plan to split the larger file once on-going review are done.

Reviewed By: sameeranjoshi

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

3 years ago[DebugInfo] Avoid re-ordering assignments in LCSSA
Nabeel Omer [Thu, 17 Dec 2020 16:06:45 +0000 (16:06 +0000)]
[DebugInfo] Avoid re-ordering assignments in LCSSA

The LCSSA pass makes use of a function insertDebugValuesForPHIs() to
propogate dbg.value() intrinsics to newly inserted PHI instructions. Faulty
behaviour occurs when the parent PHI of a newly inserted PHI is not the
most recent assignment to a source variable. insertDebugValuesForPHIs ends
up propagating a value that isn't the most recent assignemnt.

This change removes the call to insertDebugValuesForPHIs() from LCSSA,
preventing incorrect dbg.value intrinsics from being propagated.
Propagating variable locations between blocks will occur later, during
LiveDebugValues.

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

3 years ago[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
Jinsong Ji [Thu, 17 Dec 2020 15:13:45 +0000 (10:13 -0500)]
[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass

The PPCCTRLoop pass has been moved to HardwareLoops,
so the comments and some useless code are deprecated now.

Reviewed By: #powerpc, nemanjai

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

3 years ago[amdgpu] Default to code object v3
Jon Chesterfield [Thu, 17 Dec 2020 16:09:32 +0000 (16:09 +0000)]
[amdgpu] Default to code object v3

[amdgpu] Default to code object v3
v4 is not yet readily available, and doesn't appear
to be implemented in the back end

Reviewed By: t-tye, yaxunl

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

3 years ago[mlir][spirv] NFC: Shuffle code around to better follow convention
Lei Zhang [Thu, 17 Dec 2020 15:55:45 +0000 (10:55 -0500)]
[mlir][spirv] NFC: Shuffle code around to better follow convention

This commit shuffles SPIR-V code around to better follow MLIR
convention. Specifically,

* Created IR/, Transforms/, Linking/, and Utils/ subdirectories and
  moved suitable code inside.
* Created SPIRVEnums.{h|cpp} for SPIR-V C/C++ enums generated from
  SPIR-V spec. Previously they are cluttered inside SPIRVTypes.{h|cpp}.
* Fixed include guards in various header files (both .h and .td).
* Moved serialization tests under test/Target/SPIRV.
* Renamed TableGen backend -gen-spirv-op-utils into -gen-spirv-attr-utils
  as it is only generating utility functions for attributes.

Reviewed By: mravishankar

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

3 years agoEnsure SplitEdge to return the new block between the two given blocks
Bangtian Liu [Thu, 17 Dec 2020 15:58:45 +0000 (15:58 +0000)]
Ensure SplitEdge to return the new block between the two given blocks

This PR implements the function splitBasicBlockBefore to address an
issue
that occurred during SplitEdge(BB, Succ, ...), inside splitBlockBefore.
The issue occurs in SplitEdge when the Succ has a single predecessor
and the edge between the BB and Succ is not critical. This produces
the result ‘BB->Succ->New’. The new function splitBasicBlockBefore
was added to splitBlockBefore to handle the issue and now produces
the correct result ‘BB->New->Succ’.

Below is an example of splitting the block bb1 at its first instruction.

/// Original IR
bb0:
br bb1
bb1:
        %0 = mul i32 1, 2
br bb2
bb2:
/// IR after splitEdge(bb0, bb1) using splitBasicBlock
bb0:
br bb1
bb1:
br bb1.split
bb1.split:
        %0 = mul i32 1, 2
br bb2
bb2:
/// IR after splitEdge(bb0, bb1) using splitBasicBlockBefore
bb0:
br bb1.split
bb1.split
br bb1
bb1:
        %0 = mul i32 1, 2
br bb2
bb2:

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

3 years ago[llvm-symbolizer][Windows] Add start line when searching in line table sections.
Amy Huang [Thu, 17 Dec 2020 15:48:20 +0000 (07:48 -0800)]
[llvm-symbolizer][Windows] Add start line when searching in line table sections.

Fixes issue where if a line section doesn't start with a line number
then the addresses at the beginning of the section don't have line numbers.

For example, for a line section like this
```
  0001:00000010-00000014, line/column/addr entries = 1
     7 00000013 !
```
a line number wouldn't be found for addresses from 10 to 12.

This matches behavior when using the DIA SDK.

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

3 years ago[SampleFDO] Fix uninitialized field warnings. NFCI.
Simon Pilgrim [Thu, 17 Dec 2020 15:51:13 +0000 (15:51 +0000)]
[SampleFDO] Fix uninitialized field warnings. NFCI.

Seems to have been caused by D93254 which added the SecHdrTableEntry::LayoutIndex field.

3 years ago[flang][openacc] Update serial construct clauses for OpenACC 3.1
Valentin Clement [Thu, 17 Dec 2020 15:50:31 +0000 (10:50 -0500)]
[flang][openacc] Update serial construct clauses for OpenACC 3.1

Update the allowed clauses for the SERIAL construct for the new OpenACC 3.1
specification.

Reviewed By: sameeranjoshi

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

3 years ago[Clang] Make nomerge attribute a function attribute as well as a statement attribute.
Zequan Wu [Tue, 8 Dec 2020 00:37:14 +0000 (16:37 -0800)]
[Clang] Make nomerge attribute a function attribute as well as a statement attribute.

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

3 years ago[TableGen] Return const std::string& in InstrMap getName()/getFilterClass() methods...
Simon Pilgrim [Thu, 17 Dec 2020 15:22:52 +0000 (15:22 +0000)]
[TableGen] Return const std::string& in InstrMap getName()/getFilterClass() methods. NFCI.

Avoid temp std::string instances - we're never keeping these around, just printing them to streams, converting to StringRef etc.

3 years ago[InstCombine] Preserve !annotation on newly created instructions.
Florian Hahn [Thu, 17 Dec 2020 14:42:12 +0000 (14:42 +0000)]
[InstCombine] Preserve !annotation on newly created instructions.

If the source instruction has !annotation metadata, all instructions
created during combining should also have it. Tell the builder to
add it.

The !annotation system was discussed on llvm-dev as part of
'RFC: Combining Annotation Metadata and Remarks'
(http://lists.llvm.org/pipermail/llvm-dev/2020-November/146393.html)

This patch is based on an earlier patch by Francis Visoiu Mistrih.

Reviewed By: thegameg, lebedev.ri

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

3 years ago[ARM][MachineOutliner] Fix costs model.
Yvan Roux [Thu, 17 Dec 2020 15:08:23 +0000 (16:08 +0100)]
[ARM][MachineOutliner] Fix costs model.

Fix candidates calls costs models allocation and prepare stack fixups
handling.

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

3 years ago[TableGen] Make InstrMap::getFilterClass() const. NFCI.
Simon Pilgrim [Thu, 17 Dec 2020 14:34:13 +0000 (14:34 +0000)]
[TableGen] Make InstrMap::getFilterClass() const. NFCI.

Reported by cppcheck.

I've run clang-format across all the InstrMap accessors as well.

3 years agoFix dead link
Guillaume Chatelet [Thu, 17 Dec 2020 14:49:28 +0000 (15:49 +0100)]
Fix dead link

3 years agoRemove Python2 fallback and only advertise Python3 in the doc
serge-sans-paille [Fri, 11 Dec 2020 10:34:54 +0000 (11:34 +0100)]
Remove Python2 fallback and only advertise Python3 in the doc

Differential Revision: https://www.youtube.com/watch?v=RsL0cipURA0

3 years ago[lld] [ELF] AArch64: Handle DT_AARCH64_VARIANT_PCS
Adhemerval Zanella [Thu, 10 Dec 2020 14:06:49 +0000 (14:06 +0000)]
[lld] [ELF] AArch64: Handle DT_AARCH64_VARIANT_PCS

As indicated by AArch64 ELF specification, symbols with st_other
marked with STO_AARCH64_VARIANT_PCS indicates it may follow a variant
procedure call standard with different register usage convention
(for instance SVE calls).

Static linkers must preserve the marking and propagate it to the dynamic
symbol table if any reference or definition of the symbol is marked with
STO_AARCH64_VARIANT_PCS, and add a DT_AARCH64_VARIANT_PCS dynamic tag if
there are R_<CLS>_JUMP_SLOT relocations that reference that symbols.

It implements https://bugs.llvm.org/show_bug.cgi?id=48368.

Reviewed By: MaskRay

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

3 years ago[llvm-readobj/elf] - AArch64: Handle AARCH64_VARIANT_PCS for GNUStyle
Adhemerval Zanella [Thu, 10 Dec 2020 14:03:22 +0000 (14:03 +0000)]
[llvm-readobj/elf] - AArch64: Handle AARCH64_VARIANT_PCS for GNUStyle

It mimics the GNU readelf where it prints a [VARIANT_PCS] for symbols
with st_other with STO_AARCH64_VARIANT_PCS.

Reviewed By: grimar, MaskRay

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

3 years ago[obj2yaml][yaml2obj] - Add AArch64 STO_AARCH64_VARIANT_PCS support
Adhemerval Zanella [Mon, 14 Dec 2020 17:24:53 +0000 (17:24 +0000)]
[obj2yaml][yaml2obj] - Add AArch64 STO_AARCH64_VARIANT_PCS support

Reviewed By: grimar, MaskRay

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

3 years ago[clang-tidy][NFC] Reduce copies of Intrusive..FileSystem
Nathan James [Thu, 17 Dec 2020 14:09:08 +0000 (14:09 +0000)]
[clang-tidy][NFC] Reduce copies of Intrusive..FileSystem

Swapped a few instances where a move is more optimal or the target doesn't need to hold a reference.

3 years ago[SimplifyCFG] Preserve !annotation in FoldBranchToCommonDest.
Florian Hahn [Thu, 17 Dec 2020 13:42:29 +0000 (13:42 +0000)]
[SimplifyCFG] Preserve !annotation in FoldBranchToCommonDest.

When folding a branch to a common destination, preserve !annotation on
the created instruction, if the terminator of the BB that is going to be
removed has !annotation. This should ensure that !annotation is attached
to the instructions that 'replace' the original terminator.

Reviewed By: jdoerfert, lebedev.ri

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

3 years ago[InstCombine] Remove scalable vector restriction in InstCombineCasts
Jun Ma [Wed, 16 Dec 2020 07:05:49 +0000 (15:05 +0800)]
[InstCombine] Remove scalable vector restriction in InstCombineCasts

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

3 years ago[lld-macho] Use LC_LOAD_WEAK_DYLIB for dylibs with only weakrefs
Jez Ng [Thu, 17 Dec 2020 00:14:57 +0000 (19:14 -0500)]
[lld-macho] Use LC_LOAD_WEAK_DYLIB for dylibs with only weakrefs

Note that dylibs without *any* refs will still be loaded in the usual
(strong) fashion.

Reviewed By: #lld-macho, thakis

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

3 years ago[lld-macho] Add support for weak references
Jez Ng [Wed, 16 Dec 2020 02:05:06 +0000 (21:05 -0500)]
[lld-macho] Add support for weak references

Weak references need not necessarily be satisfied at runtime (but they must
still be satisfied at link time). So symbol resolution still works as per usual,
but we now pass around a flag -- ultimately emitting it in the bind table -- to
indicate if a given dylib symbol is a weak reference.

ld64's behavior for symbols that have both weak and strong references is
a bit bizarre. For non-function symbols, it will emit a weak import. For
function symbols (those referenced by BRANCH relocs), it will emit a
regular import. I'm not sure what value there is in that behavior, and
since emulating it will make our implementation more complex, I've
decided to treat regular weakrefs like function symbol ones for now.

Fixes PR48511.

Reviewed By: #lld-macho, thakis

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

3 years ago[ARM] Adding v8.7-A command-line support for the ARM target
Lucas Prates [Wed, 9 Dec 2020 16:13:36 +0000 (16:13 +0000)]
[ARM] Adding v8.7-A command-line support for the ARM target

This extends the command-line support for the 'armv8.7-a' architecture
name to the ARM target.

Based on a patch written by Momchil Velikov.

Reviewed By: ostannard

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

3 years ago[ARM][AAarch64] Initial command-line support for v8.7-A
Lucas Prates [Mon, 16 Nov 2020 14:48:22 +0000 (14:48 +0000)]
[ARM][AAarch64] Initial command-line support for v8.7-A

This introduces command-line support for the 'armv8.7-a' architecture name
(and an alias without the '-', as usual), and for the 'ls64' extension name.

Based on patches written by Simon Tatham.

Reviewed By: ostannard

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

3 years ago[AArch64] Adding the v8.7-A LD64B/ST64B Accelerator extension
Lucas Prates [Mon, 16 Nov 2020 14:23:14 +0000 (14:23 +0000)]
[AArch64] Adding the v8.7-A LD64B/ST64B Accelerator extension

This adds support for the v8.7-A LD64B/ST64B Accelerator extension
through a subtarget feature called "ls64". It adds four 64-byte
load/store instructions with an operand in the new GPR64x8 register
class, and one system register that's part of the same extension.

Based on patches written by Simon Tatham.

Reviewed By: ostannard

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

3 years ago[AArch64] Add a GPR64x8 register class
Lucas Prates [Thu, 12 Nov 2020 10:54:28 +0000 (10:54 +0000)]
[AArch64] Add a GPR64x8 register class

This adds a GPR64x8 register class that will be needed as the data
operand to the LD64B/ST64B family of instructions in the v8.7-A
Accelerator Extension, which load or store a contiguous range of eight
x-regs. It has to be its own register class so that register allocation
will have visibility of the full set of registers actually read/written
by the instructions, which will be needed when we add intrinsics and/or
inline asm access to this piece of architecture.

Patch written by Simon Tatham.

Reviewed By: ostannard

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

3 years ago[ARM][AArch64] Adding basic support for the v8.7-A architecture
Lucas Prates [Thu, 12 Nov 2020 09:50:58 +0000 (09:50 +0000)]
[ARM][AArch64] Adding basic support for the v8.7-A architecture

This introduces support for the v8.7-A architecture through a new
subtarget feature called "v8.7a". It adds two new "WFET" and "WFIT"
instructions, the nXS limited-TLB-maintenance qualifier for DSB and TLBI
instructions, a new CPU id register, ID_AA64ISAR2_EL1, and the new
HCRX_EL2 system register.

Based on patches written by Simon Tatham and Victor Campos.

Reviewed By: ostannard

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

3 years ago[NFC][AArch64] Capturing multiple feature requirements in AsmParser messages
Lucas Prates [Mon, 30 Nov 2020 15:23:27 +0000 (15:23 +0000)]
[NFC][AArch64] Capturing multiple feature requirements in AsmParser messages

This enables the capturing of multiple required features in the AArch64
AsmParser's SysAlias error messages.

Reviewed By: ostannard

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

3 years ago[NFC][AArch64] Move AArch64 MSR/MRS into a new decoder namespace
Lucas Prates [Wed, 11 Nov 2020 16:38:54 +0000 (16:38 +0000)]
[NFC][AArch64] Move AArch64 MSR/MRS into a new decoder namespace

This removes the general forms of the AArch64 MSR and MRS instructions
from the same decoding table that contains many more specific
instructions that supersede them. They're now in a separate decoding
table of their own, called "Fallback", which is only consulted in the
event of the main decoder table failing to produce an answer.

This should avoid decoding conflicts on future specialized instructions
in the MSR space.

Patch written by Simon Tatham.

Reviewed By: ostannard

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

3 years ago[IRBuilder] Generalize debug loc handling for arbitrary metadata.
Florian Hahn [Thu, 17 Dec 2020 12:59:02 +0000 (12:59 +0000)]
[IRBuilder] Generalize debug loc handling for arbitrary metadata.

This patch extends IRBuilder to allow adding/preserving arbitrary
metadata on created instructions.

Instead of using references to specific metadata nodes (like DebugLoc),
IRbuilder now keeps a vector of (metadata kind, MDNode *) pairs, which
are added to each created instruction.

The patch itself is a NFC and only moves the existing debug location
handling over to the new system. In a follow-up patch it will be used to
preserve !annotation metadata besides !dbg.

The current approach requires iterating over MetadataToCopy to avoid
adding duplicates, but given that the number of metadata kinds to
copy/preserve is going to be very small initially (0, 1 (for !dbg) or 2
(!dbg and !annotation)) that should not matter.

Reviewed By: lebedev.ri

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

3 years ago[libc] revamp memory function benchmark
Guillaume Chatelet [Thu, 17 Dec 2020 13:16:14 +0000 (13:16 +0000)]
[libc] revamp memory function benchmark

The benchmarking infrastructure can now run in two modes:
 - Sweep Mode: which generates a ramp of size values (same as before),
 - Distribution Mode: allows the user to select a distribution for the size paramater that is representative from production.

The analysis tool has also been updated to handle both modes.

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

3 years ago[lldb-vscode] Speculative fix for raciness in TestVSCode_attach
Pavel Labath [Thu, 17 Dec 2020 13:17:03 +0000 (14:17 +0100)]
[lldb-vscode] Speculative fix for raciness in TestVSCode_attach

The test appears to expect the inferior to be stopped, but the custom
"attach commands" leave it in a running state.

It's unclear how this could have ever worked.

3 years ago[mlir] Fix syntax error in markdown documentation
Alex Zinenko [Thu, 17 Dec 2020 13:09:11 +0000 (14:09 +0100)]
[mlir] Fix syntax error in markdown documentation

3 years ago[lldb] [unittests] Filter FreeBSD through CMake rather than #ifdef
Michał Górny [Thu, 17 Dec 2020 12:54:59 +0000 (13:54 +0100)]
[lldb] [unittests] Filter FreeBSD through CMake rather than #ifdef

3 years ago[lldb] [unittests] Add tests for NetBSD register offsets/sizes
Michał Górny [Tue, 15 Dec 2020 15:15:22 +0000 (16:15 +0100)]
[lldb] [unittests] Add tests for NetBSD register offsets/sizes

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

3 years ago[LV] Disable epilogue vectorization for scalable VFs
Cullen Rhodes [Wed, 9 Dec 2020 13:18:22 +0000 (13:18 +0000)]
[LV] Disable epilogue vectorization for scalable VFs

Epilogue vectorization doesn't support scalable vectorization factors
yet, disable it for now.

Reviewed By: sdesmalen, bmahjour

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

3 years ago[DebugInfo] Fix MSVC build by adding back necessary reverse_iterator != operator
Simon Pilgrim [Thu, 17 Dec 2020 12:06:28 +0000 (12:06 +0000)]
[DebugInfo] Fix MSVC build by adding back necessary reverse_iterator != operator

Put back the std::reverse_iterator<DWARFDie::iterator> != operator that was removed in D78938 to fix VS2019 builds

3 years ago[clangd] Add llvm:: qualifier to work around GCC bug. NFC
Sam McCall [Thu, 17 Dec 2020 11:41:44 +0000 (12:41 +0100)]
[clangd] Add llvm:: qualifier to work around GCC bug. NFC

Some old GCC versions seem to miss the default template parameter when
using the clang/Basic/LLVM.h forward declarations of SmallVector.

See D92788

3 years ago[AArch64] Renamed sve-masked-scatter-legalise.ll. NFC.
Kerry McLaughlin [Thu, 17 Dec 2020 11:12:14 +0000 (11:12 +0000)]
[AArch64] Renamed sve-masked-scatter-legalise.ll. NFC.

3 years ago[libcxx] Remove ifdefs in the message to static_assert. NFC.
Martin Storsjö [Tue, 15 Dec 2020 07:15:37 +0000 (09:15 +0200)]
[libcxx] Remove ifdefs in the message to static_assert. NFC.

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

3 years ago[mlir] Move LLVM Dialect Op documentation to ODS
Alex Zinenko [Thu, 17 Dec 2020 11:19:52 +0000 (12:19 +0100)]
[mlir] Move LLVM Dialect Op documentation to ODS

This was long overdue. The initial documentation for the LLVM dialect was
introduced before ODS had support for long descriptions. This is now possible,
so the documentation is moved to ODS, which can serve as a single source of
truth. The high-level description of the dialect structure is updated to
reflect that.

Depends On: D93315

Reviewed By: rriddle, mehdi_amini

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

3 years ago[mlir] partially update LLVM dialect documentation
Alex Zinenko [Tue, 15 Dec 2020 17:29:12 +0000 (18:29 +0100)]
[mlir] partially update LLVM dialect documentation

Rewrite the parts of the documentation that became stale: context/module
handling and type system. Expand the type system description.

Reviewed By: nicolasvasilache

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

3 years ago[SVE][CodeGen] Add bfloat16 support to scalable masked gather
Kerry McLaughlin [Thu, 17 Dec 2020 10:36:52 +0000 (10:36 +0000)]
[SVE][CodeGen] Add bfloat16 support to scalable masked gather

Reviewed By: david-arm

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

3 years ago[NFC] Reduce include files dependency and AA header cleanup (part 2).
dfukalov [Wed, 9 Dec 2020 12:06:50 +0000 (15:06 +0300)]
[NFC] Reduce include files dependency and AA header cleanup (part 2).

Continuing work started in https://reviews.llvm.org/D92489:

Removed a bunch of includes from "AliasAnalysis.h" and "LoopPassManager.h".

Reviewed By: RKSimon

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

3 years ago[X86] Remove extract_subvector(subv_broadcast_load()) fold.
Simon Pilgrim [Thu, 17 Dec 2020 11:02:34 +0000 (11:02 +0000)]
[X86] Remove extract_subvector(subv_broadcast_load()) fold.

This was needed in an earlier version of D92645, but isn't now - and I've just noticed that it was potentially flawed depending on the relevant widths of the broadcasted and extracted subvectors.

3 years agofix a -Wunused-variable warning in release build
Krasimir Georgiev [Thu, 17 Dec 2020 10:48:42 +0000 (11:48 +0100)]
fix a -Wunused-variable warning in release build

3 years ago[lldb] Add std::array to the supported template list of the CxxModuleHandler
Raphael Isemann [Thu, 17 Dec 2020 10:23:11 +0000 (11:23 +0100)]
[lldb] Add std::array to the supported template list of the CxxModuleHandler

Identical to the other patches that add STL containers to the supported
templated list.

3 years agoMake LLVM build in C++20 mode
Barry Revzin [Thu, 17 Dec 2020 10:41:35 +0000 (10:41 +0000)]
Make LLVM build in C++20 mode

Part of the <=> changes in C++20 make certain patterns of writing equality
operators ambiguous with themselves (sorry!).
This patch goes through and adjusts all the comparison operators such that
they should work in both C++17 and C++20 modes. It also makes two other small
C++20-specific changes (adding a constructor to a type that cases to be an
aggregate, and adding casts from u8 literals which no longer have type
const char*).

There were four categories of errors that this review fixes.
Here are canonical examples of them, ordered from most to least common:

// 1) Missing const
namespace missing_const {
    struct A {
    #ifndef FIXED
        bool operator==(A const&);
    #else
        bool operator==(A const&) const;
    #endif
    };

    bool a = A{} == A{}; // error
}

// 2) Type mismatch on CRTP
namespace crtp_mismatch {
    template <typename Derived>
    struct Base {
    #ifndef FIXED
        bool operator==(Derived const&) const;
    #else
        // in one case changed to taking Base const&
        friend bool operator==(Derived const&, Derived const&);
    #endif
    };

    struct D : Base<D> { };

    bool b = D{} == D{}; // error
}

// 3) iterator/const_iterator with only mixed comparison
namespace iter_const_iter {
    template <bool Const>
    struct iterator {
        using const_iterator = iterator<true>;

        iterator();

        template <bool B, std::enable_if_t<(Const && !B), int> = 0>
        iterator(iterator<B> const&);

    #ifndef FIXED
        bool operator==(const_iterator const&) const;
    #else
        friend bool operator==(iterator const&, iterator const&);
    #endif
    };

    bool c = iterator<false>{} == iterator<false>{} // error
          || iterator<false>{} == iterator<true>{}
          || iterator<true>{} == iterator<false>{}
          || iterator<true>{} == iterator<true>{};
}

// 4) Same-type comparison but only have mixed-type operator
namespace ambiguous_choice {
    enum Color { Red };

    struct C {
        C();
        C(Color);
        operator Color() const;
        bool operator==(Color) const;
        friend bool operator==(C, C);
    };

    bool c = C{} == C{}; // error
    bool d = C{} == Red;
}

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

3 years ago[X86] Add X86ISD::SUBV_BROADCAST_LOAD and begin removing X86ISD::SUBV_BROADCAST ...
Simon Pilgrim [Thu, 17 Dec 2020 10:12:51 +0000 (10:12 +0000)]
[X86] Add X86ISD::SUBV_BROADCAST_LOAD and begin removing X86ISD::SUBV_BROADCAST (PR38969)

Subvector broadcasts are only load instructions, yet X86ISD::SUBV_BROADCAST treats them more generally, requiring a lot of fallback tablegen patterns.

This initial patch replaces constant vector lowering inside lowerBuildVectorAsBroadcast with direct X86ISD::SUBV_BROADCAST_LOAD loads which helps us merge a number of equivalent loads/broadcasts.

As well as general plumbing/analysis additions for SUBV_BROADCAST_LOAD, I needed to wrap SelectionDAG::makeEquivalentMemoryOrdering so it can handle result chains from non generic LoadSDNode nodes.

Later patches will continue to replace X86ISD::SUBV_BROADCAST usage.

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

3 years ago[libc] add back math.h #include utils/FPUtil/ManipulationFunctions.h
Krasimir Georgiev [Thu, 17 Dec 2020 10:16:08 +0000 (11:16 +0100)]
[libc] add back math.h #include utils/FPUtil/ManipulationFunctions.h

This partially reverts cee1e7d14f4628d6174b33640d502bff3b54ae45:
  [libc][NFC][Obvious] Remove few unnecessary #include directives in tests.

That commit causes a test failure in our configuration:
[ RUN      ] ILogbTest.SpecialNumbers_ilogb
third_party/llvm/llvm-project/libc/test/src/math/ILogbTest.h:28: FAILURE
      Expected: FP_ILOGBNAN
      Which is: 2147483647
To be equal to: func(__llvm_libc::fputil::FPBits<T>::buildNaN(1))
      Which is: -2147483648