platform/upstream/llvm.git
2 years ago[X86][NFC] Use mnemonic tables in validateInstruction 2/4
Amir Ayupov [Tue, 14 Jun 2022 19:07:11 +0000 (12:07 -0700)]
[X86][NFC] Use mnemonic tables in validateInstruction 2/4

Group switch cases by opcode:
- VFCMULCPH
- VFCMULCSH
- VFMULCPH
- VFMULCSH

Reviewed By: craig.topper

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

2 years ago[X86][NFC] Use mnemonic tables in validateInstruction 1/4
Amir Ayupov [Tue, 14 Jun 2022 18:20:36 +0000 (11:20 -0700)]
[X86][NFC] Use mnemonic tables in validateInstruction 1/4

Group switch cases by opcode:
- VFCMADDCPH
- VFCMADDCSH
- VFMADDCPH
- VFMADDCSH

Reviewed By: craig.topper

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

2 years ago[ValueTracking] recognize sub X, (X -nsw Y) as not overflowing
Sanjay Patel [Tue, 14 Jun 2022 18:51:49 +0000 (14:51 -0400)]
[ValueTracking] recognize sub X, (X -nsw Y) as not overflowing

This extends a similar pattern from D125500.
If we know that operand 1 (RHS) of a subtract is itself a
non-overflowing subtract from operand 0 (LHS), then the
final/outer subtract is also non-overflowing:
https://alive2.llvm.org/ce/z/Bqan8v

InstCombine uses this analysis to trigger a narrowing
optimization, so that is what the first changed test shows.

The last test models the motivating case from issue #48013.
In that example, we determine 'nsw' on the first sub from
the srem, then we determine that the 2nd sub can be narrowed,
and that leads to eliminating both subtracts.

This works for unsigned sub too, but I left that out to keep
the patch minimal. If this looks ok, I will follow up with
that change. There are also several missing subtract narrowing
optimizations demonstrated in the tests above the diffs shown
here - those should be handled in InstCombine with another set
of patches.

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

2 years ago[MLIR][Presburger] Fix spellings of attachment
Groverkss [Tue, 14 Jun 2022 18:19:21 +0000 (23:49 +0530)]
[MLIR][Presburger] Fix spellings of attachment

2 years ago[RISCV] Split out subfields in InsertVSETVLI's demanded fields analysis [nfc]
Philip Reames [Tue, 14 Jun 2022 18:31:19 +0000 (11:31 -0700)]
[RISCV] Split out subfields in InsertVSETVLI's demanded fields analysis [nfc]

At the moment, this just gets the infrastructure in place.  Following changes will start using this in non-trivial ways.

2 years ago[mlir][Arith] Implement InferIntRangeInterface for arithmetic ops
Krzysztof Drewniak [Fri, 22 Apr 2022 19:07:59 +0000 (19:07 +0000)]
[mlir][Arith] Implement InferIntRangeInterface for arithmetic ops

Depends on D124023

Reviewed By: Mogball, rriddle

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

2 years ago[flang] Add team_type to num_images intrinsic call
Katherine Rasmussen [Tue, 31 May 2022 20:15:54 +0000 (13:15 -0700)]
[flang] Add team_type to num_images intrinsic call

num_images had previously been added to the list of intrinsics
before the type team_type had been implemented. Now that team_type
is implemented, add the num_images call that has the team argument.
Update the semantics tests for num_images.

Reviewed By: craig.rasmussen

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

2 years ago[libc++] Find a clang-format everybody is happy with
Nikolas Klauser [Tue, 14 Jun 2022 18:09:03 +0000 (20:09 +0200)]
[libc++] Find a clang-format everybody is happy with

We decided that we want to use clang-format for libc++ but we haven't decided yet how the code should be formatted. We should probably discuss things on discord. This PR is mostly to show how the clang-format would look like and to commit to one once we decided on it. I'll remove the `<string>` diff when I commit this PR.

Reviewed By: ldionne

Spies: EricWF, dschuff, krytarowski, fedor.sergeev, aheejin, mstorsjo, phosek, abrachet, libcxx-commits, arichardson

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

2 years ago[libc++] Use explicit module cache path in tests
Alex Brachet [Tue, 14 Jun 2022 18:06:59 +0000 (18:06 +0000)]
[libc++] Use explicit module cache path in tests

For reference, this test creates about 1.5G in the cache
directory. By default this will go to ~/.cache/clang/
which can fill up quick. This changes the test to put the
cache path in lit temp directories. Size considerations
aside it makes sense for tests to be hermetic and not
touch global system state.

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

2 years ago[MLIR][Presburger] Add values to PresburgerSpace
Groverkss [Tue, 14 Jun 2022 17:41:30 +0000 (23:11 +0530)]
[MLIR][Presburger] Add values to PresburgerSpace

This patch allows attaching user information, called "values" to each
identifier. The values are used to carry information along with variables and
are also used to determine if two variables are identical.

This patch is part of a series of patches to allow attaching user information
with variables in Presburger library.

Reviewed By: ftynse

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

2 years ago[NFC][libcxx] Check def of __LONG_DOUBLE_IEEE128__
David Tenty [Fri, 3 Jun 2022 20:33:53 +0000 (16:33 -0400)]
[NFC][libcxx] Check def of __LONG_DOUBLE_IEEE128__

Follow on to https://reviews.llvm.org/D108352, also check for the
definition of __LONG_DOUBLE_128__ before using it (because AIX doesn't
enable it by default).

Reviewed By: xingxue

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

2 years ago[PS5] Use __gxx_personality_v0 for TSan
Paul Robinson [Tue, 14 Jun 2022 17:22:22 +0000 (10:22 -0700)]
[PS5] Use __gxx_personality_v0 for TSan

2 years ago[analyzer][NFC] Replace getLastArg with hasArg when applicable
Balazs Benics [Tue, 14 Jun 2022 17:28:44 +0000 (19:28 +0200)]
[analyzer][NFC] Replace getLastArg with hasArg when applicable

Depends on D126215.

2 years ago[CMake][compiler-rt] Provide a dedicated option for LLVM unwinder
Petr Hosek [Wed, 27 Apr 2022 06:23:53 +0000 (23:23 -0700)]
[CMake][compiler-rt] Provide a dedicated option for LLVM unwinder

This allows configuring LLVM unwinder separately from the C++ library
matching how we configure it in libcxx.

This also applies changes made to libunwind+libcxxabi+libcxx in D113253
to compiler-rt.

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

2 years ago[libcxx][AIX] Enable ABI list checking for XCOFF
Jake Egan [Tue, 14 Jun 2022 17:15:46 +0000 (13:15 -0400)]
[libcxx][AIX] Enable ABI list checking for XCOFF

The existing nm extractors can't dump the loader symbol table information we need to do the ABI checks for XCOFF, so provide an implementation using the system dump utility. We match the symbol name, whether it's defined, it's import/export status, and its storage mapping class.

Reviewed By: #libc, ldionne

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

2 years ago[analyzer][NFC] Remove unused ExprEngine::evalBinOp functions
Balazs Benics [Tue, 14 Jun 2022 17:15:20 +0000 (19:15 +0200)]
[analyzer][NFC] Remove unused ExprEngine::evalBinOp functions

Reviewed By: martong

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

2 years ago[RISCV] Split out getEEWForLoadStore [nfc]
Philip Reames [Tue, 14 Jun 2022 17:07:56 +0000 (10:07 -0700)]
[RISCV] Split out getEEWForLoadStore [nfc]

Mostly about allowing reuse in an upcoming patch, but also makes the code slightly easier to follow.

2 years ago[analyzer][NFC] Substitute the SVal::evalMinus and evalComplement functions
Balazs Benics [Tue, 14 Jun 2022 16:56:43 +0000 (18:56 +0200)]
[analyzer][NFC] Substitute the SVal::evalMinus and evalComplement functions

Depends on D126127

Reviewed By: martong

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

2 years ago[analyzer][NFC] Relocate unary transfer functions
Balazs Benics [Tue, 14 Jun 2022 16:56:43 +0000 (18:56 +0200)]
[analyzer][NFC] Relocate unary transfer functions

This is an initial step of removing the SimpleSValBuilder abstraction. The SValBuilder alone should be enough.

Reviewed By: martong

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

2 years agoremove a duplicated include
Luboš Luňák [Tue, 14 Jun 2022 16:54:52 +0000 (18:54 +0200)]
remove a duplicated include

2 years ago[mlir] Add a generic data-flow analysis framework
Mogball [Mon, 13 Jun 2022 21:54:52 +0000 (21:54 +0000)]
[mlir] Add a generic data-flow analysis framework

This patch introduces a generic data-flow analysis framework to MLIR. The framework implements a fixed-point iteration algorithm and a dependency graph between lattice states and analysis. Lattice states and points are fully extensible to support highly-customizable analyses.

Reviewed By: phisiart, rriddle

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

2 years agofreeze does not change the constant property
Danila Malyutin [Tue, 14 Jun 2022 14:32:15 +0000 (17:32 +0300)]
freeze does not change the constant property

Traverse through freeze when checking if base is constant

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

2 years ago[PowerPC] Fix combine step for shufflevector.
Stefan Pintilie [Tue, 14 Jun 2022 14:27:03 +0000 (09:27 -0500)]
[PowerPC] Fix combine step for shufflevector.

The combine step for shufflevector will sometimes replace undef in the mask
with a defined value. This can cause an infinite loop in some cases as another
combine will then put the undef back in the mask.

This patch fixes the issue so that undefs are not replaced when doing a combine.

Reviewed By: ZarkoCA, amyk, quinnp, saghir

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

2 years ago[mlir][linalg] Add named ops for depthwise 3d convolution
Benjamin Kramer [Mon, 13 Jun 2022 20:03:56 +0000 (22:03 +0200)]
[mlir][linalg] Add named ops for depthwise 3d convolution

Also complete the set by adding a variant of depthwise 1d convolution
with the multiplier != 1.

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

2 years ago[clang] AST/Print: honor AlwaysIncludeTypeForTemplateArgument policy
Matheus Izvekov [Sun, 29 May 2022 23:22:23 +0000 (01:22 +0200)]
[clang] AST/Print: honor AlwaysIncludeTypeForTemplateArgument policy

This redoes D103040 in a way that `AlwaysIncludeTypeForTemplateArgument = false`
policy is honored for printing template specialization types.
This can be seen for example when printing a canonicalized
dependent TemplateSpecializationType which has integral arguments.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: v.g.vassilev

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

2 years ago[AMDGPU] Regenerate MIR checks for image instructions
Jay Foad [Tue, 14 Jun 2022 16:00:13 +0000 (17:00 +0100)]
[AMDGPU] Regenerate MIR checks for image instructions

2 years ago[mlir] fix compiler error due to commit landing race
Alex Zinenko [Tue, 14 Jun 2022 16:04:00 +0000 (18:04 +0200)]
[mlir] fix compiler error due to commit landing race

2 years ago[mlir] Introduce transform.alternatives op
Alex Zinenko [Tue, 14 Jun 2022 15:49:47 +0000 (17:49 +0200)]
[mlir] Introduce transform.alternatives op

Introduce a transform dialect op that allows one to attempt different
transformation sequences on the same piece of payload IR until one of them
succeeds. This op fundamentally expands the scope of possibilities in the
transform dialect that, until now, could only propagate transformation failure,
at least using in-tree operations. This requires a more detailed specification
of the execution model for the transform dialect that now indicates how failure
is handled and propagated.

Transformations described by transform operations now have tri-state results,
with some errors being fundamentally irrecoverable (e.g., generating malformed
IR) and some others being recoverable by containing ops. Existing transform ops
directly implementing the `apply` interface method are updated to produce this
directly. Transform ops with the `TransformEachTransformOpTrait` are currently
considered to produce only irrecoverable failures and will be updated
separately.

Reviewed By: springerm

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

2 years ago[InstCombine] add tests for sub with extended operands; NFC
Sanjay Patel [Mon, 13 Jun 2022 17:38:46 +0000 (13:38 -0400)]
[InstCombine] add tests for sub with extended operands; NFC

2 years ago[inliner] Add per-SCC-pass InlineAdvisor printing option
Jin Xin Ng [Tue, 14 Jun 2022 14:52:36 +0000 (07:52 -0700)]
[inliner] Add per-SCC-pass InlineAdvisor printing option

Adds option to print the contents of the Inline Advisor after each SCC Inliner pass

Reviewed By: mtrofin

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

2 years ago[libc] Guard common macro names
Alex Brachet [Tue, 14 Jun 2022 15:05:16 +0000 (15:05 +0000)]
[libc] Guard common macro names

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

2 years ago[NFC] Remove unused function parameter
Serge Pavlov [Tue, 14 Jun 2022 05:25:35 +0000 (12:25 +0700)]
[NFC] Remove unused function parameter

2 years ago[RISCV] simplify emitVSETVLIs handling of vsetvli xN, phi(), vtype case [NFC]
Philip Reames [Tue, 14 Jun 2022 14:45:40 +0000 (07:45 -0700)]
[RISCV] simplify emitVSETVLIs handling of vsetvli xN, phi(), vtype case [NFC]

This is possibly somewhat subjective, but having an explicitly named flag to track the property required and code structure that more closely matches phase 1/2 of the dataflow seems much easier to read.

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

2 years ago[Diagnostics] Fix inconsistent shift-overflow warnings in C++20
Shivam Gupta [Tue, 14 Jun 2022 12:29:13 +0000 (17:59 +0530)]
[Diagnostics] Fix inconsistent shift-overflow warnings in C++20

This fixes https://github.com/llvm/llvm-project/issues/52873.
Don't warn in C++2A mode (and newer), as signed left shifts
always wrap and never overflow. Ref. -
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1236r1.html.

2 years ago[Libomptarget] Add test config for compiling in LTO-mode
Joseph Huber [Fri, 10 Jun 2022 16:30:19 +0000 (12:30 -0400)]
[Libomptarget] Add test config for compiling in LTO-mode

We are planning on making LTO the default compilation mode for
offloading. In order to make sure it works we should run these tests on
the test suite. AMDGPU already uses the LTO compilation path for its
linking, but in LTO mode it also links the static library late.

Performing LTO requires the static library to be built, if we make the
change this will be a hard requirement and the old bitcode library will
go away. This means users will need to use either a two-step build or a
runtimes build for libomptarget.

Reviewed By: JonChesterfield

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

2 years ago[flang] Avoid losing type parameter information
Valentin Clement [Tue, 14 Jun 2022 13:57:24 +0000 (15:57 +0200)]
[flang] Avoid losing type parameter information

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years agoAdd __config formatting to .git-blame-ignore-revs
Louis Dionne [Tue, 14 Jun 2022 13:52:49 +0000 (09:52 -0400)]
Add __config formatting to .git-blame-ignore-revs

2 years ago[lld-macho] Print the name of functions containing undefined references
Daniel Bertalan [Tue, 14 Jun 2022 13:41:28 +0000 (09:41 -0400)]
[lld-macho] Print the name of functions containing undefined references

The error used to look like this:

  ld64.lld: error: undefined symbol: _foo
  >>> referenced by /path/to/bar.o

Now it displays the name of the function that contains the undefined
reference as well:

  ld64.lld: error: undefined symbol: _foo
  >>> referenced by /path/to/bar.o:(symbol _baz+0x4)

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

2 years ago[NFC][Thumb] Update frame-chain codegen test to use thumbv6m
Lucas Prates [Tue, 14 Jun 2022 13:16:38 +0000 (14:16 +0100)]
[NFC][Thumb] Update frame-chain codegen test to use thumbv6m

The `llvm/test/CodeGen/Thumb/frame-chain.ll`, recently added by D125094,
currently fails when expensive checks are enabled due to a tMOVr
instruction that is only valid from V6 onwards.

The use of the invalid instruction is unrelated to the contents of the
original patch, and continues to be triggered by this test if its
CodeGen changes are reverted, so this patch updates the test to use V6-M
while the issue is not resolved.

2 years ago[AMDGPU] gfx11 support add_f16
Joe Nash [Mon, 13 Jun 2022 20:38:18 +0000 (16:38 -0400)]
[AMDGPU] gfx11 support add_f16

The instruction was skipped in the earlier large patch adding
VOP2, https://reviews.llvm.org/D126917.

Reviewed By: rampitec, #amdgpu

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

2 years agoRevert "[MachineSSAUpdater] compile time improvement in GetValueInMiddleOfBlock"
Serguei Katkov [Tue, 14 Jun 2022 12:58:55 +0000 (19:58 +0700)]
Revert "[MachineSSAUpdater] compile time improvement in GetValueInMiddleOfBlock"

It looks like it causes buildbot failures.
As an example: https://lab.llvm.org/buildbot/#/builders/121/builds/20364

Revert to investigate...

This reverts commit 6bf27918144cb843cf5ae9a93cb5f936730f3cce.

2 years ago[OpenMP] Fix offload packager not writing to temps correctly
Joseph Huber [Mon, 13 Jun 2022 17:41:50 +0000 (13:41 -0400)]
[OpenMP] Fix offload packager not writing to temps correctly

The offloading packager doesn't have a normal offloading kind. This
would result in its output being sent to the executable name when in
save-temps mode. This would then get overwritten by the actual output.
This patch adds specific checks to make sure that it gets the correct
name.

Reviewed By: tra

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

2 years ago[libc++] Remove macros for IBM compiler
Louis Dionne [Mon, 13 Jun 2022 15:21:16 +0000 (11:21 -0400)]
[libc++] Remove macros for IBM compiler

It's not tested or used anymore -- instead a Clang-based compiler is
used on IBM nowadays.

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

2 years ago[AArch64] Add cost tests for fadd reductions with fast math flags.
Vir Narula [Tue, 14 Jun 2022 13:13:12 +0000 (14:13 +0100)]
[AArch64] Add cost tests for fadd reductions with fast math flags.

Add test coverage showing how the costs of fadd reductions is
overestimated at the moment.

Reviewed By: fhahn

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

2 years ago[ARM] Add more opaque pointer gather/scatter tests. NFC
David Green [Tue, 14 Jun 2022 13:08:43 +0000 (14:08 +0100)]
[ARM] Add more opaque pointer gather/scatter tests. NFC

Some of the newly added tests are incorrect, fixed in D127733.

2 years ago[AArch64][SME] Add ldr/str (fill/spill) intrinsics
David Sherwood [Wed, 8 Jun 2022 14:05:10 +0000 (15:05 +0100)]
[AArch64][SME] Add ldr/str (fill/spill) intrinsics

This patch adds implementations for the fill/spill SME ACLE intrinsics:

    @llvm.aarch64.sme.ldr
    @llvm.aarch64.sme.str

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

2 years ago[AMDGPU] Add a GFX11 MCA test
Jay Foad [Tue, 14 Jun 2022 12:39:11 +0000 (13:39 +0100)]
[AMDGPU] Add a GFX11 MCA test

This mostly just tests that DPFP is 1/32 rate on GFX11, instead of 1/16
rate as on GFX10.

2 years ago[flang] Support PDT declaration with initial comp value in internal procedure
Jean Perier [Tue, 14 Jun 2022 12:32:39 +0000 (14:32 +0200)]
[flang] Support PDT declaration with initial comp value in internal procedure

Lowering was crashing with "fatal internal error: node has not been analyzed"
if a PDT with initial component value was defined inside an internal
procedure. This is because the related expression cannot be analyzed
without the component values (which happens at the instatiation).
These expression do not need to be visited (the instantiations, if any
will be). Use the form of GetExpr that tolerates the parse tree expression
to not be analyzed into an evaluate::Expr when looking through the
symbols used in an internal procedure.

Note that the PDTs TODO will then fire (it happens after the PFT
analysis) as expected if the derived type is used.

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

2 years ago[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records
Lucas Prates [Fri, 6 May 2022 09:31:11 +0000 (10:31 +0100)]
[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records

Currently the a AAPCS compliant frame record is not always created for
functions when it should. Although a consistent frame record might not
be required in some cases, there are still scenarios where applications
may want to make use of the call hierarchy made available trough it.

In order to enable the use of AAPCS compliant frame records whilst keep
backwards compatibility, this patch introduces a new command-line option
(`-mframe-chain=[none|aapcs|aapcs+leaf]`) for Aarch32 and Thumb backends.
The option allows users to explicitly select when to use it, and is also
useful to ensure the extra overhead introduced by the frame records is
only introduced when necessary, in particular for Thumb targets.

Reviewed By: efriedma

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

2 years ago[InterleavedLoadComb] Rename uses when inserting new uses.
Florian Hahn [Tue, 14 Jun 2022 12:15:23 +0000 (13:15 +0100)]
[InterleavedLoadComb] Rename uses when inserting new uses.

This fixes a crash due to uses needing to be renamed.

2 years agoRevert "Reland "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder""
Jun Zhang [Tue, 14 Jun 2022 11:52:06 +0000 (19:52 +0800)]
Revert "Reland "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder""

This reverts commit 781ee538da1855876b085989a37ec959e3f2ecd1.

Asan build is still broken :(

2 years ago[analyzer][Casting] Support isa, cast, dyn_cast of SVals
Balazs Benics [Tue, 14 Jun 2022 11:43:04 +0000 (13:43 +0200)]
[analyzer][Casting] Support isa, cast, dyn_cast of SVals

This change specializes the LLVM RTTI mechanism for SVals.
After this change, we can use the well-known `isa`, `cast`, `dyn_cast`.

Examples:

  // SVal V = ...;
  // Loc MyLoc = ...;

  bool IsInteresting = isa<loc::MemRegionVal, loc::GotoLabel>(MyLoc);
  auto MRV = cast<loc::MemRegionVal>(MyLoc);
  Optional<loc::MemRegionVal> MaybeMRV = dyn_cast<loc::MemRegionVal>(V)

The current `SVal::getAs` and `castAs` member functions are redundant at
this point, but I believe that they are still handy.

The member function version is terse and reads left-to-right, which IMO
is a great plus. However, we should probably add a variadic `isa` member
function version to have the same casting API in both cases.

Thanks for the extensive TMP help @bzcheeseman!

Reviewed By: bzcheeseman

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

2 years ago[MachineSSAUpdater] compile time improvement in GetValueInMiddleOfBlock
Serguei Katkov [Thu, 26 May 2022 04:51:36 +0000 (11:51 +0700)]
[MachineSSAUpdater] compile time improvement in GetValueInMiddleOfBlock

GetValueInMiddleOfBlock uses result of GetValueAtEndOfBlockInternal if there is no value
defined for current basic block.

If there is already a value it tries (in this order):

to find single register coming from all predecessors
find existing phi node which matches our incoming registers
build new phi.
The compile time improvement is to use current available value if
it is defined out of current BB or it is a PHI register.
This is due to it can be used in the middle basic block.

Reviewed By: sameerds
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D126523

2 years ago[NFC] Remove dead code
Guillaume Chatelet [Tue, 14 Jun 2022 09:55:55 +0000 (09:55 +0000)]
[NFC] Remove dead code

2 years ago[NFC][Alignment] Use MaybeAlign in CGCleanup/CGExpr
Guillaume Chatelet [Tue, 14 Jun 2022 09:55:27 +0000 (09:55 +0000)]
[NFC][Alignment] Use MaybeAlign in CGCleanup/CGExpr

2 years ago[NFC][Alignment] Use Align in CoroFrame
Guillaume Chatelet [Tue, 14 Jun 2022 09:52:45 +0000 (09:52 +0000)]
[NFC][Alignment] Use Align in CoroFrame

2 years ago[NFC][Alignment] Use Align in SafeStack
Guillaume Chatelet [Tue, 14 Jun 2022 09:50:54 +0000 (09:50 +0000)]
[NFC][Alignment] Use Align in SafeStack

2 years ago[NFC][Alignment] Use Align in shouldAlignPointerArgs
Guillaume Chatelet [Tue, 14 Jun 2022 09:46:14 +0000 (09:46 +0000)]
[NFC][Alignment] Use Align in shouldAlignPointerArgs

2 years ago[NFC][Alignment] use getAlign in AddressSanitizer
Guillaume Chatelet [Tue, 14 Jun 2022 08:45:20 +0000 (08:45 +0000)]
[NFC][Alignment] use getAlign in AddressSanitizer

2 years ago[AMDGPU] Add GFX11 llvm-objdump tests
Jay Foad [Tue, 14 Jun 2022 10:33:09 +0000 (11:33 +0100)]
[AMDGPU] Add GFX11 llvm-objdump tests

2 years agoReland "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder"
Jun Zhang [Tue, 14 Jun 2022 09:36:41 +0000 (17:36 +0800)]
Reland "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder"

This reverts commits:
d3ddc251acae631bf5ab4da13878f7e8b5b5a451
d90eecff5c9e7e9f8263de6cd72d70322400829f

This relands below commit with asan fix:

The intent of this patch is to selectively carry some states over to
the Builder so we won't lose the information of the previous symbols.

This used to be several downstream patches of Cling, it aims to fix
errors in Clang Interpreter when trying to use inline functions.
Before this patch:

clang-repl> inline int foo() { return 42;}
clang-repl> int x = foo();

JIT session error: Symbols not found: [ _Z3foov ]
error: Failed to materialize symbols:
{ (main, { x, $.incr_module_1.__inits.0, __orc_init_func.incr_module_1 }) }

Co-authored-by: Axel Naumann <Axel.Naumann@cern.ch>
Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D127730

2 years ago[AArch64][SME] Add load/store intrinsics
Rosie Sumpter [Mon, 6 Jun 2022 15:06:43 +0000 (16:06 +0100)]
[AArch64][SME] Add load/store intrinsics

This patch adds implementations for the load/store SME ACLE intrinsics:
  - @llvm.aarch64.sme.ld1*
  - @llvm.aarch64.sme.st1*

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

2 years ago[AMDGPU][MC][GFX11] Correct ds_swizzle_b32
Dmitry Preobrazhensky [Tue, 14 Jun 2022 09:56:38 +0000 (12:56 +0300)]
[AMDGPU][MC][GFX11] Correct ds_swizzle_b32

Enable offset parsing.

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

2 years ago[SCEV] Add tests where assumes can be used to improve trip multiple.
Alon Kom [Tue, 14 Jun 2022 09:50:22 +0000 (10:50 +0100)]
[SCEV] Add tests where assumes can be used to improve trip multiple.

Add tests combing assume on trip count divisibility (tc % vf) and minimum values (tc > N).
Github issue #55645

Reviewed By: fhahn

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

2 years ago[lldb] Fix TestDyldExecLinux with xml enabled
Pavel Labath [Tue, 14 Jun 2022 09:38:45 +0000 (11:38 +0200)]
[lldb] Fix TestDyldExecLinux with xml enabled

NativeProcessLinux is not able to properly read libraries-svr4 data when
running with ld.so as the "main" executable. Normally, this is not a big
problem, as it returns an error message, and lldb can fallback to manual
library loading.

Unfortunately, lldb-server also does not clear cached svr4 data on exec,
which means that it does *not* return an error when the application
execs from the "regular" to the "ld.so" mode. Instead it returns
incorrect data (it is missing the main executable) and causes
TestDyldExecLinux to fail (but only when building with xml support
enabled).

This patch makes ensures that cached process data is cleared on exec,
fixing the test. Since TestDyldExecLinux has shown to be sensitive to
the way we read library info, I fork it into two (with svr4 enabled and
disabled).

2 years ago[ConstraintElimination] Support constraints with only const ops.
Florian Hahn [Tue, 14 Jun 2022 09:37:12 +0000 (10:37 +0100)]
[ConstraintElimination] Support constraints with only const ops.

Remove the early exit if both constraints contain no variables. This
restriction is unnecessayr for correctness and removing it simplifies
handling of trivial constant conditions in follow-up changes.

2 years ago[llvm-cxxfilt] Add description for --types in help text
gbreynoo [Tue, 14 Jun 2022 09:32:56 +0000 (10:32 +0100)]
[llvm-cxxfilt] Add description for --types in help text

It appears that in the move to tablegen the description of --types was
lost:
https://reviews.llvm.org/D105605

This change adds the missing description.

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

2 years agoAdd lowering TODO for bindings returning derived types or arrays
Jean Perier [Tue, 14 Jun 2022 08:47:40 +0000 (10:47 +0200)]
Add lowering TODO for bindings returning derived types or arrays

Codegen does not support fir.addressof of functions returning derived
types, arrays are descriptors inside GlobalOp region.

This is because the  abstract-result-opt is required to rewrite such
functions (a hidden argument must be added), but this pass is meant to
run in GlobalOp currently.

Such fir.address_of may be created when lowering procedure pointers
initial value (TODO), or when creating derived type descriptors for
types with bindings.

Add a TODO in lowering until abstract-result-opt is modified to run
on GlobalOp too.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

2 years agoReland "[analyzer] Deprecate the unused 'analyzer-opt-analyze-nested-blocks' cc1...
Balazs Benics [Tue, 14 Jun 2022 08:22:37 +0000 (10:22 +0200)]
Reland "[analyzer] Deprecate the unused 'analyzer-opt-analyze-nested-blocks' cc1 flag"

It was previously reverted by 8406839d1926486de900c7cabeea9f841bd3edf2.

---

This flag was introduced by
https://github.com/llvm/llvm-project/commit/6818991d7165f68fe196922d9e5c6648dd57cc47
    commit 6818991d7165f68fe196922d9e5c6648dd57cc47
    Author: Ted Kremenek <kremenek@apple.com>
    Date:   Mon Dec 7 22:06:12 2009 +0000

  Add clang-cc option '-analyzer-opt-analyze-nested-blocks' to treat
  block literals as an entry point for analyzer checks.

The last reference was removed by this commit:
https://github.com/llvm/llvm-project/commit/5c32dfc5fb1cfcff8ae3671284e17daa8da3a188

    commit 5c32dfc5fb1cfcff8ae3671284e17daa8da3a188
    Author: Anna Zaks <ganna@apple.com>
    Date:   Fri Dec 21 01:19:15 2012 +0000

  [analyzer] Add blocks and ObjC messages to the call graph.
  This paves the road for constructing a better function dependency graph.
  If we analyze a function before the functions it calls and inlines,
  there is more opportunity for optimization.
  Note, we add call edges to the called methods that correspond to
  function definitions (declarations with bodies).

Consequently, we should remove this dead flag.
However, this arises a couple of burning questions.
 - Should the `cc1` frontend still accept this flag - to keep
   tools/users passing this flag directly to `cc1` (which is unsupported,
   unadvertised) working.
 - If we should remain backward compatible, how long?
 - How can we get rid of deprecated and obsolete flags at some point?

Reviewed By: martong

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

2 years ago[Statepoints] FixupStatepoint: Clear isKill flag if COPY is not deleted.
Denis Antrushin [Wed, 8 Jun 2022 13:53:54 +0000 (20:53 +0700)]
[Statepoints] FixupStatepoint: Clear isKill flag if COPY is not deleted.

When spilling CSRs, FixupStatepoint pass does simple copy propagation,
trying to find COPY instruction which defines register being spilled
and spill COPY source instead. I.e., if we have CSR $x and found
  $x = COPY $y
we will spill $y instead.
But we may be unable to delete COPY instruction for some reason.
Then, spill will be inserted after it, adding another use of $y.
If COPY instruction was last use of $y (killed it), after insertion of
the spill it is not, so `isKill` flag must be cleared. We failed to do
so and this patch fixes this issue.

Reviewed By: skatkov

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

2 years ago[analyzer][NFC] Inline AnalyzerOptions::getUserMode()
Balazs Benics [Tue, 14 Jun 2022 07:42:58 +0000 (09:42 +0200)]
[analyzer][NFC] Inline AnalyzerOptions::getUserMode()

When I read the code I found it easier to reason about if `getUserMode`
is inlined. It might be a personal preference though.

Reviewed By: martong

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

2 years agoReland "[analyzer] Deprecate `-analyzer-store region` flag"
Balazs Benics [Tue, 14 Jun 2022 07:20:41 +0000 (09:20 +0200)]
Reland "[analyzer] Deprecate `-analyzer-store region` flag"

I'm trying to remove unused options from the `Analyses.def` file, then
merge the rest of the useful options into the `AnalyzerOptions.def`.
Then make sure one can set these by an `-analyzer-config XXX=YYY` style
flag.
Then surface the `-analyzer-config` to the `clang` frontend;

After all of this, we can pursue the tablegen approach described
https://discourse.llvm.org/t/rfc-tablegen-clang-static-analyzer-engine-options-for-better-documentation/61488

In this patch, I'm proposing flag deprecations.
We should support deprecated analyzer flags for exactly one release. In
this case I'm planning to drop this flag in `clang-16`.

In the clang frontend, now we won't pass this option to the cc1
frontend, rather emit a warning diagnostic reminding the users about
this deprecated flag, which will be turned into error in clang-16.

Unfortunately, I had to remove all the tests referring to this flag,
causing a mass change. I've also added a test for checking this warning.

I've seen that `scan-build` also uses this flag, but I think we should
remove that part only after we turn this into a hard error.

Reviewed By: martong

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

2 years ago[PowerPC] Correct test RUN line. NFC.
Kai Luo [Tue, 14 Jun 2022 06:55:28 +0000 (14:55 +0800)]
[PowerPC] Correct test RUN line. NFC.

2 years ago[lldb] Fix TCPSocket::Connect when getaddrinfo returns multiple addrs
Pavel Labath [Tue, 14 Jun 2022 06:44:48 +0000 (08:44 +0200)]
[lldb] Fix TCPSocket::Connect when getaddrinfo returns multiple addrs

TCPSocket::Connect() calls SocketAddress::GetAddressInfo() and tries to
connect any of them (in a for loop).

This used to work before commit 4f6d3a376c9f("[LLDB] Fix setting of
success in Socket::Close()") https://reviews.llvm.org/D116768.

As a side effect of that commit, TCPSocket can only connect to the first
address returned by SocketAddress::GetAddressInfo().

1. If the attempt to connect to the first address fails,
   TCPSocket::Connect(), calls CLOSE_SOCKET(GetNativeSocket()), which
   closes the fd, but DOES NOT set m_socket to kInvalidSocketValue.
2. On the second attempt, TCPSocket::CreateSocket() calls
   Socket::Close().
3. Socket::Close() proceeds, because IsValid() is true (m_socket was not
   reset on step 1).
4. Socket::Close() calls ::close(m_socket), which fails
5. Since commit 4f6d3a376c9f("[LLDB] Fix setting of success in
   Socket::Close()"), this is error is detected. Socket::Close() returns
   an error.
6. TCPSocket::CreateSocket() therefore returns an error.
7. TCPSocket::Connect() detects the error and continues, skipping the
   second (and the third, fourth...) address.

This commit fixes the problem by changing step 1: by calling
Socket::Close, instead of directly calling close(m_socket), m_socket is
also se to kInvalidSocketValue. On step 3, Socket::Close() is going to
return immediately and, on step 6, TCPSocket::CreateSocket() does not
fail.

How to reproduce this problem:

On my system, getaddrinfo() resolves "localhost" to "::1" (first) and to
"127.0.0.1" (second).

Start a gdbserver that only listens on 127.0.0.1:

```
gdbserver 127.0.0.1:2159 /bin/cat
Process /bin/cat created; pid = 2146709
Listening on port 2159
```

Start lldb and make it connect to "localhost:2159"

```
./bin/lldb
(lldb) gdb-remote localhost:2159
```

Before 4f6d3a376c9f("[LLDB] Fix setting of success in Socket::Close()"),
this used to work. After that commit, it stopped working. This commit
fixes the problem.

Reviewed By: labath

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

2 years ago[NFC] Fix Wswitch warning triggered by 735e6c
Chuanqi Xu [Tue, 14 Jun 2022 06:44:51 +0000 (14:44 +0800)]
[NFC] Fix Wswitch warning triggered by 735e6c

2 years ago[PowerPC][AtomicExpand] Precommit IR tests for D127609. NFC.
Kai Luo [Tue, 14 Jun 2022 06:22:29 +0000 (14:22 +0800)]
[PowerPC][AtomicExpand] Precommit IR tests for D127609. NFC.

2 years ago[Coroutines] Convert coroutine.presplit to enum attr
Chuanqi Xu [Fri, 10 Jun 2022 03:37:09 +0000 (11:37 +0800)]
[Coroutines] Convert coroutine.presplit to enum attr

This is required by @nikic in https://reviews.llvm.org/D127383 to
decrease the cost to check whether a function is a coroutine and this
fixes a FIXME too.

Reviewed By: rjmccall, ezhulenev

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

2 years ago[CodeGen] Remove addSEHCatchHandler and addSEHCleanupHandler (NFC)
Kazu Hirata [Tue, 14 Jun 2022 06:08:49 +0000 (23:08 -0700)]
[CodeGen] Remove addSEHCatchHandler and addSEHCleanupHandler (NFC)

The last uses of these functions are removed on Oct 9, 2015 in commit
14e773500e036de57ed0ca4af6fddc1f8b6767d8.

2 years ago[CodeGen] Remove restrictRef (NFC)
Kazu Hirata [Tue, 14 Jun 2022 06:08:48 +0000 (23:08 -0700)]
[CodeGen] Remove restrictRef (NFC)

The last use was removed on Apr 14, 2017 in commit
4fe9d6c640e81457db1350766bf6dfef118bcacd.

2 years ago[AArch64][NFC] Fix a comment error
zhongyunde [Tue, 14 Jun 2022 05:54:49 +0000 (13:54 +0800)]
[AArch64][NFC] Fix a comment error

Reviewed By: dmgreen

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

2 years ago[mlir][vector] Add pattern to distribute vector reduction to GPU shuffles
Thomas Raoux [Tue, 7 Jun 2022 02:34:35 +0000 (02:34 +0000)]
[mlir][vector] Add pattern to distribute vector reduction to GPU shuffles

Add a pattern to do ad hoc lowering of vector.reduction to a sequence of
warp shuffles. This allow distributing reduction on a warp for GPU targets.
Also add an execution test for warp reduction.

co-authored with @springerm

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

2 years ago[mlir][vector] Add patterns to ppropagate vector distribution
Thomas Raoux [Tue, 14 Jun 2022 04:59:08 +0000 (04:59 +0000)]
[mlir][vector] Add patterns to ppropagate vector distribution

Add patterns to propagate vector distribution and remove dead
arguments. This handles propagation for several vector operations.

recommit after minor bug fix.

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

2 years ago[mlir][ods] Make Attr/Type def accessors match the dialect
Mogball [Tue, 14 Jun 2022 05:04:56 +0000 (05:04 +0000)]
[mlir][ods] Make Attr/Type def accessors match the dialect

The generated attribute and type def accessors are changed to match the setting on the dialect. Most importantly, "prefixed" will now correctly convert snake case to camel case (e.g. `weight_zp` -> `getWeightZp`)

Reviewed By: jpienaar

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

2 years ago[JITLink][ELF][AArch64] Implement R_AARCH64_MOVW_UABS_G*_NC.
Sunho Kim [Tue, 14 Jun 2022 05:06:08 +0000 (14:06 +0900)]
[JITLink][ELF][AArch64] Implement R_AARCH64_MOVW_UABS_G*_NC.

Implements  R_AARCH64_MOVW_UABS_G*_NC fixup edges. These relocation entries can be generated when code is compiled without a PIC flag. With this patch, clang-repl can printf Hello World with ObjectLinkerLayer on aarch64 linux.

Reviewed By: lhames

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

2 years ago[Greedy RegAlloc] Fix the handling of split register in last chance re-coloring.
Serguei Katkov [Wed, 8 Jun 2022 09:21:01 +0000 (16:21 +0700)]
[Greedy RegAlloc] Fix the handling of split register in last chance re-coloring.

This is a fix for https://github.com/llvm/llvm-project/issues/55827.

When register we are trying to re-color is split the original register (we tried to recover)
has no uses after the split. However in rollback actions we assign back physical register to it.
Later it causes different assertions. One of them is in attached test.

This CL fixes this by avoiding assigning physical register back to register which has no usage
or its live interval now is empty.

Reviewed By: arsenm, qcolombet
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D127281

2 years ago[JITLink][AArch64] Implement MoveWide16 generic edge.
Sunho Kim [Tue, 14 Jun 2022 04:50:47 +0000 (13:50 +0900)]
[JITLink][AArch64] Implement MoveWide16 generic edge.

Implements MoveWide16 generic edge kind that can be used to patch MOVZ/MOVK (imm16) instructions.

Reviewed By: lhames

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

2 years ago[libc++][NFC] clang-format <__config>
Nikolas Klauser [Mon, 13 Jun 2022 15:25:23 +0000 (17:25 +0200)]
[libc++][NFC] clang-format <__config>

It's not perfect, but it's a lot better than the status quo.

Reviewed By: ldionne, #libc

Spies: EricWF, aheejin, libcxx-commits, dschuff, krytarowski, fedor.sergeev, mstorsjo, phosek, abrachet

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

2 years ago[Lex] Keep track of skipped preprocessor blocks and advance the lexer directly if...
Argyrios Kyrtzidis [Thu, 9 Jun 2022 05:00:58 +0000 (22:00 -0700)]
[Lex] Keep track of skipped preprocessor blocks and advance the lexer directly if they are revisited

This speeds up preprocessing, specifically for preprocessing the clang sources time is reduced by about -36%,
using measurements on M1Pro with a release+thinLTO build.

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

2 years ago[PowerPC] Update cfence tests to avoid using undef. NFC.
Kai Luo [Tue, 14 Jun 2022 04:44:20 +0000 (12:44 +0800)]
[PowerPC] Update cfence tests to avoid using undef. NFC.

2 years ago[mlir][sparse_tensor] fix windows build
Mogball [Tue, 14 Jun 2022 04:37:07 +0000 (04:37 +0000)]
[mlir][sparse_tensor] fix windows build

2 years ago[mlir] Include attributes in ML program dialect ops def
Jacques Pienaar [Tue, 14 Jun 2022 04:30:59 +0000 (21:30 -0700)]
[mlir] Include attributes in ML program dialect ops def

I considered adding a new dialect top-level file with all ops,
attributes & types included, but didn't see practical benefit to it.

2 years ago[JITLink][AArch64] Lift fixup functions from aarch64.cpp to aarch64.h. (NFC)
Sunho Kim [Tue, 14 Jun 2022 01:58:06 +0000 (10:58 +0900)]
[JITLink][AArch64] Lift fixup functions from aarch64.cpp to aarch64.h. (NFC)

Lift fixup functions from aarch64.cpp to aarch64.h so that they have better chance of getting inlined. Also, adds some comments documenting the purpose of functions.

Reviewed By: sgraenitz

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

2 years ago[JITLink][AArch64] Unify table managers of ELF and MachO.
Sunho Kim [Tue, 14 Jun 2022 01:58:05 +0000 (10:58 +0900)]
[JITLink][AArch64] Unify table managers of ELF and MachO.

Unifies GOT/PLT table managers of ELF and MachO on aarch64 architecture. Additionally, it migrates table managers from PerGraphGOTAndPLTStubsBuilder to generic crtp TableManager.

Reviewed By: lhames

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

2 years ago[mlir][doc] Move pass to passes list and remove redundant doc
Jacques Pienaar [Tue, 14 Jun 2022 04:01:31 +0000 (21:01 -0700)]
[mlir][doc] Move pass to passes list and remove redundant doc

The types are already included in the dialect doc (the attributes is not
properly yet, so retaining).

2 years ago[mlir][Arithmetic] Fold NegF in MulF and DivF.
jacquesguan [Fri, 20 May 2022 06:40:14 +0000 (06:40 +0000)]
[mlir][Arithmetic] Fold NegF in MulF and DivF.

This patch adds the following combination:

mulf(negf(x), negf(y)) -> mulf(x, y)
divf(negf(x), negf(y)) -> divf(x, y)

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

2 years ago[mlir][Vector] Support vectorize to vector.reduction or/and.
jacquesguan [Mon, 6 Jun 2022 09:15:36 +0000 (09:15 +0000)]
[mlir][Vector] Support vectorize to vector.reduction or/and.

This patch supports to vectorize affine.for of ori/andi to vector.reduction or/and.

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

2 years ago[InstCombine] Optimize lshr+shl+and conversion pattern
chenglin.bi [Tue, 14 Jun 2022 03:06:10 +0000 (11:06 +0800)]
[InstCombine] Optimize lshr+shl+and conversion pattern

if `C1` and `C3` are pow2 and `Log2(C3) >= C2`:
    ((C1 >> X) << C2) & C3 -> X == (Log2(C1)+C2-Log2(C3)) ? C3 : 0
https://alive2.llvm.org/ce/z/zvrkKF

Reviewed By: spatel

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

2 years ago[InstCombine] add tests for compare-signs
Chenbing Zheng [Tue, 14 Jun 2022 03:02:18 +0000 (11:02 +0800)]
[InstCombine] add tests for compare-signs

2 years ago[CodeGen] Initialize ISD after 800d222e53dabfe1e242bd06ab70f58c36e768ed
Fangrui Song [Tue, 14 Jun 2022 02:52:21 +0000 (19:52 -0700)]
[CodeGen] Initialize ISD after 800d222e53dabfe1e242bd06ab70f58c36e768ed

In the Intrinsic::fptosi_sat branch, ISD was uninitialized when Tys.empty().

2 years ago[Driver][test] Make ananas.c and solaris-ld.c robust
Fangrui Song [Tue, 14 Jun 2022 02:44:24 +0000 (19:44 -0700)]
[Driver][test] Make ananas.c and solaris-ld.c robust

`{{.*}}crt{{[^.]+}}.o` may match `"-r" "/tmp/lit-tmp-9ur5crtx/solaris-ld-4fa504.o"`
in a lit invocation.