platform/upstream/llvm.git
2 years ago[X86][AMX] combine tile cast and load/store instruction.
Luo, Yuanke [Mon, 25 Apr 2022 11:23:28 +0000 (19:23 +0800)]
[X86][AMX] combine tile cast and load/store instruction.

The `llvm.x86.cast.tile.to.vector` intrinsic is lowered to
`llvm.x86.tilestored64.internal` and `load <256 x i32>`. The
`llvm.x86.cast.vector.to.tile` is lowered to `store <256 x i32>` and
`llvm.x86.tileloadd64.internal`. When `llvm.x86.cast.tile.to.vector` is
used by `store <256 x i32>` or `load <256 x i32>` is used by
`llvm.x86.cast.vector.to.tile`, they can be combined by
`llvm.x86.tilestored64.internal` and `llvm.x86.tileloadd64.internal`.

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

2 years ago[Driver][Solaris] -r: imply -nostdlib like GCC
Brad Smith [Thu, 28 Apr 2022 04:17:48 +0000 (00:17 -0400)]
[Driver][Solaris] -r: imply -nostdlib like GCC

Similar to D116843 for Gnu.cpp

Reviewed By: MaskRay

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

2 years ago[JumpThreading][NFC][CompileTime] Do not recompute BPI/BFI analyzes
Max Kazantsev [Thu, 28 Apr 2022 03:46:08 +0000 (10:46 +0700)]
[JumpThreading][NFC][CompileTime] Do not recompute BPI/BFI analyzes

They can already be available, and even if not, DT/LI can be available.
We should not recompute them. Old PM is unchanged because it would
require changing dependencies, and we don't care enough about it.

Differential Revision: https://reviews.llvm.org/D124439
Reviewed By: nikic, aeubanks

2 years ago[InferAddressSpaces] Check if AS are the same in isNoopPtrIntCastPair
Wenju He [Thu, 28 Apr 2022 02:47:26 +0000 (10:47 +0800)]
[InferAddressSpaces] Check if AS are the same in isNoopPtrIntCastPair

isNoopAddrSpaceCast is expecting SrcAS is different from DestAS.
If the two AS are the same, consider ptrtoint/inttoptr as noop cast.

Reviewed By: arsenm

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

2 years ago[XCORE][CodeGen][NFC] Use ArrayRef in TargetLowering functions
Liqin.Weng [Thu, 28 Apr 2022 02:06:27 +0000 (02:06 +0000)]
[XCORE][CodeGen][NFC] Use ArrayRef in TargetLowering functions

Reviewed By: nigelp-xmos

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

2 years ago[X86] Check the address in machine verifier
Shengchen Kan [Tue, 26 Apr 2022 14:29:09 +0000 (22:29 +0800)]
[X86] Check the address in machine verifier

1. The scale factor must be 1, 2, 4, 8
2. The displacement must fit in 32-bit signed integer

Noticed by: https://github.com/llvm/llvm-project/issues/55091

Reviewed By: pengfei

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

2 years ago[OpaquePtr][GlobalOpt] Don't attempt to evaluate global constructors with arguments
Arthur Eubanks [Wed, 27 Apr 2022 20:44:50 +0000 (13:44 -0700)]
[OpaquePtr][GlobalOpt] Don't attempt to evaluate global constructors with arguments

Previously all entries in global_ctors had to have the void()* type and
we'd skip evaluating bitcasted functions. With opaque pointers we may
see the function directly.

Fixes #55147.

Reviewed By: #opaque-pointers, nikic

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

2 years ago[flang] Add lowering stubs for OpenMP/OpenACC declarative constructs
Peixin-Qiao [Thu, 28 Apr 2022 01:40:30 +0000 (09:40 +0800)]
[flang] Add lowering stubs for OpenMP/OpenACC declarative constructs

This patch provides the basic infrastructure for lowering declarative
constructs for OpenMP and OpenACC.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: kiranchandramohan, shraiysh, clementval

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

2 years agoDrop '* text=auto' from .gitattributes and normalize
Aaron Puchert [Thu, 28 Apr 2022 01:05:09 +0000 (03:05 +0200)]
Drop '* text=auto' from .gitattributes and normalize

Git wants to check in 'text' files with LF endings, so this changes them
in the repository but not in the checkout, where they keep CRLF endings.

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

2 years agoFix test fail-file-open.test on Windows to hopefully fix the Windows buildbots.
Douglas Yung [Thu, 28 Apr 2022 00:28:57 +0000 (17:28 -0700)]
Fix test fail-file-open.test on Windows to hopefully fix the Windows buildbots.

2 years ago[lldb] Fix escaping when launching in terminal with AppleScript
Jonas Devlieghere [Wed, 27 Apr 2022 23:37:42 +0000 (16:37 -0700)]
[lldb] Fix escaping when launching in terminal with AppleScript

Fix escaping when launching in terminal with AppleScript. The invocation
we're building up is wrapped in single quotes when passed to bash and
wrapped in double quotes for AppleScript.

Here's an example invocation with the new escaping:

  tell application "Terminal"
    activate
          do script "/bin/bash -c 'arch -arch arm64 'darwin-debug'
            --unix-socket=/tmp/dL2jSh --arch=arm64 --working-dir
            \"/private/tmp/with spaces\" --disable-aslr --  \"foo\"
            \"bar\" \"baz\" ; echo Process exited with status $?';exit"
  end tell

Previously we were using unescaped single quotes which resulted in the
whole bash invocation being passed in pieces. That works most of the
time but breaks when you have a space in your current working directory
for example.

rdar://91870763

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

2 years ago[dsymutil] Fix memory issue in the BinaryHolder
Jonas Devlieghere [Wed, 27 Apr 2022 23:32:38 +0000 (16:32 -0700)]
[dsymutil] Fix memory issue in the BinaryHolder

The BinaryHolder has two caches for object and archive entries. These
are implemented as StringMaps of ObjectEntry and ArchiveEntry
respectively. The fact that they're stored by value is problematic
because the BinaryHolder hands out references that become invalidate
when the data structure grows. This patch wraps those object instances
in unique pointers and changes the interface to hand out pointers. This
resulted in transient failures.

rdar://90412671

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

2 years ago[LegacyPM] Remove ThreadSanitizerLegacyPass
Fangrui Song [Wed, 27 Apr 2022 23:25:41 +0000 (16:25 -0700)]
[LegacyPM] Remove ThreadSanitizerLegacyPass

Using the legacy PM for the optimization pipeline was deprecated in 13.0.0.
Following recent changes to remove non-core features of the legacy
PM/optimization pipeline, remove ThreadSanitizerLegacyPass.

Reviewed By: #sanitizers, vitalybuka

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

2 years agoRevert "[Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics [2/2]"
Kirill Stoimenov [Wed, 27 Apr 2022 23:10:36 +0000 (23:10 +0000)]
Revert "[Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics [2/2]"

This reverts commit 74273d575f9938d751a1c67862cffe553fe2de8b.

Buildbot: https://lab.llvm.org/buildbot/#/builders/5/builds/22795
Failing with memory leak.

2 years ago[llvm-symbolizer][native-pdb] Don't reset CurLineOffset if NextLineOffset is none
Zequan Wu [Wed, 27 Apr 2022 23:05:09 +0000 (16:05 -0700)]
[llvm-symbolizer][native-pdb] Don't reset CurLineOffset if NextLineOffset is none

2 years agoRevert "BranchFolder: Assert on SSA functions"
Matt Arsenault [Wed, 27 Apr 2022 23:01:24 +0000 (19:01 -0400)]
Revert "BranchFolder: Assert on SSA functions"

This reverts commit 6ff91d17d66da46572e97f9a0b042182762cbe9e.

2 years ago[modules] Merge equivalent extensions and diagnose ivar redeclarations for extensions...
Volodymyr Sapsai [Wed, 2 Mar 2022 04:08:01 +0000 (20:08 -0800)]
[modules] Merge equivalent extensions and diagnose ivar redeclarations for extensions loaded from different modules.

Emitting metadata for the same ivar multiple times can lead to
miscompilations. Objective-C runtime adds offsets to calculate ivar
position in memory and presence of duplicate offsets causes wrong final
position thus overwriting unrelated memory.

Such a situation is impossible with modules disabled as clang diagnoses
ivar redeclarations during sema checks after parsing
(`Sema::ActOnFields`). Fix the case with modules enabled by checking
during deserialization if ivar is already declared. We also support
a use case where the same category ends up in multiple modules. We
don't want to treat this case as ivar redeclaration and instead merge
corresponding ivars.

rdar://83468070

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

2 years agollvm-reduce: Fix incorrect cloning of MachineMemOperands
Matt Arsenault [Tue, 19 Apr 2022 17:51:20 +0000 (13:51 -0400)]
llvm-reduce: Fix incorrect cloning of MachineMemOperands

There were two problems with directly copying the MMOs from the old
function. The MMOs are owned by the function's Allocator, so need to
be reallocated anyways (surprisingly I didn't notice breakage on
this). Second, the PseudoSourceValues are also allocated per function
and need to be reallocated.

2 years agoBranchFolder: Assert on SSA functions
Matt Arsenault [Mon, 25 Apr 2022 12:12:32 +0000 (08:12 -0400)]
BranchFolder: Assert on SSA functions

We probably should have the opposite of getRequiredProperties for this

2 years ago[PS5] Enable dead-stripping globals in ASan
Paul Robinson [Wed, 27 Apr 2022 22:44:22 +0000 (15:44 -0700)]
[PS5] Enable dead-stripping globals in ASan

2 years ago[X86] Move target-generic code into CodeGen [NFC]
Bill Wendling [Wed, 27 Apr 2022 22:37:08 +0000 (15:37 -0700)]
[X86] Move target-generic code into CodeGen [NFC]

This code is the same for all platforms.

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

2 years agollvm-reduce: Fix crashing on file opening error for mir path
Matt Arsenault [Fri, 22 Apr 2022 21:40:25 +0000 (17:40 -0400)]
llvm-reduce: Fix crashing on file opening error for mir path

2 years agollvm-reduce: Support multiple MachineFunctions
Matt Arsenault [Tue, 19 Apr 2022 02:19:57 +0000 (22:19 -0400)]
llvm-reduce: Support multiple MachineFunctions

The current testcase I'm trying to reduce only reproduces with IPRA
enabled and requires handling multiple functions.

The only real difference vs. the IR is the extra indirect to look for
the underlying MachineFunction, so treat the ReduceWorkItem as the
module instead of the function.

The ugliest piece of this is really the ugliness of
MachineModuleInfo. It not only tracks actual module state, but has a
number of transient fields used for isel and/or the asm printer. These
shouldn't do any harm for the use here, though they should be
separated out.

2 years agollvm-reduce: Try to fix test on windows buildbots
Matt Arsenault [Wed, 27 Apr 2022 21:56:46 +0000 (17:56 -0400)]
llvm-reduce: Try to fix test on windows buildbots

2 years ago[flang] Fix MAXLOC/MINLOC when MASK is scalar .FALSE.
Peter Steinfeld [Tue, 26 Apr 2022 22:21:03 +0000 (15:21 -0700)]
[flang] Fix MAXLOC/MINLOC when MASK is scalar .FALSE.

When passing a scalar .FALSE. as the MASK argument to MAXLOC, we were getting
bad memory references.  We were falling into the code intended when the MASK
argument was missing.

I fixed this by checking for a scalar MASK with a .FALSE. value and
setting the result to all zeroes in that case.  I also added tests for
MAXLOC and MINLOC with scalar values of .TRUE. and .FALSE. for the MASK
argument.

I also special cased situations where the MASK argument is a scalar with
a .TRUE. value and passed along a nullptr in such cases.

Along the way, I eliminated the unused "chars" argument from the constructor
for ExtremumLocAccumulator.

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

2 years agollvm-reduce: Try to parse triple/datalayout from module
Matt Arsenault [Mon, 18 Apr 2022 22:57:43 +0000 (18:57 -0400)]
llvm-reduce: Try to parse triple/datalayout from module

This saves needing to specify -mtriple on nearly every use for MIR
reduction.

2 years agoDWP parsing: Use the index by hash when available
David Blaikie [Wed, 27 Apr 2022 21:45:05 +0000 (21:45 +0000)]
DWP parsing: Use the index by hash when available

Rather than looking up by offset - actually use the hash table to
perform faster lookup where possible. (for DWARFv4 DWP compilation units
the hash isn't in the header - it's in the root DIE, but to parse the
DIE you need the abbrev section and to get the abbrev section you need
the index - so in that case lookup by offset is required)

2 years ago[llvm-pdbutil] Add options to only dump symbol record at specified offset and its...
Zequan Wu [Sat, 23 Apr 2022 01:35:00 +0000 (18:35 -0700)]
[llvm-pdbutil] Add options to only dump symbol record at specified offset and its parents or children with spcified depth.

Right now, if we want to dump symbol at specified offset, we need to use `grep`.
And it can only show surrounding symbols in layout (not in lexical scope sense).

This adds similar options to `dump` command as `llvm-dwarfdump` to allow users
to dump symbol record at specified offset and its parents or children with
spcified depth.

`--symbol-offset=` must be used with `--modi` to dump only one symbol at given
offset.

`--show-parents`/`--show-children` must be used with `--symbol-offset` to
dump all symbols that are parents/children of the symbol at given offset.

`--parent-recurse-depth`/`--children-recurse-depth` must be used with
`--show-parents`/`--show-children` to specify the max up/down depth.

Reviewed By: rnk

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

2 years agollvm-reduce: Fix not cloning MachineInstr flags
Matt Arsenault [Wed, 27 Apr 2022 21:15:57 +0000 (17:15 -0400)]
llvm-reduce: Fix not cloning MachineInstr flags

2 years ago[clang-format] Adjust editor cursor position past #include blocks
owenca [Tue, 26 Apr 2022 13:47:36 +0000 (06:47 -0700)]
[clang-format] Adjust editor cursor position past #include blocks

Fixes #55027.

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

2 years agoDebugInfo: Use hash-based unit lookup when available in dwp files
David Blaikie [Wed, 27 Apr 2022 21:17:01 +0000 (21:17 +0000)]
DebugInfo: Use hash-based unit lookup when available in dwp files

Fix a test case that had a bogus (probably I hand crafted it at some
point) index that didn't point to the right data in the process.

2 years ago[PS5] Test sanitizer options/lib names
Paul Robinson [Wed, 27 Apr 2022 20:45:15 +0000 (13:45 -0700)]
[PS5] Test sanitizer options/lib names

The functionality was added in 7726ad0, catching up on the tests now.

2 years ago[SimpleLoopUnswitch] Fix CHECK lines of tests added in 93182c9ff4c.
Florian Hahn [Wed, 27 Apr 2022 20:36:53 +0000 (21:36 +0100)]
[SimpleLoopUnswitch] Fix CHECK lines of tests added in 93182c9ff4c.

When generating the tests I accidentally had some other changes applied.
Fix the CHECK lines for current main.

2 years ago[SimpleLoopUnswitch] Add test cases where freeze of OR/AND cons needed.
Florian Hahn [Wed, 27 Apr 2022 20:19:13 +0000 (21:19 +0100)]
[SimpleLoopUnswitch] Add test cases where freeze of OR/AND cons needed.

Freezing just the result of the AND/OR here is not enough.

2 years ago[X86] setcc.ll - add bmi2 + tbm test coverage
Simon Pilgrim [Wed, 27 Apr 2022 20:09:53 +0000 (21:09 +0100)]
[X86] setcc.ll - add bmi2 + tbm test coverage

As discussed on Issue #55138 - BMI2 (fast shrx) shouldn't always fold to BT

2 years ago[X86] setcc.ll - remove unnecessary cpu attributes
Simon Pilgrim [Wed, 27 Apr 2022 20:06:02 +0000 (21:06 +0100)]
[X86] setcc.ll - remove unnecessary cpu attributes

2 years ago[X86] Add test case for Issue #55138
Simon Pilgrim [Wed, 27 Apr 2022 20:03:47 +0000 (21:03 +0100)]
[X86] Add test case for Issue #55138

2 years ago[X86] Use is128BitLaneRepeatedShuffleMask wrapper. NFC.
Simon Pilgrim [Wed, 27 Apr 2022 20:03:25 +0000 (21:03 +0100)]
[X86] Use is128BitLaneRepeatedShuffleMask wrapper. NFC.

We don't need to know the actual repeated mask.

2 years agoUpdate PGO and 3-stage cache files
Chris Bieneman [Wed, 27 Apr 2022 14:26:56 +0000 (09:26 -0500)]
Update PGO and 3-stage cache files

These files are out of date and haven't been updated to work within the
monorepo. This change updates them appropriately so that they build
using the monorepo build infrastructure.

2 years ago[flang] Downgrade a fatal error to a warning
Peter Klausler [Tue, 26 Apr 2022 20:29:55 +0000 (13:29 -0700)]
[flang] Downgrade a fatal error to a warning

A non-CHARACTER expression in a CASE statement is allowed to have
a distinct kind (not type) from the expression in its SELECT CASE.
If a value in a CASE statement is out of range for the SELECT CASE
type, emit a warning, but it should not be a fatal error.

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

2 years ago[flang] Allow for host association in ConvertTo(Object|Proc)Entity
Peter Klausler [Tue, 26 Apr 2022 20:01:00 +0000 (13:01 -0700)]
[flang] Allow for host association in ConvertTo(Object|Proc)Entity

Name resolution fails with a bogus "is not a variable" error message
when a host-associated object appears in a NAMELIST group.  The root
cause is that ConvertToObjectEntity() returns false for host-associated
objects.  Fix that, and also apply a similar fix to ConvertToProcEntity()
nearby.

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

2 years ago[Darwin][UBSan][Sanitizer] abort_on_error ubsan test fix for arm64
Blue Gaston [Tue, 26 Apr 2022 21:33:08 +0000 (14:33 -0700)]
[Darwin][UBSan][Sanitizer] abort_on_error ubsan test fix for arm64

The current darwin abort_on_error test specifically tests for a division
by zero undefined behavior. However arm does not trap by default for this
behavior. x86 signals the abort, which is why the test passes on x86.
This patch updates the test to test for a case where the ubsan runtime
specifically calls Die() to trigger an abort by default.

rdar://92108564

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

2 years agoRevert "[Driver] Support for compressed debug info on Fuchsia"
Petr Hosek [Wed, 27 Apr 2022 18:41:41 +0000 (11:41 -0700)]
Revert "[Driver] Support for compressed debug info on Fuchsia"

This reverts commit 2d0c897212d0551966b26eae986209ea31c4f032 which
is still breaking on the sanitizer bots.

2 years agollvm-reduce: Fix mangling types of generic registers
Matt Arsenault [Tue, 19 Apr 2022 18:59:32 +0000 (14:59 -0400)]
llvm-reduce: Fix mangling types of generic registers

2 years ago[Driver] Support for compressed debug info on Fuchsia
Petr Hosek [Wed, 17 Nov 2021 19:06:03 +0000 (11:06 -0800)]
[Driver] Support for compressed debug info on Fuchsia

Pass the --compress-debug-sections=zlib argument to the linker when
the use of compressed debug info is requested.

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

2 years agollvm-reduce: Preserve subregisters and other fields for top block def
Matt Arsenault [Tue, 19 Apr 2022 14:15:40 +0000 (10:15 -0400)]
llvm-reduce: Preserve subregisters and other fields for top block def

2 years ago[InstCombine] C0 >> (X - C1) --> (C0 << C1) >> X
Nicolas Abram Lujan [Wed, 27 Apr 2022 17:41:25 +0000 (13:41 -0400)]
[InstCombine] C0 >> (X - C1) --> (C0 << C1) >> X

With the right pre-conditions, we can fold the offset
into the shifted constant:
https://alive2.llvm.org/ce/z/drMRBU
https://alive2.llvm.org/ce/z/cUQv-_

Fixes #55016

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

2 years ago[RISCV] Add isCommutable to scalar FMA instructions.
Craig Topper [Wed, 27 Apr 2022 17:32:54 +0000 (10:32 -0700)]
[RISCV] Add isCommutable to scalar FMA instructions.

The default implementation of findCommutedOpIndices picks the
first two source operands. That's exactly what we want for the
scalar FMA instructions.

Reviewed By: reames

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

2 years ago[InstCombine] Fold strnlen calls in equality to zero.
Martin Sebor [Wed, 27 Apr 2022 18:01:35 +0000 (12:01 -0600)]
[InstCombine] Fold strnlen calls in equality to zero.

Reviewed By: nikic

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

2 years ago[COST]Improve cost model for shuffles in SLP.
Alexey Bataev [Wed, 14 Apr 2021 14:49:32 +0000 (07:49 -0700)]
[COST]Improve cost model for shuffles in SLP.

Introduced masks where they are not added and improved target dependent
cost models to avoid returning of the incorrect cost results after
adding masks.

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

2 years ago[LLDB][NativePDB] Minor fix ParseInlinesite.
Zequan Wu [Wed, 27 Apr 2022 17:46:51 +0000 (10:46 -0700)]
[LLDB][NativePDB] Minor fix ParseInlinesite.

- Don't reset cur_line_offset to llvm::None when we don't have next_line_offset, because we may need to reuse it in new range after a code end.
- Don't use CombineConsecutiveEntriesWithEqualData for inline_site_sp->ranges, because that will combine consecutive entries with same data in the vector regardless of the entry's range. Originally, I thought that it only combine consecutive entries if adjacent entries' ranges are adjoining or intersecting with each other.

2 years ago[lit] Support %if ... %else syntax for RUN lines
Andrew Savonichev [Wed, 27 Apr 2022 16:36:54 +0000 (19:36 +0300)]
[lit] Support %if ... %else syntax for RUN lines

This syntax allows to modify RUN lines based on features
available. For example:

    RUN: ... | FileCheck %s --check-prefix=%if windows %{CHECK-W%} %else %{CHECK-NON-W%}
    CHECK-W: ...
    CHECK-NON-W: ...

The whole command can be put under %if ... %else:

    RUN: %if tool_available %{ %tool %} %else %{ true %}

or:

    RUN: %if tool_available %{ %tool %}

If tool_available feature is missing, we'll have an empty command in
this RUN line.  LIT used to emit an error for empty commands, but now
it treats such commands as nop in all cases.

Multi-line expressions are also supported:

    RUN: %if tool_available %{ \
    RUN:   %tool               \
    RUN: %} %else %{           \
    RUN:   true                \
    RUN: %}

Background and motivation:
D121727 [NVPTX] Integrate ptxas to LIT tests
https://reviews.llvm.org/D121727

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

2 years ago[CHR] Skip region containing llvm.coro.id
Wei Wang [Mon, 25 Apr 2022 21:00:41 +0000 (14:00 -0700)]
[CHR] Skip region containing llvm.coro.id

When a block containing llvm.coro.id is cloned during CHR, it inserts an invalid
PHI node with token type to the beginning of the block containing llvm.coro.begin.
To avoid such case, we exclude regions with llvm.coro.id.

Reviewed By: ChuanqiXu

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

2 years ago[mlir][sparse] optimize COO index handling
Aart Bik [Wed, 27 Apr 2022 04:25:32 +0000 (21:25 -0700)]
[mlir][sparse] optimize COO index handling

By using a shared index pool, we reduce the footprint of each "Element"
in the COO scheme and, in addition, reduce the overhead of allocating
indices (trading many allocations of vectors for allocations in a single
vector only). When the capacity is known, this means *all* allocation
can be done in advance.

This is a big win. For example, reading matrix SK-2005, with dimensions
50,636,154 x 50,636,154 and 1,949,412,601 nonzero elements improves
as follows (time in ms), or about 3.5x faster overall

```
SK-2005 before        after      speedup
  ---------------------------------------------
read     305,086.65    180,318.12    1.69
sort   2,836,096.23    510,492.87    5.56
pack     364,485.67    312,009.96    1.17
  ---------------------------------------------
TOTAL  3,505,668.56  1,002,820.95    3.50
```

Reviewed By: bixia

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

2 years ago[NFC] Renamed /test/Analysis/CostModel/X86/splat-load.ll test and added more checks.
Vasileios Porpodas [Tue, 26 Apr 2022 15:31:19 +0000 (08:31 -0700)]
[NFC] Renamed /test/Analysis/CostModel/X86/splat-load.ll test and added more checks.

Renamed test/Analysis/CostModel/X86/splat-load.ll to shuffle-load.ll
to align it with AArch64's similar test.

Also added a complete list of checks for all vector combinations up to 512-bits.

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

2 years ago[mlir][LLVMIR] Do not cache llvm::Constant into instMap
Min-Yih Hsu [Wed, 20 Apr 2022 17:40:37 +0000 (10:40 -0700)]
[mlir][LLVMIR] Do not cache llvm::Constant into instMap

Constants in MLIR are not globally unique, unlike that in LLVM IR.
Therefore, reusing previous-translated constants might cause the user
operations not being dominated by the constant (because the
previous-translated ones can be placed in arbitrary place)

This indeed misses some opportunities where we actually can reuse a
previous-translated constants, but verbosity is not our first priority
here.

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

2 years ago[mlir][LLVMIR] Do not cache Instruction generated on-the-fly
Min-Yih Hsu [Wed, 20 Apr 2022 17:30:43 +0000 (10:30 -0700)]
[mlir][LLVMIR] Do not cache Instruction generated on-the-fly

More specifically, the llvm::Instruction generated by
llvm::ConstantExpr::getAsInstruction. Such Instruction will be deleted
right away, but it's possible that when getAsInstruction is called
again, it will create a new Instruction that has the same address with
the one we just deleted. Thus, we shouldn't keep it in the `instMap` to
avoid a conflicting index that triggers an assertion in
processInstruction.

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

2 years ago[mlir][LLVMIR] Add support for importing struct-type ConstantAggregate(Zero)
Min-Yih Hsu [Wed, 20 Apr 2022 17:48:42 +0000 (10:48 -0700)]
[mlir][LLVMIR] Add support for importing struct-type ConstantAggregate(Zero)

And move importer test files from `test/Target/LLVMIR` into
`test/Target/LLVMIR/Import`.

We simply translate struct-type ConstantAggregate(Zero) into a
serious of `llvm.insertvalue` operations against a `llvm.undef` root.
Note that this doesn't affect the original logics on translating
vector/array-type ConstantAggregate values.

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

2 years ago[flang] Fix UBOUND() folding for constant arrays
Mike Kashkarov [Wed, 27 Apr 2022 13:14:10 +0000 (16:14 +0300)]
[flang] Fix UBOUND() folding for constant arrays

Similarly to LBOUND in https://reviews.llvm.org/D123237, fix UBOUND() folding
for constant arrays (for both w/ and w/o DIM=): convert
GetConstantArrayLboundHelper into common helper class for both lower/upper
bounds.

Reviewed By: jeanPerier

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

2 years ago[mlir] Allow setting operation legality with an OperationName
Mathieu Fehr [Wed, 27 Apr 2022 15:43:37 +0000 (08:43 -0700)]
[mlir] Allow setting operation legality with an OperationName

This is necessary to handle conversions of operations defined at runtime in extensible dialects.

Reviewed By: rriddle

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

2 years ago[DXIL] [NFC] Remove dead attribute code paths
Chris Bieneman [Wed, 27 Apr 2022 15:43:31 +0000 (10:43 -0500)]
[DXIL] [NFC] Remove dead attribute code paths

DXIL doesn't support attributes added after LLVM 3.7. The DXILPrepare
pass removes those attributes so they should never be present by the
time we reach the DXIL bitcode writer.

In the event that we somehow try to write a newer attribute in the DXIL
writer, we should fail hard (crash), because the output would be
invalid. This case should only be possible if the DXIL writer were
called without DXILPrepare being run first, which shouldn't be possible.

This patch also adds a default case to the switch statement over the
attribute list which covers all the removed cases and any new attribute
kinds that may be added in the future. The default case is handled like
other unsupported cases by a call to llvm_unreachable.

2 years agoRemove the Visual Studio/MSBuild integration (llvm/tools/msbuild/)
Hans Wennborg [Wed, 27 Apr 2022 12:14:39 +0000 (14:14 +0200)]
Remove the Visual Studio/MSBuild integration (llvm/tools/msbuild/)

This has been obsolete and abandoned since MS started including an
integration themselves in Visual Studio 2019.

See discussion at
https://discourse.llvm.org/t/building-the-llvm-with-msbuild/62053/

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

2 years agoRemove Python 2 checks from the test suite
Jonas Devlieghere [Wed, 27 Apr 2022 01:23:10 +0000 (18:23 -0700)]
Remove Python 2 checks from the test suite

We dropped downstream support for Python 2 in the previous release. Now
that we have branched for the next release the window where this kind of
change could introduce conflicts is closing too. Remove Python 2 checks
from the test suite.

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

2 years agoRemove Python 2 support from the ScriptInterpreter plugin
Jonas Devlieghere [Tue, 26 Apr 2022 03:14:44 +0000 (20:14 -0700)]
Remove Python 2 support from the ScriptInterpreter plugin

We dropped downstream support for Python 2 in the previous release. Now
that we have branched for the next release the window where this kind of
change could introduce conflicts is closing too. Start by getting rid of
Python 2 support in the Script Interpreter plugin.

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

2 years agotsan: avoid false positives related to epoll
Dmitry Vyukov [Wed, 27 Apr 2022 09:23:41 +0000 (11:23 +0200)]
tsan: avoid false positives related to epoll

An application can use the mere fact of epoll_wait returning an fd
as synchronization with the write on the fd that triggered the notification.
This pattern come up in an internal networking server (b/229276331).

If an fd is added to epoll, setup a link from the fd to the epoll fd
and use it for synchronization as well.

Reviewed By: melver

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

2 years ago[X86] collectConcatOps - add ability to collect from vector 'widening' patterns
Simon Pilgrim [Wed, 27 Apr 2022 14:29:03 +0000 (15:29 +0100)]
[X86] collectConcatOps - add ability to collect from vector 'widening' patterns

Recognise insert_subvector(undef, x, lo/hi) patterns where we double the width of a vector - creating an UNDEF subvector on the fly.

2 years ago[AArch64] Attempt to fix bots by ensuring legalized type is a vector
David Green [Wed, 27 Apr 2022 14:36:15 +0000 (15:36 +0100)]
[AArch64] Attempt to fix bots by ensuring legalized type is a vector

2 years ago[NVPTX] Fix NVPTX DebugInfo tests on Windows
Andrew Savonichev [Tue, 26 Apr 2022 19:41:10 +0000 (22:41 +0300)]
[NVPTX] Fix NVPTX DebugInfo tests on Windows

2 years ago[mlir][spirv] Add conversion from vector.reduction
Lei Zhang [Wed, 27 Apr 2022 14:22:41 +0000 (10:22 -0400)]
[mlir][spirv] Add conversion from vector.reduction

Only supports addition and multiplication for now; other cases
to be implemented.

Reviewed By: hanchung

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

2 years ago[InstCombine] 'round up integer': if bias is just right, just reuse instructions
Roman Lebedev [Wed, 27 Apr 2022 13:48:02 +0000 (16:48 +0300)]
[InstCombine] 'round up integer': if bias is just right, just reuse instructions

This is only useful if we can't create new instruction
because %x.aligned has other uses and already sticks around.

2 years ago[InstCombine] Fold 'round up integer' pattern (when alignment is a power of two)
Roman Lebedev [Wed, 27 Apr 2022 11:44:03 +0000 (14:44 +0300)]
[InstCombine] Fold 'round up integer' pattern (when alignment is a power of two)

But don't deal with non-splats.

The test coverage is sufficiently exhaustive,
and alive is happy about the changes there.

Example with constants: https://alive2.llvm.org/ce/z/EUaJ5- / https://alive2.llvm.org/ce/z/Bkng2X
General proof: https://alive2.llvm.org/ce/z/3RjJ5A

2 years ago[NFC][InstCombine] Add some tests for open-coded round-up of an integer w/ power...
Roman Lebedev [Tue, 26 Apr 2022 23:25:33 +0000 (02:25 +0300)]
[NFC][InstCombine] Add some tests for open-coded round-up of an integer w/ power-of-2 target alignment

2 years ago[mlir][spirv] Allow converting from index type in unsigned ops
Lei Zhang [Wed, 27 Apr 2022 14:13:17 +0000 (10:13 -0400)]
[mlir][spirv] Allow converting from index type in unsigned ops

`index` type is converted to `i32` in SPIR-V. This is fine to
support for all signed/unsigned ops.

Reviewed By: hanchung

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

2 years ago[SLP] Fix a typo that causes redundant assertion and potential segment fault
Shilei Tian [Wed, 27 Apr 2022 14:07:49 +0000 (10:07 -0400)]
[SLP] Fix a typo that causes redundant assertion and potential segment fault

Reviewed By: ABataev

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

2 years ago[lldb] Remove sanity check from TestWithLimitDebugInfo
Pavel Labath [Wed, 27 Apr 2022 14:01:54 +0000 (16:01 +0200)]
[lldb] Remove sanity check from TestWithLimitDebugInfo

The trick with opening the .o file does not work on arm (unhandled
relocations), and I can't think of a quick fix for that.

2 years ago[OpenMP] Properly handle the `-f/-fno` veraints for the new driver
Joseph Huber [Wed, 27 Apr 2022 13:56:37 +0000 (09:56 -0400)]
[OpenMP] Properly handle the `-f/-fno` veraints for the new driver

Summary:
We provide the `-f(no-)openmp-new-driver` option to allow users to use
the old or new driver. Previously this wasn't handled in the expected
way and only `-fno-openmp-new-driver` was checked. This patch fixes that
by using the `hasFlag` method as is standard.

2 years ago[InstCombine] add tests for ashr/lshr of constant with shift amount offset; NFC
Sanjay Patel [Wed, 27 Apr 2022 13:01:19 +0000 (09:01 -0400)]
[InstCombine] add tests for ashr/lshr of constant with shift amount offset; NFC

Baseline tests for D124369

2 years ago[gn build] Port 6ddf2a824da9
LLVM GN Syncbot [Wed, 27 Apr 2022 13:44:43 +0000 (13:44 +0000)]
[gn build] Port 6ddf2a824da9

2 years ago[GVN] Add more tests for opaque pointer GEPs (NFC)
Nikita Popov [Wed, 27 Apr 2022 12:56:40 +0000 (14:56 +0200)]
[GVN] Add more tests for opaque pointer GEPs (NFC)

Some of these are equivalent when considering an offset encoding.

2 years ago[AMDGPU] Adjust wave priority based on VMEM instructions to avoid duty-cycling.
Ivan Kosarev [Wed, 27 Apr 2022 13:07:52 +0000 (14:07 +0100)]
[AMDGPU] Adjust wave priority based on VMEM instructions to avoid duty-cycling.

As older waves execute long sequences of VALU instructions, this may
prevent younger waves from address calculation and then issuing their
VMEM loads, which in turn leads the VALU unit to idle. This patch tries
to prevent this by temporarily raising the wave's priority.

Reviewed By: foad

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

2 years ago[NFC] XFAIL tests which need visibility in XCOFF objectwriting
David Tenty [Wed, 27 Apr 2022 13:31:36 +0000 (09:31 -0400)]
[NFC] XFAIL tests which need visibility in XCOFF objectwriting

on AIX since this is currently unsupported and we added an error in D124392.

2 years ago[IRCE] Avoid computing potentially unnecessary analyses. NFC
Anna Thomas [Tue, 26 Apr 2022 21:15:48 +0000 (17:15 -0400)]
[IRCE] Avoid computing potentially unnecessary analyses. NFC

IRCE is a function pass that operates on loops. If there are no loops in
the function (as seen through LI), we should avoid computing the
remaining expensive analyses (such as BPI). Reordered the analyses
requests and early return if there are no loops. This is an NFC with
compile time improvement.

The same will be done in a follow-up patch for the loop vectorizer.

Reviewed-By: nikic
Differential Revision: https://reviews.llvm.org/D124478

2 years agoInstCombine: Add tests to show or-and scenarios which can be possibly be combined...
Biplob Mishra [Wed, 27 Apr 2022 13:17:54 +0000 (14:17 +0100)]
InstCombine: Add tests to show or-and scenarios which can be possibly be combined generically

2 years ago[lldb] Fix TestWithLimitDebugInfo.py
Pavel Labath [Tue, 26 Apr 2022 14:13:48 +0000 (16:13 +0200)]
[lldb] Fix TestWithLimitDebugInfo.py

The test was broken (in the sense that it was not testing what it was
supposed to test) in two ways:
- a Makefile refactor caused it to stop being built with
  -flimit-debug-info
- clang's constructor homing changed the "home" of the type

This patch fixes the Makefile, and modifies the source code to produce
the same result with both type homing strategies. Due to constructor
homing I had to use a different implicitly-defined function for the test
-- I chose the assignment operator.

I also added some sanity checks to the test to ensure that the test is
indeed operating on limited debug info.

2 years ago[lldb] Make test names unique
Pavel Labath [Wed, 27 Apr 2022 13:01:01 +0000 (15:01 +0200)]
[lldb] Make test names unique

2 years ago[SimpleLoopUnswitch] Add trivial unswitching tests with selects.
Florian Hahn [Wed, 27 Apr 2022 13:06:35 +0000 (14:06 +0100)]
[SimpleLoopUnswitch] Add trivial unswitching tests with selects.

Add tests with selects that match both logical AND and logical OR. Note
that some of the tests get miscompiled at the moment.

Also moves a related test to the newly added test file.

2 years ago[StatepointLowering] Only export STATEPOINT results if used in nonlocal blocks.
Denis Antrushin [Tue, 26 Apr 2022 10:52:43 +0000 (17:52 +0700)]
[StatepointLowering] Only export STATEPOINT results if used in nonlocal blocks.

Cuurently we always export STATEPOINT results (GC pointers lowered via VRegs)
to virtual registers. When processing gc.relocate instructions we have to
generate CopyFromRegs node and then export it to VReg again if gc.relocate
is used in other basic blocks. This results in generation of extra COPY MIR
instruction if statepoint and its gc.relocate are in the same BB, but gc.relocate
result is used in other blocks.

This patch changes this behavior to export statepoint results only if used
in other basic blocks. For local uses StatepointLoweringState.(get|set)Location()
API is used to communicate appropriate statepoint result from `LowerStatepoint()`
to `visitGCRelocate()`

This is NFC and is purely compile time optimization. On big methids it can improve
codegen compile time up to 10%.

Reviewed By: reames

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

2 years ago[AArch64] Break up larger shuffle-masks into legal sizes in getShuffleCost
David Green [Wed, 27 Apr 2022 12:51:50 +0000 (13:51 +0100)]
[AArch64] Break up larger shuffle-masks into legal sizes in getShuffleCost

Given a larger-than-legal shuffle mask, the final codegen will split
into multiple sub-vectors. This attempts to model that in
AArch64TTIImpl::getShuffleCost, splitting masks up according to the size
of the legalized vectors. If the sub-masks have at most 2 input sources
we can call getShuffleCost on them and sum the costs, to get a more
accurate final cost for the entire shuffle. The call to
improveShuffleKindFromMask helps to improve the shuffle kind for the
sub-mask cost call.

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

2 years ago[AArch64] Add some larger shuffle cost tests. NFC
David Green [Wed, 27 Apr 2022 12:30:50 +0000 (13:30 +0100)]
[AArch64] Add some larger shuffle cost tests. NFC

2 years ago[Flang] Lower the FailImage Statement
Kiran Chandramohan [Wed, 27 Apr 2022 12:19:54 +0000 (12:19 +0000)]
[Flang] Lower the FailImage Statement

Lowering of FailImage statement generates a runtime call and the
unreachable operation. The unreachable operation cannot terminate
a structured operation like the IF operation, hence  mark as
unstructured.

Note: This patch is part of upstreaming code from the fir-dev branch of
https://github.com/flang-compiler/f18-llvm-project.

Reviewed By: clementval

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[AST] Consider QualifiedTemplateName in TemplateName::getAsUsingDecl().
Haojian Wu [Tue, 26 Apr 2022 07:34:46 +0000 (09:34 +0200)]
[AST] Consider QualifiedTemplateName in TemplateName::getAsUsingDecl().

If the underlying template name of a qualified template name is a using
decl, TemplateName::getAsUsingDecl() will return it.

This will make the UsingTemplateName consumer life easier.

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

2 years ago[Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics [2/2]
Chris Jackson [Wed, 27 Apr 2022 12:08:03 +0000 (13:08 +0100)]
[Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics [2/2]

This relands commit 8f550368b169b0a3d4ebc3e65efec49ec1e0798a.

The test is amended with REQUIRES: x86-registered-target, in line with
the other debuginfo-scev-salvage tests.

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

2 years agoRevert [Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics[2/2]
Chris Jackson [Wed, 27 Apr 2022 12:06:03 +0000 (13:06 +0100)]
Revert [Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics[2/2]

This reverts commit 8f550368b169b0a3d4ebc3e65efec49ec1e0798a.

2 years ago[Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics [2/2]
Chris Jackson [Wed, 27 Apr 2022 11:38:12 +0000 (12:38 +0100)]
[Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics [2/2]

Second of two patches to extend SCEV-based salvaging to dbg.value
intrinsics that have multiple location ops pre-LSR. This second patch
adds the core implementation.

Reviewers: @StephenTozer, @djtodoro

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

2 years agoRevert "[Driver] Support for compressed debug info on Fuchsia"
Tom Weaver [Wed, 27 Apr 2022 11:29:04 +0000 (12:29 +0100)]
Revert "[Driver] Support for compressed debug info on Fuchsia"

This reverts commit 19190cc651ef153c308d23fb56f064223b144488.

Causes test failures on following build bot:

http://lab.llvm.org:8011/#/builders/216

2 years ago[AArch64] Use PerfectShuffle costs in AArch64TTIImpl::getShuffleCost
David Green [Wed, 27 Apr 2022 11:09:01 +0000 (12:09 +0100)]
[AArch64] Use PerfectShuffle costs in AArch64TTIImpl::getShuffleCost

Given a shuffle with 4 elements size 16 or 32, we can use the costs
directly from the PerfectShuffle tables to get a slightly more accurate
cost for the resulting shuffle.

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

2 years ago[Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics [1/2] [NFC]
Chris Jackson [Wed, 27 Apr 2022 10:27:10 +0000 (11:27 +0100)]
[Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics [1/2] [NFC]

First of two patches that extends SCEV-based salvaging to enable
salvaging of dbg.value instrinsics that have multiple locations ops
before the Loop Strength Reduction pass.

The existing single-op SCEV-based salvaging can generate variadic
dbg.value intrinsics in order to salvage a dbg.value that has a single
location op. If a dbg.value has multiple location ops before LSR, and
LSR optimises away one or more of the location operands, then currently
no salvaging will be attempted.

Salvaging can now be added, but first this patch cleans up consistency
in both the code and comments, and applies some refactoring to make
application of the new salvaging implementation more straightforward.

- Use SCEVDbgValueBuilder for both types of recovery expressions:
  IV-offset based and iteration count based.
- Combine the functions that write the final DIExpression.
- Move some static functions into member functions.

Reviewers: @Orlando

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

2 years ago[mlir][bazel] Add suport for PDLL tests.
Stephan Herhut [Wed, 27 Apr 2022 10:11:03 +0000 (12:11 +0200)]
[mlir][bazel] Add suport for PDLL tests.

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

2 years ago[libc++] Implement P0980R1 (constexpr std::string)
Nikolas Klauser [Wed, 27 Apr 2022 08:11:44 +0000 (10:11 +0200)]
[libc++] Implement P0980R1 (constexpr std::string)

Reviewed By: #libc, ldionne

Spies: daltenty, sdasgup3, ldionne, arichardson, MTC, ChuanqiXu, mehdi_amini, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes, tatianashp, rdzhabarov, teijeong, cota, dcaballe, Chia-hungDuan, wrengr, wenzhicui, arphaman, Mordante, miscco, Quuxplusone, smeenai, libcxx-commits

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

2 years ago[GVN][NewGVN] Regenerate no_speculative_loads_with_asan.ll tests
Simon Pilgrim [Wed, 27 Apr 2022 09:45:39 +0000 (10:45 +0100)]
[GVN][NewGVN] Regenerate no_speculative_loads_with_asan.ll tests

As discussed on D124284 - ensure we actually checking the codegen not just a label + return