platform/upstream/llvm.git
3 years ago[mlir:Async] Implement recursive async work splitting for scf.parallel operation...
Eugene Zhulenev [Thu, 24 Jun 2021 12:27:42 +0000 (05:27 -0700)]
[mlir:Async] Implement recursive async work splitting for scf.parallel operation (async-parallel-for pass)

Depends On D104780

Recursive work splitting instead of sequential async tasks submission gives ~20%-30% speedup in microbenchmarks.

Algorithm outline:
1. Collapse scf.parallel dimensions into a single dimension
2. Compute the block size for the parallel operations from the 1d problem size
3. Launch parallel tasks
4. Each parallel task reconstructs its own bounds in the original multi-dimensional iteration space
5. Each parallel task computes the original parallel operation body using scf.for loop nest

Reviewed By: herhut

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

3 years ago[mlir:Async] Add the size parameter to the async.group
Eugene Zhulenev [Wed, 23 Jun 2021 13:24:09 +0000 (06:24 -0700)]
[mlir:Async] Add the size parameter to the async.group

Specify the `!async.group` size (the number of tokens that will be added to it) at construction time. `async.await_all` operation can potentially race with `async.execute` operations that keep updating the group, for this reason it is required to know upfront how many tokens will be added to the group.

Reviewed By: ftynse, herhut

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

3 years ago[instcombine] Fold overflow check using umulo to comparison
Philip Reames [Fri, 25 Jun 2021 17:24:10 +0000 (10:24 -0700)]
[instcombine] Fold overflow check using umulo to comparison

If we have a umul.with.overflow where the multiply result is not used and one of the operands is a constant, we can perform the overflow check cheaper with a comparison then by performing the multiply and extracting the overflow flag.

(Noticed when looking at the conditions SCEV emits for overflow checks.)

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

3 years ago[UpdateCCTestChecks] Support --check-globals
Joel E. Denny [Fri, 25 Jun 2021 16:40:04 +0000 (12:40 -0400)]
[UpdateCCTestChecks] Support --check-globals

This option is already supported by update_test_checks.py, but it can
also be useful in update_cc_test_checks.py.  For example, I'd like to
use it in OpenMP offload codegen tests to check global variables like
`.offload_maptypes*`.

Reviewed By: jdoerfert, arichardson, ggeorgakoudis

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

3 years ago[test][instcombine] Add test cases for all x.with.overflow overflow checks
Philip Reames [Thu, 24 Jun 2021 01:50:00 +0000 (18:50 -0700)]
[test][instcombine] Add test cases for all x.with.overflow overflow checks

For each of the x.with.overflow variants, if only the overflow bit is consumed, we can generate a direct overflow comparison.  This precommits tests for each of the variants and tries to cover interesting cornercases.

3 years ago[mlir][memref] Introduce UnrankedMemRefOf to tablegen definitions
Stephan Herhut [Fri, 25 Jun 2021 10:44:22 +0000 (12:44 +0200)]
[mlir][memref] Introduce UnrankedMemRefOf to tablegen definitions

This enables specifying operations that only support some element types for
unranked memrefs.

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

3 years ago[ModuloSchedule] Pass loop block explicitly to kernel rewriter.
Hendrik Greving [Wed, 23 Jun 2021 19:32:04 +0000 (12:32 -0700)]
[ModuloSchedule] Pass loop block explicitly to kernel rewriter.

This change is NFC upstream. We pass in the loop's block to the kernel
rewriter explicitly, instead of assuming it's the loop's top block. This
change is made for downstream targets where this assumption doesn't hold.

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

3 years ago[Coroutines] Remove all legacy test command
Xun Li [Fri, 25 Jun 2021 16:46:55 +0000 (09:46 -0700)]
[Coroutines] Remove all legacy test command

With new pm becomes the default, the old-style test command becomes exactly the same as the new test command, i.e. the two commands are now redundant.
We should just delete the old command. (unless someone wants to add enable-new-pm=0 to all old commands.

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

3 years agoRevert "[GlobalISel] NFC: Have LLT::getSizeInBits/Bytes return a TypeSize."
Sander de Smalen [Fri, 25 Jun 2021 16:36:44 +0000 (17:36 +0100)]
Revert "[GlobalISel] NFC: Have LLT::getSizeInBits/Bytes return a TypeSize."

This patch seems to be causing build errors, reverting it for now.

This reverts commit aeab9d9570ac8cb554aff6e1af24a471fdf5b4e5.

3 years ago[OpaquePtr] Allow globals with opaque pointer value type
Nikita Popov [Fri, 25 Jun 2021 09:26:15 +0000 (11:26 +0200)]
[OpaquePtr] Allow globals with opaque pointer value type

Do this by making opaque pointers a valid pointer element type,
for which we implicitly create an opaque pointer (moving the logic
from getPointerTo into PointerType::get).

We'll never create something like a "pointer to opaque pointer",
but accept it in the API, because a lot of code reasonably assumes
that you can create a pointer to pointer type.

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

3 years ago[lldb-vscode] Make extension contribute breakpoints use new package.json schema
Chris Bond [Fri, 25 Jun 2021 16:15:04 +0000 (18:15 +0200)]
[lldb-vscode] Make extension contribute breakpoints use new package.json schema

See https://code.visualstudio.com/updates/v1_42#_implement-a-debug-adapter-inside-an-extension

Reviewed By: clayborg

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

3 years ago[Analysis] use better version of getLibFunc to check for alloc/free calls
Sanjay Patel [Fri, 25 Jun 2021 15:36:28 +0000 (11:36 -0400)]
[Analysis] use better version of getLibFunc to check for alloc/free calls

There's no reason to use the weaker name-only analysis when we
have a function prototype to check (in fact, we probably should
not even have that name-only function exposed for general use,
but removing it requires auditing all of the callers).

The version of getLibFunc that takes a Function argument also
does some prototype checking to make sure the arguments/return
type match the expected signature of a real library call.

This is NFC-intended because the code in MemoryBuiltins does its
own function signature checking. For now, that means there may
be some redundancy in the checking, but that should not be above
the noise for compile-time. Ideally, we can move the checks to
a single location.

There's still a hole in the logic that allows the example in
https://llvm.org/PR50846 to cause a compiler crash.

3 years ago[GlobalISel] NFC: Have LLT::getSizeInBits/Bytes return a TypeSize.
Sander de Smalen [Fri, 25 Jun 2021 14:55:03 +0000 (15:55 +0100)]
[GlobalISel] NFC: Have LLT::getSizeInBits/Bytes return a TypeSize.

To reflect that the size may be scalable, a TypeSize is returned
instead of an unsigned. In places where the result is used,
it currently relies on an implicit cast of TypeSize -> uint64_t,
which asserts that the type is not scalable.

This patch is NFC for fixed-width vectors.

Reviewed By: aemerson

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

3 years ago[AMDGPU] Removed unused Predicate HasOffset3fBug. NFC.
Jay Foad [Fri, 25 Jun 2021 15:57:34 +0000 (16:57 +0100)]
[AMDGPU] Removed unused Predicate HasOffset3fBug. NFC.

The predicate definition didn't make sense anyway because it was defined
as being the opposite of what the name suggests.

3 years ago[Hexagon] Convert getTypeAlignment to return Align
Krzysztof Parzyszek [Fri, 25 Jun 2021 15:22:01 +0000 (10:22 -0500)]
[Hexagon] Convert getTypeAlignment to return Align

Plus some minor related changes of the same nature.

3 years ago[flang][unittest] Add a missing dependency
Andrzej Warzynski [Fri, 25 Jun 2021 15:27:36 +0000 (16:27 +0100)]
[flang][unittest] Add a missing dependency

In https://reviews.llvm.org/D103612, a definition of an instance of
`Fortran::parser::AnalyzedObjectsAsFortran` was moved (that object is
used in unparsing). That, in turn, introduced a dependency of the unit
tests on the `FortranEvaluate` library, which defines
`AnalyzedObjectsAsFortran`.

That dependency was missed in D103612 and has caused shared-library
builds to fail. I'm submitting this without a review, as it's rather
straightforward omission.

3 years ago[libc++][NFC] Rename include guard.
Mark de Wever [Fri, 25 Jun 2021 15:34:30 +0000 (17:34 +0200)]
[libc++][NFC] Rename include guard.

3 years ago[GlobalISel] NFC: Change LLT::changeNumElements to LLT::changeElementCount.
Sander de Smalen [Fri, 25 Jun 2021 10:27:41 +0000 (11:27 +0100)]
[GlobalISel] NFC: Change LLT::changeNumElements to LLT::changeElementCount.

Reviewed By: aemerson

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

3 years ago[clangd] Introduce a log-prefix flag to remote-index-server
Kadir Cetinkaya [Thu, 24 Jun 2021 09:38:23 +0000 (11:38 +0200)]
[clangd] Introduce a log-prefix flag to remote-index-server

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

3 years ago[clangd] Call malloc_trim in clangd-index-server periodically
Kadir Cetinkaya [Thu, 24 Jun 2021 06:18:40 +0000 (08:18 +0200)]
[clangd] Call malloc_trim in clangd-index-server periodically

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

3 years ago[clang] Fix build failure due to _S
Yaxun (Sam) Liu [Fri, 25 Jun 2021 14:10:27 +0000 (10:10 -0400)]
[clang] Fix build failure due to _S

_S is a reserved identifier in <ctype.h> on Solaris.

3 years ago[OpenCL] Do not include default header for preprocessor output as input
Yaxun (Sam) Liu [Wed, 23 Jun 2021 17:54:03 +0000 (13:54 -0400)]
[OpenCL] Do not include default header for preprocessor output as input

When clang driver is used with -save-temps to compile OpenCL program,
clang driver first launches clang -cc1 -E to generate preprocessor expansion output,
then launches clang -cc1 with the generated preprocessor expansion output as input
to generate LLVM IR.

Currently clang by default passes "-finclude-default-header" "-fdeclare-opencl-builtins"
in both steps, which causes default header included again in the second step, which
causes error.

This patch let clang not to include default header when input type is preprocessor expansion
output, which fixes the issue.

Reviewed by: Anastasia Stulova

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

3 years ago[LV] Reflow comment for VectorizationCostTy (NFC).
Florian Hahn [Fri, 25 Jun 2021 12:55:08 +0000 (13:55 +0100)]
[LV] Reflow comment for VectorizationCostTy (NFC).

3 years ago[flang][driver] Add `-fno-analyzed-objects-for-unparse`
Andrzej Warzynski [Fri, 4 Jun 2021 14:25:58 +0000 (15:25 +0100)]
[flang][driver] Add `-fno-analyzed-objects-for-unparse`

This patch adds a new option for the new Flang driver:
`-fno-analyzed-objects-for-unparse`. The semantics are similar to
`-funparse-typed-exprs-to-f18-fc` from `f18`. For consistency, the
latter is replaced with `-fno-analyzed-objects-for-unparse`.

The new option controls the behaviour of the unparser (i.e. the action
corresponding to `-fdebug-unparse`). The default behaviour is to use the
analyzed objects when unparsing. The new flag can be used to turn this
off, so that the original parse-tree objects are used. The analyzed
objects are generated during the semantic checks [1].

This patch also updates the semantics of
`-fno-analyzed-objects-for-unparse`/`-funparse-typed-exprs-to-f18-fc`
in `f18`, so that this flag is always taken into account when `Unparse`
is used (this way the semantics in `f18` and `flang-new` are identical).

The added test file is based on example from Peter Steinfeld.

[1]
https://github.com/llvm/llvm-project/blob/main/flang/docs/Semantics.md

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

3 years ago[NFC] remove unreferenced function ResolveIPV4HostName
serge-sans-paille [Fri, 25 Jun 2021 08:02:33 +0000 (10:02 +0200)]
[NFC] remove unreferenced function ResolveIPV4HostName

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

3 years ago[OpenMP][NFC] Drop unused headers from amdgpu plugin
Jon Chesterfield [Fri, 25 Jun 2021 11:08:56 +0000 (12:08 +0100)]
[OpenMP][NFC] Drop unused headers from amdgpu plugin

3 years ago[OpenCL] Use DW_LANG_OpenCL language tag for OpenCL C
Stuart Brady [Wed, 23 Jun 2021 13:21:15 +0000 (14:21 +0100)]
[OpenCL] Use DW_LANG_OpenCL language tag for OpenCL C

Note regarding C++ for OpenCL:

   When compiling C++ for OpenCL, DW_LANG_C_plus_plus* is emitted.

   There is no DWARF language code defined for C++ for OpenCL as of yet,
   but DWARF issue 210514.1 has been raised to request one.

   In the mean time, continuing to emit DW_LANG_C_plus_plus* for C++ for
   OpenCL allows the potential to distinguish between C++ for OpenCL and
   OpenCL C in !DICompileUnit nodes, whereas using DW_LANG_OpenCL for
   C++ for OpenCL would prevent this.

   This change therefore leaves C++ for OpenCL as-is.

Reviewed By: shchenz, Anastasia

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

3 years ago[GlobalISel] NFC: Change LLT::scalarOrVector to take ElementCount.
Sander de Smalen [Fri, 25 Jun 2021 07:25:41 +0000 (08:25 +0100)]
[GlobalISel] NFC: Change LLT::scalarOrVector to take ElementCount.

Reviewed By: aemerson

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

3 years ago[lldb] Re-enable GDB server client memory tag read tests
David Spickett [Fri, 25 Jun 2021 09:57:46 +0000 (09:57 +0000)]
[lldb] Re-enable GDB server client memory tag read tests

These were disabled in 473a3a773ea565612e836ae6c2093178c5a9eb72
because they failed on 32 bit platforms. (Arm for sure but I assume
any 32 bit)

This was due to the printf formatter used. These assumed
that types like uint64_t/size_t would be certain size/type and
that changes on 32 bit.

Instead use "z" to print the size_t and PRI<...> formatters
for the addr_t (always uint64_t) and the int32_t.

3 years ago[SLP][AArch64] Precommit test for D103629, checking <4 x i8> loads. NFC.
Sjoerd Meijer [Thu, 3 Jun 2021 16:04:56 +0000 (17:04 +0100)]
[SLP][AArch64] Precommit test for D103629, checking <4 x i8> loads. NFC.

3 years ago[Analyzer][solver] Fix crashes during symbol simplification
Gabor Marton [Wed, 23 Jun 2021 14:25:49 +0000 (16:25 +0200)]
[Analyzer][solver] Fix crashes during symbol simplification

Consider the code
```
  void f(int a0, int b0, int c)
  {
      int a1 = a0 - b0;
      int b1 = (unsigned)a1 + c;
      if (c == 0) {
          int d = 7L / b1;
      }
  }
```
At the point of divisiion by `b1` that is considered to be non-zero,
which results in a new constraint for `$a0 - $b0 + $c`. The type
of this sym is unsigned, however, the simplified sym is `$a0 -
$b0` and its type is signed. This is probably the result of the
inherent improper handling of casts. Anyway, Range assignment
for constraints use this type information. Therefore, we must
make sure that first we simplify the symbol and only then we
assign the range.

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

3 years ago[lldb] Skip TestDataFormatterSynthVal.py with GCC as the test compiler
Raphael Isemann [Fri, 25 Jun 2021 09:48:12 +0000 (11:48 +0200)]
[lldb] Skip TestDataFormatterSynthVal.py with GCC as the test compiler

3 years ago[lldb] Skip libstdc++ tests failing with GCC
Raphael Isemann [Fri, 25 Jun 2021 09:45:57 +0000 (11:45 +0200)]
[lldb] Skip libstdc++ tests failing with GCC

Tracked in llvm.org/pr50861

These tests fail with all GCC versions I tested (8.5, 9.4, 10.3, 11.1).

3 years ago[lldb] Skip tests failing with GCC due to LLDB not being able to call constructors
Raphael Isemann [Thu, 24 Jun 2021 15:21:12 +0000 (17:21 +0200)]
[lldb] Skip tests failing with GCC due to LLDB not being able to call constructors

Tracked in llvm.org/pr50814

These tests fail with all GCC versions I tested (8.5, 9.4, 10.3, 11.1).

3 years ago[SCEV] Support single-cond range check idiom in applyLoopGuards.
Florian Hahn [Fri, 25 Jun 2021 08:29:47 +0000 (09:29 +0100)]
[SCEV] Support single-cond range check idiom in applyLoopGuards.

This patch extends applyLoopGuards to detect a single-cond range check
idiom that InstCombine generates.

It extends applyLoopGuards to detect conditions of the form
(-C1 + X < C2). InstCombine will create this form when combining two
checks of the form (X u< C2 + C1) and (X >=u C1).

In practice, this enables us to correctly compute a tight trip count
bounds for code as in the function below. InstCombine will fold the
minimum iteration check created by LoopRotate with the user check (< 8).

    void unsigned_check(short *pred, unsigned width) {
        if (width < 8) {
            for (int x = 0; x < width; x++)
                pred[x] = pred[x] * pred[x];
        }
    }

As a consequence, LLVM creates dead vector loops for the code above,
e.g. see https://godbolt.org/z/cb8eTcqET

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

Reviewed By: nikic

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

3 years ago[OpaquePtr] Allow alias to opaque pointer
Nikita Popov [Fri, 25 Jun 2021 09:13:36 +0000 (11:13 +0200)]
[OpaquePtr] Allow alias to opaque pointer

By relaxing the LLParser pointer type assertion.

3 years ago[OpaquePtr] Split force-opaque-pointers test (NFC)
Nikita Popov [Fri, 25 Jun 2021 09:08:19 +0000 (11:08 +0200)]
[OpaquePtr] Split force-opaque-pointers test (NFC)

Separate out the case that uses llvm-dis without
--force-opaque-pointers. This will generally produce a different
result from the other cases, because things like global symbol
pointers will be non-opaque in this case.

3 years ago[lldb] Fix memory tag unsupported test
David Spickett [Fri, 25 Jun 2021 08:52:36 +0000 (08:52 +0000)]
[lldb] Fix memory tag unsupported test

This corrects the test added in
31f9960c38529ce805edf9764535eb0ce188cadf
and temporarily patched in
3b4aad1186e8e8e6f6c7887cb5e8d9bfd7d3ce2f.

This test checks that the memory tag read
command errors when you use it on a platform
without memory tagging.
(which is why we skip the test if you actually
have MTE)

The problem with this test is that there's
two levels of unsupported each with it's own
specific error.

On anything that isn't AArch64, there's no
tagging extension we support. So you're told
that that is the case. As in "this won't ever work".

When you're on AArch64 we know that MTE could
be present on the remote and when we find that it
isn't, we tell you that instead.

Expect a different error message on AArch64 to fix
the test.

3 years ago[llvm-cov] Enforce alignment of function records
serge-sans-paille [Tue, 22 Jun 2021 20:50:37 +0000 (22:50 +0200)]
[llvm-cov] Enforce alignment of function records

Function Records are required to be aligned on 8 bytes. This is enforced for each
records except the first, when one relies on the default alignment within an
std::string. There's no such guarantee, and indeed on 32 bits for some
implementation of std::string this is not enforced.

Provide a portable implementation based on llvm's MemoryBuffer.

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

3 years ago[AArch64] Custom lower <4 x i8> loads
Sjoerd Meijer [Thu, 24 Jun 2021 18:29:13 +0000 (19:29 +0100)]
[AArch64] Custom lower <4 x i8> loads

This custom lowers <4 x i8> vector loads using a 32-bit load, followed by 2
SSHLL instructions to extend it to e.g. a <4 x i32> vector. Before, it was
really inefficient and expensive to construct a <4 x i32> for this as 4 byte
loads and 4 moves were used. With this improvement SLP vectorisation might for
example become profitable, see D103629.

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

3 years ago[OpaquePtr] Enumerate alloca type
Nikita Popov [Fri, 25 Jun 2021 08:48:57 +0000 (10:48 +0200)]
[OpaquePtr] Enumerate alloca type

This is no longer implicitly enumerated through the pointer type.

3 years ago[OpaquePtr] Enumerate global variable type
Nikita Popov [Fri, 25 Jun 2021 08:45:29 +0000 (10:45 +0200)]
[OpaquePtr] Enumerate global variable type

This is no longer implicitly enumerated through the pointer type.

3 years ago[PowerPC] Change VSRpRC allocation order
Qiu Chaofan [Fri, 25 Jun 2021 08:00:07 +0000 (16:00 +0800)]
[PowerPC] Change VSRpRC allocation order

On PowerPC, VSRpRC represents the pairs of even and odd VSX register,
and VRRC corresponds to higher 32 VSX registers. In some cases, extra
copies are produced when handling incoming VRRC arguments with VSRpRC.

This patch changes allocation order of VSRpRC to eliminate this kind of
copy.

Stack frame sizes may increase if allocating non-volatile registers, and
some other vector copies happen. They need fix in future changes.

Reviewed By: nemanjai

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

3 years ago[LLD] [COFF] Fix handling of LTO comdats with nontrivial selection types after 728cc0...
Martin Storsjö [Sun, 20 Jun 2021 20:58:46 +0000 (23:58 +0300)]
[LLD] [COFF] Fix handling of LTO comdats with nontrivial selection types after 728cc0075e5dfdb454eb

Commit 728cc0075e5dfdb454ebe6418b63bdffae71ec14 made comdat symbols
from LTO objects be treated as any regular comdat symbol. This works
great for symbols that actually are IMAGE_COMDAT_SELECT_ANY, but
if the symbols have a less trivial selection type that require comparing
either the section chunk size or contents, we can't check that before
actually doing the LTO compilation.

Therefore bring back one aspect of handling from before; that comdat
resolution with a leader from an LTO symbol is essentially skipped,
like it was before 728cc0075e5dfdb454ebe6418b63bdffae71ec14.

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

3 years ago[ARM] Fix crash in chained BFI combine due to incorrectly RAUW'ing a node.
Amara Emerson [Thu, 24 Jun 2021 18:10:42 +0000 (11:10 -0700)]
[ARM] Fix crash in chained BFI combine due to incorrectly RAUW'ing a node.

For a bfi chain like:
a = bfi input, x, y
b = bfi a, x', y'

The previous code was RAUW'ing a with x, mutating the second 'b' bfi, and when
SelectionDAG's CSE code ended up deleting it unexpectedly, bad things happend.
There's no need to RAUW in this case because we can just return our newly
created replacement BFI node. It also looked incorrect because it didn't account
for other users of the 'a' bfi.

Since it seems that chains of more than 2 BFI nodes are hard/impossible to
produce without this combine kicking in at some point, I've removed that
functionality since it had no test coverage.

rdar://79095399

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

3 years ago[RISCV] Permit larger RVV stacks and stack offsets
Fraser Cormack [Tue, 22 Jun 2021 17:08:52 +0000 (18:08 +0100)]
[RISCV] Permit larger RVV stacks and stack offsets

This patch teaches the compiler to generate code to handle larger RVV
stack sizes and stack offsets which resolve an amount larger than 2047
vector registers in size.

The previous behaviour was asserting on such large values as it was only
able to materialize the constant by feeding it to the 12-bit immediate
of an `ADDI` instruction. The compiler can now materialize this amount
into a temporary register before continuing with the computation.

A test case for this scenario is included which also checks that the
temporary register used to materialize the amount doesn't require an
additional spill slot over what we're already reserving for RVV code.

Reviewed By: rogfer01

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

3 years ago[X86] Add description of FXAM instruction
Serge Pavlov [Wed, 23 Jun 2021 06:33:55 +0000 (13:33 +0700)]
[X86] Add description of FXAM instruction

Previously this instruction could be used only in assembler. This change
makes it available for compiler also. Scheduling information was copied
from FTST instruction, hopefully this can be a satisfactory approximation.

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

3 years ago[MC][ELF] Change SHT_LLVM_CALL_GRAPH_PROFILE relocations from SHT_RELA to SHT_REL
Fangrui Song [Fri, 25 Jun 2021 04:35:48 +0000 (21:35 -0700)]
[MC][ELF] Change SHT_LLVM_CALL_GRAPH_PROFILE relocations from SHT_RELA to SHT_REL

... even on targets preferring RELA. The section is only consumed by ld.lld
which can handle REL.

Follow-up to D104080 as I explained in the review. There are two advantages:

* The D104080 code only handles RELA, so arm/i386/mips32 etc may warn for -fprofile-use=/-fprofile-sample-use= usage.
* Decrease object file size for RELA targets

While here, change the relocation to relocate weights, instead of 0,1,2,3,..
I failed to catch the issue during review.

3 years agoRevert "[BuildLibCalls/SimplifyLibCalls] Fix attributes on created CallInst instruct...
Arthur Eubanks [Fri, 25 Jun 2021 02:21:16 +0000 (19:21 -0700)]
Revert "[BuildLibCalls/SimplifyLibCalls]  Fix attributes on created CallInst instructions."

This reverts commit 1eda5453f2dcc9a9a4b4578fe74163c529974503.

Causes https://crbug.com/1223647:
Incompatible argument and return types for 'returned' attribute
  tail call void @llvm.memset.p0i8.i64(i8* noalias noundef returned writeonly align 1 dereferenceable(255) %arraydecay, i8 0, i64 255, i1 false), !dbg !985

3 years ago[lld-macho] Move ICF members from InputSection to ConcatInputSection
Jez Ng [Fri, 25 Jun 2021 02:23:04 +0000 (22:23 -0400)]
[lld-macho] Move ICF members from InputSection to ConcatInputSection

`icfEqClass` only makes sense on ConcatInputSections since (in contrast
to literal sections) they are deduplicated as an atomic unit.

Similarly, `hasPersonality` and `replacement` don't make sense on
literal sections.

This mirrors LLD-ELF, which stores `icfEqClass` only on non-mergeable
sections.

Reviewed By: #lld-macho, gkm

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

3 years ago[PowerPC] Move PPCBranchSelector as close to asm printer as possible
Kai Luo [Fri, 25 Jun 2021 01:43:31 +0000 (01:43 +0000)]
[PowerPC] Move PPCBranchSelector as close to asm printer as possible

Currently, PPCBranchSelector is not immediately preceding asm printer pass. `-debug-pass=Structure` gives
```
      PowerPC Branch Selector
      Contiguously Lay Out Funclets
      StackMap Liveness Analysis
      Live DEBUG_VALUE analysis
      Lazy Machine Block Frequency Analysis
      Machine Optimization Remark Emitter
      Linux PPC Assembly Printer
```
After the patch
```
      Contiguously Lay Out Funclets
      StackMap Liveness Analysis
      Live DEBUG_VALUE analysis
      PowerPC Branch Selector
      Lazy Machine Block Frequency Analysis
      Machine Optimization Remark Emitter
      Linux PPC Assembly Printer
```

Reviewed By: nemanjai, #powerpc

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

3 years ago[PowerPC] Add XL compat __compare_and_swap builtins
Jinsong Ji [Fri, 25 Jun 2021 01:08:32 +0000 (01:08 +0000)]
[PowerPC] Add XL compat __compare_and_swap builtins

Prototype
int __compare_and_swap (volatile int* addr, int* old_val_addr, int
new_val);

int __compare_and_swaplp (volatile long* addr, long* old_val_addr, long
new_val);

Refer to
https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1?topic=functions-compare-swap-compare-swaplp

Reviewed By: w2yehia

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

3 years ago[RISCV] Add vget/vset intrinsics for inserting and extracting between different lmuls.
Craig Topper [Thu, 24 Jun 2021 22:53:47 +0000 (15:53 -0700)]
[RISCV] Add vget/vset intrinsics for inserting and extracting between different lmuls.

These allow getting a whole register from a larger lmul. Or
inserting a whole register into a larger lmul register. Fractional
lmuls are not supported as they would require a vslide.

Based on this update to the intrinsic doc
https://github.com/riscv/rvv-intrinsic-doc/pull/99

Reviewed By: HsiangKai

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

3 years agoUnsupported sanitize-coverage-old-pm.c on 32 bit Arm
Muhammad Omair Javaid [Fri, 25 Jun 2021 00:55:25 +0000 (00:55 +0000)]
Unsupported sanitize-coverage-old-pm.c on 32 bit Arm

sanitize-coverage-old-pm.c is passing intermittently on different
arm v7 machines. This patch moves it to unsupported on all arm 32
targets reporting armv8l core.

3 years agoRevert "[hwasan] print exact mismatch offset for short granules."
Vitaly Buka [Fri, 25 Jun 2021 00:30:03 +0000 (17:30 -0700)]
Revert "[hwasan] print exact mismatch offset for short granules."

Breaks sanitizer-x86_64-linux-android and sanitizer-x86_64-linux-qemu bots.

This reverts commit 7e3f8b8affd0392c997564b5f34c61d6115a3516.

3 years ago[scudo] Clang-format tests
Vitaly Buka [Fri, 25 Jun 2021 00:28:01 +0000 (17:28 -0700)]
[scudo] Clang-format tests

3 years ago[gn build] Port 69d5a6662115
LLVM GN Syncbot [Fri, 25 Jun 2021 00:29:34 +0000 (00:29 +0000)]
[gn build] Port 69d5a6662115

3 years ago[libcxx][modularisation] splits `<utility>` into self-contained headers
Christopher Di Bella [Wed, 9 Jun 2021 23:10:17 +0000 (23:10 +0000)]
[libcxx][modularisation] splits `<utility>` into self-contained headers

* moves `std::hash` and `std::unary_function` into `__functional`
* Everything else goes into `__utility/${NAME}.h`

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

3 years agoChange the flang reshape runtime routine interface to use a result
Mark Leair [Thu, 24 Jun 2021 23:55:45 +0000 (16:55 -0700)]
Change the flang reshape runtime routine interface to use a result
argument instead of a result result object.

Change the reshape flang unit test to use the new interface. Also, add an
order argument to exercise the order subscript code in the rehsape runtime
routine.

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

3 years agoRevert "[Clang] XFAIL sanitize-coverage-old-pm.c on 32bit Armv8l"
Muhammad Omair Javaid [Thu, 24 Jun 2021 23:59:32 +0000 (04:59 +0500)]
Revert "[Clang] XFAIL sanitize-coverage-old-pm.c on 32bit Armv8l"

This reverts commit c5028f3473ed50a7433fe278984cd1a755b338b9.

3 years ago[PowerPC] Fix vec_add for 64-bit on pre-Power7 subtargets
Nemanja Ivanovic [Thu, 24 Jun 2021 23:41:12 +0000 (18:41 -0500)]
[PowerPC] Fix vec_add for 64-bit on pre-Power7 subtargets

The shift of the carry was actually incorrect.

3 years agoUpdate Bazel build for 744146f60b
Geoffrey Martin-Noble [Thu, 24 Jun 2021 23:33:13 +0000 (16:33 -0700)]
Update Bazel build for 744146f60b

Updates Bazel build files to match
https://github.com/llvm/llvm-project/commit/744146f60b

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

3 years ago[PowerPC] Fix bswap combine for big endian systems
Nemanja Ivanovic [Thu, 24 Jun 2021 23:03:06 +0000 (18:03 -0500)]
[PowerPC] Fix bswap combine for big endian systems

Commit 0464586ac515e8cfebe4c7615387fd625c8869f5 added a combine
for a 64-bit load feeding a bswap but the implementation is only
correct for little endian systems.
This fixes it for big endian systems.

3 years ago[MLIR][Sparse] Refactor lattice code into its own file
Gus Smith [Thu, 24 Jun 2021 22:18:40 +0000 (22:18 +0000)]
[MLIR][Sparse] Refactor lattice code into its own file

Moves iteration lattice/merger code into new SparseTensor/Utils directory. A follow-up CL will add lattice/merger unit tests.

Reviewed By: aartbik

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

3 years ago[OpenMP][NFC] libomp: fix wrong debug assertion.
AndreyChurbanov [Thu, 24 Jun 2021 23:02:14 +0000 (02:02 +0300)]
[OpenMP][NFC] libomp: fix wrong debug assertion.

Normalized bounds of chunk of iterations to steal from are inclusive,
so upper bound should not be decremented in expression to check.
Problem was in attempt to steal iterations 0:0, that caused assertion after
wrong decrement. Reported in comment to https://reviews.llvm.org/D103648.

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

3 years ago[AMDGPU] Reserve AMDGPU ELF e_flags machine 0x43
Tony Tye [Thu, 24 Jun 2021 02:01:24 +0000 (02:01 +0000)]
[AMDGPU] Reserve AMDGPU ELF e_flags machine 0x43

Reviewed By: kzhuravl, rampitec

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

3 years agoDisable TestAArch64UnwindPAC.py for non PAC targets
Muhammad Omair Javaid [Thu, 24 Jun 2021 22:49:05 +0000 (22:49 +0000)]
Disable TestAArch64UnwindPAC.py for non PAC targets

TestAArch64UnwindPAC.py started failing on LLDB buildbot as underlying
hardware does not support PAC. This patch skips this test for targets
which do not support PAC feature.

3 years ago[mlir][VectorToGPU] Add conversion for scf::For op with Matrix operands
thomasraoux [Thu, 24 Jun 2021 22:42:28 +0000 (15:42 -0700)]
[mlir][VectorToGPU] Add conversion for scf::For op with Matrix operands

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

3 years ago[mlir][VectorToGPU] Add conversion for splat constant to MMA const matrix
thomasraoux [Thu, 24 Jun 2021 22:29:49 +0000 (15:29 -0700)]
[mlir][VectorToGPU] Add conversion for splat constant to MMA const matrix

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

3 years agoDisable check_qmemtags unit tests
Muhammad Omair Javaid [Thu, 24 Jun 2021 22:30:06 +0000 (22:30 +0000)]
Disable check_qmemtags unit tests

check_qmemtags tests are broken on Arm 32 bits. This patch disables
these tests.

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

3 years ago[ELF] Fix .rela.llvm.call-graph-profile detection after D104080
Fangrui Song [Thu, 24 Jun 2021 22:21:28 +0000 (15:21 -0700)]
[ELF] Fix .rela.llvm.call-graph-profile detection after D104080

A SHT_SYMTAB section's sh_info is the number of local symbols.
sh_info may coincide with the section header index of SHT_LLVM_CALL_GRAPH_PROFILE.

3 years agoFix typo in TestMemoryTag.py
Muhammad Omair Javaid [Thu, 24 Jun 2021 22:17:50 +0000 (22:17 +0000)]
Fix typo in TestMemoryTag.py

TestMemoryTag.py should fail if underlying target doesnt support MTE.

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

3 years ago[OptTable] Rename PrintHelp to printHelp
Fangrui Song [Thu, 24 Jun 2021 21:47:03 +0000 (14:47 -0700)]
[OptTable] Rename PrintHelp to printHelp

To be consistent with other member functions and match the coding standard.

3 years ago[LLDB] Fix broken LLDB build due MemoryTagManager.h
Muhammad Omair Javaid [Thu, 24 Jun 2021 21:35:10 +0000 (02:35 +0500)]
[LLDB] Fix broken LLDB build due MemoryTagManager.h

Commit e0f2744a115c41e8d295b93dd74b39535c852390 broke LLDB build.
This patch fixes the build. Tested on Arm/AArch64 Linux.

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

3 years ago[ADT] Complete the StringRef case insensitive method renaming
Martin Storsjö [Wed, 23 Jun 2021 20:22:25 +0000 (23:22 +0300)]
[ADT] Complete the StringRef case insensitive method renaming

Remove the old name for the methods. These were only left behind to
ease the transition for downstreams.

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

3 years ago[mlir] Rename StringRef _lower() method calls to _insensitive()
Martin Storsjö [Thu, 24 Jun 2021 08:06:49 +0000 (11:06 +0300)]
[mlir] Rename StringRef _lower() method calls to _insensitive()

3 years ago[lldb] Rename StringRef _lower() method calls to _insensitive()
Martin Storsjö [Thu, 24 Jun 2021 08:06:42 +0000 (11:06 +0300)]
[lldb] Rename StringRef _lower() method calls to _insensitive()

3 years ago[lld] Rename StringRef _lower() method calls to _insensitive()
Martin Storsjö [Thu, 24 Jun 2021 08:06:35 +0000 (11:06 +0300)]
[lld] Rename StringRef _lower() method calls to _insensitive()

3 years ago[clang-tools-extra] Rename StringRef _lower() method calls to _insensitive()
Martin Storsjö [Thu, 24 Jun 2021 08:04:01 +0000 (11:04 +0300)]
[clang-tools-extra] Rename StringRef _lower() method calls to _insensitive()

3 years ago[clang] Rename StringRef _lower() method calls to _insensitive()
Martin Storsjö [Wed, 23 Jun 2021 11:52:36 +0000 (14:52 +0300)]
[clang] Rename StringRef _lower() method calls to _insensitive()

This is mostly a mechanical change, but a testcase that contains
parts of the StringRef class (clang/test/Analysis/llvm-conventions.cpp)
isn't touched.

3 years ago[llvm] Rename StringRef _lower() method calls to _insensitive()
Martin Storsjö [Wed, 23 Jun 2021 11:52:36 +0000 (14:52 +0300)]
[llvm] Rename StringRef _lower() method calls to _insensitive()

This is a mechanical change. This actually also renames the
similarly named methods in the SmallString class, however these
methods don't seem to be used outside of the llvm subproject, so
this doesn't break building of the rest of the monorepo.

3 years ago[ADT] Rename StringRef case insensitive methods for clarity
Martin Storsjö [Wed, 23 Jun 2021 11:52:36 +0000 (14:52 +0300)]
[ADT] Rename StringRef case insensitive methods for clarity

Rename functions with the `xx_lower()` names to `xx_insensitive()`.
This was requested during the review of D104218.

Test names and variables in llvm/unittests/ADT/StringRefTest.cpp
that refer to "lower" are renamed to "insensitive" correspondingly.

Unused function aliases with the former method names are left
in place (without any deprecation attributes) for transition purposes.

All references within the monorepo will be changed (with essentially
mechanical changes), and then the old names will be removed in a
later commit.

Also remove the superfluous method names at the start of doxygen
comments, for the methods that are touched here. (There are more
occurrances of this left in other methods though.) Also remove
duplicate doxygen comments from the implementation file.

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

3 years ago[Hexagon] Opaquify pointer usage in GEP commoning
Krzysztof Parzyszek [Thu, 24 Jun 2021 15:50:06 +0000 (10:50 -0500)]
[Hexagon] Opaquify pointer usage in GEP commoning

3 years ago[LangRef] clarify the meaning of noimplicitfloat
Bob Haarman [Thu, 10 Jun 2021 19:03:16 +0000 (12:03 -0700)]
[LangRef] clarify the meaning of noimplicitfloat

Adds some more text to the documentation for the noimplicitfloat
function attribute. Hopefully, this makes it clearer what
qualifies an implicit vs. explicit float, without becoming overly
long or going into target-specific details.

Reviewed By: rnk, craig.topper

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

3 years ago[lld-macho] Align all cstrings to 16 bytes when deduplicating
Jez Ng [Thu, 24 Jun 2021 20:22:49 +0000 (16:22 -0400)]
[lld-macho] Align all cstrings to 16 bytes when deduplicating

We previously did this only for x86_64, but it turns out that
arm64 needs this too -- see PR50791.

Ultimately this is a hack, and we should avoid over-aligning strings
that don't need it. I'm just having a hard time figuring out how ld64 is
determining the right alignment.

No new test for this since we were already testing this behavior for
x86_64, and extending it to arm64 seems too trivial.

Reviewed By: #lld-macho, thakis

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

3 years ago[Polly][ScopInliner] Indicate if the IR has changed.
Michael Kruse [Thu, 24 Jun 2021 20:17:21 +0000 (15:17 -0500)]
[Polly][ScopInliner] Indicate if the IR has changed.

Return true to indicate that the IR has changed if the nested pass
manager has changed it.

Fixes the ScopInliner tests in the LLVM_ENABLE_EXPENSIVE_CHECKS=ON
configuration.

Thanks to Alexandre Ganea for reporting.

3 years ago[compiler-rt][test] fix zero_page_pc on arm64e
Emily Shi [Thu, 24 Jun 2021 01:11:51 +0000 (18:11 -0700)]
[compiler-rt][test] fix zero_page_pc on arm64e

on arm64e, pointer auth would catch this access violation before asan.
sign the function pointer so pointer auth will ignore this violation and let asan catch it in this test case.

rdar://79652167

Reviewed By: delcypher

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

3 years ago[InstCombine] Make indexed compare fold opaque ptr compatible
Nikita Popov [Thu, 24 Jun 2021 20:31:06 +0000 (22:31 +0200)]
[InstCombine] Make indexed compare fold opaque ptr compatible

Rather than relying on pointer type equality (which, for a change,
is silently incorrect with opaque pointers) check that the GEP
source element types match.

3 years ago[OpaquePtr] Introduce option to force all pointers to be opaque pointers
Arthur Eubanks [Thu, 24 Jun 2021 15:21:24 +0000 (08:21 -0700)]
[OpaquePtr] Introduce option to force all pointers to be opaque pointers

We don't want to start updating tests to use opaque pointers until we're
close to the opaque pointer transition. However, before the transition
we want to run tests as if pointers are opaque pointers to see if there
are any crashes.

At some point when we have a flag to only create opaque pointers in the
bitcode and textual IR readers, and when we have fixed all places that
try to read a pointee type, this flag will be useless. However, until
then, this can help us find issues more easily.

Since the cl::opt is read into LLVMContext, we need to make sure
LLVMContext is created after cl::ParseCommandLineOptions().

Previously ValueEnumerator would visit the value types of global values
via the pointer type, but with opaque pointers we have to manually visit
the value type.

Reviewed By: nikic, dexonsmith

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

3 years ago[WPD] Don't optimize calls more than once
Arthur Eubanks [Wed, 23 Jun 2021 01:53:12 +0000 (18:53 -0700)]
[WPD] Don't optimize calls more than once

WPD currently assumes that there is a one to one correspondence between
type test assume sequences and virtual calls. However, with
-fstrict-vtable-pointers this may not be true. This ends up causing
crashes when we try to optimize a virtual call more than once (
applyUniformRetValOpt()/applyUniqueRetValOpt()/applyVirtualConstProp()/applySingleImplDevirt()).

applySingleImplDevirt() actually didn't previous crash because it would
replace the devirtualized call with the same direct call. Adding an
assert that the call is indirect causes the corresponding test to crash
with the rest of the patch.

This makes Chrome successfully build with -fstrict-vtable-pointers + WPD.

Reviewed By: tejohnson

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

3 years ago[Clang-Format] Add ReferenceAlignment directive
Seraphime Kirkovski [Thu, 24 Jun 2021 19:24:59 +0000 (21:24 +0200)]
[Clang-Format] Add ReferenceAlignment directive

This introduces ReferenceAlignment style option modeled around
PointerAlignment.
Style implementors can specify Left, Right, Middle or Pointer to
follow whatever the PointerAlignment option specifies.

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

3 years ago[PowerPC] Combine 64-bit bswap(load) without LDBRX
Nemanja Ivanovic [Thu, 24 Jun 2021 19:44:17 +0000 (14:44 -0500)]
[PowerPC] Combine 64-bit bswap(load) without LDBRX

When targeting CPUs that don't have LDBRX, we end up producing code that is
very inefficient and large for this common idiom. This patch just
optimizes it two 32-bit LWBRX instructions along with a merge.

This fixes https://bugs.llvm.org/show_bug.cgi?id=49610

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

3 years ago[InstCombine] Make varargs cast transform compatible with opaque ptrs
Nikita Popov [Thu, 24 Jun 2021 19:46:55 +0000 (21:46 +0200)]
[InstCombine] Make varargs cast transform compatible with opaque ptrs

The whole transform can be dropped once we have fully transitioned
to opaque pointers (as it's purpose is to remove no-op pointer
casts). For now, make sure that it handles opaque pointers correctly.

3 years ago[BuildLibCalls/SimplifyLibCalls] Fix attributes on created CallInst instructions.
Jonas Paulsson [Wed, 9 Jun 2021 21:35:22 +0000 (23:35 +0200)]
[BuildLibCalls/SimplifyLibCalls]  Fix attributes on created CallInst instructions.

- When emitting libcalls, do not only pass the calling convention from the
  function prototype but also the attributes.

- Do not pass attributes from e.g. libc memcpy to llvm.memcpy.

Review: Reid Kleckner, Eli Friedman, Arthur Eubanks

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

3 years ago[clang-format][NFC] Fix documentation
Björn Schäpers [Thu, 24 Jun 2021 19:19:14 +0000 (21:19 +0200)]
[clang-format][NFC] Fix documentation

This amends 64cf5eba06bd4f81954253b1e7a10be6fe92403e.

3 years ago[CodeGen] Don't create fake FunctionDecls when generating block/byref
Akira Hatanaka [Thu, 24 Jun 2021 18:45:52 +0000 (11:45 -0700)]
[CodeGen] Don't create fake FunctionDecls when generating block/byref
copy/dispose helper functions

We found out that these fake functions would cause clang to crash if the
changes proposed in https://reviews.llvm.org/D98799 were made.

The original patch was reverted in f681fd927e883301658dcac9a78109ee0aba12a8
because debug locations were missing in the body of the block byref
helper functions. This patch fixes the bug by calling CreateArtificial
after the calls to StartFunction.

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

3 years ago[NFC][Codegen] Autogenerate Thumb2/setjmp_longjmp.ll test
Roman Lebedev [Thu, 24 Jun 2021 18:33:43 +0000 (21:33 +0300)]
[NFC][Codegen] Autogenerate Thumb2/setjmp_longjmp.ll test

3 years ago[AMDGPU] Add gfx1035 target
Aakanksha Patil [Thu, 24 Jun 2021 18:32:41 +0000 (14:32 -0400)]
[AMDGPU] Add gfx1035 target

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

3 years ago[SimplifyCFG] Tail-merging all blocks with `resume` terminator
Roman Lebedev [Thu, 24 Jun 2021 18:25:06 +0000 (21:25 +0300)]
[SimplifyCFG] Tail-merging all blocks with `resume` terminator

Similar to what we already do for `ret` terminators.
As noted by @rnk, clang seems to already generate a single `ret`/`resume`,
so this isn't likely to cause widespread changes.

Reviewed By: rnk

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

3 years ago[libcxx][nfc] Update the synopsis comment in <ranges> to include drop_view.
zoecarver [Thu, 24 Jun 2021 18:05:50 +0000 (11:05 -0700)]
[libcxx][nfc] Update the synopsis comment in <ranges> to include drop_view.