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

2 years ago[clang][NFC] In parts of Objective-C Sema use Obj-C-specific types instead of `Decl`.
Volodymyr Sapsai [Thu, 31 Mar 2022 18:06:42 +0000 (11:06 -0700)]
[clang][NFC] In parts of Objective-C Sema use Obj-C-specific types instead of `Decl`.

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

2 years ago[RISCV][SelectionDAG] Support VP_REDUCE_ADD mask operation.
Lian Wang [Thu, 5 May 2022 06:30:12 +0000 (06:30 +0000)]
[RISCV][SelectionDAG] Support VP_REDUCE_ADD mask operation.

Reviewed By: craig.topper

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

2 years agoXFAIL some PGO tests on AIX until the new linker becomes publicly available.
Wael Yehia [Fri, 6 May 2022 00:08:34 +0000 (20:08 -0400)]
XFAIL some PGO tests on AIX until the new linker becomes publicly available.

2 years agoInsert crashing stack frame when call to null func ptr
Jason Molenda [Fri, 6 May 2022 00:53:43 +0000 (17:53 -0700)]
Insert crashing stack frame when call to null func ptr

On arm64 targets, when the crashing pc is 0, the caller
frame can be found by looking at $lr, but the crash
reports don't use that trick to show the actual crashing
frame.  This patch adds that stack frame that lldb shows.

Also fix an issue where some register names were printed
as having a prefix of 'None'.

Differential Revision: https://reviews.llvm.org/D125042
rdar://92631787

2 years ago[gn build] (semi-manually) port 70a66c08fc65
Nico Weber [Fri, 6 May 2022 00:34:49 +0000 (20:34 -0400)]
[gn build] (semi-manually) port 70a66c08fc65

2 years ago[NFC][test] Replace hardcoded number with numeric substitution blocks
Sheng [Fri, 6 May 2022 00:04:52 +0000 (08:04 +0800)]
[NFC][test] Replace hardcoded number with numeric substitution blocks

In VarLenDecoder.td, the opcode in CHECK line is hardcoded, which
causes chaos in several downstream projects. This patch is trying
to fix that.

2 years ago[mlir] Fix printer when it is a DenseElementsAttr of i1
Chengji Yao [Thu, 5 May 2022 23:29:33 +0000 (16:29 -0700)]
[mlir] Fix printer when it is a DenseElementsAttr of i1

A large DenseElementsAttr of i1could trigger a bug in printer/parser roundtrip.

Ex. A DenseElementsAttr of i1 with 200 elements will print as Hex format of length 400 before the fix. However, when parsing the printed text, an error will be triggered. After fix, the printed length will be 50.

Reviewed By: rriddle

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

2 years ago[HWASan] Clean up hwasan_symbolize.
Florian Mayer [Thu, 5 May 2022 18:51:53 +0000 (11:51 -0700)]
[HWASan] Clean up hwasan_symbolize.

The globals are better expressed as members of the Symbolizer, and all
functions operating on it should be methods instead.

Also using the standard idiom of wrapping the main code in
`if __name__ == '__main__'`.

Reviewed By: eugenis

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

2 years ago[HWASan] Allow to linkify symbolizer output.
Florian Mayer [Tue, 3 May 2022 22:12:30 +0000 (15:12 -0700)]
[HWASan] Allow to linkify symbolizer output.

Reviewed By: eugenis

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

2 years ago[compiler-rt][builtins] Add helper functions for uint16/sint16/uint8/sint8 div and mod
Ben Shi [Thu, 5 May 2022 07:35:09 +0000 (07:35 +0000)]
[compiler-rt][builtins] Add helper functions for uint16/sint16/uint8/sint8 div and mod

__udivmodhi4 : uint16 div and mod
__udivmodqi4 : uint8 div and mod
__divmodhi4  : sint16 div and mod
__divmodqi4  : sint8 div and mod

The above helper functions in libgcc have special ABI as described at
https://gcc.gnu.org/wiki/avr-gcc#Exceptions_to_the_Calling_Convention .

Reviewed By: aykevl

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

2 years ago[SPIRV] Add SPIR-V specific intrinsics, two passes and tests
Ilia Diachkov [Thu, 5 May 2022 20:29:26 +0000 (23:29 +0300)]
[SPIRV] Add SPIR-V specific intrinsics, two passes and tests

The patch adds SPIR-V specific intrinsics required to keep information
critical to SPIR-V consistency (types, constants, etc.) during translation
from IR to MIR.

Two related passes (SPIRVEmitIntrinsics and SPIRVPreLegalizer) and several
LIT tests (passed with this change) have also been added.

It also fixes the issue with opaque pointers in SPIRVGlobalRegistry.cpp
and the mismatch of the data layout between the SPIR-V backend and clang
(Issue #55122).

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

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
2 years ago[docs] Fix uses of `foo` that should be ``foo`` throughout release notes.
Richard Smith [Thu, 5 May 2022 23:04:19 +0000 (16:04 -0700)]
[docs] Fix uses of `foo` that should be ``foo`` throughout release notes.

2 years ago[docs] Add blank lines to help Sphinx parse nested bullets.
Richard Smith [Thu, 5 May 2022 22:57:17 +0000 (15:57 -0700)]
[docs] Add blank lines to help Sphinx parse nested bullets.

2 years agoRevert "Pedantically warn about // comments in gnu89 mode"
Aaron Ballman [Thu, 5 May 2022 22:39:13 +0000 (18:39 -0400)]
Revert "Pedantically warn about // comments in gnu89 mode"

This reverts commit f6dff93641b2259623e686eb13a1884b8b9f4a00.

This diagnostic is also in the -Wcomment group, which is in the -Wall
group, so the diagnostic is enabled in a wider context than GCC does.
That turns out to be disruptive for the Linux kernel builds still using
-std=gnu89 because the kernel requires C source files to start with //
comments: https://kernel.org/doc/html/v5.18-rc5/process/license-rules.html#license-identifier-syntax

2 years ago[mlir][sparse] add more zero-preserving unary ops to sparse compiler
Aart Bik [Thu, 5 May 2022 21:02:03 +0000 (14:02 -0700)]
[mlir][sparse] add more zero-preserving unary ops to sparse compiler

Although we now have semi-rings to deal with arbitrary ops,
it is still good to convey zero-preserving semantics of
ops to the sparse compiler.

Reviewed By: bixia

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

2 years ago[flang] Change "unsupported" messages in the runtime to "not yet implemented"
Peter Steinfeld [Thu, 5 May 2022 21:54:57 +0000 (14:54 -0700)]
[flang] Change "unsupported" messages in the runtime to "not yet implemented"

If a programmer is able to compile and link a program that contains types that
are not yet supported by the runtime, it must be because they're not yet
implemented.

This change will make it easier to find unimplemented code in tests.

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