platform/upstream/llvm.git
2 years ago[RISCV] Add swapped patterns to VPatIntegerSetCCVL_VIPlus1.
Craig Topper [Thu, 7 Apr 2022 16:05:51 +0000 (09:05 -0700)]
[RISCV] Add swapped patterns to VPatIntegerSetCCVL_VIPlus1.

This matches VPatIntegerSetCCVL_VI_Swappable. But as noted in the
FIXME this may only be needed due to lack of canonicalization on
VP_SETCC.

Reviewed By: rogfer01

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

2 years ago[SVE] Add more gather/scatter tests to highlight bugs in their generated code.
Paul Walker [Thu, 7 Apr 2022 15:42:08 +0000 (16:42 +0100)]
[SVE] Add more gather/scatter tests to highlight bugs in their generated code.

2 years ago[libc] Add a linux Thread class in __support/threads.
Siva Chandra Reddy [Fri, 1 Apr 2022 06:42:14 +0000 (06:42 +0000)]
[libc] Add a linux Thread class in __support/threads.

This change is essentially a mechanical change which moves the thread
creation and join implementations from src/threads/linux to
src/__support/threads/linux/thread.h. The idea being that, in future, a
pthread implementation can reuse the common thread implementations in
src/__support/threads.

Reviewed By: lntue

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

2 years ago[libcxx] Add flag to disable __builtin_assume in _LIBCPP_ASSERT
Arthur Eubanks [Wed, 6 Apr 2022 02:16:39 +0000 (19:16 -0700)]
[libcxx] Add flag to disable __builtin_assume in _LIBCPP_ASSERT

Introduce _LIBCPP_ASSERTIONS_DISABLE_ASSUME which makes _LIBCPP_ASSERT
not call __builtin_assume when _LIBCPP_ENABLE_ASSERTIONS == 0.

Calling __builtin_assume was introduced in D122397.

__builtin_assume is generally supposed to improve optimizations, but can
cause regressions when LLVM has trouble handling the calls to
`llvm.assume()` (see comments in D122397).

Reviewed By: philnik

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

2 years agoAMDGPU: Set implicit kernarg size to be of 256 bytes for code object version 5
Changpeng Fang [Thu, 7 Apr 2022 15:35:23 +0000 (08:35 -0700)]
AMDGPU: Set implicit kernarg size to be of 256 bytes for code object version 5

Summary:
  If implicitarg_ptr intrinsic is not used, set implicit kernarg size to 0, otherwise
set it to 256 bytes for code object version 5 (and beyond).

Reviewers: arsenm

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

2 years ago[X86] Enable fast variable per-lane shuffle tuning on all Ryzen targets (PR44795)
Simon Pilgrim [Thu, 7 Apr 2022 15:00:42 +0000 (16:00 +0100)]
[X86] Enable fast variable per-lane shuffle tuning on all Ryzen targets (PR44795)

rGa3b8695bf592 enabled this for znver3, but AMD SoG, Agner and uops.info all agree that even znver1 has a fast per-lane shuffle op (VPSHUFB), but cross-lane shuffles seem to be slow (PERMPS etc.)

Fixes #44140

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

2 years agoRemove a few effectively-unused FileEntry APIs. NFC
Sam McCall [Wed, 6 Apr 2022 09:37:25 +0000 (11:37 +0200)]
Remove a few effectively-unused FileEntry APIs. NFC

- isValid: FileManager only ever returns valid FileEntries (see next point)

- construction from outside FileManager (both FileEntry and DirectoryEntry).
  It's not possible to create a useful FileEntry this way, there are no setters.
  This was only used in FileEntryTest, added a friend to enable this.
  A real constructor is cleaner but requires larger changes to FileManager.

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

2 years ago[mlir] specify dialect names in doc generation
Alex Zinenko [Thu, 7 Apr 2022 14:36:30 +0000 (16:36 +0200)]
[mlir] specify dialect names in doc generation

In several cases, a doc is being generated from a .td file that includes
files containing other dialects. Specify the dialect for which the
documentation is being generated explicitly.

2 years ago[Sink] Don't sink non-willreturn calls (PR51188)
Nikita Popov [Thu, 7 Apr 2022 14:23:56 +0000 (16:23 +0200)]
[Sink] Don't sink non-willreturn calls (PR51188)

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

2 years ago[Sink] Add willreturn test
Nikita Popov [Thu, 7 Apr 2022 14:21:23 +0000 (16:21 +0200)]
[Sink] Add willreturn test

Explicitly test the nounwind/willreturn combinations.

2 years ago[InstCombine] SimplifyDemandedUseBits - allow and(srem(X,Pow2),C) -> and(X,C) to...
Simon Pilgrim [Thu, 7 Apr 2022 14:13:46 +0000 (15:13 +0100)]
[InstCombine] SimplifyDemandedUseBits - allow and(srem(X,Pow2),C) -> and(X,C) to work on vector types

Replace m_ConstantInt with m_APInt to match uniform (no-undef) vector remainder amounts.

2 years ago[MLIR][Presburger] refactor subtraction to be non-recursive
Arjun P [Thu, 7 Apr 2022 13:41:04 +0000 (14:41 +0100)]
[MLIR][Presburger] refactor subtraction to be non-recursive

Subtraction was previously implemented recursively. This refactors it to be
non-recursive to avoid issues with potential stack overflows.

Reviewed By: Groverkss

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

2 years ago[libc++] Add back-deployment testing on arm64 macs
Louis Dionne [Mon, 4 Apr 2022 21:53:31 +0000 (17:53 -0400)]
[libc++] Add back-deployment testing on arm64 macs

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

2 years agoAdd missing template keywords
Alexey Bataev [Thu, 7 Apr 2022 13:18:17 +0000 (06:18 -0700)]
Add missing template keywords

GCC 14 warns about these.

Reviewed By: ABataev

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

2 years agoRevert "Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON"""
Nico Weber [Thu, 7 Apr 2022 14:06:45 +0000 (10:06 -0400)]
Revert "Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON"""

This reverts commit 2aca33baf15926afe2520a06b1427a9894226fd2.
Broke tests on several bots, see comments on https://reviews.llvm.org/D120305

2 years ago[AMDGPU][MC][GFX10] Added syntactic sugar for s_waitcnt_depctr operand
Dmitry Preobrazhensky [Thu, 7 Apr 2022 14:02:50 +0000 (17:02 +0300)]
[AMDGPU][MC][GFX10] Added syntactic sugar for s_waitcnt_depctr operand

Added the following helpers:

    depctr_hold_cnt(...)
    depctr_sa_sdst(...)
    depctr_va_vdst(...)
    depctr_va_sdst(...)
    depctr_va_ssrc(...)
    depctr_va_vcc(...)
    depctr_vm_vsrc(...)

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

2 years ago[InstCombine] Regenerate and(srem(X,Pow2),C) test and add vector coverage
Simon Pilgrim [Thu, 7 Apr 2022 13:58:39 +0000 (14:58 +0100)]
[InstCombine] Regenerate and(srem(X,Pow2),C) test and add vector coverage

2 years agoremove dead code in parseRegisterList checking for ARM::RA_AUTH_CODE
Ties Stuij [Thu, 7 Apr 2022 13:35:30 +0000 (14:35 +0100)]
remove dead code in parseRegisterList checking for ARM::RA_AUTH_CODE

Reviewed By: RKSimon

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

2 years ago[InstCombine] SimplifyDemandedUseBits - add TODO to remove shl node if we only demand...
Simon Pilgrim [Thu, 7 Apr 2022 13:35:11 +0000 (14:35 +0100)]
[InstCombine] SimplifyDemandedUseBits - add TODO to remove shl node if we only demand known sign bits of the shift source

Similar to what we already perform for ashr/lshr

2 years ago[InstCombine] SimplifyDemandedUseBits - remove lshr node if we only demand known...
Simon Pilgrim [Thu, 7 Apr 2022 13:33:31 +0000 (14:33 +0100)]
[InstCombine] SimplifyDemandedUseBits - remove lshr node if we only demand known sign bit

This is a lshr equivalent to D122340 - if we don't demand any of the additional sign bits introduced by the ashr, the lshr can be treated as an ashr and we can remove the shift entirely if we only demand already known sign bits.

Another step towards PR21929

https://alive2.llvm.org/ce/z/6f3kjq

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

2 years ago[gn build] Port 1306b1025c50
LLVM GN Syncbot [Thu, 7 Apr 2022 13:18:45 +0000 (13:18 +0000)]
[gn build] Port 1306b1025c50

2 years ago[libc++][ranges] Implement ranges::count{, _if}
Nikolas Klauser [Thu, 7 Apr 2022 11:02:02 +0000 (13:02 +0200)]
[libc++][ranges] Implement ranges::count{, _if}

Reviewed By: var-const, Mordante, ldionne, #libc

Spies: tcanens, libcxx-commits, mgorny

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

2 years ago[lld-macho][nfc] Factor out findSymbolAtOffset
Jez Ng [Thu, 7 Apr 2022 13:05:33 +0000 (09:05 -0400)]
[lld-macho][nfc] Factor out findSymbolAtOffset

Our compact unwind handling code currently has some logic to locate a
symbol at a given offset in an InputSection. The EH frame code will need
to do something similar, so let's factor out the code.

Reviewed By: #lld-macho, thakis

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

2 years agoFix MSVC "not all control paths return a value" warning
Simon Pilgrim [Thu, 7 Apr 2022 13:01:06 +0000 (14:01 +0100)]
Fix MSVC "not all control paths return a value" warning

2 years ago[X86] Ensure ZN3Tuning inherits from ZN2Tuning instead of ZNTuning
Simon Pilgrim [Thu, 7 Apr 2022 12:38:21 +0000 (13:38 +0100)]
[X86] Ensure ZN3Tuning inherits from ZN2Tuning instead of ZNTuning

At the moment ZN2Tuning is just a copy of ZNTuning, but we should try to keep a clean inheritance.

2 years ago[X86] Add test case for PR44795
Simon Pilgrim [Thu, 7 Apr 2022 12:36:37 +0000 (13:36 +0100)]
[X86] Add test case for PR44795

2 years ago[clang] Verify internal entity module mangling
Nathan Sidwell [Wed, 6 Apr 2022 14:24:06 +0000 (07:24 -0700)]
[clang] Verify internal entity module mangling

Internal symbol mangling is implementation-defined.  We do not mangle
any module attachment, and this adds a test to verify that.

Reviewed By: dblaikie

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

2 years agoFix warnings when `-Wdeprecated-enum-enum-conversion` is enabled
Antonio Frighetto [Thu, 7 Apr 2022 12:20:54 +0000 (08:20 -0400)]
Fix warnings when `-Wdeprecated-enum-enum-conversion` is enabled

clang may throw the following warning:
include/clang/AST/DeclarationName.h:210:52: error: arithmetic between
different enumeration types ('clang::DeclarationName::StoredNameKind'
and 'clang::detail::DeclarationNameExtra::ExtraKind') is deprecated
when flags -Werror,-Wdeprecated-enum-enum-conversion are on.

This adds the `addEnumValues()` helper function to STLExtras.h to hide
the details of adding enumeration values together from two different
enumerations.

2 years ago[gn build] (manually) port 3031fa88f01e
Nico Weber [Thu, 7 Apr 2022 12:15:33 +0000 (08:15 -0400)]
[gn build] (manually) port 3031fa88f01e

2 years ago[gn build] (manually) port 5390606aa963
Nico Weber [Thu, 7 Apr 2022 12:13:26 +0000 (08:13 -0400)]
[gn build] (manually) port 5390606aa963

2 years ago[lld/mac] Don't emit stabs entries for functions folded during ICF
Nico Weber [Wed, 6 Apr 2022 19:55:42 +0000 (15:55 -0400)]
[lld/mac] Don't emit stabs entries for functions folded during ICF

This matches ld64, and makes dsymutil work better with lld's output.
Fixes PR54783, see there for details.

Reduces time needed to run dsymutil on Chromium Framework from 8m30s
(which is already down from 26 min with D123218) to 6m30s and removes
many lines of "could not find object file symbol for symbol" from dsymutil output
(previously: several MB of those messages, now dsymutil is completely silent).

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

2 years ago[libc++] Remove redundant __invoke_constexpr functions
Nikolas Klauser [Wed, 6 Apr 2022 21:10:21 +0000 (23:10 +0200)]
[libc++] Remove redundant __invoke_constexpr functions

There are `constexpr` versions for the different `__invoke` functions, which seem to be identical other than begin `constexpr` since C++11 instead of being `constexpr` since C++20.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[Clang] Remove redundant -no-opaque-pointers flag in test (NFC)
Nikita Popov [Thu, 7 Apr 2022 11:52:19 +0000 (13:52 +0200)]
[Clang] Remove redundant -no-opaque-pointers flag in test (NFC)

This was accidentally caught in an automated replacement. This
test is testing the -opaque-pointers flag itself, so we shouldn't
add -no-opaque-pointers here (though it doesn't hurt either).

Also drop the line testing the default, as the default is now
determined by a cmake option.

2 years ago[clang][DebugInfo] Support debug info for alias variable
Kavitha Natarajan [Mon, 7 Mar 2022 07:15:52 +0000 (12:45 +0530)]
[clang][DebugInfo] Support debug info for alias variable

clang to emit DWARF information for global alias variable as
DW_TAG_imported_declaration. This change also handles nested
(recursive) imported declarations.

Reviewed by: dblaikie, aprantl

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

2 years ago[LoongArch] Split asmstr to opcstr and opnstr in LAInst class definition. NFC
Weining Lu [Thu, 7 Apr 2022 08:07:42 +0000 (16:07 +0800)]
[LoongArch] Split asmstr to opcstr and opnstr in LAInst class definition. NFC

This change removes a lot of redundant strconcat usings.

2 years ago[bugpoint] ReduceCrashingFunctions::TestFuncs - fix dereference of null point static...
Simon Pilgrim [Thu, 7 Apr 2022 11:13:55 +0000 (12:13 +0100)]
[bugpoint] ReduceCrashingFunctions::TestFuncs - fix dereference of null point static analyzer warning

Alias.getAliaseeObject() shouldn't be null, do use dyn_cast instead of dyn_cast_or_null

Also, remove redundant `else if (!F)` test - that is always true at the point in the if-else chain

2 years agoFix grammar and punctuation across several docs; NFC
Priyansh Singh [Thu, 7 Apr 2022 11:11:11 +0000 (07:11 -0400)]
Fix grammar and punctuation across several docs; NFC

2 years ago[AMDGPU] Regenerate xor3-i1-const.ll test(NFC)
chenglin.bi [Thu, 7 Apr 2022 11:08:59 +0000 (19:08 +0800)]
[AMDGPU] Regenerate xor3-i1-const.ll test(NFC)

2 years ago[RISCV] Fix crash for section alignment with .option norvc
Luís Marques [Thu, 7 Apr 2022 11:00:41 +0000 (12:00 +0100)]
[RISCV] Fix crash for section alignment with .option norvc

The existing code wasn't getting the subtarget info from the fragment,
so the current status of RVC would be ignored. This would cause a crash
for the new test case when the target then reported it couldn't write
the requested number of code alignment bytes.

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

2 years ago[DebugInfo] Use DW_ATE_signed encoding when creating a Fortran
Chih-Ping Chen [Mon, 28 Mar 2022 13:45:19 +0000 (09:45 -0400)]
[DebugInfo] Use DW_ATE_signed encoding when creating a Fortran
array index type.

2 years ago[clangd] NFC: Fix doc typos
Kirill Bobyrev [Thu, 7 Apr 2022 10:56:56 +0000 (12:56 +0200)]
[clangd] NFC: Fix doc typos

2 years ago[Clang] Add -no-opaque-pointers to more tests (NFC)
Nikita Popov [Thu, 7 Apr 2022 10:15:37 +0000 (12:15 +0200)]
[Clang] Add -no-opaque-pointers to more tests (NFC)

This adds the flag to more tests that were not caught by the
mass-migration in 532dc62b907554b3f07f17205674aa71e76fc863.

2 years ago[CSKY] Support bitcast operation from/to double to/from two GPRs
Zi Xuan Wu [Thu, 7 Apr 2022 10:24:34 +0000 (18:24 +0800)]
[CSKY] Support bitcast operation from/to double to/from two GPRs

In soft ABI, floating num is passing in GPRs. So we need support
bitcovert from double to Hi and Lo GPRs and vice versa

2 years ago[X86] Add Issue #50412 fcmp-logic test case
Simon Pilgrim [Thu, 7 Apr 2022 10:24:56 +0000 (11:24 +0100)]
[X86] Add Issue #50412 fcmp-logic test case

2 years agoFix "result of 32-bit shift implicitly converted to 64 bits" MSVC warning. NFC.
Simon Pilgrim [Thu, 7 Apr 2022 10:19:54 +0000 (11:19 +0100)]
Fix "result of 32-bit shift implicitly converted to 64 bits" MSVC warning. NFC.

2 years ago[bazel] Port 3031fa88f0
Benjamin Kramer [Thu, 7 Apr 2022 10:14:14 +0000 (12:14 +0200)]
[bazel] Port 3031fa88f0

2 years ago[OpaquePtrs][Clang] Add -no-opaque-pointers to tests (NFC)
Nikita Popov [Thu, 7 Apr 2022 10:03:55 +0000 (12:03 +0200)]
[OpaquePtrs][Clang] Add -no-opaque-pointers to tests (NFC)

This adds -no-opaque-pointers to clang tests whose output will
change when opaque pointers are enabled by default. This is
intended to be part of the migration approach described in
https://discourse.llvm.org/t/enabling-opaque-pointers-by-default/61322/9.

The patch has been produced by replacing %clang_cc1 with
%clang_cc1 -no-opaque-pointers for tests that fail with opaque
pointers enabled. Worth noting that this doesn't cover all tests,
there's a remaining ~40 tests not using %clang_cc1 that will need
a followup change.

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

2 years ago[libc++][ranges] Add implicit conversion to bool test for ranges::find{, if, if_not}
Nikolas Klauser [Thu, 7 Apr 2022 10:01:49 +0000 (12:01 +0200)]
[libc++][ranges] Add implicit conversion to bool test for ranges::find{, if, if_not}

Reviewed By: ldionne, var-const, #libc

Spies: libcxx-commits

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

2 years ago[lldb] Fix building standalone LLDB on Windows.
Mehdi Chinoune [Thu, 7 Apr 2022 09:11:52 +0000 (12:11 +0300)]
[lldb] Fix building standalone LLDB on Windows.

It was broken since https://reviews.llvm.org/D110172

Reviewed By: JDevlieghere

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

2 years ago[MLIR] Standalone: Fix copy-and-paste typo (NFC)
Lorenzo Chelini [Thu, 7 Apr 2022 09:17:21 +0000 (11:17 +0200)]
[MLIR] Standalone: Fix copy-and-paste typo (NFC)

Remove duplicate statements.

2 years ago[lldb] [CMake] Disable GCC's -Wstringop-truncation warning. NFC.
Martin Storsjö [Wed, 6 Apr 2022 20:18:55 +0000 (23:18 +0300)]
[lldb] [CMake] Disable GCC's -Wstringop-truncation warning. NFC.

This warning gives false positives about lldb's correct use of
strncpy to fill fixed length fields that don't need null termination,
in lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp, like this:

    In file included from /usr/include/string.h:495,
                     from /usr/include/c++/9/cstring:42,
                     from ../include/llvm/ADT/StringRef.h:19,
                     from ../tools/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:10:
    In function ‘char* strncpy(char*, const char*, size_t)’,
        inlined from ‘lldb::offset_t CreateAllImageInfosPayload(const ProcessSP&, lldb::offset_t, lldb_private::StreamString&, lldb::SaveCoreStyle)’ at ../tools/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:6341:16:
    /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:34: warning: ‘char* __builtin_strncpy(char*, const char*, long unsigned int)’ specified bound 16 equals destination size [-Wstringop-truncation]
      106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
          |          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~

The warning could be squelched locally with

    #pragma GCC diagnostic ignored "-Wstringop-truncation"

too, but Clang also interprets those GCC pragmas, and produces
a -Wunknown-warning-option warning instead. That could be remedied
by wrapping the pragma in an "#ifndef __clang__" - but that makes
things even more messy. Instead, just silence this warning entirely.

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

2 years ago[clang][ASTImporter] Not using consumeError at failed import of in-class initializer.
Balázs Kéri [Thu, 7 Apr 2022 08:31:09 +0000 (10:31 +0200)]
[clang][ASTImporter] Not using consumeError at failed import of in-class initializer.

The error can be returned from the function, the problem written in comment before
does not exist. The same is done already in ASTImporter at various import failures.

After a declaration is created in an `ASTNodeImporter` import function
with `GetImportedOrCreateDecl`, that function registers it with
`MapImported`. At many places import errors can happen after this
and the error is returned. The same can be done in the place where
the in-class initializer is imported.

Reviewed By: martong

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

2 years ago[clang-tidy] Silence unused variable warning in release builds. NFCI.
Benjamin Kramer [Thu, 7 Apr 2022 09:00:28 +0000 (11:00 +0200)]
[clang-tidy] Silence unused variable warning in release builds. NFCI.

2 years ago[LoongArch] Improve td files indentation a little bit. NFC
Weining Lu [Thu, 7 Apr 2022 07:16:59 +0000 (15:16 +0800)]
[LoongArch] Improve td files indentation a little bit. NFC

2 years ago[RISCV] Select unmasked integer setcc insts via ISel post-process
Fraser Cormack [Wed, 6 Apr 2022 13:26:20 +0000 (14:26 +0100)]
[RISCV] Select unmasked integer setcc insts via ISel post-process

This patch has no effect on the generated code, whilst mitigating the
increase in ISel table size caused by the recent addition of masked
patterns.

I aim to do the same for floating-point patterns once D123051 lands,
giving us a reason to use masked floating-point patterns.

Reviewed By: arcbbb

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

2 years ago[bazel] Port 5390606aa963
Benjamin Kramer [Thu, 7 Apr 2022 08:40:55 +0000 (10:40 +0200)]
[bazel] Port 5390606aa963

2 years agoTransforms: Remove unused include
Benjamin Kramer [Thu, 7 Apr 2022 08:40:28 +0000 (10:40 +0200)]
Transforms: Remove unused include

Utils can't depend on Scalar transforms.

2 years ago[VPlan] Use vector.body as header name in VPlan native path.
Florian Hahn [Thu, 7 Apr 2022 08:31:12 +0000 (10:31 +0200)]
[VPlan] Use vector.body as header name in VPlan native path.

This brings the VPlan block naming in line with the naming of the
generated basic blocks.

2 years ago[RISCV][VP] Add basic RVV codegen for vp.fcmp
Fraser Cormack [Mon, 4 Apr 2022 17:19:11 +0000 (18:19 +0100)]
[RISCV][VP] Add basic RVV codegen for vp.fcmp

This patch adds the necessary infrastructure to lower vp.fcmp via
ISD::VP_SETCC to RVV instructions.

Most notably this patch adds cond-code legalization for VP_SETCC,
reusing the existing TargetLowering::LegalizeSetCCCondCode by passing in
additional SDValue parameters for the Mask and EVL. This method then
uses VP operations to legalize the condcode.

There is still a general lack of canonicalization on VP_SETCC as opposed
to SETCC which results in worse code than is theoretically possible.

Reviewed By: craig.topper

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

2 years ago[lld] Remove support for legacy pass manager
Nikita Popov [Wed, 6 Apr 2022 14:21:20 +0000 (16:21 +0200)]
[lld] Remove support for legacy pass manager

This removes options for performing LTO with the legacy pass
manager in LLD. Options that explicitly enable the new pass manager
are retained as no-ops.

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

2 years ago[OpaquePtr][Clang] Add CLANG_ENABLE_OPAQUE_POINTERS cmake option
Nikita Popov [Tue, 5 Apr 2022 12:45:51 +0000 (14:45 +0200)]
[OpaquePtr][Clang] Add CLANG_ENABLE_OPAQUE_POINTERS cmake option

This option controls whether -opaque-pointers or -no-opaque-pointers
is the default. Once opaque pointers are enabled by default, this
will provide a simple way to temporarily opt-out of the change.

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

2 years ago[mlir][CSE] Remove duplicated operations with MemRead side-effect
Valentin Clement [Thu, 7 Apr 2022 08:06:50 +0000 (10:06 +0200)]
[mlir][CSE] Remove duplicated operations with MemRead side-effect

This patch enhances the CSE pass to deal with simple cases of duplicated
operations with MemoryEffects.

It allows the CSE pass to remove safely duplicate operations with the
MemoryEffects::Read that have no other side-effecting operations in
between. Other MemoryEffects::Read operation are allowed.

The use case is pretty simple so far so we can build on top of it to add
more features.

This patch is also meant to avoid a dedicated CSE pass in FIR and was
brought together afetr discussion on https://reviews.llvm.org/D112711.
It does not currently cover the full range of use cases described in
https://reviews.llvm.org/D112711 but the idea is to gradually enhance
the MLIR CSE pass to handle common use cases that can be used by
other dialects.

This patch takes advantage of the new CSE capabilities in Fir.

Reviewed By: mehdi_amini, rriddle, schweitz

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

2 years ago[x86] Improve select lowering for smin(x, 0) & smax(x, 0)
Wei Xiao [Tue, 5 Apr 2022 08:00:46 +0000 (16:00 +0800)]
[x86] Improve select lowering for smin(x, 0) & smax(x, 0)

smin(x, 0):
  (select (x < 0), x, 0) -> ((x >> (size_in_bits(x)-1))) & x

smax(x, 0):
  (select (x > 0), x, 0) -> (~(x >> (size_in_bits(x)-1))) & x
  The comparison is testing for a positive value, we have to invert the sign
  bit mask, so only do that transform if the target has a bitwise 'and not'
  instruction (the invert is free).

The transform is performed only when CMP has a single user to avoid
increasing total instruction number.

https://alive2.llvm.org/ce/z/euUnNm
https://alive2.llvm.org/ce/z/37339J

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

2 years ago[LoopSink] Use MemorySSA with legacy pass manager
Nikita Popov [Wed, 6 Apr 2022 12:39:20 +0000 (14:39 +0200)]
[LoopSink] Use MemorySSA with legacy pass manager

LoopSink with the legacy pass manager still uses AST, because we
can't compute MemorySSA conditionally. I think now that the legacy
pass manager will be removed soon(TM) we don't need to care about
compile-time impact here anymore. Additionally, since MemorySSA is
no longer eagerly optimized, the impact is actually not that high
anymore (~0.2% geomean regression on CTMark).

This just makes legacy PM and new PM behavior line up -- as a
followup I'll drop these options entirely and make MemorySSA use
mandatory.

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

2 years ago[clang-tidy] bugprone-signal-handler: Message improvement and code refactoring.
Balázs Kéri [Thu, 7 Apr 2022 07:00:01 +0000 (09:00 +0200)]
[clang-tidy] bugprone-signal-handler: Message improvement and code refactoring.

Another change of the code design.
Code simplified again, now there is a single place to check
a handler function and less functions for bug report emitting.
More details are added to the bug report messages.

Reviewed By: whisperity

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

2 years ago[LLD][COFF] Fix TypeServerSource matcher with more than one collision
Tobias Hieta [Wed, 6 Apr 2022 15:06:37 +0000 (17:06 +0200)]
[LLD][COFF] Fix TypeServerSource matcher with more than one collision

Follow-up from 98bc304e9faded44f1d8988ffa4c5d8b50c759ec - while that
commit fixed when you had two PDBs colliding on the same Guid it didn't
fix the case where you had more than two PDBs using the same Guid.

This commit fixes that and also tests much more carefully that all
the types are correct no matter the order.

Reviewed By: aganea, saudi

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

2 years ago[AMDGPU] Fix test difference in debug and release. NFC.
Stanislav Mekhanoshin [Thu, 7 Apr 2022 06:47:14 +0000 (23:47 -0700)]
[AMDGPU] Fix test difference in debug and release. NFC.

Added -disable-gisel-legality-check to couple GlobalISel tests
which have not legal instructions to avoid difference in
debug and release builds.

2 years agoCorrect debugserver to write xmm/ymm/zmm reg values
Jason Molenda [Thu, 7 Apr 2022 06:33:19 +0000 (23:33 -0700)]
Correct debugserver to write xmm/ymm/zmm reg values

debugserver does not call thread_set_state when changing xmm/ymm/zmm
register values, so the register contents are never updated.  Fix
that.  Mark the shell tests which xfail'ed these tests on darwin systems
to xfail them when the system debugserver, they will pass when using
the in-tree debugserver.  When this makes it into the installed
system debugservers, we'll remove the xfails.

Differential Revision: https://reviews.llvm.org/D123269
rdar://91258333
rdar://31294382

2 years ago[RISCV] Add CMOV isel pattern for (select (setgt X, Imm), Y, Z)
Liqin Weng [Thu, 7 Apr 2022 05:45:06 +0000 (05:45 +0000)]
[RISCV] Add CMOV isel pattern for (select (setgt X, Imm), Y, Z)

Reviewed By: craig.topper

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

2 years ago[CMake][Fuchsia] Include bolt
Petr Hosek [Thu, 7 Apr 2022 00:37:23 +0000 (17:37 -0700)]
[CMake][Fuchsia] Include bolt

We would like to use bolt with Fuchsia toolchain.

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

2 years ago[ELF] Ignore --no-add-needed
Fangrui Song [Thu, 7 Apr 2022 05:41:27 +0000 (22:41 -0700)]
[ELF] Ignore --no-add-needed

It is used by a few projects like keepassxc and mumble.
Also see https://bugzilla.redhat.com/show_bug.cgi?id=2070813 that Fedora gcc has
an (unneeded) gcc12-no-add-needed.patch which adds --no-add-needed, although
--[no-]add-needed has been deprecated in GNU ld since 2009. Adding this has low
costs and makes several folks happy.

This basically restores 8f13bef575c97db4d6c146c3bb647ac9e73a9248.

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

2 years ago[Driver][test] Fix csky-toolchain.c to be CLANG_DEFAULT_PIE_ON_LINUX agnostic
Fangrui Song [Thu, 7 Apr 2022 04:14:24 +0000 (21:14 -0700)]
[Driver][test] Fix csky-toolchain.c to be CLANG_DEFAULT_PIE_ON_LINUX agnostic

2 years ago[lld-macho][nfc] Rearrange order of statements to clarify data dependencies
Jez Ng [Thu, 7 Apr 2022 04:00:41 +0000 (00:00 -0400)]
[lld-macho][nfc] Rearrange order of statements to clarify data dependencies

2 years ago[Driver][test] Fix csky-toolchain.c to be CLANG_DEFAULT_PIE_ON_LINUX agnostic
Fangrui Song [Thu, 7 Apr 2022 03:41:39 +0000 (20:41 -0700)]
[Driver][test] Fix csky-toolchain.c to be CLANG_DEFAULT_PIE_ON_LINUX agnostic

2 years agoReland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""
Fangrui Song [Thu, 7 Apr 2022 03:19:07 +0000 (20:19 -0700)]
Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""

(The upgrade of the ppc64le bot and D121257 have fixed compiler-rt failures. Tested by nemanjai.)

Default the option introduced in D113372 to ON to match all(?) major Linux
distros. This matches GCC and improves consistency with Android and linux-musl
which always default to PIE.
Note: CLANG_DEFAULT_PIE_ON_LINUX may be removed in the future.

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

2 years ago[CSKY] Fix some Clang warnings. NFC
Fangrui Song [Thu, 7 Apr 2022 03:09:32 +0000 (20:09 -0700)]
[CSKY] Fix some Clang warnings. NFC

Reviewed By: zixuan-wu

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

2 years agoLink aganist clangSema to fix broken build.
Jun Zhang [Thu, 7 Apr 2022 02:45:56 +0000 (10:45 +0800)]
Link aganist clangSema to fix broken build.

Signed-off-by: Jun Zhang <jun@junz.org>
2 years agoAMDGPU: Handle private atomics
Matt Arsenault [Tue, 5 Apr 2022 22:42:39 +0000 (18:42 -0400)]
AMDGPU: Handle private atomics

Use new NotAtomic expansion to turn these into the equivalent
non-atomic operations. Independent lanes cannot access the private
memory of other lanes, so there's no possibility for synchronization.

These don't really appear directly in user code, but
InferAddressSpaces can make these appear after optimizations.

Fixes issues 54693 and 54274.

2 years agoAtomicExpand: Add NotAtomic lowering strategy
Matt Arsenault [Tue, 5 Apr 2022 20:38:19 +0000 (16:38 -0400)]
AtomicExpand: Add NotAtomic lowering strategy

Currently LowerAtomics exists as a separate pass which blindly
replaces all atomics. Add a new lowering strategy option to eliminate
the atomics which the target can control on a per-instruction level.

2 years agoAtomicExpand: Change return type for shouldExpandAtomicStoreInIR
Matt Arsenault [Tue, 5 Apr 2022 21:48:50 +0000 (17:48 -0400)]
AtomicExpand: Change return type for shouldExpandAtomicStoreInIR

Use the same enum as the other atomic instructions for consistency, in
preparation for addition of another strategy.

Introduce a new "Expand" option, since the store expansion does not
use cmpxchg. Alternatively, the existing CmpXChg strategy could be
renamed to Expand.

2 years ago[RISCV] Supplement patterns for vnsrl.wx/vnsra.wx when splat shift is sext or zext
Lian Wang [Thu, 31 Mar 2022 07:07:42 +0000 (07:07 +0000)]
[RISCV] Supplement patterns for vnsrl.wx/vnsra.wx when splat shift is sext or zext

Reviewed By: craig.topper

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

2 years ago[clang-format][docs] Fix incorrect 'clang-format 11' option markers
Krystian Kuzniarek [Thu, 7 Apr 2022 01:33:18 +0000 (18:33 -0700)]
[clang-format][docs] Fix incorrect 'clang-format 11' option markers

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

2 years ago[mlir:Parser][NFC] Replace SSAUseInfo with OpAsmParser::UnresolvedOperand
River Riddle [Thu, 7 Apr 2022 01:24:31 +0000 (18:24 -0700)]
[mlir:Parser][NFC] Replace SSAUseInfo with OpAsmParser::UnresolvedOperand

These are functionally identical, and merging the two removes the number of
redundant conversions within the parser.

2 years ago[AMDGPU] Check SI LDS offset bug in the allowsMisalignedMemoryAccesses
Stanislav Mekhanoshin [Wed, 6 Apr 2022 23:02:46 +0000 (16:02 -0700)]
[AMDGPU] Check SI LDS offset bug in the allowsMisalignedMemoryAccesses

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

2 years ago[libomptarget] Add device RTL to regression test dependencies.
Michael Kruse [Thu, 7 Apr 2022 00:20:07 +0000 (19:20 -0500)]
[libomptarget] Add device RTL to regression test dependencies.

In a clean build directory, `check-openmp` or `check-libomptarget` will fail because of missing device RTL .bc files. Ensure that the new targets new custom targets `omptarget.devicertl.nvptx` and `omptarget.devicertl.amdgpu` (corresponding to the plugin rtl targets `omptarget.rtl.cuda`, respectively `omptarget.rlt.amdgpu` ) are dependencies of the regression tests.

Reviewed By: JonChesterfield

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

2 years ago[gn build] Port 39f156863392
LLVM GN Syncbot [Thu, 7 Apr 2022 00:55:44 +0000 (00:55 +0000)]
[gn build] Port 39f156863392

2 years agoTransforms: Split LowerAtomics into separate Utils and pass
Matt Arsenault [Tue, 5 Apr 2022 20:37:58 +0000 (16:37 -0400)]
Transforms: Split LowerAtomics into separate Utils and pass

This will allow code sharing from AtomicExpandPass. Not entirely sure
why these exist as separate passes though.

2 years ago[mlir:PDL] Expand how native constraint/rewrite functions can be defined
River Riddle [Sat, 19 Mar 2022 22:08:09 +0000 (15:08 -0700)]
[mlir:PDL] Expand how native constraint/rewrite functions can be defined

This commit refactors the expected form of native constraint and rewrite
functions, and greatly reduces the necessary user complexity required when
defining a native function. Namely, this commit adds in automatic processing
of the necessary PDLValue glue code, and allows for users to define
constraint/rewrite functions using the C++ types that they actually want to
use.

As an example, lets see a simple example rewrite defined today:

```
static void rewriteFn(PatternRewriter &rewriter, PDLResultList &results,
                      ArrayRef<PDLValue> args) {
  ValueRange operandValues = args[0].cast<ValueRange>();
  TypeRange typeValues = args[1].cast<TypeRange>();
  ...
  // Create an operation at some point and pass it back to PDL.
  Operation *op = rewriter.create<SomeOp>(...);
  results.push_back(op);
}
```

After this commit, that same rewrite could be defined as:

```
static Operation *rewriteFn(PatternRewriter &rewriter ValueRange operandValues,
                            TypeRange typeValues) {
  ...
  // Create an operation at some point and pass it back to PDL.
  return rewriter.create<SomeOp>(...);
}
```

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

2 years ago[CMake][compiler-rt] Include the missing variables
Petr Hosek [Thu, 7 Apr 2022 00:40:29 +0000 (17:40 -0700)]
[CMake][compiler-rt] Include the missing variables

This includes the missing variables as pointed out in
https://reviews.llvm.org/rGb0e2ffe151c3

2 years ago[mlir][sparse] replace stack-based access pattern with dyn-alloc
Aart Bik [Wed, 6 Apr 2022 20:22:08 +0000 (13:22 -0700)]
[mlir][sparse] replace stack-based access pattern with dyn-alloc

Rationale:
Allocating the temporary buffers for access pattern expansion on the stack
(using alloca) is a bit too agressive, since it easily runs out of stack space
for large enveloping tensor dimensions. This revision changes the dynamic
allocation of these buffers with explicit alloc/dealloc pairs.

Reviewed By: bixia, wrengr

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

2 years ago[MIPS] Initial support for MIPS-I load delay slots
Simon Dardis [Wed, 6 Apr 2022 23:31:33 +0000 (00:31 +0100)]
[MIPS] Initial support for MIPS-I load delay slots

LLVM so far has only supported the MIPS-II and above architectures. MIPS-II is pretty close to MIPS-I, the major difference
being that "load" instructions always take one extra instruction slot to propogate to registers. This patch adds support for
MIPS-I by adding hazard handling for load delay slots, alongside MIPSR6 forbidden slots and FPU slots, inserting a NOP
instruction between a load and any instruction immediately following that reads the load's destination register. I also
included a simple regression test. Since no existing tests target MIPS-I, those all still pass.

Issue ref: https://github.com/simias/psx-sdk-rs/issues/1

I also tested by building a simple demo app with Clang and running it in an emulator.

Patch by: @impiaaa

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

2 years ago[AMDGPU] Regenerate global isel lds ops test checks. NFC.
Stanislav Mekhanoshin [Wed, 6 Apr 2022 23:14:08 +0000 (16:14 -0700)]
[AMDGPU] Regenerate global isel lds ops test checks. NFC.

2 years ago[libc++abi] Remove XFAIL on arm64
Louis Dionne [Wed, 6 Apr 2022 23:01:39 +0000 (19:01 -0400)]
[libc++abi] Remove XFAIL on arm64

The underlying TLS destruction order bug has been fixed in the OS. This
would technically still fail when running on top of macOS < 12, however
we don't have a good way of encoding that using Lit features. Indeed,
the existing target=<FOO> Lit feature encodes the deployment target,
not the actual runtime system that the tests are being run on.

If this test starts failing on your machine after this patch, upgrading
to macOS 12 should solve the problem.

2 years ago[MSSA] Print memory phis when inspecting walker.
Alina Sbirlea [Wed, 6 Apr 2022 21:22:52 +0000 (14:22 -0700)]
[MSSA] Print memory phis when inspecting walker.

This makes the MemorySSA and MemorySSA Walker printers consistent.
Invokation `-print<memoryssa-walker>` should also have the MemoryPhis.

2 years agoRevert f7381a795ab235d34c94eaf01dc880eb5b89619d
Alina Sbirlea [Tue, 29 Mar 2022 23:05:08 +0000 (16:05 -0700)]
Revert f7381a795ab235d34c94eaf01dc880eb5b89619d

Roll-forward 29fada4a3d3db309f11f7fa7a0c61cd4021e9947.
Issue triggered was due to UB.

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

2 years ago[mips] Remove stale comment (NFC)
Simon Dardis [Wed, 6 Apr 2022 22:18:26 +0000 (23:18 +0100)]
[mips] Remove stale comment (NFC)

Test commit for my current email address.

2 years ago[Darwin][ASan] Fix "interceptor working?" check for DriverKit platform
Blue Gaston [Wed, 6 Apr 2022 22:47:18 +0000 (15:47 -0700)]
[Darwin][ASan] Fix "interceptor working?" check for DriverKit platform

The previous check for interceptors used `pthread_create()` which is not
available on DriverKit.  We need an intercepted symbol that satisfies
the following constraints:

- Symbol is available in DriverKit
- Symbol is provided by simulator runtime dylibs (`dlsym()` fails to
  look up host-provided symbols)

`puts()` satisfies all of the above constraints.

rdar://87895539

Reviewed By: yln

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

2 years agogn build: Fix some tests for host_os to instead check current_os.
Peter Collingbourne [Wed, 6 Apr 2022 22:40:09 +0000 (15:40 -0700)]
gn build: Fix some tests for host_os to instead check current_os.

Should fix Windows build:
http://45.33.8.238/win/55809/step_4.txt

2 years ago[pseudo] Include missing `count` in test deps.
Sam McCall [Wed, 6 Apr 2022 22:13:59 +0000 (00:13 +0200)]
[pseudo] Include missing `count` in test deps.

We don't use this for testing, but one of the lit python modules requires it :-\

After this, check-clang-pseudo passes with a clean build tree.

2 years ago[AArch64][AMDGPU][WebAssembly] Use static_cast instead of a reinterpret_cast to downc...
Craig Topper [Wed, 6 Apr 2022 21:50:49 +0000 (14:50 -0700)]
[AArch64][AMDGPU][WebAssembly] Use static_cast instead of a reinterpret_cast to downcast in parseMachineFunctionInfo. NFC

static_cast is a little safer here since the compiler will
ensure we're casting to a class derived from
yaml::MachineFunctionInfo.

I believe this first appeared on AMDGPU and was copied to the
other two targets.

Spotted when it was being copied to RISCV in D123178.

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