platform/upstream/llvm.git
3 years ago[libcxx][iterator] adds `std::indirectly_readable` and `std::indirectly_writable`
Christopher Di Bella [Wed, 21 Apr 2021 16:41:13 +0000 (16:41 +0000)]
[libcxx][iterator] adds `std::indirectly_readable` and `std::indirectly_writable`

Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D99873.

Reviewed By: ldionne, #libc

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

3 years ago[PollyACC] Fix declaration/stub definition mismatch. NFC.
Michael Kruse [Wed, 21 Apr 2021 15:12:23 +0000 (10:12 -0500)]
[PollyACC] Fix declaration/stub definition mismatch. NFC.

external.c defines stub functions that are never used because of how
Polly uses PPCG. Unfortunately, they are declared as functions without
return values or parameters which does not match their declarations.
Since they are never called, this was usually not a problem, but an LTO
build gets confused with differently declared functions, or in case of
pet_options_args, a global variable declaration that is defined as a
function

Resolve by including the declaring headers in external.c which forces
the declaration and definition to match at compile-time.

This fixes llvm.org/50021

3 years ago[libc++] s/_LIBCPP_NO_HAS_CHAR8_T/_LIBCPP_HAS_NO_CHAR8_T/g
Arthur O'Dwyer [Mon, 19 Apr 2021 01:47:08 +0000 (21:47 -0400)]
[libc++] s/_LIBCPP_NO_HAS_CHAR8_T/_LIBCPP_HAS_NO_CHAR8_T/g

This was raised in D94511.

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

3 years ago[libc++] [test] Remove epicyclic workarounds for vector/span; use T[] or std::array.
Arthur O'Dwyer [Tue, 20 Apr 2021 18:14:35 +0000 (14:14 -0400)]
[libc++] [test] Remove epicyclic workarounds for vector/span; use T[] or std::array.

Simplify the test code, and drive-by also test that these algorithms
return the right iterator as their return value.

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

3 years ago[CSSPGO] Exclude pseudo probe from slotindex verification.
Hongtao Yu [Wed, 21 Apr 2021 16:14:50 +0000 (09:14 -0700)]
[CSSPGO] Exclude pseudo probe from slotindex verification.

3 years ago[gn build] add llvm-profgen to gn build
Nico Weber [Wed, 21 Apr 2021 15:49:17 +0000 (11:49 -0400)]
[gn build] add llvm-profgen to gn build

Didn't notice it missing due to https://reviews.llvm.org/D89707#2705110

3 years ago[gn build] Port 97e383aa061b
LLVM GN Syncbot [Wed, 21 Apr 2021 15:39:33 +0000 (15:39 +0000)]
[gn build] Port 97e383aa061b

3 years ago[lld][MachO] Refactor findCommand
Alexander Shaposhnikov [Wed, 21 Apr 2021 15:18:20 +0000 (08:18 -0700)]
[lld][MachO] Refactor findCommand

Refactor findCommand to allow passing multiple types. NFC.

Test plan: make check-lld-macho

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

3 years ago[lldb/test] Clean up TestThreadSpecificBpPlusCondition inferior
Pavel Labath [Wed, 21 Apr 2021 15:31:41 +0000 (17:31 +0200)]
[lldb/test] Clean up TestThreadSpecificBpPlusCondition inferior

The test had a race that could cause two threads to end up with the same
"thread local" value. I believe this would not cause the test to fail,
but it could cause it to succeed even when the functionality is broken.

The new implementation removes this uncertainty, and removes a lot of
cruft left over from the time this test was written using pthreads.

3 years ago[AMDGPU] Lower regbanks reassign threshold to 15000
Stanislav Mekhanoshin [Tue, 20 Apr 2021 22:58:01 +0000 (15:58 -0700)]
[AMDGPU] Lower regbanks reassign threshold to 15000

Let it work on a very small kernels only. Measurements showed
the performance benefit is not worth the compile time.

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

3 years ago[libc++] Add std::ranges::iter_move and std::iter_rvalue_reference_t
Louis Dionne [Tue, 20 Apr 2021 18:40:43 +0000 (14:40 -0400)]
[libc++] Add std::ranges::iter_move and std::iter_rvalue_reference_t

Original patch by @cjdb, modified by @ldionne.

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

3 years ago[flang] iwyu fixes after ba7a92c01e8
Nico Weber [Wed, 21 Apr 2021 15:10:45 +0000 (11:10 -0400)]
[flang] iwyu fixes after ba7a92c01e8

3 years ago[mlir] hopefully final round of iwyu fixes after ba7a92c01e8
Nico Weber [Wed, 21 Apr 2021 15:02:58 +0000 (11:02 -0400)]
[mlir] hopefully final round of iwyu fixes after ba7a92c01e8

3 years ago[lldb/test] Modernize lldb-server test inferior
Pavel Labath [Fri, 16 Apr 2021 19:52:59 +0000 (21:52 +0200)]
[lldb/test] Modernize lldb-server test inferior

Avoid c string manipulation by introducing a StringRef-like
consume_front operation.

3 years ago[mlir] yet more iwyu fixes after ba7a92c01e8
Nico Weber [Wed, 21 Apr 2021 14:54:44 +0000 (10:54 -0400)]
[mlir] yet more iwyu fixes after ba7a92c01e8

3 years ago[mlir] more iwyu fixes after ba7a92c01e8
Nico Weber [Wed, 21 Apr 2021 14:50:59 +0000 (10:50 -0400)]
[mlir] more iwyu fixes after ba7a92c01e8

3 years ago[mlir] some iwyu fixes after ba7a92c01e8
Nico Weber [Wed, 21 Apr 2021 14:48:54 +0000 (10:48 -0400)]
[mlir] some iwyu fixes after ba7a92c01e8

3 years agoclang-format: [JS] do not wrap after `asserts`
Martin Probst [Wed, 21 Apr 2021 13:43:41 +0000 (15:43 +0200)]
clang-format: [JS] do not wrap after `asserts`

`asserts` is a pseudo keyword in TypeScript used in return types.
Wrapping after it triggers automatic semicolon insertion, which
breaks the code semantics/syntax.

`asserts` is different from other pseudo keywords in that it is
specific to TS and only carries meaning in a very specific location.
Thus introducing a token type is probably overkill.

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

3 years ago[TTI] NFC: Change getVectorSplitCost to return InstructionCost
dfukalov [Wed, 21 Apr 2021 13:38:53 +0000 (16:38 +0300)]
[TTI] NFC: Change getVectorSplitCost to return InstructionCost

This patch migrates the TTI cost interfaces to return an InstructionCost.

See this patch for the introduction of the type: https://reviews.llvm.org/D91174
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2020-November/146408.html

Reviewed By: sdesmalen

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

3 years ago[AsmParser][ms][X86] Fix possible misbehaviour in parsing of special tokens at start...
Anirudh Prasad [Wed, 21 Apr 2021 14:19:52 +0000 (10:19 -0400)]
[AsmParser][ms][X86] Fix possible misbehaviour in parsing of special tokens at start of string.

- Previously, https://reviews.llvm.org/D72680 introduced a new attribute called `AllowSymbolAtNameStart` (in relation to the MAsmParser changes) in `MCAsmInfo.h` which (according to the comment in the header) allows the following behaviour:

```
  /// This is true if the assembler allows $ @ ? characters at the start of
  /// symbol names. Defaults to false.
```

- However, the usage of this field in AsmLexer.cpp doesn't seem completely accurate* for a couple of reasons.

```
  default:
    if (MAI.doesAllowSymbolAtNameStart()) {
      // Handle Microsoft-style identifier: [a-zA-Z_$.@?][a-zA-Z0-9_$.@#?]*
      if (!isDigit(CurChar) &&
          isIdentifierChar(CurChar, MAI.doesAllowAtInName(),
                           AllowHashInIdentifier))
        return LexIdentifier();
    }
```

1. The Dollar and At tokens, when occurring at the start of the string, are treated as separate tokens (AsmToken::Dollar and AsmToken::At respectively) and not lexed as an Identifier.
2. I'm not too sure why `MAI.doesAllowAtInName()` is used when `AllowAtInIdentifier` could be used. For X86 platforms, afaict, this shouldn't be an issue, since the `CommentString` attribute isn't "@". (alternatively the call to the setter can be set anywhere else as needed). The `AllowAtInName` does have an additional important meaning, but in the context of AsmLexer, shouldn't mean anything different compared to `AllowAtInIdentifier`

My proposal is the following:

- Introduce 3 new fields called `AllowQuestionTokenAtStartOfString`, `AllowDollarTokenAtStartOfString` and `AllowAtTokenAtStartOfString` in MCAsmInfo.h which will encapsulate the previously documented behaviour of "allowing $, @, ? characters at the start of symbol names")
- Introduce these fields where "$", "@" are lexed, and treat them as identifiers depending on whether `Allow[Dollar|At]TokenAtStartOfString` is set.
- For the sole case of "?", append it to the existing logic for treating a "default" token as an Identifier.

z/OS (HLASM) will also make use of some of these fields in follow up patches.

completely accurate* - This was based on the comments and the intended behaviour the code. I might have completely misinterpreted it, and if that is the case my sincere apologies. We can close this patch if necessary, if there are no changes to be made :)

Depends on https://reviews.llvm.org/D99374

Reviewed By: Jonathan.Crowther

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

3 years ago[mlir][NFC] Refactor linalg substituteMin and AffineMinSCF canonizalizations
thomasraoux [Wed, 21 Apr 2021 14:02:17 +0000 (07:02 -0700)]
[mlir][NFC] Refactor linalg substituteMin and AffineMinSCF canonizalizations

Break up the dependency between SCF ops and substituteMin helper and make a
more generic version of AffineMinSCFCanonicalization. This reduce dependencies
between linalg and SCF and will allow the logic to be used with other kind of
ops. (Like ID ops).

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

3 years ago[Support] Don't include VirtualFileSystem.h in CommandLine.h
Nico Weber [Wed, 21 Apr 2021 14:00:30 +0000 (10:00 -0400)]
[Support] Don't include VirtualFileSystem.h in CommandLine.h

CommandLine.h is indirectly included in ~50% of TUs when building
clang, and VirtualFileSystem.h is large.

(Already remarked by jhenderson on D70769.)

No behavior change.

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

3 years ago[PhaseOrdering] Add test case for PR45682
Simon Pilgrim [Wed, 21 Apr 2021 14:06:35 +0000 (15:06 +0100)]
[PhaseOrdering] Add test case for PR45682

Ensures that the correct sequence of simplifycfg/instcombine/sroa reduce the IR to just a icmp+assume (which will be dropped in backend)

3 years ago[MC] MCInstrDesc.h - remove unnecessary <string> include. NFCI.
Simon Pilgrim [Wed, 21 Apr 2021 10:42:17 +0000 (11:42 +0100)]
[MC] MCInstrDesc.h - remove unnecessary <string> include. NFCI.

3 years ago[Clang][ARM] Define __VFP_FP__ macro unconditionally
Victor Campos [Mon, 12 Apr 2021 16:03:06 +0000 (17:03 +0100)]
[Clang][ARM] Define __VFP_FP__ macro unconditionally

Clang only defines __VFP_FP__ when the FPU is enabled. However, gcc
defines it unconditionally.

This patch aligns Clang with gcc.

Reviewed By: peter.smith, rengolin

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

3 years ago[SelectionDAG] Fix minor typo in ISDOpcodes.h. NFC
Fraser Cormack [Wed, 21 Apr 2021 13:37:50 +0000 (14:37 +0100)]
[SelectionDAG] Fix minor typo in ISDOpcodes.h. NFC

3 years agoDo not pass null attributes to BuildAttributedStmt during instantiation
Aaron Ballman [Wed, 21 Apr 2021 13:25:00 +0000 (09:25 -0400)]
Do not pass null attributes to BuildAttributedStmt during instantiation

When transforming an attribute during template instantiation, if the
transformation fails, it may result in a null attribute being returned.
This null attribute should not be passed in as one of the attributes
used to create an attributed statement.

If all of the attributes fail to transform, we do not create an
attributed statement at all.

There are no attributes that return null currently, so there is no easy
way to test this currently. However, this fixes a crash caused by
8344675908424ee532d4ae30e5043c5a5834e02c.

3 years ago[libc] Enhance ArrayRef + unittests
Guillaume Chatelet [Wed, 21 Apr 2021 13:25:24 +0000 (13:25 +0000)]
[libc] Enhance ArrayRef + unittests

This patch mostly adds unittests for `ArrayRef` and `MutableArrayRef`, additionnaly:
 - We mimic the behavior of `std::vector` and disallow CV qualified type (`ArrayRef<const X>` is not allowed).
   This is to make sure that the type traits are always valid (e.g. `value_type`, `pointer`, ...).
 - In the previous implementation `ArrayRef` would define `value_type` as `const T` but this is not correct, it should be `T` for both `MutableArrayRef` and `ArrayRef`.
 - We add the `equals` method to ease testing,
 - We define the constructor taking an `Array` outside of the base implementation to ensure we match `const Array<T>&` and not `Array<const T>&` in the case of `ArrayRef`.

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

3 years ago[AArch64][SVE] Fix crash with icmp+select
Caroline Concatto [Mon, 12 Apr 2021 10:22:53 +0000 (11:22 +0100)]
[AArch64][SVE] Fix crash with icmp+select

This patch changes the lowering of SELECT_CC from Legal to Expand for scalable
vector and adds support for scalable vectors in performSelectCombine.

When selecting the nodes to lower in visitSELECT it checks if it is possible to
use SELECT_CC in cases where SETCC is followed by SELECT. visistSELECT checks
if SELECT_CC is legal or custom to replace SELECT by SELECT_CC.
SELECT_CC used to be legal for scalable vector, so the node changes to
SELECT_CC. This used to crash the compiler as there is no support for SELECT_CC
with scalable vectors. So now the compiler lowers to VSELECT instead of
SELECT_CC.

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

3 years agoAMDGPU: Fix indirect tail calls
Matt Arsenault [Tue, 20 Apr 2021 18:44:41 +0000 (14:44 -0400)]
AMDGPU: Fix indirect tail calls

Fix a selection error on uniform callees, and use a regular call if
divergent.

3 years agoSome FormatEntity.cpp cleanup and unit testing
Neal (nealsid) [Wed, 21 Apr 2021 13:11:17 +0000 (15:11 +0200)]
Some FormatEntity.cpp cleanup and unit testing

Just fixing a few things I noticed as I am working on another feature for format
strings in the prompt: forward decls, adding constexpr constructors, various
checks, and unit tests for FormatEntity::Parse and new Definition constructors,
etc.

Reviewed By: teemperor

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

3 years ago[clang] Recognize ppc32 as valid mcpu value
LemonBoy [Wed, 21 Apr 2021 13:08:44 +0000 (15:08 +0200)]
[clang] Recognize ppc32 as valid mcpu value

The `ppc32` cpu model was introduced a while ago in a9321059b912155cd81cf0776d54a7d6838ef7ab as an independent copy of the `ppc` one but was never wired into clang.

Reviewed By: #powerpc, nemanjai

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

3 years agoFix clang/test/Frontend/plugin-annotate-functions.c
John Brawn [Wed, 21 Apr 2021 12:44:54 +0000 (13:44 +0100)]
Fix clang/test/Frontend/plugin-annotate-functions.c

FileCheck now gives an error when there's a check for an undefined
variable, which this test does in one of its NOT checks. Fix this by
being a bit looser in what the test checks.

3 years ago[lld][MachO] Add support for LC_VERSION_MIN_* load commands
Alexander Shaposhnikov [Wed, 21 Apr 2021 12:41:14 +0000 (05:41 -0700)]
[lld][MachO] Add support for LC_VERSION_MIN_* load commands

This diff adds initial support for the legacy LC_VERSION_MIN_* load commands.

Test plan: make check-lld-macho

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

3 years agoReland "[clang-scan-deps] Add support for clang-cl"
Sylvain Audi [Tue, 20 Apr 2021 20:56:49 +0000 (16:56 -0400)]
Reland "[clang-scan-deps] Add support for clang-cl"

This reverts commit 199c39748292cbc89cd148a0d8364ebb1014ec38.
This time, clang-scan-deps's search for output argument in clang-cl command line will now ignore arguments preceded by "-Xclang".
That way, it won't detect a /o argument in "-Xclang -ivfsoverlay -Xclang /opt/subpath"

Initial patch description:
clang-scan-deps contains some command line parsing and modifications.
This patch adds support for clang-cl command options.

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

3 years ago[AArch64] Add and update reverse mask tests. NFC
David Green [Wed, 21 Apr 2021 11:11:41 +0000 (12:11 +0100)]
[AArch64] Add and update reverse mask tests. NFC

3 years ago[OpenCL] Do not add builtins with unavailable types
Sven van Haastregt [Wed, 21 Apr 2021 10:58:37 +0000 (11:58 +0100)]
[OpenCL] Do not add builtins with unavailable types

Add functionality to assign extensions to types in OpenCLBuiltins.td
and use that information to filter candidates that should not be
exposed if a type is not available.

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

3 years ago[OpenCL] Refactor shuffle builtin decls
Sven van Haastregt [Wed, 21 Apr 2021 10:58:29 +0000 (11:58 +0100)]
[OpenCL] Refactor shuffle builtin decls

The shuffle and shuffle2 builtins relied on processing two TypeLists
for different arguments in sync.  This will no longer work when a type
(e.g. double) in one of the TypeLists is optional.

Rewrite the declarations using explicit types instead of GenericTypes.

3 years ago[llvm-rc] Fix a new test to disambiguate macOS paths like /Users/... from options...
Martin Storsjö [Wed, 21 Apr 2021 10:33:13 +0000 (13:33 +0300)]
[llvm-rc] Fix a new test to disambiguate macOS paths like /Users/... from options starting with a slash

This should fix test failures on macOS.

3 years ago[ARM][Driver][Windows] Allow command-line upgrade to Armv8.
Simon Tatham [Wed, 21 Apr 2021 10:19:37 +0000 (11:19 +0100)]
[ARM][Driver][Windows] Allow command-line upgrade to Armv8.

If you gave clang the options `--target=arm-pc-windows-msvc` and
`-march=armv8-a+crypto` together, the crypto extension would not be
enabled in the compilation, and you'd see the following warning
message suggesting that the 'armv8-a' had been ignored:

  clang: warning: ignoring extension 'crypto' because the 'armv7-a' architecture does not support it [-Winvalid-command-line-argument]

This happens because Triple::getARMCPUForArch(), for the Win32 OS,
unconditionally returns "cortex-a9" (an Armv7 CPU) regardless of
MArch, which overrides the architecture setting on the command line.

I don't think that the combination of Windows and AArch32 _should_
unconditionally outlaw the use of the crypto extension. MSVC itself
doesn't think so: you can perfectly well compile Thumb crypto code
using its AArch32-targeted compiler.

All the other default CPUs in the same switch statement are
conditional on a particular MArch setting; this is the only one that
returns a particular CPU _regardless_ of MArch. So I've fixed this one
by adding a condition, so that if you ask for an architecture *above*
v7, the default of Cortex-A9 no longer overrides it.

Reviewed By: mstorsjo

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

3 years ago[lldb] [MainLoop] Support multiple callbacks per signal
Michał Górny [Tue, 13 Apr 2021 22:54:08 +0000 (00:54 +0200)]
[lldb] [MainLoop] Support multiple callbacks per signal

Support registering multiple callbacks for a single signal.  This is
necessary to support multiple co-existing native process instances, with
separate SIGCHLD handlers.

The system signal handler is registered on first request, additional
callback are added on subsequent requests.  The system signal handler
is removed when last callback is unregistered.

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

3 years ago[DAG] TargetLowering.cpp - breakup if-else chains where each block returns. NFCI.
Simon Pilgrim [Wed, 21 Apr 2021 10:17:01 +0000 (11:17 +0100)]
[DAG] TargetLowering.cpp - breakup if-else chains where each block returns. NFCI.

Match style guide that requests that if+return blocks are separate.

3 years ago[DAGCombiner] Support all-ones/all-zeros SPLAT_VECTOR in more combines
Fraser Cormack [Tue, 20 Apr 2021 13:30:27 +0000 (14:30 +0100)]
[DAGCombiner] Support all-ones/all-zeros SPLAT_VECTOR in more combines

This patch adds incrementally-better support for SPLAT_VECTOR in a
handful of vector combines by changing a few more
isBuildVectorAllOnes/isBuildVectorAllZeros to the equivalent
isConstantSplatVectorAllOnes/Zeros calls.

Reviewed By: paulwalker-arm

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

3 years ago[RISCV] Further fixes for RVV stack offset computation
Fraser Cormack [Tue, 20 Apr 2021 10:41:32 +0000 (11:41 +0100)]
[RISCV] Further fixes for RVV stack offset computation

This patch fixes a case missed out by D100574, in which RVV scalable
stack offset computations may require three live registers in the case
where the offset's fixed component is 12 bits or larger and has a
scalable component.

Instead of adding an additional emergency spill slot, this patch further
optimizes the scalable stack offset computation sequences to reduce
register usage.

By emitting the sequence to compute the scalable component before the
fixed component, we can free up one scratch register to be reallocated
by the sequence for the fixed component. Doing this saves one register
and thus one additional emergency spill slot.

Compare:

    $x5 = LUI 1
    $x1 = ADDIW killed $x5, -1896
    $x1 = ADD $x2, killed $x1
    $x5 = PseudoReadVLENB
    $x6 = ADDI $x0, 50
    $x5 = MUL killed $x5, killed $x6
    $x1 = ADD killed $x1, killed $x5

versus:

    $x5 = PseudoReadVLENB
    $x1 = ADDI $x0, 50
    $x5 = MUL killed $x5, killed $x1
    $x1 = LUI 1
    $x1 = ADDIW killed $x1, -1896
    $x1 = ADD $x2, killed $x1
    $x1 = ADD killed $x1, killed $x5

Reviewed By: HsiangKai

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

3 years ago[llvm-rc] Try to fix the Preprocessor/llvm-rc.rc test on non arm/x86 architectures
Martin Storsjö [Wed, 21 Apr 2021 09:40:39 +0000 (12:40 +0300)]
[llvm-rc] Try to fix the Preprocessor/llvm-rc.rc test on non arm/x86 architectures

When llvm-rc invokes clang for preprocessing, it uses a target
triple derived from the default target. The test verifies that
e.g. _WIN32 is defined when preprocessing.

If running clang with e.g. -target ppc64le-windows-msvc, that
particular arch/OS combination isn't hooked up, so _WIN32 doesn't
get defined in that configuration. Therefore, the preprocessing
test fails.

Instead make llvm-rc inspect the architecture of the default target.
If it's one of the known supported architectures, use it as such,
otherwise set a default one (x86_64). (Clang can run preprocessing
with an x86_64 target triple, even if the x86 backend isn't
enabled.)

Also remove superfluous llvm:: specifications on enums in llvm-rc.cpp.

3 years ago[flang][driver] Add support for `-fget-definition`
Andrzej Warzynski [Wed, 14 Apr 2021 10:43:14 +0000 (10:43 +0000)]
[flang][driver] Add support for `-fget-definition`

This patch adds `-fget-definition` to `flang-new`. The semantics of this
option are identical in both drivers. The error message in the
"throwaway" driver is updated so that it matches the one from
`flang-new` (which is auto-generated and cannot be changed easily).

Tests are updated accordingly. A dedicated test for error handling was
added: get-definition.f90 (for the sake of simplicity,
getdefinition01.f90 no longer tests for errors).

The `ParseFrontendArgs` function is updated so that it can return
errors. This change is required in order to report invalid values
following `-fget-definition`.

The actual implementation of `GetDefinitionAction::ExecuteAction()` was
extracted from f18.cpp (i.e. the bit that deals with
`-fget-definition`).

Depends on: https://reviews.llvm.org/D100556

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

3 years ago[lldb/ELF] Fix IDs of synthetic eh_frame symbols
Pavel Labath [Sat, 17 Apr 2021 16:31:17 +0000 (18:31 +0200)]
[lldb/ELF] Fix IDs of synthetic eh_frame symbols

The code used the total number of symbols to create a symbol ID for the
synthetic symbols. This is not correct because the IDs of real symbols
can be higher than their total number, as we do not add all symbols (and
in particular, we never add symbol zero, which is not a real symbol).

This meant we could have symbols with duplicate IDs, which caused
problems if some relocations were referring to the duplicated IDs. This
was the cause of the failure of the test D97786.

This patch fixes the code to use the ID of the highest (last) symbol
instead.

3 years ago[mlir] Assume terminators in nested regions are always legal in FuncBufferizePass
Butygin [Sat, 10 Apr 2021 16:38:11 +0000 (19:38 +0300)]
[mlir] Assume terminators in nested regions are always legal in FuncBufferizePass

Previously, any terminator without ReturnLike and BranchOpInterface traits (e.g. scf.condition) were causing pass to fail.

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

3 years ago[llvm-rc] Run clang to preprocess input files
Martin Storsjö [Wed, 14 Apr 2021 13:24:30 +0000 (16:24 +0300)]
[llvm-rc] Run clang to preprocess input files

Allow opting out from preprocessing with a command line argument.

Update tests to pass -no-preprocess to make it not try to use clang
(which isn't a build level dependency of llvm-rc), but add a test that
does preprocessing under clang/test/Preprocessor.

Update a few options to allow them both joined (as -DFOO) and separate
(-D BR), as rc.exe allows both forms of them.

With the verbose flag set, this prints the preprocessing command
used (which differs from what rc.exe does).

Tests under llvm/test/tools/llvm-rc only test constructing the
preprocessor commands, while tests under clang/test/Preprocessor test
actually running the preprocessor.

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

3 years ago[llvm-cvtres] Reduce the set of dependencies of llvm-cvtres. NFC.
Martin Storsjö [Thu, 15 Apr 2021 11:01:06 +0000 (14:01 +0300)]
[llvm-cvtres] Reduce the set of dependencies of llvm-cvtres. NFC.

Don't use createBinary() but call the WindowsResource class directly.
The createBinary() function references all supported object file
types and ends up pulling way more from all the underlying libraries
than what is necessary.

This shrinks a stripped llvm-cvtres from 4.6 MB to 463 KB.

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

3 years ago[RISCV][Clang] Add RVV AMO builtins
ShihPo Hung [Wed, 21 Apr 2021 08:48:02 +0000 (01:48 -0700)]
[RISCV][Clang] Add RVV AMO builtins

Add vamo[swap/add/xor/and/or/min/max/minu/maxu] builtins.

Reviewed By: khchen

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

3 years ago[AArch64] Add instruction costs for FP_TO_UINT and FP_TO_SINT with half types
David Sherwood [Tue, 6 Apr 2021 10:06:58 +0000 (11:06 +0100)]
[AArch64] Add instruction costs for FP_TO_UINT and FP_TO_SINT with half types

We were missing some instruction costs when converting vectors of
floating point half types into integers, so I've added those here.
I also manually generated assembly code for each FP->int case and
looked at the number of instructions generated, which meant
adjusting some of the existing costs too.

I've updated an existing test to reflect the new costs:

  Analysis/CostModel/AArch64/sve-fptoi.ll

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

3 years ago[NFC] fixed link in documentation
Christian Kühnel [Wed, 21 Apr 2021 08:17:03 +0000 (10:17 +0200)]
[NFC] fixed link in documentation

3 years agoRevert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"
Pushpinder Singh [Wed, 21 Apr 2021 08:05:13 +0000 (08:05 +0000)]
Revert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"

This reverts commit 3194761d2763a471dc6426a3e77c1445cb9ded3b.

3 years ago[lld][ELF] Fix "enumeral and non-enumeral type in conditional expression" warning...
Yang Fan [Wed, 21 Apr 2021 08:00:57 +0000 (16:00 +0800)]
[lld][ELF] Fix "enumeral and non-enumeral type in conditional expression" warning (NFC)

GCC warning:
```
/llvm-project/lld/ELF/SyntheticSections.cpp: In member function ‘virtual void lld::elf::VersionTableSection::writeTo(uint8_t*)’:
/llvm-project/lld/ELF/SyntheticSections.cpp:3128:34: warning: enumeral and non-enumeral type in conditional expression [-Wextra]
 3128 |     write16(buf, s.sym->isLazy() ? VER_NDX_GLOBAL : s.sym->versionId);
      |                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

3 years ago[SCEV] Fix -Wunused-variable warning (NFC)
Yang Fan [Wed, 21 Apr 2021 07:45:25 +0000 (15:45 +0800)]
[SCEV] Fix -Wunused-variable warning (NFC)

GCC warning:
```
/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp: In member function ‘const llvm::SCEV* llvm::ScalarEvolution::getLosslessPtrToIntExpr(const llvm::SCEV*, unsigned int)::SCEVPtrToIntSinkingRewriter::visitUnknown(const llvm::SCEVUnknown*)’:
/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:1152:13: warning: unused variable ‘ExprPtrTy’ [-Wunused-variable]
 1152 |       Type *ExprPtrTy = Expr->getType();
      |             ^~~~~~~~~
```

3 years agoadded section on CI system
Christian Kühnel [Wed, 24 Feb 2021 13:44:37 +0000 (14:44 +0100)]
added section on CI system

Add documentation for working with the CI systems.

This is based on the discussion in the Infrastructure Working Group:
https://github.com/ChristianKuehnel/iwg-workspace/issues/37

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

3 years agoRevert "[InstSimplify] Bypass no-op `and`-mask, using known bits (PR49543)"
Nikita Popov [Wed, 21 Apr 2021 07:44:54 +0000 (09:44 +0200)]
Revert "[InstSimplify] Bypass no-op `and`-mask, using known bits (PR49543)"

This reverts commit ea1a0d7c9ae3e5232a4163fc67efad4aabd51f2b.

While this is strictly more powerful, it is also strictly slower.
InstSimplify intentionally does not perform many folds that it
is allowed to perform, if doing so requires a KnownBits calculation
that will be repeated in InstCombine.

Maybe it's worthwhile to do this here, but that needs a more
explicitly stated motivation, evaluated in a review.

3 years ago[Docs] Fix formatting issue for llvm.experimental.stepvector in LangRef
David Sherwood [Tue, 20 Apr 2021 16:23:18 +0000 (17:23 +0100)]
[Docs] Fix formatting issue for llvm.experimental.stepvector in LangRef

The llvm.experimental.stepvector section was missing the '^^^' line
underneath the intrinsic name.

3 years ago[RISCV][MC] Mask load should not have VMConstraint.
Zakk Chen [Fri, 9 Apr 2021 05:21:04 +0000 (22:21 -0700)]
[RISCV][MC] Mask load should not have VMConstraint.

Add a test, dest register could be v0.

Reviewed By: HsiangKai

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

3 years ago[mlir][linalg] adapt named op generalization to work with captures.
Tobias Gysi [Wed, 21 Apr 2021 06:37:18 +0000 (06:37 +0000)]
[mlir][linalg] adapt named op generalization to work with captures.

Instead of always running the region builder check if the generalized op has a region attached. If yes inline the existing region instead of calling the region builder. This change circumvents a problem with named operations that have a region builder taking captures and the generalization pass not knowing about this captures.

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

3 years ago[PollyACC] Configure PollyPPCG only if needed.
Michael Kruse [Wed, 21 Apr 2021 05:40:47 +0000 (00:40 -0500)]
[PollyACC] Configure PollyPPCG only if needed.

The PollyPPCG library is only needed when POLLY_ENABLE_GPGPU_CODEGEN=ON.
If disabled, the library target is still created, but not linked against
anything.

This change does not add create the PollyPPCG build target if not
needed.

Motivated by llvm.org/PR50021

3 years ago[PollyACC] Fix implicit function definitions. NFC.
Michael Kruse [Wed, 21 Apr 2021 05:09:53 +0000 (00:09 -0500)]
[PollyACC] Fix implicit function definitions. NFC.

The isl_id_* have been in used without including the correspodning
isl/id.h header. According to rules in C, a function is defined
implicitly when first used with an assumed int return type (32 bits on
64 bit systems). But the implementation returns a pointer (64 bits on 64
bit systems). Is usually has no consequence because the return value is
stored in a registers that is 64 bits (RAX) and the optimizer does not
truncate its value before using it again as a pointer value. However,
LTO optimizers will be rightfull;y confused.

Fix by including <isl/id.h>

This fixes llvm.org/PR50021

3 years ago[libc] Add fma to the C standard spec.
Siva Chandra Reddy [Wed, 21 Apr 2021 04:52:55 +0000 (04:52 +0000)]
[libc] Add fma to the C standard spec.

3 years ago[RISCV] Introduce floating point control and state registers
Serge Pavlov [Fri, 19 Mar 2021 13:10:01 +0000 (20:10 +0700)]
[RISCV] Introduce floating point control and state registers

New registers FRM, FFLAGS and FCSR was defined. They represent
corresponding system registers. The new registers are necessary to
properly order floating point instructions in non-default modes.

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

3 years agoUse SmallVector instead of std::vector to manage storage of llvm::BitVector
serge-sans-paille [Mon, 19 Apr 2021 08:14:21 +0000 (10:14 +0200)]
Use SmallVector instead of std::vector to manage storage of llvm::BitVector

This is a follow-up to https://reviews.llvm.org/D100387.

std::vector is not the best storage container here. My local benchmark (counting
the number of instruction when compiling the sqlite3 amalgamation) yields the
following:

- std::vector<BitVector> -> 5,860,885,896
- SmallVector<BitWord, 0> -> 5,858,991,997
- SmallVector<BitWord> -> 5,817,679,224

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

3 years ago[NFC] Remove redundant InstCombinePass name
Arthur Eubanks [Wed, 21 Apr 2021 05:22:42 +0000 (22:22 -0700)]
[NFC] Remove redundant InstCombinePass name

3 years ago[Test] Add a negative unit test
Max Kazantsev [Wed, 21 Apr 2021 05:10:07 +0000 (12:10 +0700)]
[Test] Add a negative unit test

3 years ago[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed
Pushpinder Singh [Mon, 19 Apr 2021 07:12:48 +0000 (07:12 +0000)]
[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

This patch adds new clang tool named amdgpu-arch which uses
HSA to detect installed AMDGPU and report back latter's march.
This tool is built only if system has HSA installed.

The value printed by amdgpu-arch is used to fill -march when
latter is not explicitly provided in -Xopenmp-target.

Reviewed By: JonChesterfield, gregrodgers

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

3 years ago[libc] Disable fma and fmaf for x86_64.
Siva Chandra Reddy [Wed, 21 Apr 2021 04:58:56 +0000 (04:58 +0000)]
[libc] Disable fma and fmaf for x86_64.

The version of clang installed on the buildbot workers is not able to
compile them. However, the version of gcc installed is able to compile
them fine. So, this change disables them until we can find a way to
compile them using clang on the buildbot workers.

3 years ago[lsan] Test to show lsan dependency on globals
Vitaly Buka [Tue, 20 Apr 2021 22:56:27 +0000 (15:56 -0700)]
[lsan] Test to show lsan dependency on globals

This test from @MaskRay comment on D69428. The patch is looking to
break this behavior. If we go with D69428 I hope we will have some
workaround for this test or include explicit test update into the patch.

Reviewed By: MaskRay

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

3 years ago[lldb] Simplify check for nill value in breakpoint_function_callback.test
Jonas Devlieghere [Wed, 21 Apr 2021 04:53:09 +0000 (21:53 -0700)]
[lldb] Simplify check for nill value in breakpoint_function_callback.test

3 years ago[NFC][CSKY] Resort the instruction description in td
Zi Xuan Wu [Wed, 21 Apr 2021 04:36:07 +0000 (12:36 +0800)]
[NFC][CSKY] Resort the instruction description in td

Resort the instruction description in td to make it easy to upstream more instructions and add predicts later.

3 years ago[libc] Add hardware implementations of fma and fmaf for x86_64 and aarch64.
Siva Chandra [Tue, 20 Apr 2021 04:06:25 +0000 (04:06 +0000)]
[libc] Add hardware implementations of fma and fmaf for x86_64 and aarch64.

The current generic implementation of the fmaf function has been moved
to the FPUtil directory. This allows one use the fma operation from
implementations of other math functions like the trignometric functions
without depending on/requiring the fma/fmaf/fmal function targets. If
this pattern ends being convenient, we will switch all generic math
implementations to this pattern.

Reviewed By: lntue

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

3 years agoRevert "[Driver] Support default libc++ library location on Darwin"
Jonas Devlieghere [Wed, 21 Apr 2021 03:42:26 +0000 (20:42 -0700)]
Revert "[Driver] Support default libc++ library location on Darwin"

This reverts the following commits because it breaks
TestAppleSimulatorOSType.py on GreenDragon [1].

caff17e503fe81d69e90dd69b14f5149659f9db4
f5efe0aa048b2bd3363b3a53efe9ae7367244801
ae8b2cab67408a043a4fe964d16e4803553c4ee0

[1] http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/31346/

3 years ago[X86] Support some missing intrinsics
Liu, Chen3 [Wed, 21 Apr 2021 02:50:33 +0000 (10:50 +0800)]
[X86] Support some missing intrinsics

Support for _mm512_i32logather_pd, _mm512_mask_i32logather_pd,
_mm512_i32logather_epi64, _mm512_mask_i32logather_epi64, _mm512_i32loscatter_pd,
_mm512_mask_i32loscatter_pd, _mm512_i32loscatter_epi64,
_mm512_mask_i32loscatter_epi64.

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

3 years ago[RISCV] Add missing SEW=64 tests to vmslt-rv32.ll. NFC
Craig Topper [Wed, 21 Apr 2021 01:31:12 +0000 (18:31 -0700)]
[RISCV] Add missing SEW=64 tests to vmslt-rv32.ll. NFC

3 years ago[mlir] Support hoisting whole affine for loops in LICM
Amy Zhuang [Wed, 21 Apr 2021 00:09:15 +0000 (17:09 -0700)]
[mlir] Support hoisting whole affine for loops in LICM

Reviewed By: bondhugula

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

3 years ago[dfsan] Enable origin tracking with fast8 mode
George Balatsouras [Tue, 20 Apr 2021 22:31:58 +0000 (15:31 -0700)]
[dfsan] Enable origin tracking with fast8 mode

All related instrumentation tests have been updated.

Reviewed By: stephan.yichao.zhao

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

3 years ago[sanitizer] Fix glibc sparc build and add GetTls support
Fangrui Song [Wed, 21 Apr 2021 00:42:41 +0000 (17:42 -0700)]
[sanitizer] Fix glibc sparc build and add GetTls support

sanitizer_linux_libcdep.cpp doesn't build for Linux sparc (with minimum support
but can build) after D98926. I wasn't aware because the file didn't mention
`__sparc__`.

While here, add the relevant support since it does not add complexity
(the D99566 approach).  Adds an explicit `#error` for unsupported
non-Android Linux and FreeBSD architectures.

ThreadDescriptorSize is only used by lsan to scan thread-specific data keys in
the thread control block.

On TLS Variant II architectures (i386/x86_64/s390/sparc), our dl_iterate_phdr
based approach can cover the region from the first byte of the static TLS block
(static TLS surplus) to the thread pointer.
We just need to extend the range to include the first few members of struct
pthread. offsetof(struct pthread, specific_used) satisfies the requirement and
has not changed since 2007-05-10. We don't need to update ThreadDescriptorSize
for each glibc version.

Technically we could use the 524/1552 for x86_64 as well but there is potential
risk that large applications with thousands of shared object dependency may
dislike the time complexity increase if there are many threads, so I don't make
the simplification for now.

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

3 years agoMake sure PHIElimination doesn't copy debug locations across basic blocks.
Adrian Prantl [Tue, 20 Apr 2021 20:26:40 +0000 (13:26 -0700)]
Make sure PHIElimination doesn't copy debug locations across basic blocks.

PHIElimination may insert copy instructions in multiple basic
blocks. Moving debug locations across basic block boundaries would be
misleading as illustrated by the test case.

rdar://75463656

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

3 years ago[WebAssembly] Update README. NFC.
Sam Clegg [Tue, 20 Apr 2021 20:47:02 +0000 (13:47 -0700)]
[WebAssembly] Update README. NFC.

This is just a cleanup of the very high level stuff.  I'm sure there is
more to update here but I'll leave that to others and/or a followup.

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

3 years ago[lld-macho] Skip platform checks for a few libSystem re-exports
Jez Ng [Tue, 20 Apr 2021 23:54:41 +0000 (19:54 -0400)]
[lld-macho] Skip platform checks for a few libSystem re-exports

XCode 12 ships with mismatched platforms for these libraries,
so this hack is necessary...

Fixes PR49799.

Reviewed By: #lld-macho, gkm, smeenai

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

3 years ago[FuncAttrs] Always preserve FunctionAnalysisManagerCGSCCProxy
Arthur Eubanks [Tue, 20 Apr 2021 22:04:41 +0000 (15:04 -0700)]
[FuncAttrs] Always preserve FunctionAnalysisManagerCGSCCProxy

FunctionAnalysisManagerCGSCCProxy should not be preserved if any of its
keys may be invalid. Since we are not removing/adding functions in
FuncAttrs, it's fine to preserve it.

Reviewed By: asbirlea

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

3 years ago[CMake][llvm] avoid changing global flags (may be used outside of llvm)
Jim Radford [Tue, 20 Apr 2021 23:03:53 +0000 (16:03 -0700)]
[CMake][llvm] avoid changing global flags (may be used outside of llvm)

Changing global flags can break builds of projects that include/build
llvm as a sub-project, as the effect is global. Ideally we would
disable this warning at the directory level instead, but the obvious
way (disabling warning D9025) isn't supported. At least we can limit
the effect to only MSVC.

Patch by Jim Radford.

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

3 years agoRevert "[InstCombine] Recognize `((x * y) s/ x) !=/== y` as an signed multiplication...
Reid Kleckner [Tue, 20 Apr 2021 22:53:34 +0000 (15:53 -0700)]
Revert "[InstCombine] Recognize `((x * y) s/ x) !=/== y` as an signed multiplication overflow check (PR48769)"

This reverts commit 13ec913bdf500e2354cc55bf29e2f5d99e0c709e.

This commit introduces new uses of the overflow checking intrinsics that
depend on implementations in compiler-rt, which Windows users generally
do not link against. I filed an issue (somewhere) to make clang
auto-link the builtins library to resolve this situation, but until that
happens, it isn't reasonable for the optimizer to introduce new link
time dependencies.

3 years ago[mlir] Disallow broadcast dimensions on TransferWriteOp.
Matthias Springer [Tue, 20 Apr 2021 11:36:55 +0000 (20:36 +0900)]
[mlir] Disallow broadcast dimensions on TransferWriteOp.

The current implementation allows for TransferWriteOps with broadcasts that do not make sense. E.g., a broadcast could write a vector into a single (scalar) memory location, which is effectively the same as writing only the last element of the vector.

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

3 years agoRevert "Allow invokable sub-classes of IntrinsicInst"
Philip Reames [Tue, 20 Apr 2021 22:37:49 +0000 (15:37 -0700)]
Revert "Allow invokable sub-classes of IntrinsicInst"

This reverts commit d87b9b81ccb95217181ce75515c6c68bbb408ca4.

Post commit review raised concerns, reverting while discussion happens.

3 years ago[Clang, builtins] Added aligned_alloc, memalign support
Dávid Bolvanský [Tue, 20 Apr 2021 22:10:52 +0000 (00:10 +0200)]
[Clang, builtins] Added aligned_alloc, memalign support

3 years agoRevert "[InstCombine] `sext(trunc(x)) --> sext(x)` iff trunc is NSW (PR49543)"
Roman Lebedev [Tue, 20 Apr 2021 22:10:10 +0000 (01:10 +0300)]
Revert "[InstCombine] `sext(trunc(x)) --> sext(x)` iff trunc is NSW (PR49543)"

I forgot about the case where we sign-extend to width smaller than the original.

This reverts commit 1e6ca23ab8e350c7bab5d7f93e4d3dee18d180cc.

3 years agoRevert "[InstCombine] "Bypass" NUW trunc of lshr if we are going to sext the result...
Roman Lebedev [Tue, 20 Apr 2021 22:08:59 +0000 (01:08 +0300)]
Revert "[InstCombine] "Bypass" NUW trunc of lshr if we are going to sext the result (PR49543)"

I forgot about the case where we sign-extend to width smaller than the original.

This reverts commit 41b71f718b94c6f12bbaa670e97cabb070308ed2.

3 years agoAllow invokable sub-classes of IntrinsicInst
Philip Reames [Tue, 20 Apr 2021 22:01:55 +0000 (15:01 -0700)]
Allow invokable sub-classes of IntrinsicInst

It used to be that all of our intrinsics were call instructions, but over time, we've added more and more invokable intrinsics. According to the verifier, we're up to 8 right now. As IntrinsicInst is a sub-class of CallInst, this puts us in an awkward spot where the idiomatic means to check for intrinsic has a false negative if the intrinsic is invoked.

This change switches IntrinsicInst from being a sub-class of CallInst to being a subclass of CallBase. This allows invoked intrinsics to be instances of IntrinsicInst, at the cost of requiring a few more casts to CallInst in places where the intrinsic really is known to be a call, not an invoke.

After this lands and has baked for a couple days, planned cleanups:
    Make GCStatepointInst a IntrinsicInst subclass.
    Merge intrinsic handling in InstCombine and use idiomatic visitIntrinsicInst entry point for InstVisitor.
    Do the same in SelectionDAG.
    Do the same in FastISEL.

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

3 years ago[flang][msvc] Fix compilation of RuntimeGtest
Mehdi Chinoune [Tue, 20 Apr 2021 18:52:47 +0000 (12:52 -0600)]
[flang][msvc] Fix compilation of RuntimeGtest

Removes alternate spelling 'not' with '!'.

Reviewed by: ashermancinelli, awarzynski, Meinersbur

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

3 years ago[InstCombine] "Bypass" NUW trunc of lshr if we are going to sext the result (PR49543)
Roman Lebedev [Tue, 20 Apr 2021 21:19:51 +0000 (00:19 +0300)]
[InstCombine] "Bypass" NUW trunc of lshr if we are going to sext the result (PR49543)

This is a more convoluted form of the same pattern "sext of NSW trunc",
but in this case the operand of trunc was a right-shift,
and the truncation chops off just the zero bits that were shifted-in.

3 years ago[NFC][InstCombine] Add tests for sext-of-trunc-nuw-of-lshr (PR49543)
Roman Lebedev [Tue, 20 Apr 2021 21:17:23 +0000 (00:17 +0300)]
[NFC][InstCombine] Add tests for sext-of-trunc-nuw-of-lshr (PR49543)

3 years ago[InstSimplify] Bypass no-op `and`-mask, using known bits (PR49543)
Roman Lebedev [Tue, 20 Apr 2021 19:54:10 +0000 (22:54 +0300)]
[InstSimplify] Bypass no-op `and`-mask, using known bits (PR49543)

We already special-cased a few interesting patterns,
but that is strictly less powerful than using KnownBits.

So instead get the known bits for the operand of `and`,
and iff all the unset bits of the `and`-mask are known to be zeros
in the operand, we can omit said `and`.

3 years ago[NFC][InstSimplify] Add one more test for unneeded 'and'
Roman Lebedev [Tue, 20 Apr 2021 19:47:03 +0000 (22:47 +0300)]
[NFC][InstSimplify] Add one more test for unneeded 'and'

3 years ago[InstCombine] `sext(trunc(x)) --> sext(x)` iff trunc is NSW (PR49543)
Roman Lebedev [Tue, 20 Apr 2021 19:16:11 +0000 (22:16 +0300)]
[InstCombine] `sext(trunc(x)) --> sext(x)` iff trunc is NSW (PR49543)

If we can tell that trunc only chops off sign bits, and not all of them,
then we can simply sign-extend the trunc's source.

3 years ago[NFC][InstCombine] Add test for sign-extending NSW trunc (PR49543)
Roman Lebedev [Tue, 20 Apr 2021 19:11:41 +0000 (22:11 +0300)]
[NFC][InstCombine] Add test for sign-extending NSW trunc (PR49543)

3 years ago[InstCombine] fold shift-of-srem-by-2 to mask+shift
Sanjay Patel [Tue, 20 Apr 2021 20:56:34 +0000 (16:56 -0400)]
[InstCombine] fold shift-of-srem-by-2 to mask+shift

There are several potential srem-by-2 folds
because the result is known {-1,0,1}.

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