platform/upstream/llvm.git
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

2 years ago[flang][driver] NFC: Make code more in line with LLVM style
Andrzej Warzynski [Fri, 22 Apr 2022 10:59:31 +0000 (10:59 +0000)]
[flang][driver] NFC: Make code more in line with LLVM style

This patch basically implements [1] in ExecuteCompilerInvocation.cpp. It
also:
  * replaces `CreateFrontendBaseAction` with `CreateFrontendAction`
    (only one method is needed ATM, this change removes the extra
    indirection)
  * removes `InvalidAction` from the `ActionKind` enum (I don't think it
    adds much and keeping it would mean adding a new void case in
    `CreateFrontendAction`)
  * sets the default frontend action in FrontendOptions.h to
    `ParseSyntaxOnly` (note that this is still overridden independently
    in `ParseFrontendArg` in CompilerInvocation.cpp)

No new functionality is added, hence no tests.

[1] https://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations

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

2 years ago[MIPS][SelectionDAG] Enable TargetLowering::hasBitTest for masks that fit in ANDI.
Liqin.Weng [Wed, 27 Apr 2022 08:05:01 +0000 (08:05 +0000)]
[MIPS][SelectionDAG] Enable TargetLowering::hasBitTest for masks that fit in ANDI.

Reviewed By: sdardis

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

2 years ago[DebugInfo][InstrRef] Describe value sizes when spilt to stack
Jeremy Morse [Wed, 27 Apr 2022 08:40:31 +0000 (09:40 +0100)]
[DebugInfo][InstrRef] Describe value sizes when spilt to stack

InstrRefBasedLDV can track and describe variable values that are spilt to
the stack -- however it does not current describe the size of the value on
the stack. This can cause uninitialized bytes to be read from the stack if
a small register is spilt for a larger variable, or theoretically on
big-endian machines if a large value on the stack is used for a small
variable.

Fix this by using DW_OP_deref_size to specify the amount of data to load
from the stack, if there's any possibility for ambiguity. There are a few
scenarios where this can be omitted (such as when using DW_OP_piece and a
non-DW_OP_stack_value location), see deref-spills-with-size.mir for an
explicit table of inputs flavours and output expressions.

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

2 years ago[CostModel] Add basic fptoi_sat costs
David Green [Wed, 27 Apr 2022 08:30:00 +0000 (09:30 +0100)]
[CostModel] Add basic fptoi_sat costs

This adds some basic fptosi_sat and fptoui_sat target independent cost
modelling. The fptosi_sat is modelled as a fmin/fmax to saturate the
value, followed by a fp convert. The signed values then have an
additional fcmp+select for handling Nan correctly.

The AArch64/Arm costs may be more incorrect, as the instruction exist
natively. This can be fixed with target specific cost updates.

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

2 years agoRevert "[asan] Enable detect_stack_use_after_return=1 by default"
Vitaly Buka [Wed, 27 Apr 2022 07:20:11 +0000 (00:20 -0700)]
Revert "[asan] Enable detect_stack_use_after_return=1 by default"

Temporarily revert the option to fix
https://bugs.chromium.org/p/chromium/issues/detail?id=1319387

This reverts option default and documentation of the commit. Test
changes are not being reverted as they are improvement and break
reliance on option defaults.

Additional memory usage is a problem on mobile devices with low memory.
Even heavy thread desktop programs may need some FakeStack tunning.

This reverts commit 4b4437c084e2b8a2643e97e7aef125c438635a4d.

2 years ago[InstCombine] Combine opaque pointer GEPs with mismatching element types
Nikita Popov [Tue, 26 Apr 2022 12:27:09 +0000 (14:27 +0200)]
[InstCombine] Combine opaque pointer GEPs with mismatching element types

Currently, two GEPs will only be combined if the result element
type of one is the same as the source element type of the other.
However, this means we may miss folding opportunities where the
second GEP could be rewritten using a different element type. This
is especially relevant for opaque pointers, where constant GEPs
often use i8 element type.

Address this by converting GEP indices to offsets, adding them,
and then converting them back to indices. The first (inner) GEP
is allowed to have variable indices as well, in which case only
the constant suffix is converted into an offset.

This should address the regression reported in
https://reviews.llvm.org/D123300#3467615.

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

2 years ago[AsmParser] Automatically declare and lex attribute keywords (NFC)
Nikita Popov [Tue, 26 Apr 2022 16:50:44 +0000 (18:50 +0200)]
[AsmParser] Automatically declare and lex attribute keywords (NFC)

Rather than listing these by hand, include all enum attribute
keywords from Attributes.inc. This reduces the number of places
one has to update whenever an enum attribute is added.

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

2 years ago[RISCV][NFC] Update and add missing closed curly bracket comment in RISCVInstrInfoZb.td
Jim Lin [Wed, 27 Apr 2022 04:57:58 +0000 (12:57 +0800)]
[RISCV][NFC] Update and add missing closed curly bracket comment in RISCVInstrInfoZb.td

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 ago[clangd] Output inlay hints with `clangd --check`
Tobias Ribizel [Wed, 27 Apr 2022 06:36:08 +0000 (02:36 -0400)]
[clangd] Output inlay hints with `clangd --check`

With the addition of inlay hints to clangd, it would be useful to output them during verbose `clangd --check`.
This patch adds an output step for inlay hints and unifies the way `--check-lines` are passed around

Reviewed By: nridge

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

2 years ago[FuncSpec] Conditional jump or move depends on uninitialised value(s).
Alexandros Lamprineas [Wed, 27 Apr 2022 06:25:01 +0000 (07:25 +0100)]
[FuncSpec] Conditional jump or move depends on uninitialised value(s).

I found this bug when performing a two-stage build of clang with
Function Specialization enabled and tuned aggressively. The crash
appears only on release builds.

Fixes https://github.com/llvm/llvm-project/issues/55000.

Before accessing the contents of the ArgInfo iterator inside
SCCPInstVisitor::markArgInFuncSpecialization, we should be
checking that the iterator is valid.

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

2 years agoRevert "[CMake][compiler-rt] Use COMPILE_OPTIONS and LINK_OPTIONS"
Petr Hosek [Wed, 27 Apr 2022 06:25:38 +0000 (23:25 -0700)]
Revert "[CMake][compiler-rt] Use COMPILE_OPTIONS and LINK_OPTIONS"

This reverts commit d47565ed62a383175ebb5cb5733f169d72715253.

2 years ago[CMake][compiler-rt] Use COMPILE_OPTIONS and LINK_OPTIONS
Petr Hosek [Wed, 30 Mar 2022 17:33:40 +0000 (10:33 -0700)]
[CMake][compiler-rt] Use COMPILE_OPTIONS and LINK_OPTIONS

This avoids the need for string-ification and lets CMake deduplicate
potentially duplicate flags.

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

2 years ago[docs] Fix typos in the 'CodeGenerator' doc
Youngsuk Kim [Wed, 27 Apr 2022 04:46:06 +0000 (21:46 -0700)]
[docs] Fix typos in the 'CodeGenerator' doc

NFC.

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

2 years ago[RISCV][RVV] Select unmasked TU RVV pseudos in a DAG post-process
ShihPo Hung [Tue, 22 Mar 2022 02:58:46 +0000 (19:58 -0700)]
[RISCV][RVV] Select unmasked TU RVV pseudos in a DAG post-process

Following D118810 that reduced the size of ISel table,
this patch optimizes allone-masked RVV pseudos with TU policy and
swap them out to their unmasked TU pseudos.

Since the UNDEF merge operand is not preserved, we turn it into TA
pseudo regardless of the policy operand.

Reviewed By: craig.topper, frasercrmck
Differential Revision: https://reviews.llvm.org/D121881

2 years ago[RISCV] Precommit test for D121881
ShihPo Hung [Fri, 8 Apr 2022 12:56:21 +0000 (05:56 -0700)]
[RISCV] Precommit test for D121881

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

2 years ago[clang-tidy] Modernize-macro-to-enum should skip macros used in other macros
Richard [Sat, 23 Apr 2022 01:35:48 +0000 (19:35 -0600)]
[clang-tidy] Modernize-macro-to-enum should skip macros used in other macros

If a macro is used in the expansion of another macro, that can cause
a compile error if the macro is replaced with an enum.  Token-pasting is
an example where converting a macro defined as an integral constant can
cause code to no longer compile.

This change causes such macros to be skipped from the conversion
process in order to prevent fixits from creating code that no longer
compiles.

A subsequent enhancement will examine macro usage in more detail to
allow more cases to be handled without breaking code.

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

Fixes #54948

2 years ago[mlir] Add extensible dialects
Mathieu Fehr [Wed, 27 Apr 2022 02:48:13 +0000 (19:48 -0700)]
[mlir] Add extensible dialects

Depends on D104534
Add support for extensible dialects, which are dialects that can be
extended at runtime with new operations and types.

These operations and types cannot at the moment implement traits
or interfaces.

Reviewed By: rriddle

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

2 years ago[mlir:PDLL] Use normalized paths in compilation database test
River Riddle [Wed, 27 Apr 2022 02:45:30 +0000 (19:45 -0700)]
[mlir:PDLL] Use normalized paths in compilation database test

This fixes issues with the compilation database when the file path
isn't in the correct form.

2 years ago[mlir:PDLL] Fix build on windows related to different file paths
River Riddle [Wed, 27 Apr 2022 02:40:41 +0000 (19:40 -0700)]
[mlir:PDLL] Fix build on windows related to different file paths

This fixes issues with the compilation database when the file path
isn't in the correct form.

2 years ago[ELF] Prevent LTO stripping of wrapped script-referenced symbols
Shoaib Meenai [Tue, 26 Apr 2022 05:51:10 +0000 (22:51 -0700)]
[ELF] Prevent LTO stripping of wrapped script-referenced symbols

After 1af25a986069f2ae8c724133fa8649bb795a7925, we stop unconditionally
retaining wrapped symbols, which means that LTO's summary-based global
dead stripping can eliminate them even if they'll be referenced by a
linker script after the wrapping is performed. Mark symbols referenced
in linker scripts as `referenced` in addition to `isUsedInRegularObj`,
so that the wrapping logic correctly sets `referencedAfterWrap` for the
symbols which will be referenced after wrapping, which will prevent LTO
from eliminating them.

An alternative would have been to change the `referencedAfterWrap` logic
to look at `isUsedInRegularObj` in addition to `referenced`, but
`isUsedInRegularObj` is also set in other places (e.g. for the entry
symbol), and it's not clear that we want `referencedAfterWrap` to take
all those places into account, so it seemed better to keep that logic
as-is and instead set `referenced` for linker script-referenced symbols.

Reviewed By: MaskRay

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

2 years ago[RISCV][NFC] Add RV64Zbs invalid tests
Ping Deng [Wed, 27 Apr 2022 01:38:21 +0000 (09:38 +0800)]
[RISCV][NFC] Add RV64Zbs invalid tests

Add a new test rv64zbs-invalid.s along with the aleady
existing rv32zbs-invalid.s.

Reviewed By: craig.topper, asb

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

2 years ago[mlir][PDLL-LSP] Add code completion for include file paths
River Riddle [Wed, 20 Apr 2022 18:58:11 +0000 (11:58 -0700)]
[mlir][PDLL-LSP] Add code completion for include file paths

This allows for providing completion results for include directive
file paths by searching the set of include directories for the current
file.

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

2 years ago[mlir][PDLL] Add document link and hover support to mlir-pdll-lsp-server
River Riddle [Wed, 20 Apr 2022 09:14:08 +0000 (02:14 -0700)]
[mlir][PDLL] Add document link and hover support to mlir-pdll-lsp-server

This allows for navigating to included files on click, and also provides hover
information about the include file (similarly to clangd).

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

2 years ago[mlir][PDLL] Add initial support for a PDLL compilation database
River Riddle [Wed, 20 Apr 2022 06:53:42 +0000 (23:53 -0700)]
[mlir][PDLL] Add initial support for a PDLL compilation database

The compilation database acts in a similar way to the compilation database
(compile_commands.json) used by clang-tidy, i.e. it provides additional
information about the compilation of project files to help the language
server. The main piece of information provided by the PDLL compilation
database in this commit is the set of include directories used when processing
the input .pdll file. This allows for the server to properly process .pdll files
that use includes anchored by the include directories set up in the build system.

The structure of the textual form of a compilation database is a yaml file
containing documents of the following form:

```
--- !FileInfo:
  filepath: <string> - Absolute file path of the file.
  includes: <string> - Semi-colon delimited list of include directories.
```

This commit also adds support to cmake for automatically generating
a `pdll_compile_commands.yml` file at the top-level of the build
directory.

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

2 years ago[mlir][PDLL] Add support for generating PDL patterns from PDLL at build time
River Riddle [Wed, 20 Apr 2022 05:46:34 +0000 (22:46 -0700)]
[mlir][PDLL] Add support for generating PDL patterns from PDLL at build time

This essentially sets up mlir-pdll to function in a similar manner to mlir-tblgen. Aside
from the boilerplate of configuring CMake and setting up a basic initial test, two new
options are added to mlir-pdll to mirror options provided by tblgen:

* -d
 This option generates a dependency file (i.e. a set of build time dependencies) while
 processing the input file.

* --write-if-changed
 This option only writes to the output file if the data would have changed, which for
 the build system prevents unnecesarry rebuilds if the file was touched but not actually
 changed.

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

2 years ago[mlir][PDLL] Don't use the result of `Constraint::getDefName()` when uniquing
River Riddle [Wed, 20 Apr 2022 03:34:21 +0000 (20:34 -0700)]
[mlir][PDLL] Don't use the result of `Constraint::getDefName()` when uniquing

In the case of anonymous defs this may return the name of the base def class,
which can lead to two different defs with the same name (which hits an assert).
This commit adds a new `getUniqueDefName` method that returns a unique name
for the constraint.

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

2 years agoDon't push null ExecutionContext on CommandInterp exectx stack
Jason Molenda [Wed, 27 Apr 2022 01:30:18 +0000 (18:30 -0700)]
Don't push null ExecutionContext on CommandInterp exectx stack

The driver can push a null ExecutionContext on to this stack,
and later calls to SBCommandInterpreter::HandleCommand which
don't specify an ExecutionContext can pull an entry from the
stack, resulting in settings that aren't applied.

Differential Revision: https://reviews.llvm.org/D111209
rdar://81489207

2 years agoUpstream test for wide character literals.
Eric Schweitz [Tue, 26 Apr 2022 23:49:01 +0000 (16:49 -0700)]
Upstream test for wide character literals.

Reviewed By: vdonaldson

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

2 years ago[Support] Factor out isCrash from throwIfCrash
Alexander Shaposhnikov [Wed, 27 Apr 2022 00:21:33 +0000 (00:21 +0000)]
[Support] Factor out isCrash from throwIfCrash

This diff factors out the check "isCrash" from the static method "throwIfCrash".
This is a helper function that can be useful in debugging / analysis, in particular,
I'm planning to use it in the future patches for lld-fuzzer.

Test plan:
1/ ninja check-all
2/ export LLD_IN_TEST=5 ninja check-lld

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

2 years ago[AMDGPU] Remove now unused variable HasLdsModifier. NFC.
Stanislav Mekhanoshin [Wed, 27 Apr 2022 00:45:41 +0000 (17:45 -0700)]
[AMDGPU] Remove now unused variable HasLdsModifier. NFC.

2 years ago[CUDA][HIP] Fix linkage of __clang_gpu_used_external
Yaxun (Sam) Liu [Tue, 26 Apr 2022 17:06:53 +0000 (13:06 -0400)]
[CUDA][HIP] Fix linkage of __clang_gpu_used_external

Different TU's may have this globl var. appending linkage can
only be used with lld recognized special variables.

Change it to internal linkage.

Reviewed by: Artem Belevich

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

2 years ago[AMDGPU] Add both mayLoad and mayStore to MUBUF LDS opcodes
Stanislav Mekhanoshin [Tue, 26 Apr 2022 22:00:42 +0000 (15:00 -0700)]
[AMDGPU] Add both mayLoad and mayStore to MUBUF LDS opcodes

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

2 years ago[AMDGPU] Remove vdata from buffer to lds load
Stanislav Mekhanoshin [Tue, 26 Apr 2022 21:58:42 +0000 (14:58 -0700)]
[AMDGPU] Remove vdata from buffer to lds load

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

2 years agoFix [libc] Minor test signedness fixes
Dominic Chen [Wed, 27 Apr 2022 00:14:39 +0000 (17:14 -0700)]
Fix [libc] Minor test signedness fixes

Add namespace specifier

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

2 years ago[libc] Minor test signedness fixes
Dominic Chen [Tue, 26 Apr 2022 17:25:05 +0000 (10:25 -0700)]
[libc] Minor test signedness fixes

Resolve compiler warnings about signed conversion

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

2 years agoFix missing import for test
Jeffrey Tan [Tue, 26 Apr 2022 21:29:10 +0000 (14:29 -0700)]
Fix missing import for test

The last fix missed an import in one test file causing skipIfWindows attribute
can't be recognized.
I feel embarrassed to miss it. I have run all tests on Mac to make sure them
passing in this patch.

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

2 years ago[NFC] Fix argument types in doxygen comment
Warren Ristow [Tue, 26 Apr 2022 23:29:33 +0000 (16:29 -0700)]
[NFC] Fix argument types in doxygen comment

The argument types for _mm_extract_epi16 and _mm_insert_epi16 were
incorrectly identified as '__m256i' instead of '__m128i'.  Introduced
by df08b3493869540bad5d4b040dae814e078b411d, and fixed here.

2 years ago[AIX][XCOFF] error on emit symbol visibility for XCOFF object file
David Tenty [Fri, 22 Apr 2022 18:37:17 +0000 (14:37 -0400)]
[AIX][XCOFF] error on emit symbol visibility for XCOFF object file

This is a follow on to the revert of D84265 to add an error if we'd need
to write a non-zero visibility type in the xcoff object file. We can't
currently do that because we lack the auxilary header to interpret the
bits in XCOFF32. This is important because visibility is being enabled
in the assembly writing path, and without this error the visibility
could be silently ignored.

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

2 years ago[SimplifyLibCalls] avoid slicing 64-bit integers in an ILP32 build (PR #54739)
Martin Sebor [Tue, 26 Apr 2022 22:26:09 +0000 (16:26 -0600)]
[SimplifyLibCalls] avoid slicing 64-bit integers in an ILP32 build (PR #54739)

Reviewed By: nikic

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

2 years ago[BOLT][NFC] Fix warning for unqualified call to std::move
Paul Kirth [Tue, 26 Apr 2022 23:17:26 +0000 (23:17 +0000)]
[BOLT][NFC] Fix warning for unqualified call to std::move

Fixes warning from RetpolineInsertion.cpp:171:44:
warning: unqualified call to std::move [-Wunqualified-std-cast-call]

Reviewed By: maksfb

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

2 years ago[mlir][sparse] support pattern-only matrices from Matrix Market
Aart Bik [Tue, 26 Apr 2022 20:30:57 +0000 (13:30 -0700)]
[mlir][sparse] support pattern-only matrices from Matrix Market

We simply set nonzero entries to the value "1" in this case.

Reviewed By: bixia

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

2 years ago[InstCombine] Fold strnlen of constant strings.
Martin Sebor [Tue, 26 Apr 2022 22:12:57 +0000 (16:12 -0600)]
[InstCombine] Fold strnlen of constant strings.

Reviewed By: nikic

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

2 years agotry to fix check-llvm on windows after 0a27622a1d62
Nico Weber [Tue, 26 Apr 2022 22:00:37 +0000 (18:00 -0400)]
try to fix check-llvm on windows after 0a27622a1d62

2 years ago[NFC] More synching of sources for upstreaming.
Eric Schweitz [Tue, 26 Apr 2022 20:44:34 +0000 (13:44 -0700)]
[NFC] More synching of sources for upstreaming.

Reviewed By: clementval

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

2 years ago[NFC] Cleanup miscellaneous header items
Warren Ristow [Tue, 26 Apr 2022 21:33:14 +0000 (14:33 -0700)]
[NFC] Cleanup miscellaneous header items

- Explain the use of the _MM_SHUFFLE and _MM_SHUFFLE2 macros
- Update some doxygen parameter descriptions to match the implementations
- Add "see also" doxygen tags to some intrinsics
- Minor clang-format changes

Reviewers: RKSimon

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

2 years ago[InstCombine] Update predicate when canonicalizing comparisons in canonicalizeClampLike.
Ricky Zhou [Tue, 26 Apr 2022 21:26:54 +0000 (17:26 -0400)]
[InstCombine] Update predicate when canonicalizing comparisons in canonicalizeClampLike.

canonicalizeClampLike canonicalizes the ule/ugt comparisons to ult/uge,
respectively. However, it does not update the variable holding the
comparison predicate type after doing this. Later code fails to handle
the non-canonical predicate type (specifically, the swap of
ThresholdLowIncl and ThresholdHighExcl when Pred0 has been canonicalized
from ugt to uge). This leads to the miscompile reported in PR53252. Fix
this by updating the comparison predicate after canonicalizing.

Fixes #53252

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

2 years ago[OpenMPIRBuilder] Remove ContinuationBB argument from Body callback.
Michael Kruse [Tue, 26 Apr 2022 18:35:13 +0000 (13:35 -0500)]
[OpenMPIRBuilder] Remove ContinuationBB argument from Body callback.

The callback is expected to create a branch to the ContinuationBB (sometimes called FiniBB in some lambdas) argument when finishing. This creates problems:

 1. The InsertPoint used for CodeGenIP does not need to be the end of a block. If it is not, a naive callback will insert a branch instruction into the middle of the block.

 2. The BasicBlock the CodeGenIP is pointing to may or may not have a terminator. There is an conflict where to branch to if the block already has a terminator.

 3. Some API functions work only with block having a terminator. Some workarounds have been used to insert a temporary terminator that is removed again.

 4. Some callbacks are sensitive to whether the BasicBlock has a terminator or not. This creates a callback ordering problem where different callback may have different behaviour depending on whether a previous callback created a terminator or not. The problem also exists for FinalizeCallbackTy where some callbacks do create branch to another "continue" block, but unlike BodyGenCallbackTy does not receive the target as argument. This is not addressed in this patch.

With this patch, the callback receives an CodeGenIP into a BasicBlock where to insert instructions. If it has to insert control flow, it can split the block at that position as needed but otherwise no separate ContinuationBB is needed. In particular, a callback can be empty without breaking the emitted IR. If the caller needs the control flow to branch to a specific target, it can insert the branch instruction itself and pass an InsertPoint before the terminator to the callback.

Certain frontends such as Clang may expect the current IRBuilder position to be at the end of a basic block. In this case its callbacks must split the block at CodeGenIP before setting the IRBuilder position such that the instructions after CodeGenIP are moved to another basic block and before returning create a new branch instruction to the split block.

Some utility functions such as `splitBB` are supporting correct splitting of BasicBlocks, independent of whether they have a terminator or not, returning/setting the InsertPoint of an IRBuilder to the end of split predecessor block, and optionally omitting creating a branch to the split successor block to be added later.

Reviewed By: kiranchandramohan

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

2 years ago[InstCombine] Add tests reproducing PR53252 (NFC)
Ricky Zhou [Tue, 26 Apr 2022 21:21:27 +0000 (17:21 -0400)]
[InstCombine] Add tests reproducing PR53252 (NFC)

This are baseline tests for D119690 ( #53252 )

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

2 years agoRevert "[compiler-rt] Use C_STANDARD instead of custom logic for adding -std=c11"
Martin Storsjö [Tue, 26 Apr 2022 21:19:14 +0000 (00:19 +0300)]
Revert "[compiler-rt] Use C_STANDARD instead of custom logic for adding -std=c11"

This reverts commit 2f251925db060f83894a4cf5448259b7a1255552.

This was reported to break the Builtins-powerpc64le-linux::qdiv_test.c
test on ppc64le buildbots, e.g. these:

https://lab.llvm.org/buildbot/#/builders/105/builds/24538
https://lab.llvm.org/buildbot/#/builders/121/builds/18755

2 years ago[AMDGPU] Properly mark MUBUF and FLAT LDS DMA instructions. NFC.
Stanislav Mekhanoshin [Tue, 26 Apr 2022 19:34:27 +0000 (12:34 -0700)]
[AMDGPU] Properly mark MUBUF and FLAT LDS DMA instructions. NFC.

Add these bits to the MUBUF and FLAT LDS DMA instructions:

- LGKM_CNT - these operate on LDS;
- VALU - SPG 3.9.8: This instruction acts as both a MUBUF and
VALU instruction;

Codegen currently does not produce any of this, so the change is NFC.

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

2 years agoRecommit "[SLP][TTI] Refactoring of `getShuffleCost` `Args` to work like `getArithmet...
Vasileios Porpodas [Tue, 26 Apr 2022 18:32:24 +0000 (11:32 -0700)]
Recommit "[SLP][TTI] Refactoring of `getShuffleCost` `Args` to work like `getArithmeticInstrCost`"

This reverts commit 6a9bbd9f20dcd700e28738788bb63a160c6c088c.

Code review: https://reviews.llvm.org/D124202

2 years ago[PS5] Add debug option testing for the PS5 target
Paul Robinson [Tue, 26 Apr 2022 20:36:22 +0000 (13:36 -0700)]
[PS5] Add debug option testing for the PS5 target

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

This test mostly runs clang and checks one thing each time, which isn't
very efficient.  I added some -DAG suffixes and combined some checks so
adding PS5 checking didn't actually increase the number of clang runs.

2 years agoDisable symbol on-demand feature for Windows
Jeffrey Tan [Tue, 26 Apr 2022 19:13:49 +0000 (12:13 -0700)]
Disable symbol on-demand feature for Windows

Symbol on-demand feature is never tested on Windows so it is not a surprise
that we are getting Buildbot failure from Windows:
https://lab.llvm.org/buildbot/#/builders/83/builds/18228

This patch disables symbol on-demand feature on Windows. I will find a Windows
machine to test and re-enable symbol on-demand feature as follow-up.

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

2 years agoRevert "[demangler] Simplify OutputBuffer initialization"
Kirill Stoimenov [Tue, 26 Apr 2022 20:24:06 +0000 (20:24 +0000)]
Revert "[demangler] Simplify OutputBuffer initialization"

Reverting due to a bot failure:
https://lab.llvm.org/buildbot/#/builders/5/builds/22738

This reverts commit 5b3ca24a35e91bf9c19af856e7f92c69b17f989e.

2 years ago[InstCombine] Fold memrchr calls with a constant character.
Martin Sebor [Tue, 26 Apr 2022 19:15:03 +0000 (13:15 -0600)]
[InstCombine] Fold memrchr calls with a constant character.

Reviewed By: nikic

Differential Revision: //reviews.llvm.org/D123629

2 years ago[InstCombine] Fold memrchr calls with constant size, bail on excessive.
Martin Sebor [Tue, 26 Apr 2022 17:52:15 +0000 (11:52 -0600)]
[InstCombine] Fold memrchr calls with constant size, bail on excessive.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D123626
Differential Revision: https://reviews.llvm.org/D123628

2 years ago[InstCombine] Fold strnlen with a bound of zero and one.
Martin Sebor [Tue, 26 Apr 2022 17:48:43 +0000 (11:48 -0600)]
[InstCombine] Fold strnlen with a bound of zero and one.

Reviewed By: nikic

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

2 years ago[InstCombine] add a strnlen handler stub.
Martin Sebor [Tue, 26 Apr 2022 17:35:59 +0000 (11:35 -0600)]
[InstCombine] add a strnlen handler stub.

Reviewed By: nikic

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

2 years ago[NVPTX] Temporary disable dwarf-file-dir.ll on Windows
Andrew Savonichev [Tue, 26 Apr 2022 19:22:38 +0000 (22:22 +0300)]
[NVPTX] Temporary disable dwarf-file-dir.ll on Windows

The test was added in D121299 and it fails on Windows:

    error: CHECK-NODIR: expected string
    not found in input
    ; CHECK-NODIR: .file {{[0-9]+}} "/tmp/dbginfo/a/a.cpp"
   ^
    <stdin>:1:1: note: scanning from here
    //
    ^
    <stdin>:25:2: note: possible intended match here
     .file 1 "/tmp/dbginfo/a\\a.cpp"

2 years ago[NFC] Fix order of initialization in MCTargetOptions
Andrew Savonichev [Tue, 26 Apr 2022 19:05:32 +0000 (22:05 +0300)]
[NFC] Fix order of initialization in MCTargetOptions

This patch fixes a compiler warning after D121299:

field 'MCUseDwarfDirectory' will be initialized after field
'MCIncrementalLinkerCompatible'

2 years ago[EarlyCSE] Add tests demonstrating missed opportunitites
Artur Pilipenko [Tue, 26 Apr 2022 18:58:08 +0000 (11:58 -0700)]
[EarlyCSE] Add tests demonstrating missed opportunitites

Add tests demonstrating missed opportunitites around
invariant.start intrinsic.

NFC.