platform/upstream/llvm.git
2 years agoEnable the use of ThreadPoolTaskGroup in MLIR threading helper to enable nested paral...
Mehdi Amini [Fri, 6 May 2022 19:38:49 +0000 (19:38 +0000)]
Enable the use of ThreadPoolTaskGroup in MLIR threading helper to enable nested parallelism

The LLVM ThreadPool recently got the addition of the concept of
ThreadPoolTaskGroup: this is a way to "partition" the threadpool
into a group of tasks and enable nested parallelism through this
grouping at every level of nesting.
We make use of this feature in MLIR threading abstraction to fix a long
lasting TODO and enable nested parallelism.

Reviewed By: rriddle

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

2 years agoApply clang-tidy fixes for llvm-else-after-return in Merger.cpp (NFC)
Mehdi Amini [Thu, 5 May 2022 23:09:44 +0000 (23:09 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in Merger.cpp (NFC)

2 years agoApply clang-tidy fixes for llvm-prefer-isa-or-dyn-cast-in-conditionals in OpenMPDiale...
Mehdi Amini [Thu, 5 May 2022 23:02:38 +0000 (23:02 +0000)]
Apply clang-tidy fixes for llvm-prefer-isa-or-dyn-cast-in-conditionals in OpenMPDialect.cpp (NFC)

2 years ago[clang-tidy][NFC] Fix doc typo for bugprone-unchecked-optional-access
Yitzhak Mandelbaum [Fri, 6 May 2022 19:23:15 +0000 (19:23 +0000)]
[clang-tidy][NFC] Fix doc typo for bugprone-unchecked-optional-access

2 years ago[libc][NFC] add index mode to printf parser
Michael Jones [Thu, 7 Apr 2022 21:22:48 +0000 (14:22 -0700)]
[libc][NFC] add index mode to printf parser

This patch is a followup to the previous patch which implemented the
main printf parsing logic as well as sequential mode. This patch adds
index mode.

Reviewed By: sivachandra

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

2 years ago[clang-tidy] New check for safe usage of `std::optional` and like types.
Yitzhak Mandelbaum [Sun, 6 Mar 2022 19:01:46 +0000 (19:01 +0000)]
[clang-tidy] New check for safe usage of `std::optional` and like types.

This check verifies the safety of access to `std::optional` and related
types (including `absl::optional`). It is based on a corresponding Clang
Dataflow Analysis, which does most of the work. This check merely runs it and
converts its findings into diagnostics.

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

2 years ago[HLSL] add -fcgl option flag.
python3kgae [Thu, 5 May 2022 06:15:40 +0000 (23:15 -0700)]
[HLSL] add -fcgl option flag.

fcgl option will make compilation stop after clang codeGen and output the llvm ir.
It is added to check clang codeGen output for HLSL.

It will be translated into -S -emit-llvm and -disable-llvm-passes.

Reviewed By: aaron.ballman

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

2 years ago[libc] Update windows entrypoint list
Michael Jones [Thu, 5 May 2022 23:40:28 +0000 (16:40 -0700)]
[libc] Update windows entrypoint list

The entrypoint list for windows hasn't been updated in a while, this
adds all of the entrypoints that are working for windows now.

Reviewed By: sivachandra, lntue

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

2 years ago[clangd] Speed up a slow sleeping testcase.
Sam McCall [Fri, 6 May 2022 16:24:48 +0000 (18:24 +0200)]
[clangd] Speed up a slow sleeping testcase.

This testcase runs slowly due to 3.2s of sleeps = 2 + 1 + 0.2s.
After this patch it has 0.55s only.

Reduced by:
 - observed that the last test was bogus: we were sleeping until the queue was
   idle, effectively just a second copy of the first test. This avoids 1s sleep.
 - when waiting for debounce, sleep only until test passes, not for enough
   time to be safe (in practice was 2x debounce time, now 1x debounce time)
 - scaling delays down by a factor of 2 (note: factor of 10 caused bot failures)

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

2 years ago[AArch64] Fix sub with carry
Kazu Hirata [Fri, 6 May 2022 18:04:17 +0000 (11:04 -0700)]
[AArch64] Fix sub with carry

13403a70e45b2d22878ba59fc211f8dba3a8deba introduced a bug where we
generate the outgoing carry inverted, which in turn breaks the
lowering of @llvm.usub.sat.i128, returning the normal difference on
saturation and zero otherwise.

Note that AArch64 has peculiar semantics where the subtraction
instructions generate borrow inverted.  The problem is that we mix the
two forms of semantics -- the normal carry and inverted carry -- in
the area of extended precision subtractions.  Specifically, we have
three problems:

- lowerADDSUBCARRY takes the non-inverted incoming carry from a
  subtraction and feeds it to SBCS without inverting it first.

- lowerADDSUBCARRY makes available the outgoing carry from SBCS
  without inverting it.

- foldOverflowCheck folds:

  (SBC{S} l r (CMP (CSET LO carry) 1)) => (SBC{S} l r carry)

  When the incoming carry flag is set, CSET LO results in zero.  CMP
  in turn generates a borrow, *clearing* the carry flag.  Instead, we
  should fold:

  (SBC{S} l r (CMP 0 (CSET LO carry))) => (SBC{S} l r carry)

  When the incoming carry flag is set, CSET LO results in zero.  CMP
  does not generate a borrow, *setting* the carry flag.

IIUC, we should use the normal (that is, non-inverted) semantics for
carry everywhere.

This patch fixes the three problems above.

This patch does not add any new testcases because we have a plenty of
them covering the instruction in question.  In particular,
@u128_saturating_sub is identical to the testcase in the motivating
issue.

Fixes: #55253

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

2 years ago[DAGCombine] Make combineShuffleOfBitcast LittleEndian specific
David Green [Fri, 6 May 2022 17:42:44 +0000 (18:42 +0100)]
[DAGCombine] Make combineShuffleOfBitcast LittleEndian specific

Something is going wrong with the BigEndian PowerPC bot. It is hard to
tell what is wrong from here, but attempt to fix it by disabling the
combineShuffleOfBitcast combine for bigendian.

2 years ago[mlir][sparse] integration test for zero preserving math op
Aart Bik [Fri, 6 May 2022 16:47:59 +0000 (09:47 -0700)]
[mlir][sparse] integration test for zero preserving math op

Also fixes omission in lowering math ops that require lib support

Reviewed By: bixia

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

2 years ago[riscv] Add strict asserts for VSETVLI insertion algorithm to help catch bugs
Philip Reames [Thu, 5 May 2022 19:50:47 +0000 (12:50 -0700)]
[riscv] Add strict asserts for VSETVLI insertion algorithm to help catch bugs

This assertion should hold for any reasonable data flow algorithm, but is known not to in several cases today. I'd like to go ahead and land this off-by-default, so that we can collaborate on fixes and have a common definition of success.

Differential: https://reviews.llvm.org/D125035

2 years ago[AArch64] Add extra reverse costs.
David Green [Fri, 6 May 2022 17:23:36 +0000 (18:23 +0100)]
[AArch64] Add extra reverse costs.

This adds some extra costs for reverse shuffles under AArch64, filling
in the i16/f16/i8 gaps in the cost model.

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

2 years ago[InstCombine] Add tests for combining AArch64 neon min/max intrinsics.
Florian Hahn [Fri, 6 May 2022 16:59:22 +0000 (17:59 +0100)]
[InstCombine] Add tests for combining AArch64 neon min/max intrinsics.

2 years ago[libc++][NFC] Fix formatting that was incorrectly changed by D124695
Louis Dionne [Fri, 6 May 2022 16:41:07 +0000 (12:41 -0400)]
[libc++][NFC] Fix formatting that was incorrectly changed by D124695

2 years ago[SimplifyLibcalls] Tests for libcall folding of subobjects [NFC]
Martin Sebor [Fri, 6 May 2022 16:34:13 +0000 (10:34 -0600)]
[SimplifyLibcalls] Tests for libcall folding of subobjects [NFC]

Add tests exercising the future enancement of folding library function
calls with arguments involving subobjects such as elements of arrays
or struct members.

2 years ago[SelectionDAG] Improve asserts in SelectionDAG::getSelect.
Craig Topper [Fri, 6 May 2022 16:39:39 +0000 (09:39 -0700)]
[SelectionDAG] Improve asserts in SelectionDAG::getSelect.

The VT passed in must match the type of LHS and RHS.
Previously we only checked that the vectorness matched.

2 years ago[clang-tidy][NFC] Add createChecks method that also checks for LangaugeOptions
Nathan James [Fri, 6 May 2022 16:30:30 +0000 (17:30 +0100)]
[clang-tidy][NFC] Add createChecks method that also checks for LangaugeOptions

This method won't add a check if it isn't supported in the Contexts current LanguageOptions.

Reviewed By: aaron.ballman

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

2 years ago[SelectionDAG] Clear promoted bits before UREM on shift amount in PromoteIntRes_Funne...
Craig Topper [Fri, 6 May 2022 07:04:43 +0000 (00:04 -0700)]
[SelectionDAG] Clear promoted bits before UREM on shift amount in PromoteIntRes_FunnelShift.

Otherwise we have garbage in the upper bits that can affect the
results of the UREM.

Fixes PR55296.

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

2 years agoAutomatically generates several X86/sse tests cases. NFC
Amaury Séchet [Fri, 6 May 2022 15:54:31 +0000 (15:54 +0000)]
Automatically generates several X86/sse tests cases. NFC

2 years agoAutomatically generate CodeGen/X86/sse-align-*.ll test cases. NFC
Amaury Séchet [Fri, 6 May 2022 15:44:50 +0000 (15:44 +0000)]
Automatically generate CodeGen/X86/sse-align-*.ll test cases. NFC

2 years ago[flang] Fix internal error with DATA-statement style initializers
Daniil Dudkin [Fri, 6 May 2022 15:18:33 +0000 (18:18 +0300)]
[flang] Fix internal error with DATA-statement style initializers

The code below causes flang to crash with an exception.
After fixing the crash flang with an internal error "no symbol found for 'bar'"
This change fixes all the issues.

  program name
    implicit none
    integer, parameter :: bar = 1
    integer foo(bar) /bar*2/
  end program name

Reviewed By: kiranchandramohan, klausler

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

2 years ago[OpenMP] Add basic support for properly handling static libraries
Joseph Huber [Fri, 6 May 2022 13:37:08 +0000 (09:37 -0400)]
[OpenMP] Add basic support for properly handling static libraries

Currently we handle static libraries like any other object in the
linker wrapper. However, this does not preserve the sematnics that
dictate static libraries should be lazily loaded as the symbols are
needed. This allows us to ignore linking in architectures that are not
used by the main application being compiled. This patch adds the basic
support for detecting if a file came from a static library, and only
including it in the link job if it's used by other object files.

This patch only adds the basic support, to be more correct we should
check the symbols and only inclue the library if the link job contains
symbols that are needed. Ideally we could just put this on the linker
itself, but nvlink doesn't seem to support `.a` files.

Reviewed By: jdoerfert

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

2 years agoRevert "[clangd] Speed up an unfortunate timer-based test."
Sam McCall [Fri, 6 May 2022 15:18:39 +0000 (17:18 +0200)]
Revert "[clangd] Speed up an unfortunate timer-based test."

This reverts commit 076dd0a763fd803897b0f806e0e350a27d2c087c.

http://45.33.8.238/macm1/34776/step_9.txt

2 years ago[libc++][NFC] Add release note for constexpr std::string
Louis Dionne [Fri, 6 May 2022 15:18:01 +0000 (11:18 -0400)]
[libc++][NFC] Add release note for constexpr std::string

2 years ago[InstCombine] Fold icmp of select with implied condition
Nikita Popov [Fri, 6 May 2022 14:48:02 +0000 (16:48 +0200)]
[InstCombine] Fold icmp of select with implied condition

When threading the icmp over the select, check whether the
condition can be folded when taking into account the select
condition.

2 years ago[InstCombine] Add icmp of select with implied condition tests (NFC)
Nikita Popov [Fri, 6 May 2022 14:59:57 +0000 (16:59 +0200)]
[InstCombine] Add icmp of select with implied condition tests (NFC)

2 years agoFix LLDB test broken by 499d0b96cb52c828e7fc4d58825b5e8b3f9931c5
Sam McCall [Fri, 6 May 2022 15:09:02 +0000 (17:09 +0200)]
Fix LLDB test broken by 499d0b96cb52c828e7fc4d58825b5e8b3f9931c5

2 years ago[Frontend] Fix broken createInvocation test due to bad merge
Sam McCall [Fri, 6 May 2022 15:05:47 +0000 (17:05 +0200)]
[Frontend] Fix broken createInvocation test due to bad merge

2 years ago[libc++][NFC] Move swap_noexcept test to .compile.pass.cpp
Louis Dionne [Fri, 6 May 2022 15:02:17 +0000 (11:02 -0400)]
[libc++][NFC] Move swap_noexcept test to .compile.pass.cpp

2 years ago[libc++][NFC] Slight refactoring of some std::vector tests
Louis Dionne [Fri, 6 May 2022 14:49:14 +0000 (10:49 -0400)]
[libc++][NFC] Slight refactoring of some std::vector tests

2 years ago[ELF] Change (NOLOAD) type mismatch to use SHT_NOBITS instead of SHT_PROGBITS
Fangrui Song [Fri, 6 May 2022 14:49:42 +0000 (07:49 -0700)]
[ELF] Change (NOLOAD) type mismatch to use SHT_NOBITS instead of SHT_PROGBITS

Placing a non-SHT_NOBITS input section in an output section specified with
(NOLOAD) is fishy but used by some projects. D118840 changed the output type to
SHT_PROGBITS, but using the specified type seems to make more sense and improve
GNU ld compatibility: `(NOLOAD)` seems to change the output section type
regardless of input.

I think we should keep the current type mismatch warning as it does indicate an
error-prone usage.

Reviewed By: peter.smith

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

2 years ago[MC][X86] Add vcmpps disassembler tests for Issue #41491
Simon Pilgrim [Fri, 6 May 2022 14:39:05 +0000 (15:39 +0100)]
[MC][X86] Add vcmpps disassembler tests for Issue #41491

We were missing coverage for vcmpps imm, vreg, vreg, mreg {mreg} patterns

2 years ago[DAG] visitREM - merge buildOptimizedSREM into if(). NFCI.
Simon Pilgrim [Fri, 6 May 2022 14:17:00 +0000 (15:17 +0100)]
[DAG] visitREM - merge buildOptimizedSREM into if(). NFCI.

2 years ago[clangd] Eliminate direct usage of isAvailable() matcher. NFC
Sam McCall [Fri, 6 May 2022 14:34:06 +0000 (16:34 +0200)]
[clangd] Eliminate direct usage of isAvailable() matcher. NFC

This prepares to replace the implementation of EXPECT_[UN]AVAILABLE with
something more efficient.

2 years ago[clangd] Speed up an unfortunate timer-based test.
Sam McCall [Fri, 6 May 2022 14:29:10 +0000 (16:29 +0200)]
[clangd] Speed up an unfortunate timer-based test.

2 years agoFix lifetime of DiagnosticsEngine in diagtool.
Sam McCall [Fri, 6 May 2022 14:21:23 +0000 (16:21 +0200)]
Fix lifetime of DiagnosticsEngine in diagtool.

2 years ago[clang] createInvocationFromCommandLine -> createInvocation, delete former. NFC
Sam McCall [Thu, 5 May 2022 14:17:47 +0000 (16:17 +0200)]
[clang] createInvocationFromCommandLine -> createInvocation, delete former. NFC

(Followup from 40c13720a4b977d4347bbde53c52a4d0703823c2)

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

2 years ago[flang] Add one semantic check for masked array assignment
PeixinQiao [Fri, 6 May 2022 14:19:20 +0000 (22:19 +0800)]
[flang] Add one semantic check for masked array assignment

As Fortran 2018 states, in each where-assignment-stmt, the mask-expr and
the variable being defined shall be arrays of the same shape. The
previous check does not consider checking if it is an array.

Reviewed By: klausler

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

2 years ago[flang] Support external procedure passed as actual argument with implicit character...
PeixinQiao [Fri, 6 May 2022 14:14:51 +0000 (22:14 +0800)]
[flang] Support external procedure passed as actual argument with implicit character type

As Fortran 2018 15.5.2.9 point 2, the actual argument and dummy argument
have the same type and type parameters and an external function with
assumed character length may be associated with a dummy argument with
explicit character length. As Fortran 2018 15.5.2.9 point 7, if an
external procedure is used as an actual argument, it can be explicitly
declared to have the EXTERNAL attribute. This supports the external
procedure passed as actual argument with implicit character type, either
explicit character length or assumed character length.

Reviewed By: Jean Perier, klausler

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

2 years ago[clangd] Add parsing for IgnoreHeaders config option
Kadir Cetinkaya [Fri, 6 May 2022 12:32:04 +0000 (14:32 +0200)]
[clangd] Add parsing for IgnoreHeaders config option

2 years ago[flang] Fix AllocaOp/AllocMemOp type conversion
PeixinQiao [Fri, 6 May 2022 14:10:13 +0000 (22:10 +0800)]
[flang] Fix AllocaOp/AllocMemOp type conversion

For arrays without a constant interior or arrays of character with
dynamic length arrays, the data types are converted to a pointer to the
element type, so the scale size of the constant extents needs to be
counted. The previous AllocaOp conversion does not consider the arrays
of character with dynamic length arrays, and the previous AllocMemOp
conversion does not consider arrays without a constant interior. This
fixes them and refactors the code so that it can be shared. Also add
the test cases.

Reviewed By: Jean Perier

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

2 years ago[InstCombine] Fold icmp of select with non-constant operand
Nikita Popov [Fri, 6 May 2022 13:07:01 +0000 (15:07 +0200)]
[InstCombine] Fold icmp of select with non-constant operand

Try to push an icmp into a select even if the icmp operand isn't
constant - perform a generic SimplifyICmpInst instead.

This doesn't appear to impact compile-time much, and forming
logical and/or is generally profitable, as we have very good
support for them.

2 years ago[InstCombine] Add additional icmp of select tests (NFC)
Nikita Popov [Fri, 6 May 2022 13:59:01 +0000 (15:59 +0200)]
[InstCombine] Add additional icmp of select tests (NFC)

2 years ago[gn build] Port 586efd52b93f
LLVM GN Syncbot [Fri, 6 May 2022 13:54:41 +0000 (13:54 +0000)]
[gn build] Port 586efd52b93f

2 years ago[gn build] Port 37ba1b9d1ac7
LLVM GN Syncbot [Fri, 6 May 2022 13:54:40 +0000 (13:54 +0000)]
[gn build] Port 37ba1b9d1ac7

2 years agoRevert "[HWASan] Allow to linkify symbolizer output."
Nico Weber [Fri, 6 May 2022 13:52:58 +0000 (09:52 -0400)]
Revert "[HWASan] Allow to linkify symbolizer output."

This reverts commit 4af9392e13a212fe295dc33455bc591b2dc8f859.
The new test fails on several machines (including some bots),
see https://reviews.llvm.org/D124950

2 years agoRevert "[HWASan] Clean up hwasan_symbolize."
Nico Weber [Fri, 6 May 2022 13:52:32 +0000 (09:52 -0400)]
Revert "[HWASan] Clean up hwasan_symbolize."

This reverts commit 6ca1df61d29c1c46d8d6f51a1091a7651c8b1ab1.
Prerequisite for reverting 4af9392e13a212fe295dc.

2 years ago[libc++][P0943] Add stdatomic.h header.
Louis Dionne [Mon, 11 Apr 2022 14:42:45 +0000 (10:42 -0400)]
[libc++][P0943] Add stdatomic.h header.

* https://wg21.link/P0943
* https://eel.is/c++draft/stdatomic.h.syn

This is a re-application of 5d1c1a24, which was reverted in 987c7f407
because it broke the LLDB build.

Co-authored-by: Marek Kurdej <marek.kurdej@gmail.com>
Differential Revision: https://reviews.llvm.org/D97044

2 years ago[Support] Fix asan AllocatorTest after ba0d50ad7ec66
Sam McCall [Fri, 6 May 2022 13:50:33 +0000 (15:50 +0200)]
[Support] Fix asan AllocatorTest after ba0d50ad7ec66

We were counting the number of bytes allocated, but under asan there's
extra redzone bytes by default. Disable this.

2 years ago[SLP][X86] Add test coverage for Issue #51088
Simon Pilgrim [Fri, 6 May 2022 13:49:27 +0000 (14:49 +0100)]
[SLP][X86] Add test coverage for Issue #51088

2 years ago[clang][X86] Rename some intrinsics tests to use the *-builtins.c naming convention
Simon Pilgrim [Fri, 6 May 2022 13:34:39 +0000 (14:34 +0100)]
[clang][X86] Rename some intrinsics tests to use the *-builtins.c naming convention

2 years ago[compiler-rt][builtins] Fix wrong ABI of AVR __mulqi3 & __mulhi3
Ben Shi [Fri, 6 May 2022 07:21:19 +0000 (07:21 +0000)]
[compiler-rt][builtins] Fix wrong ABI of AVR __mulqi3 & __mulhi3

Reviewed By: aykevl, dylanmckay

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

2 years ago[RS4GC] Add support for 'freeze' instruction to findBaseDefiningValue
Max Kazantsev [Fri, 6 May 2022 13:42:30 +0000 (20:42 +0700)]
[RS4GC] Add support for 'freeze' instruction to findBaseDefiningValue

Because this instruction is a noop, we can simply go through it in
search of the base.

2 years ago[gn build] try to (manually) port 9ef451d1fdaa9a1 (hwasan_symbolize)
Nico Weber [Fri, 6 May 2022 12:33:16 +0000 (08:33 -0400)]
[gn build] try to (manually) port 9ef451d1fdaa9a1 (hwasan_symbolize)

needed by check-hwasan as of 4af9392e13a212

2 years ago[NFC] Fix typo in assert message
Max Kazantsev [Fri, 6 May 2022 13:31:04 +0000 (20:31 +0700)]
[NFC] Fix typo in assert message

2 years ago[clang][dataflow][NFC] Clarify guarantees on returned vector size for `runDataflowAna...
Yitzhak Mandelbaum [Fri, 6 May 2022 12:56:44 +0000 (12:56 +0000)]
[clang][dataflow][NFC] Clarify guarantees on returned vector size for `runDataflowAnalysis`.

Adjusts the comment to specify that the output vector's size matches the number of CFG blocks.

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

2 years ago[MLIR] Fix build with make
Nikita Popov [Thu, 5 May 2022 13:47:34 +0000 (15:47 +0200)]
[MLIR] Fix build with make

https://reviews.llvm.org/D124075 causes MLIR to no longer build
when using make rather than ninja, due to a tablegen-generated
header being used before it is created.

It seems that this is related to the use of LLVM_ENABLE_OBJLIB when
using add_tablgen with a non-Ninja/Xcode generator. In that case an
intermediate objlib target is generated.

This patch fixes the issue by a) declaring dependencies in
add_tablegen for mlir-pdll and b) making sure those dependencies
are added to the objlib target.

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

2 years agoFix underlining length; NFC
Aaron Ballman [Fri, 6 May 2022 12:47:19 +0000 (08:47 -0400)]
Fix underlining length; NFC

2 years ago[InstCombine] Extract icmp of select transform (NFC)
Nikita Popov [Fri, 6 May 2022 12:46:12 +0000 (14:46 +0200)]
[InstCombine] Extract icmp of select transform (NFC)

To make it either to extend to the case where the other operand
is not a constant.

2 years ago[CostModel][X86] Relax fcmp costs on SSE41 targets or later
Simon Pilgrim [Fri, 6 May 2022 12:29:40 +0000 (13:29 +0100)]
[CostModel][X86] Relax fcmp costs on SSE41 targets or later

Only pre-SSE41 targets double-pump the fp comparison ops

2 years ago[InstCombine] Fix scalable-vector bitwise select matching
Fraser Cormack [Thu, 5 May 2022 10:06:41 +0000 (11:06 +0100)]
[InstCombine] Fix scalable-vector bitwise select matching

D113035 enhanced the matching of bitwise selects from vector types. This
change unfortunately introduced crashes as it tries to cast scalable
vector types to integers.

Reviewed By: spatel

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

2 years ago[CostModel][X86] Adjust 128-bit select costs to account for slow BLENDV op
Simon Pilgrim [Fri, 6 May 2022 12:07:26 +0000 (13:07 +0100)]
[CostModel][X86] Adjust 128-bit select costs to account for slow BLENDV op

Based off the script from D103695 - Jaguar, Bulldozer, Silvermont (et al) and Haswell all have slow BLENDV ops, so adjust the worse case cost values

2 years ago[Flang][OpenMP] Initial lowering of the OpenMP worksharing loop
Kiran Chandramohan [Fri, 6 May 2022 11:45:18 +0000 (11:45 +0000)]
[Flang][OpenMP] Initial lowering of the OpenMP worksharing loop

The OpenMP worksharing loop operation in the dialect is a proper loop
operation and not a container of a loop. So we have to lower the
parse-tree OpenMP loop construct and the do-loop inside the construct
to a omp.wsloop operation and there should not be a fir.do_loop inside
it. This is achieved by skipping fir.do_loop creation and calling genFIR
for the nested evaluations in the lowering of the do construct.

Note: Handling of more clauses, parallel do, storage of loop index variable etc will come in separate patches.

Part of the upstreaming effort to move LLVM Flang from fir-dev branch of
https://github.com/flang-compiler/f18-llvm-project to the LLVM Project.

Reviewed By: peixin

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

Co-authored-by: Sourabh Singh Tomar <SourabhSingh.Tomar@amd.com>
Co-authored-by: Shraiysh Vaishay <Shraiysh.Vaishay@amd.com>
2 years ago[RISCV] Add an extra vsetvli insertion test
Fraser Cormack [Fri, 6 May 2022 11:14:09 +0000 (12:14 +0100)]
[RISCV] Add an extra vsetvli insertion test

This test starts failing with the changes in D125021.

2 years ago[libc++] Implement ranges::is_partitioned
Nikolas Klauser [Wed, 4 May 2022 12:19:09 +0000 (14:19 +0200)]
[libc++] Implement ranges::is_partitioned

Reviewed By: var-const, #libc

Spies: libcxx-commits, mgorny

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

2 years ago[CostModel][X86] Adjust pre-SSE41 fp scalar select costs to account for vector ops
Simon Pilgrim [Fri, 6 May 2022 10:41:45 +0000 (11:41 +0100)]
[CostModel][X86] Adjust pre-SSE41 fp scalar select costs to account for vector ops

Based off the script from D103695, we now mainly use BLENDV or OR(AND,ANDN) to select scalar float/double ops

2 years agoGeneralize "check-all" umbrella targets, use for check-clang-tools
Sam McCall [Wed, 16 Mar 2022 18:46:28 +0000 (19:46 +0100)]
Generalize "check-all" umbrella targets, use for check-clang-tools

The mechanism behind "check-all" is recording params of add_lit_testsuite()
calls in global variables LLVM_LIT_*, and then creating an extra suite with
their union at the end.
This avoids composing the check-* targets directly, which doesn't work well.

We generalize this by allowing multiple families of variables LLVM_{name}_LIT_*:
  umbrella_lit_testsuite_begin(check-foo)
  ... test suites here will be added to LLVM_FOO_LIT_* variables ...
  umbrella_lit_testsuite_end(check-foo)
(This also moves some implementation muck out of {llvm,clang}/CMakeLists.txt

This patch also changes check-clang-tools to use be an umbrella test target,
which means the clangd and clang-pseudo tests are included in it, along with the
the other testsuites that already are (like check-clang-extra-clang-tidy).

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

2 years ago[CostModel][X86] Adjust 256-bit select costs to account for slow BLENDV op
Simon Pilgrim [Fri, 6 May 2022 10:27:37 +0000 (11:27 +0100)]
[CostModel][X86] Adjust 256-bit select costs to account for slow BLENDV op

Based off the script from D103695, on AVX1, Jaguar/Bulldozer both have low throughput for ymm select patterns (BLENDV + OR(AND,ANDN))), and even on AVX2 Haswell still struggles with BLENDV ops

2 years ago[SLP][X86] Regenerate ssat tests to remove defunct AVX1/AVX2 checks
Simon Pilgrim [Fri, 6 May 2022 10:21:44 +0000 (11:21 +0100)]
[SLP][X86] Regenerate ssat tests to remove defunct AVX1/AVX2 checks

2 years ago[pseudo] Strip directives from a token stream
Sam McCall [Wed, 6 Apr 2022 19:29:59 +0000 (21:29 +0200)]
[pseudo] Strip directives from a token stream

This includes only the taken branch of conditional sections.
The API allows for producing a stream for a particular PP branch, which
will be used later for the secondary GLR parses of not-taken branches.

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

2 years agoRevert "[analyzer] Canonicalize SymIntExpr so the RHS is positive when possible"
Balazs Benics [Fri, 6 May 2022 10:13:51 +0000 (12:13 +0200)]
Revert "[analyzer] Canonicalize SymIntExpr so the RHS is positive when possible"

It seems like multiple users are affected by a crash introduced by this
commit, thus I'm reverting it for the time being.
Read more about the found reproducers at Phabricator.

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

This reverts commit f0d6cb4a5cf5723d7ddab2c7dab74f2f62116a6d.

2 years ago[libcxx] Reject month 0 in get_date/__get_month
David Spickett [Thu, 21 Apr 2022 14:09:56 +0000 (14:09 +0000)]
[libcxx] Reject month 0 in get_date/__get_month

[libcxx] Reject month 0 in get_date/__get_month

This fixes #47663.

Months in dates should be >= 1 and <= 12.
We parse up to two digits then minus one, because
we want to store this as "months since January"
(0-11).

However we didn't check that the result of that
was not -1. For example if you had (MM/DD/YYYY)
00/21/2022.

Added tests for:
* Failing if month is 0
* Failing if month is 13
* Allowing a leading zero in month e.g. "01"

Note that libc++ and libstdc++ return different
values on parsing failure, and MSVC STL returns
end of stream instead.

Handle the first two by checking for defines, MSVC STL
expects these tests to fail for other reasons already:
https://github.com/microsoft/STL/blob/main/tests/libcxx/expected_results.txt#L372
so not handling that case here.

Reviewed By: #libc, Mordante

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

2 years ago[libc++] Mark tests that use check_assertion.h as requiring unix headers
John Brawn [Fri, 6 May 2022 09:43:06 +0000 (10:43 +0100)]
[libc++] Mark tests that use check_assertion.h as requiring unix headers

On targets without unistd.h or sys/wait.h (such as bare metal targets)
any test that uses check_assertion.h will fail, so add
REQUIRES: has-unix-headers to them and autodetect whether we have
these headers or not.

These tests currently have unsupported on windows, but that's exactly
because windows doesn't have these headers so we can remove the
specific check for windows.

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

2 years ago[DAG][PowerPC] Combine shuffle(bitcast(X), Mask) to bitcast(shuffle(X, Mask'))
David Green [Fri, 6 May 2022 09:50:31 +0000 (10:50 +0100)]
[DAG][PowerPC] Combine shuffle(bitcast(X), Mask) to bitcast(shuffle(X, Mask'))

If the mask is made up of elements that form a mask in the higher type
we can convert shuffle(bitcast into the bitcast type, simplifying the
instruction sequence. A v4i32 2,3,0,1 for example can be treated as a
1,0 v2i64 shuffle. This helps clean up some of the AArch64 concat load
combines, along with helping simplify a number of other tests.

The PowerPC combine for v16i8 splat vector loads needed some fixes to
keep it working for v16i8 vectors. This improves the handling of v2i64
shuffles to match too, hopefully improving them in general.

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

2 years ago[CostModel][X86] Add more complete float/double select cost test coverage
Simon Pilgrim [Fri, 6 May 2022 09:43:49 +0000 (10:43 +0100)]
[CostModel][X86] Add more complete float/double select cost test coverage

We were only testing basic vector types

2 years ago[mlir][bufferize] Disallow adding new bufferizable ops during bufferization
Matthias Springer [Fri, 6 May 2022 09:01:39 +0000 (18:01 +0900)]
[mlir][bufferize] Disallow adding new bufferizable ops during bufferization

Ops that are created during the bufferization were not analyzed (when run with One-Shot Bufferize), and users should instead create memref ops directly.

Futhermore, this fixes an issue where an op was erased (and put on the `erasedOps` list), but subsequently a new tensor op was created at the same memory location. This op was then not bufferized. Disallowing the creation of new tensor ops simplifies the bufferization and fixes such issues.

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

2 years ago[RISCV] Enable MachineOutliner by default under -Oz for RISCV
wangpc [Fri, 6 May 2022 09:30:49 +0000 (17:30 +0800)]
[RISCV] Enable MachineOutliner by default under -Oz for RISCV

Enable default outlining when the function has the minsize attribute.

`addr-label.ll` crashed after enabling this, so a barrier is added before
instruction selection as a workaround.

Reviewed By: luismarques

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

2 years ago[lldb] Correct hex digit regex in some tests
David Spickett [Fri, 6 May 2022 09:28:21 +0000 (09:28 +0000)]
[lldb] Correct hex digit regex in some tests

"A-f" -> "A-F"

2 years ago[Flang] Lower Unstructured do loops
Kiran Chandramohan [Fri, 6 May 2022 09:09:01 +0000 (09:09 +0000)]
[Flang] Lower Unstructured do loops

The FIR `do_loop` is designed as a structured operation with a single
block inside it. Presence of unstructured constructs like jumps, exits
inside the loop will cause the loop to be marked as unstructured. These
loops are lowered using the `control-flow` dialect branch operations.

Fortran semantics do not allow the loop variable to be modified inside
the loop. To prevent accidental modification, the iteration of the
loop is modeled by two variables, trip-count and loop-variable.
-> The trip-count and loop-variable are initialized in the pre-header.
The trip-count is set as (end-start+step)/step where end, start and
step have the usual meanings. The loop-variable is initialized to start.
-> The header block contains a conditional branch instruction which
selects between branching to the body of the loop or the exit block
depending on the value of the trip-count.
-> Inside the body, the trip-count is decremented and the loop-variable
incremented by the step value. Finally it branches to the header of the
loop.

Part of the upstreaming effort to move LLVM Flang from fir-dev branch of
https://github.com/flang-compiler/f18-llvm-project to the LLVM Project.

Reviewed By: awarzynski

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

Co-authored-by: Val Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Peter Klausler <pklausler@nvidia.com>
2 years ago[SimpleLoopUnswitch] Collect either logical ANDs/ORs but not both.
Florian Hahn [Fri, 6 May 2022 08:50:03 +0000 (09:50 +0100)]
[SimpleLoopUnswitch] Collect either logical ANDs/ORs but not both.

After D97756, collectHomogenousInstGraphLoopInvariants may collect
conditions for both logical ANDs and logical ORs in case the root is a
select that matches both logical AND & OR.

This means the function won't return invariant values of either AND/OR
chains, but both. This can result in incorrect transformations.

See llvm/test/Transforms/SimpleLoopUnswitch/trivial-unswitch-logical-and-or.ll.
Without the patch, Alive2 rejects the modified tests with:
    Source and target don't have the same return domain.

Note that this also applies to the test case added in D97756
(@test_partial_condition_unswitch_or_select). We can't unswitch on
%cond6, because the graph leading to it contains and AND and an OR.

This only fixes trivial unswitching for now, but a similar problem
likely exists with non-trivial unswitching.

Reviewed By: nikic

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

2 years ago[flang][driver] Add support for -save-temps
Andrzej Warzynski [Fri, 29 Apr 2022 11:48:36 +0000 (11:48 +0000)]
[flang][driver] Add support for -save-temps

This patch adds support for `-save-temps` in `flang-new`, Flang's
compiler driver. The semantics of this option are inherited from Clang.

The file extension for temporary Fortran preprocessed files is set to
`i`. This is identical to what Clang uses for C (or C++) preprocessed
files. I have tried researching what other compilers do here, but I
couldn't find any definitive answers. One GFortran thread [1] suggests
that indeed it is not clear what the right approach should be.

Normally, various phases in Clang/Flang are combined. The `-save-temps`
option works by forcing the compiler to run every phase separately. As
there is no integrated assembler driver in Flang, user will have to use
`-save-temps` together with `-fno-integrated-as`. Otherwise, an
invocation to the integrated assembler would be generated generated,
which is going to fail (i.e. something equivalent to `clang -cc1as` from
Clang).

There are no specific plans for implementing an integrated assembler for
Flang for now. One possible solution would be to share it entirely with
Clang.

Note that on Windows you will get the following error when using
`-fno-integrated-as`:
```bash
  flang-new: error: there is no external assembler that can be used on this platform
```
Unfortunately, I don't have access to a Windows machine to investigate
this. Instead, I marked the tests in this patch as unsupported on
Windows.

[1] https://gcc.gnu.org/bugzilla//show_bug.cgi?id=81615

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

2 years ago[mlir][bufferize] Do not copy buffers with undefined contents
Matthias Springer [Fri, 6 May 2022 08:30:02 +0000 (17:30 +0900)]
[mlir][bufferize] Do not copy buffers with undefined contents

Buffers with undefined contents (e.g., the result of an init_tensor) are no longer copied.

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

2 years ago[mlir][scf] Implement BufferizableOpInterface for scf::WhileOp
Matthias Springer [Fri, 6 May 2022 08:22:44 +0000 (17:22 +0900)]
[mlir][scf] Implement BufferizableOpInterface for scf::WhileOp

This follows the same implementation strategy as scf::ForOp and common functionality is extracted into helper functions.

This implementation works well in cases where each yielded value (from either body/condition region) is equivalent to the corresponding bbArg of the parent block. In that case, each OpResult of the loop may be aliasing with the corresponding OpOperand of the loop (and with no other OpOperand).

In the absence of said equivalence relationship, new buffer copies must be inserted, so that the aliasing OpOperand/OpResult contract of scf::WhileOp is honored. In essence, by yielding a newly allocated buffer, we can enforce the specified may-alias relationship. (Newly allocated buffers cannot alias with any OpOperands of the loop.)

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

2 years ago[fastregalloc] Add test case for self loop (D125079).
Luo, Yuanke [Fri, 6 May 2022 07:38:42 +0000 (15:38 +0800)]
[fastregalloc] Add test case for self loop (D125079).

2 years ago[flang] Add ExternalNameConversionPass to pass pipeline
Diana Picus [Wed, 2 Mar 2022 11:02:59 +0000 (11:02 +0000)]
[flang] Add ExternalNameConversionPass to pass pipeline

This seems to be the consensus in
https://github.com/flang-compiler/f18-llvm-project/issues/1316

The patch adds ExternalNameConversion to the default FIR CodeGen pass
pipeline, right before the FIRtoLLVM pass. It also adds a flag to
optionally disable it, and sets it in `tco`. In other words, `flang-new`
and `flang-new -fc1` will both run the pass by default, whereas `tco`
will not, so none of the tests need to be updated.

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

2 years ago[pseudo] Add fuzzer for the pseudoparser.
Sam McCall [Thu, 5 May 2022 19:20:32 +0000 (21:20 +0200)]
[pseudo] Add fuzzer for the pseudoparser.

As confirmation, running this locally found 2 crashes:
 - trivial: crashes on file with no tokens
 - lexer: hits an assertion failure on bytes: 0x5c,0xa,0x5c,0x1,0x65,0x5c,0xa

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

2 years ago[Instrumentation] Share InstrumentationIRBuilder between TSan and SanCov
Marco Elver [Fri, 6 May 2022 06:53:31 +0000 (08:53 +0200)]
[Instrumentation] Share InstrumentationIRBuilder between TSan and SanCov

Factor our InstrumentationIRBuilder and share it between ThreadSanitizer
and SanitizerCoverage. Simplify its usage at the same time (use function
of passed Instruction or BasicBlock).

This class may be used in other instrumentation passes in future.

NFCI.

Reviewed By: nickdesaulniers

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

2 years ago[VectorCombine] Fold shuffle select pattern
David Green [Fri, 6 May 2022 07:13:18 +0000 (08:13 +0100)]
[VectorCombine] Fold shuffle select pattern

This patch adds a combine to attempt to reduce the costs of certain
select-shuffle patterns. The form of code it attempts to detect is:
  %x = shuffle ...
  %y = shuffle ...
  %a = binop %x, %y
  %b = binop %x, %y
  shuffle %a, %b, selectmask

A classic select-mask will pick items from each lane of a or b. These
do not always have a great lowering on many architectures. This patch
attempts to pack a and b into the lower elements, creating a differently
ordered shuffle for reconstructing the orignal which may be better than
the select mask. This can be better for performance, especially if less
elements of a and b need to be computed and the input shuffles are
cheaper.

Because select-masks are just one form of shuffle, we generalize to any
mask. So long as the backend has decent costmodel for the shuffles, this
can generally improve things when they come up. For more basic cost
models the folds do not appear to be profitable, not getting past the
cost checks.

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

2 years ago[libcxx] [ci] Add a i386 Windows configuration to CI
Martin Storsjö [Wed, 4 May 2022 08:05:44 +0000 (11:05 +0300)]
[libcxx] [ci] Add a i386 Windows configuration to CI

Adding a mingw based config is easy in the current CI environment
(where we can just choose the different target by calling
`i686-w64-mingw32-clang`), while adding a clang-cl based config would
require setting up different environment variables pointing to the
i386 library directory.

Just adding one config (DLL) instead of exhaustively testing both
(DLL and static) as very few tests would differ in practice, to keep
the CI load reasonable.

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

2 years ago[Support] Fix UB in BumpPtrAllocator when first allocation is zero.
Sam McCall [Thu, 5 May 2022 20:54:22 +0000 (22:54 +0200)]
[Support] Fix UB in BumpPtrAllocator when first allocation is zero.

BumpPtrAllocator::Allocate() is marked __attribute__((returns_nonnull)) when the
compiler supports it, which makes it UB to return null.

When there have been no allocations yet, the current slab is [nullptr, nullptr).
A zero-sized allocation fits in this range, and so Allocate(0, 1) returns null.

There's no explicit docs whether Allocate(0) is valid. I think we have to assume
that it is:
 - the implementation tries to support it (e.g. >= tests instead of >)
 - malloc(0) is allowed
 - requiring each callsite to do a check is bug-prone
 - I found real LLVM code that makes zero-sized allocations

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

2 years ago[pseudo] Only expand UCNs for raw_identifiers
Sam McCall [Thu, 5 May 2022 22:15:07 +0000 (00:15 +0200)]
[pseudo] Only expand UCNs for raw_identifiers

It turns out clang::expandUCNs only works on tokens that contain valid UCNs
and no other random escapes, and clang only uses it on raw_identifiers.

Currently we can hit an assertion by creating tokens with stray non-valid-UCN
backslashes in them.

Fortunately, expanding UCNs in raw_identifiers is actually all we need.
Most tokens (keywords, punctuation) can't have them. UCNs in literals can be
treated as escape sequences like \n even this isn't the standard's
interpretation. This more or less matches how clang works.
(See https://isocpp.org/files/papers/P2194R0.pdf which points out that the
standard's description of how UCNs work is misaligned with real implementations)

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

2 years ago[Lex] Don't assert when decoding invalid UCNs.
Sam McCall [Thu, 5 May 2022 23:44:41 +0000 (01:44 +0200)]
[Lex] Don't assert when decoding invalid UCNs.

Currently if a lexically-valid UCN encodes an invalid codepoint, then we
diagnose that, and then hit an assertion while trying to decode it.

Since there isn't anything preventing us reaching this state, remove the
assertion. expandUCNs("X\UAAAAAAAAY") will produce "XY".

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

2 years ago[AVR][NFC] Eliminate warning 'unused variable'
Ben Shi [Fri, 6 May 2022 06:10:37 +0000 (06:10 +0000)]
[AVR][NFC] Eliminate warning 'unused variable'

Reviewed By: Patryk27, aykevl

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

2 years ago[Coroutines] Don't re-materialize for debug instructions
Chuanqi Xu [Fri, 6 May 2022 05:50:08 +0000 (13:50 +0800)]
[Coroutines] Don't re-materialize for debug instructions

Re-materialize for debug instructions would cause a different code
generated if we enabled `-g`. This is bad. So we disable to
re-materialize for debug instructions.

2 years agoApply clang-tidy fixes for llvm-else-after-return in OpenMPDialect.cpp (NFC)
Mehdi Amini [Thu, 5 May 2022 23:01:50 +0000 (23:01 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in OpenMPDialect.cpp (NFC)

2 years agoApply clang-tidy fixes for bugprone-argument-comment in AffineOps.cpp (NFC)
Mehdi Amini [Thu, 5 May 2022 22:37:00 +0000 (22:37 +0000)]
Apply clang-tidy fixes for bugprone-argument-comment in AffineOps.cpp (NFC)

2 years ago[InstCombine] precommit tests for D124590
Chenbing Zheng [Fri, 6 May 2022 02:53:12 +0000 (10:53 +0800)]
[InstCombine] precommit tests for D124590

2 years ago[InstCombine] try to narrow more shifted bswap-of-zext
Chenbing Zheng [Fri, 6 May 2022 02:45:10 +0000 (10:45 +0800)]
[InstCombine] try to narrow more shifted bswap-of-zext

Try to narrow more bswap, if the shift amount is less than the zext
(bswap (zext X)) >> C --> (zext (bswap X)) << C'

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

Reviewed By: RKSimon

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