platform/upstream/llvm.git
2 years ago[libc++][P2321R2] Add vector<bool>::reference::operator=(bool) const
Nikolas Klauser [Wed, 2 Feb 2022 21:48:42 +0000 (22:48 +0100)]
[libc++][P2321R2] Add vector<bool>::reference::operator=(bool) const

Add vector<bool>::reference::operator(bool) const

Reviewed By: Quuxplusone, ldionne, #libc

Spies: BRevzin, libcxx-commits

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

2 years ago[libc][obvious] only include vector with malloc
Michael Jones [Thu, 10 Feb 2022 19:10:20 +0000 (11:10 -0800)]
[libc][obvious] only include vector with malloc

the vector class, due to being dynamically resized, needs malloc. This
fixes the build so that it only includes it when malloc should be
available.

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

2 years ago[compiler-rt] Fix endianness in get_sock_peer_name test
Michał Górny [Thu, 10 Feb 2022 18:40:28 +0000 (19:40 +0100)]
[compiler-rt] Fix endianness in get_sock_peer_name test

Fix passing the port and IP address with the wrong endianness
in get_sock_peer_name() that causes the connect() to fail inside
without an outgoing network interface (it's trying to connect
to 1.0.0.127 instead of 127.0.0.1).

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

2 years ago[OpenMP][CUDA] Refine the logic to determine grid size
Shilei Tian [Thu, 10 Feb 2022 19:13:18 +0000 (14:13 -0500)]
[OpenMP][CUDA] Refine the logic to determine grid size

This patch refines the logic to determine grid size as previous method
can escape the check of whether `CudaBlocksPerGrid` could be greater than the actual
hardware limit.

Reviewed By: jdoerfert

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

2 years agoAdd -fmodules-local-submodule-visibility to MANDATORY_MODULE_BUILD_CFLAGS
Adrian Prantl [Thu, 10 Feb 2022 19:09:40 +0000 (11:09 -0800)]
Add -fmodules-local-submodule-visibility to MANDATORY_MODULE_BUILD_CFLAGS

to work around build failure introduced in https://reviews.llvm.org/D119036

2 years ago[libc] add a vector internal class
Michael Jones [Fri, 4 Feb 2022 00:00:10 +0000 (16:00 -0800)]
[libc] add a vector internal class

Add a basic implementation of the vector class for use internally to
LLVM-libc.

Reviewed By: sivachandra

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

2 years ago[TTI][X86] Pull out repeated getSizeInBits() calls. NFC.
Simon Pilgrim [Thu, 10 Feb 2022 18:58:22 +0000 (18:58 +0000)]
[TTI][X86] Pull out repeated getSizeInBits() calls. NFC.

2 years agoFix a double debug info size counting in top level stats for "statistics dump".
Greg Clayton [Thu, 10 Feb 2022 02:48:17 +0000 (18:48 -0800)]
Fix a double debug info size counting in top level stats for "statistics dump".

This mainly affects Darwin targets (macOS, iOS, tvOS and watchOS) when these targets don't use dSYM files and the debug info was in the .o files. All modules, including the .o files that are loaded by the debug maps, were in the global module list. This was great because it allows us to see each .o file and how much it contributes. There were virtual functions on the SymbolFile class to fetch the symtab/debug info parse and index times, and also the total debug info size. So the main executable would add all of the .o file's stats together and report them as its own data. Then the "totalDebugInfoSize" and many other "totalXXX" top level totals were all being added together. This stems from the fact that my original patch only emitted the modules for a target at the start of the patch, but as comments from the reviews came in, we switched to emitting all of the modules from the global module list.

So this patch fixes it so when we have a SymbolFileDWARFDebugMap that loads .o files, the main executable will have no debug info size or symtab/debug info parse/index times, but each .o file will have its own data as a separate module. Also, to be able to tell when/if we have a dSYM file I have added a "symbolFilePath" if the SymbolFile for the main modules path doesn't match that of the main executable. We also include a "symbolFileModuleIdentifiers" key in each module if the module does have multiple lldb_private::Module objects that contain debug info so that you can track down the information for a module and add up the contributions of all of the .o files.

Tests were added that are labeled with @skipUnlessDarwin and @no_debug_info_test that test all of this functionality so it doesn't regress.

For a module with a dSYM file, we can see the "symbolFilePath" is included:
```
  "modules": [
    {
      "debugInfoByteSize": 1070,
      "debugInfoIndexLoadedFromCache": false,
      "debugInfoIndexSavedToCache": false,
      "debugInfoIndexTime": 0,
      "debugInfoParseTime": 0,
      "identifier": 4873280600,
      "path": "/Users/gclayton/Documents/src/lldb/main/Debug/lldb-test-build.noindex/commands/statistics/basic/TestStats.test_dsym_binary_has_symfile_in_stats/a.out",
      "symbolFilePath": "/Users/gclayton/Documents/src/lldb/main/Debug/lldb-test-build.noindex/commands/statistics/basic/TestStats.test_dsym_binary_has_symfile_in_stats/a.out.dSYM/Contents/Resources/DWARF/a.out",
      "symbolTableIndexTime": 7.9999999999999996e-06,
      "symbolTableLoadedFromCache": false,
      "symbolTableParseTime": 7.8999999999999996e-05,
      "symbolTableSavedToCache": false,
      "triple": "arm64-apple-macosx12.0.0",
      "uuid": "E1F7D85B-3A42-321E-BF0D-29B103F5F2E3"
    },
```
And for the DWARF in .o file case we can see the "symbolFileModuleIdentifiers" in the executable's module stats:
```
  "modules": [
    {
      "debugInfoByteSize": 0,
      "debugInfoIndexLoadedFromCache": false,
      "debugInfoIndexSavedToCache": false,
      "debugInfoIndexTime": 0,
      "debugInfoParseTime": 0,
      "identifier": 4603526968,
      "path": "/Users/gclayton/Documents/src/lldb/main/Debug/lldb-test-build.noindex/commands/statistics/basic/TestStats.test_no_dsym_binary_has_symfile_identifiers_in_stats/a.out",
      "symbolFileModuleIdentifiers": [
        4604429832
      ],
      "symbolTableIndexTime": 7.9999999999999996e-06,
      "symbolTableLoadedFromCache": false,
      "symbolTableParseTime": 0.000112,
      "symbolTableSavedToCache": false,
      "triple": "arm64-apple-macosx12.0.0",
      "uuid": "57008BF5-A726-3DE9-B1BF-3A9AD3EE8569"
    },
```
And the .o file for 4604429832 looks like:
```
    {
      "debugInfoByteSize": 1028,
      "debugInfoIndexLoadedFromCache": false,
      "debugInfoIndexSavedToCache": false,
      "debugInfoIndexTime": 0,
      "debugInfoParseTime": 6.0999999999999999e-05,
      "identifier": 4604429832,
      "path": "/Users/gclayton/Documents/src/lldb/main/Debug/lldb-test-build.noindex/commands/statistics/basic/TestStats.test_no_dsym_binary_has_symfile_identifiers_in_stats/main.o",
      "symbolTableIndexTime": 0,
      "symbolTableLoadedFromCache": false,
      "symbolTableParseTime": 0,
      "symbolTableSavedToCache": false,
      "triple": "arm64-apple-macosx"
    }
```

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

2 years agoWild guess to fix LLDB bot
Renato Golin [Thu, 10 Feb 2022 18:51:29 +0000 (18:51 +0000)]
Wild guess to fix LLDB bot

2 years ago[gn build] Port bd3a1de683f8
LLVM GN Syncbot [Thu, 10 Feb 2022 18:38:23 +0000 (18:38 +0000)]
[gn build] Port bd3a1de683f8

2 years ago[MLIR][GPU] Add now-required include to SerializeToHsaco
Krzysztof Drewniak [Thu, 10 Feb 2022 17:46:02 +0000 (17:46 +0000)]
[MLIR][GPU] Add now-required include to SerializeToHsaco

Reviewed By: whchung

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

2 years ago[flang] Handle "type(foo) function f" when foo is defined in f
Peter Klausler [Sat, 5 Feb 2022 02:04:58 +0000 (18:04 -0800)]
[flang] Handle "type(foo) function f" when foo is defined in f

Fortran allows forward references to derived types, including
function results that are typed in a prefix of a FUNCTION statement.
If a type is defined in the body of the function, a reference to
that type from a prefix on the FUNCTION statement must resolve to
the local symbol, even and especially when that type shadows one
from the host scope.

The solution is to defer the processing of that type until the
end of the function's specification part.  But the language doesn't
allow for forward references to other names in the prefix, so defer
the processing of the type only when it is not an intrinsic type.
The data structures in name resolution that track this information
for functions needed to become a stack in order to make this work,
since functions can contain interfaces that are functions.

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

2 years ago[clang-cl] Support the /JMC flag
Yuanfang Chen [Thu, 10 Feb 2022 17:40:05 +0000 (09:40 -0800)]
[clang-cl] Support the /JMC flag

The introduction and some examples are on this page:
https://devblogs.microsoft.com/cppblog/announcing-jmc-stepping-in-visual-studio/

The `/JMC` flag enables these instrumentations:
- Insert at the beginning of every function immediately after the prologue with
  a call to `void __fastcall __CheckForDebuggerJustMyCode(unsigned char *JMC_flag)`.
  The argument for `__CheckForDebuggerJustMyCode` is the address of a boolean
  global variable (the global variable is initialized to 1) with the name
  convention `__<hash>_<filename>`. All such global variables are placed in
  the `.msvcjmc` section.
- The `<hash>` part of `__<hash>_<filename>` has a one-to-one mapping
  with a directory path. MSVC uses some unknown hashing function. Here I
  used DJB.
- Add a dummy/empty COMDAT function `__JustMyCode_Default`.
- Add `/alternatename:__CheckForDebuggerJustMyCode=__JustMyCode_Default` link
  option via ".drectve" section. This is to prevent failure in
  case `__CheckForDebuggerJustMyCode` is not provided during linking.

Implementation:
All the instrumentations are implemented in an IR codegen pass. The pass is placed immediately before CodeGenPrepare pass. This is to not interfere with mid-end optimizations and make the instrumentation target-independent (I'm still working on an ELF port in a separate patch).

Reviewed By: hans

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

2 years ago[AArch64][ARM] add -Wunaligned-access only for clang
Yuanfang Chen [Thu, 10 Feb 2022 17:33:49 +0000 (09:33 -0800)]
[AArch64][ARM] add -Wunaligned-access only for clang

Reviewed By: lenary

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

2 years ago [AArch64][LoadStoreOptimizer] Ignore undef registers when checking rename register...
Huihui Zhang [Thu, 10 Feb 2022 18:05:39 +0000 (10:05 -0800)]
 [AArch64][LoadStoreOptimizer] Ignore undef registers when checking rename register used between paired instructions.

The content of undef registers are not used in meaningful ways, when checking
if a rename register is used between paired instructions we should ignore
undef registers.

Reviewed By: efriedma

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

2 years ago[clang-format] Do not remove required spaces when aligning tokens.
Marek Kurdej [Thu, 10 Feb 2022 18:11:26 +0000 (19:11 +0100)]
[clang-format] Do not remove required spaces when aligning tokens.

Fixes https://github.com/llvm/llvm-project/issues/44292.
Fixes https://github.com/llvm/llvm-project/issues/45874.

Reviewed By: HazardyKnusperkeks, owenpan

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

2 years ago[mlir][vector] Add pattern to drop lead unit dim for Contraction Op
Nirvedh [Fri, 28 Jan 2022 05:25:27 +0000 (05:25 +0000)]
[mlir][vector] Add pattern to drop lead unit dim for Contraction Op

If the result operand has a unit leading dim it is removed from all operands.

Reviewed By: ThomasRaoux

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

2 years ago[X86] Add smulo and umulo with add+load test coverage
Simon Pilgrim [Thu, 10 Feb 2022 17:47:14 +0000 (17:47 +0000)]
[X86] Add smulo and umulo with add+load test coverage

2 years ago[clangd] Crash in __memcmp_avx2_movbe
Ivan Murashko [Thu, 10 Feb 2022 17:40:24 +0000 (09:40 -0800)]
[clangd] Crash in __memcmp_avx2_movbe

There is a clangd crash at `__memcmp_avx2_movbe`. Short problem description is below.

The method `HeaderIncludes::addExistingInclude` stores `Include` objects by reference at 2 places: `ExistingIncludes` (primary storage) and `IncludesByPriority` (pointer to the object's location at ExistingIncludes). `ExistingIncludes` is a map where value is a `SmallVector`. A new element is inserted by `push_back`. The operation might do resize. As result pointers stored at `IncludesByPriority` might become invalid.

Typical stack trace
```
    frame #0: 0x00007f11460dcd94 libc.so.6`__memcmp_avx2_movbe + 308
    frame #1: 0x00000000004782b8 clangd`llvm::StringRef::compareMemory(Lhs="
\"t2.h\"", Rhs="", Length=6) at StringRef.h:76:22
    frame #2: 0x0000000000701253 clangd`llvm::StringRef::compare(this=0x0000
7f10de7d8610, RHS=(Data = "", Length = 7166742329480737377)) const at String
Ref.h:206:34
  * frame #3: 0x00000000007603ab clangd`llvm::operator<(llvm::StringRef, llv
m::StringRef)(LHS=(Data = "\"t2.h\"", Length = 6), RHS=(Data = "", Length =
7166742329480737377)) at StringRef.h:907:23
    frame #4: 0x0000000002d0ad9f clangd`clang::tooling::HeaderIncludes::inse
rt(this=0x00007f10de7fb1a0, IncludeName=(Data = "t2.h\"", Length = 4), IsAng
led=false) const at HeaderIncludes.cpp:365:22
    frame #5: 0x00000000012ebfdd clangd`clang::clangd::IncludeInserter::inse
rt(this=0x00007f10de7fb148, VerbatimHeader=(Data = "\"t2.h\"", Length = 6))
const at Headers.cpp:262:70
```

A unit test test for the crash was created (`HeaderIncludesTest.RepeatedIncludes`). The proposed solution is to use std::list instead of llvm::SmallVector

Test Plan
```
./tools/clang/unittests/Tooling/ToolingTests --gtest_filter=HeaderIncludesTest.RepeatedIncludes
```

Reviewed By: sammccall

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

2 years ago[RISCV] Lower the shufflevector equivalent of vector.splice
Craig Topper [Thu, 10 Feb 2022 17:29:39 +0000 (09:29 -0800)]
[RISCV] Lower the shufflevector equivalent of vector.splice

We can lower a vector splice to a vslidedown and a vslideup.

The majority of the matching code here came from X86's code for matching
PALIGNR and VPALIGND/Q.

The slidedown and slideup lowering don't really require it to be concatenation,
but it happened to be an interesting pattern with existing analysis code I
could use.

This helps with cases where the scalar loop optimizer forwarded a load
result from a previous loop iteration. For example, this happens if the
loop uses x[i] and x[i+1] on the same iteration. The scalar optimizer
will forward x[i+1] load from the previous loop to satisfy x[i] on this
loop. When this get vectorized it results in one element of a vector
being forwarded from the previous loop to be concatenated with elements
loaded on this iteration.

Whether that's more efficient than doing a shifted loaded or reloading
the single scalar and using vslide1up is an interesting question.
But that's not something the backend can help with.

Reviewed By: khchen

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

2 years ago[flang] Lower simple RETURN statement
Valentin Clement [Thu, 10 Feb 2022 17:35:16 +0000 (18:35 +0100)]
[flang] Lower simple RETURN statement

This patch adds the lowering for the RETURN statement
without alternate returns in the main program or in subroutine
and functions.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: kiranchandramohan

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

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[flang][NFC] Replace hardcoded attribute name
Valentin Clement [Thu, 10 Feb 2022 17:33:57 +0000 (18:33 +0100)]
[flang][NFC] Replace hardcoded attribute name

Replace the hardcoded attribute name with the constexpr StringRef
defined in the FIROps.td file.

Reviewed By: kiranchandramohan

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

2 years ago[RISCV] Move the creation of VLMaxSentinel to isel. Use X0 during lowering.
Craig Topper [Thu, 10 Feb 2022 17:14:51 +0000 (09:14 -0800)]
[RISCV] Move the creation of VLMaxSentinel to isel. Use X0 during lowering.

The VLMaxSentinel is represented as TargetConstant, but that's included
in isa<ConstantSDNode>. To keep constant VLs and VLMax separate as long
as possible, use the X0 register during lowering and only convert to
VLMaxSentinel during isel.

Reviewed By: frasercrmck

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

2 years ago[clang-cl] Accept the "legacy" -target flag spelling
Hans Wennborg [Thu, 10 Feb 2022 16:21:04 +0000 (17:21 +0100)]
[clang-cl] Accept the "legacy" -target flag spelling

we already accept "--target=". No reason to not accept "-target" too
(that's the one I typically use for some reason).

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

2 years ago[SVE] Remove AArch64ISD::ADD_PRED and AArch64ISD::SUB_PRED.
Paul Walker [Wed, 9 Feb 2022 17:12:54 +0000 (17:12 +0000)]
[SVE] Remove AArch64ISD::ADD_PRED and AArch64ISD::SUB_PRED.

These nodes provide an indirection that is not necessary because
SVE has unpredicated add/sub instructions and there's no downside
to using them for partial register operations. In fact, the test
changes show that unifying how fixed-length and scalable vector
add/sub are lowered enables better use of existing isel patterns.

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

2 years ago[X86] Add tests showing failure to use LEA to avoid spoiling EFLAGS from smulo
Simon Pilgrim [Thu, 10 Feb 2022 17:21:44 +0000 (17:21 +0000)]
[X86] Add tests showing failure to use LEA to avoid spoiling EFLAGS from smulo

Add smulo and umulo test coverage

2 years ago[X86] getFMA3OpcodeToCommuteOperands - use unreachable to detect fma3 format mismatch
Simon Pilgrim [Thu, 10 Feb 2022 17:14:00 +0000 (17:14 +0000)]
[X86] getFMA3OpcodeToCommuteOperands - use unreachable to detect fma3 format mismatch

Matches what we do in getThreeSrcCommuteCase.

Fixes static analyzer out of bounds array access warning.

2 years ago[hwasan][test] Rework memaccess-clobber.ll
Arthur Eubanks [Thu, 10 Feb 2022 01:03:54 +0000 (17:03 -0800)]
[hwasan][test] Rework memaccess-clobber.ll

Previously memaccess-clobber.ll relied on both legacy PM-specific things
like `-analyze` and MemoryDependenceAnalysis, which are both deprecated.

This uses MemorySSA, which is the cool new thing that a bunch of passes
have migrated to.

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

2 years ago[RISCV] Remove stale comment. NFC
Craig Topper [Thu, 10 Feb 2022 17:00:18 +0000 (09:00 -0800)]
[RISCV] Remove stale comment. NFC

Now that we pre-process SPLAT_VECTOR to VFMV_V_F_VL, these patterns
handled scalable vectors and vectors converted from fixed. These
are also used by vp.fma lowering.

2 years ago[libc++] Remove usage of `_LIBCPP_DEBUG` in `__comp_ref_type` and replace with `_LIBC...
Jordan Rupprecht [Thu, 3 Feb 2022 22:51:54 +0000 (14:51 -0800)]
[libc++] Remove usage of `_LIBCPP_DEBUG` in `__comp_ref_type` and replace with `_LIBCPP_DEBUG_LEVEL`

In libc++, checking specific `_LIBCPP_DEBUG_LEVEL` levels is used everywhere except in `comp_ref_type.h`. `_LIBCPP_DEBUG` is meant as a user-facing option, and internally libc++ should be checking the value of `_LIBCPP_DEBUG_LEVEL`.

The definition of `std::__debug_less` doesn't need to be hidden behind the macro, we can unconditionally expose it. It will be unused by `__comp_ref_type` unless debug mode is enabled.

This was suggested in D118940.

Reviewed By: #libc, philnik, Quuxplusone, ldionne

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

2 years ago[libc++] Fix std::__debug_less in c++17.
Jordan Rupprecht [Thu, 3 Feb 2022 20:39:45 +0000 (12:39 -0800)]
[libc++] Fix std::__debug_less in c++17.

b07b5bd72716625e0976a84d23652d94d8d0165a adds a use of `__comp_ref_type.h` to `std::min`. When libc++ is built with `-D_LIBCPP_DEBUG=0`, this enables `std::__debug_less`, which is only marked constexpr after c++17.

`std::min` itself is marked as being `constexpr` as of c++14, so by extension, `std::__debug_less` should also be marked `constexpr` for the same versions so that `std::min` can use it. This change lowers the guard from `> 17` to `> 11`.

Reproducer in godbolt: https://godbolt.org/z/ans3TGsj8

```

constexpr int x() { return std::min<int>({1, 2, 3, 4}); }

static_assert(x() == 1);
```

Reviewed By: #libc, philnik, Quuxplusone, ldionne

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

2 years ago[libc++][nfc] Add TEST_HAS_NO_LOCALIZATION.
Mark de Wever [Wed, 2 Feb 2022 18:28:05 +0000 (19:28 +0100)]
[libc++][nfc] Add TEST_HAS_NO_LOCALIZATION.

This avoids using an libc++ internal macro in our tests.

Reviewed By: #libc, ldionne

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

2 years ago[DebugInfo][InstrRef] Avoid duplicate instruction numbers in x86-lea-fixup
Jeremy Morse [Thu, 10 Feb 2022 16:01:12 +0000 (16:01 +0000)]
[DebugInfo][InstrRef] Avoid duplicate instruction numbers in x86-lea-fixup

This new-ish LEA-fixup code path creates two substitutions for an
instruction number -- this is incorrect because each Value should be
replaced by a single replacement Value. Fix by deleting the duplicate
substitution. Add some test coverage for this path with debug-info
attached.

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

2 years ago[AMDGPU] Missed sign/zero extend patterns for divergence-driven instruction selection
alex-t [Wed, 9 Feb 2022 00:06:25 +0000 (03:06 +0300)]
[AMDGPU] Missed sign/zero extend patterns for divergence-driven instruction selection

This change includes tablegen patterns that were missed by https://reviews.llvm.org/D110950 and https://reviews.llvm.org/D76230

Reviewed By: foad

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

2 years ago[AMDGPU] Pull out repeated getVecSize() calls. NFC.
Simon Pilgrim [Thu, 10 Feb 2022 16:31:24 +0000 (16:31 +0000)]
[AMDGPU] Pull out repeated getVecSize() calls. NFC.

This is guaranteed to be evaluated so we can avoid repeated calls.

Helps the static analyzer as it couldn't recognise that each getVecSize() would return the same value.

2 years ago[AArch64] Improve codegen for get.active.lane.mask when SVE is available
David Sherwood [Wed, 5 Jan 2022 15:17:24 +0000 (15:17 +0000)]
[AArch64] Improve codegen for get.active.lane.mask when SVE is available

When lowering the get.active.lane.mask intrinsic with a fixed-width
predicate vector result, we can actually make use of the SVE whilelo
instruction when SVE is enabled. We do this by carefully choosing
a sensible VT for the whilelo instruction, then promoting it to an
integer vector, i.e. nxv16i1 -> nx16i8. We can then extract a v16i8
subvector and truncate back to the original return type, i.e. v16i1.
This leads to a significant improvement in code quality.

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

2 years ago[libc++] Prepare string.{contains, ends_with, iterators, require, starts_with} tests...
Nikolas Klauser [Wed, 9 Feb 2022 01:03:27 +0000 (02:03 +0100)]
[libc++] Prepare string.{contains, ends_with, iterators, require, starts_with} tests for constexpr

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[LV] Add tests with chained first-order recurrences.
Florian Hahn [Thu, 10 Feb 2022 15:55:19 +0000 (15:55 +0000)]
[LV] Add tests with chained first-order recurrences.

2 years ago[mlir][sparse][pytaco] migrate to sparse compiler pipeline
Aart Bik [Thu, 10 Feb 2022 01:07:54 +0000 (17:07 -0800)]
[mlir][sparse][pytaco] migrate to sparse compiler pipeline

Reviewed By: bixia

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

2 years ago[OpenMP][NFC] update status for 5.1 'nothing' directive to 'worked on'
dreachem [Thu, 10 Feb 2022 15:21:45 +0000 (09:21 -0600)]
[OpenMP][NFC] update status for 5.1 'nothing' directive to 'worked on'

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

2 years ago[fir] Fix FlangOptimizerTests link on Solaris
Rainer Orth [Thu, 10 Feb 2022 15:09:50 +0000 (16:09 +0100)]
[fir] Fix FlangOptimizerTests link on Solaris

As reported in Issue #53690,
`tools/flang/unittests/Optimizer/FlangOptimizerTests` `FAIL`s to link on
Solaris:

  Undefined                       first referenced
   symbol                             in file
  _ZN3fir7runtimeL8getModelIcEEPFN4mlir4TypeEPNS2_11MLIRContextEEv lib/libFIRBuilder.a(Reduction.cpp.o)

which is `mlir::Type (*fir::runtime::getModel<char>())(mlir::MLIRContext*)`.

`clang++` warn's

  In file included from /var/llvm/llvm-14.0.0-rc1/rc1/llvm-project/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp:14:
  /var/llvm/llvm-14.0.0-rc1/rc1/llvm-project/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h:60:34: warning: function 'fir::runtime::getModel<char>' has internal linkage but is not defined [-Wundefined-internal]
  static constexpr TypeBuilderFunc getModel();
                                   ^
  /var/llvm/llvm-14.0.0-rc1/rc1/llvm-project/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h:289:29: note: used here
        TypeBuilderFunc ret = getModel<RT>();
                              ^

Fixed by adding an explicit template instantiation for `getModel<char>`.  I
suppose this is necessary because on Solaris `char` is `signed`.

Tested on `sparcv9-sun-solaris2.11`.

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

2 years ago[gn build] Port 9d9053190498
LLVM GN Syncbot [Thu, 10 Feb 2022 15:02:15 +0000 (15:02 +0000)]
[gn build] Port 9d9053190498

2 years ago[InstSimplify] Remove zero-index opaque pointer GEP
Nikita Popov [Thu, 10 Feb 2022 15:00:41 +0000 (16:00 +0100)]
[InstSimplify] Remove zero-index opaque pointer GEP

With opaque pointers, a zero-index GEP is a no-op. It does not
need to be retained for the pointer element type change it may
perform.

2 years ago[libc++][ranges] Implement std::ranges::swap_ranges()
Nikolas Klauser [Thu, 10 Feb 2022 12:33:03 +0000 (13:33 +0100)]
[libc++][ranges] Implement std::ranges::swap_ranges()

Implement `std::ranges::swap_ranges()`

Reviewed By: Quuxplusone, #libc, ldionne

Spies: ldionne, mgorny, jloser, libcxx-commits

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

2 years agoclangd: Set a diagnostic on a code action resulting from a tweak
Christian Kandeler [Thu, 10 Feb 2022 14:51:29 +0000 (15:51 +0100)]
clangd: Set a diagnostic on a code action resulting from a tweak

... if there is a match.
This is needed to that clients can can make a connection between a
diagnostic and an associated quickfix-tweak.
Ideally, quickfix-kind tweak code actions would be provided inline along
with the non-tweak fixes, but this doesn't seem easily achievable.

Reviewed By: sammccall

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

2 years ago[AMDGPU] Rename DSAtomicCmpXChg to DSAtomicCmpXChgSwapped. NFC.
Jay Foad [Thu, 10 Feb 2022 10:23:27 +0000 (10:23 +0000)]
[AMDGPU] Rename DSAtomicCmpXChg to DSAtomicCmpXChgSwapped. NFC.

This is just a reminder that the operands are swapped compared with all
the other CmpXChg instructions.

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

2 years ago[SVE] Remove redundant hasBF16 calls from lowering code.
Paul Walker [Tue, 8 Feb 2022 13:08:44 +0000 (13:08 +0000)]
[SVE] Remove redundant hasBF16 calls from lowering code.

The are several places where hasBF16 is used to protect code that
has no requirement for the +bf16 feature.  The lowering code uses
stock SVE instructions for things like loads and stores and so is
safe even when +bf16 is not available.

NOTE: Currently the nxvbf16 type is not legal unless the +bf16
feature is available, but that isn't an issue because the affected
code is post type legalisation.

NOTE: This patch mirrors previous work that removed the same
redundant protection from isel patterns where the resulting
selection emitted stock SVE instructions.

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

2 years ago[NFC][SCEV] `createNodeForSelectOrPHIViaUMinSeq()`: refactor `i1 cond ? i1 x : i1...
Roman Lebedev [Thu, 10 Feb 2022 14:21:44 +0000 (17:21 +0300)]
[NFC][SCEV] `createNodeForSelectOrPHIViaUMinSeq()`: refactor `i1 cond ? i1 x : i1 y` handling

While that effectively concludes i1 select handling,
that boolean restriction can be lifted later.

2 years ago[NFC][SCEV] `createNodeForSelectOrPHIViaUMinSeq()`: refactor `i1 cond ? i1 C : i1...
Roman Lebedev [Thu, 10 Feb 2022 14:08:10 +0000 (17:08 +0300)]
[NFC][SCEV] `createNodeForSelectOrPHIViaUMinSeq()`: refactor `i1 cond ? i1 C : i1 y` pattern

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

2 years ago[NFC][SCEV] `createNodeForSelectOrPHIViaUMinSeq()`: refactor `i1 cond ? i1 x : i1...
Roman Lebedev [Thu, 10 Feb 2022 14:03:26 +0000 (17:03 +0300)]
[NFC][SCEV] `createNodeForSelectOrPHIViaUMinSeq()`: refactor `i1 cond ? i1 x : i1 C` pattern

https://alive2.llvm.org/ce/z/2Q7Du_

2 years ago[SCEV] Recognize `cond ? i1 0 : i1 y` as `umin_seq ~cond, x`
Roman Lebedev [Thu, 10 Feb 2022 13:46:34 +0000 (16:46 +0300)]
[SCEV] Recognize `cond ? i1 0 : i1 y` as `umin_seq ~cond, x`

By definition, `umin_seq` has the exact same
poison stopping properties the original `select` had:
https://alive2.llvm.org/ce/z/N6XwV-

2 years ago[SCEV] Recognize `cond ? i1 x : i1 1` as `~umin_seq cond, ~x`
Roman Lebedev [Thu, 10 Feb 2022 13:36:29 +0000 (16:36 +0300)]
[SCEV] Recognize `cond ? i1 x : i1 1` as `~umin_seq cond, ~x`

By definition, `umin_seq` has the exact same
poison stopping properties the original `select` had:
https://alive2.llvm.org/ce/z/aqe9GK

2 years ago[SCEV] Recognize logical `or` as `not umin_seq (not, not)`
Roman Lebedev [Thu, 10 Feb 2022 13:25:00 +0000 (16:25 +0300)]
[SCEV] Recognize logical `or` as `not umin_seq (not, not)`

By definition, `umin_seq` has the exact same
poison stopping properties the original `select` had:
https://alive2.llvm.org/ce/z/MUfbTL

2 years ago[SCEV] Recognize logical `and` as `umin_seq`
Roman Lebedev [Thu, 10 Feb 2022 12:59:23 +0000 (15:59 +0300)]
[SCEV] Recognize logical `and` as `umin_seq`

By definition, `umin_seq` has the exact same
poison stopping properties the original `select` had:
https://alive2.llvm.org/ce/z/59KuZZ

2 years ago[SCEV] `createNodeForSelectOrPHI()`: try constant-folding even if not an Instruction
Roman Lebedev [Thu, 10 Feb 2022 12:21:27 +0000 (15:21 +0300)]
[SCEV] `createNodeForSelectOrPHI()`: try constant-folding even if not an Instruction

We'd catch the tautological select pattern later anyways
due to constant folding, so that leaves PHI-like select,
but it does not appear to fire there.

2 years ago[NFC][SCEV] Prepare `createNodeForSelectOrPHI()` for gaining additional strategy
Roman Lebedev [Thu, 10 Feb 2022 11:58:55 +0000 (14:58 +0300)]
[NFC][SCEV] Prepare `createNodeForSelectOrPHI()` for gaining additional strategy

Currently `createNodeForSelectOrPHI()` takes an Instruction,
and only works on the Cond that is an ICmpInst,
but that can be relaxed somewhat.

For now, simply rename the existing function,
and add a thin wrapper ontop that still does
the same thing as it used to.

2 years ago[SCEV] Recognize binary `xor` as bit-wise `add`
Roman Lebedev [Thu, 10 Feb 2022 10:12:39 +0000 (13:12 +0300)]
[SCEV] Recognize binary `xor` as bit-wise `add`

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

We could transparently handle wider bitwidths,
by effectively casting iN to <N x i1> and performing the `add`
bit/element -wise, the expression will be rather large,
so let's not do that for now.

2 years ago[SCEV] Recognize binary `and` as bit-wise `umin`
Roman Lebedev [Thu, 10 Feb 2022 10:06:01 +0000 (13:06 +0300)]
[SCEV] Recognize binary `and` as bit-wise `umin`

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

We could transparently handle wider bitwidths,
by effectively casting iN to <N x i1> and performing the `umin`
bit/element -wise, the expression will be rather large,
so let's not do that for now.

2 years ago[SCEV] Recognize binary `or` as bit-wise `umax`
Roman Lebedev [Thu, 10 Feb 2022 09:59:14 +0000 (12:59 +0300)]
[SCEV] Recognize binary `or` as bit-wise `umax`

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

We could transparently handle wider bitwidths,
by effectively casting iN to <N x i1> and performing the `umax`
bit/element -wise, the expression will be rather large,
so let's not do that for now.

2 years ago[NFC][SCEV] Add some tests with logical operations and whatnot
Roman Lebedev [Thu, 10 Feb 2022 09:37:21 +0000 (12:37 +0300)]
[NFC][SCEV] Add some tests with logical operations and whatnot

2 years ago[SVE] Prefer zero-extending loads when lowering ISD::EXTLOAD.
Paul Walker [Tue, 8 Feb 2022 12:48:14 +0000 (12:48 +0000)]
[SVE] Prefer zero-extending loads when lowering ISD::EXTLOAD.

The decision is perhaps arbitrary but I figure zeroing has no
dependency on the value being loaded.

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

2 years ago[SVE][CodeGen] Bail out for scalable vectors in AArch64TargetLowering::ReconstructShuffle
David Sherwood [Tue, 4 Jan 2022 13:11:47 +0000 (13:11 +0000)]
[SVE][CodeGen] Bail out for scalable vectors in AArch64TargetLowering::ReconstructShuffle

Previously the code in AArch64TargetLowering::ReconstructShuffle assumed
the input vectors were always fixed-width, however this is not always
the case since you can extract elements from scalable vectors and insert
into fixed-width ones. We were hitting crashes here for two different
cases:

1. When lowering a fixed-length vector extract from a scalable vector
with i1 element types. This happens due to the fact the i1 elements
get promoted to larger integer types for fixed-width vectors and leads
to sequences of INSERT_VECTOR_ELT and EXTRACT_VECTOR_ELT nodes. In this
case AArch64TargetLowering::ReconstructShuffle will still fail to make
a transformation, but at least it no longer crashes.
2. When lowering a sequence of extractelement/insertelement operations
on mixed fixed-width/scalable vectors.

For now, I've just changed AArch64TargetLowering::ReconstructShuffle to
bail out if it finds a scalable vector.

Tests for both instances described above have been added here:

  (1) CodeGen/AArch64/sve-extract-fixed-vector.ll
  (2) CodeGen/AArch64/sve-fixed-length-reshuffle.ll

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

2 years ago[mlir] Add missing dep to new cf dialect
Marius Brehler [Thu, 10 Feb 2022 14:15:20 +0000 (14:15 +0000)]
[mlir] Add missing dep to new cf dialect

2 years ago[cross-project-tests] REQUIRES: system-darwin in llgdb-tests/asan-deque.cpp
OCHyams [Thu, 10 Feb 2022 13:49:18 +0000 (13:49 +0000)]
[cross-project-tests] REQUIRES: system-darwin in llgdb-tests/asan-deque.cpp

Some configurations of gdb pretty print std::deque and some don't. Make
this test run only on system-darwin (which uses lldb instead), otherwise
it will fail on some non-darwin machines and not others.

2 years ago[clang] Add test for C++ DR2390
Timm Bäder [Tue, 8 Feb 2022 10:12:28 +0000 (11:12 +0100)]
[clang] Add test for C++ DR2390

DR2390 clarifies that the argument to __has_cpp_attribute() needs to be
macro-expanded. Clang already supports this and tests it explicitly in
clang/test/Preprocessor/has_attribute.cpp.

Copy the test over to clang/test/CXX/drs/ so the make_cxx_drs script
picks it up.

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

2 years ago[clang][tests] Add test for C++ DR2406
Timm Bäder [Tue, 8 Feb 2022 09:36:43 +0000 (10:36 +0100)]
[clang][tests] Add test for C++ DR2406

Clang already handles this fine, so add a test case to let the
make_cxx_dr_status script pick it up.

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

2 years ago[mlir][linalg] Fold tensor.pad(linalg.fill) with the same value
Lei Zhang [Thu, 10 Feb 2022 13:18:00 +0000 (08:18 -0500)]
[mlir][linalg] Fold tensor.pad(linalg.fill) with the same value

Reviewed By: mravishankar

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

2 years ago[mlir][vector] Add helper that builds a scalar reduction according to CombiningKind
Matthias Springer [Thu, 10 Feb 2022 13:21:34 +0000 (22:21 +0900)]
[mlir][vector] Add helper that builds a scalar reduction according to CombiningKind

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

2 years ago[clang-tidy] add option performance-move-const-arg.CheckMoveToConstRef
Greg Miller [Thu, 10 Feb 2022 13:19:22 +0000 (13:19 +0000)]
[clang-tidy] add option performance-move-const-arg.CheckMoveToConstRef

This option allows callers to disable the warning from
https://clang.llvm.org/extra/clang-tidy/checks/performance-move-const-arg.html
that would warn on the following

```
void f(const string &s);
string s;
f(std::move(s));  // ALLOWED if performance-move-const-arg.CheckMoveToConstRef=false
```

The reason people might want to disable this check, is because it allows
callers to use `std::move()` or not based on local reasoning about the
argument, and without having to care about how the function `f` accepts
the argument. Indeed, `f` might accept the argument by const-ref today,
but change to by-value tomorrow, and if the caller had moved the
argument that they were finished with, the code would work as
efficiently as possible regardless of how `f` accepted the parameter.

Reviewed By: ymandel

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

2 years ago[InstCombine] Extend fold (icmp sgt smin(PosA, B) 0) -> (icmp sgt B 0) to support...
Simon Pilgrim [Thu, 10 Feb 2022 13:28:15 +0000 (13:28 +0000)]
[InstCombine] Extend fold (icmp sgt smin(PosA, B) 0) -> (icmp sgt B 0) to support smin intrinsic

Replace matchSelectPattern pattern match with the more general m_SMin so that it can handle smin intrinsics as well as the icmp+select pattern

Noticed while reviewing regressions from D98152

2 years ago[InstCombine] Add test showing failure to fold (icmp sgt smin(PosA, B) 0) -> (icmp...
Simon Pilgrim [Thu, 10 Feb 2022 13:20:49 +0000 (13:20 +0000)]
[InstCombine] Add test showing failure to fold (icmp sgt smin(PosA, B) 0) -> (icmp sgt B 0) with smin intrinsic

Noticed while reviewing regressions from D98152

2 years ago[InstCombine] reduce mul operands based on undemanded high bits
Sanjay Patel [Thu, 10 Feb 2022 12:43:23 +0000 (07:43 -0500)]
[InstCombine] reduce mul operands based on undemanded high bits

We already do this in SDAG, but mul was left out of the fold
for unused high bits in IR.

The high bits of a mul's operands do not change the low bits
of the result:
https://alive2.llvm.org/ce/z/XRj5Ek

Verify some test diffs to confirm that they are correct:
https://alive2.llvm.org/ce/z/y_W8DW
https://alive2.llvm.org/ce/z/7DM5uf
https://alive2.llvm.org/ce/z/GDiHCK

This gets a fold that was presumed not possible in D114272:
https://alive2.llvm.org/ce/z/tAN-WY

Removing nsw/nuw is needed for general correctness (and is
also done in the codegen version), but we might be able to
recover more of those with better analysis.

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

2 years ago[FastISel] Remove redundant reg class check (NFC)
Nikita Popov [Thu, 10 Feb 2022 13:09:00 +0000 (14:09 +0100)]
[FastISel] Remove redundant reg class check (NFC)

SrcVT and DstVT are the same in this branch, as such their register
classes will also be the same.

2 years ago[CodeGen] Regenerate test checks (NFC)
Nikita Popov [Thu, 10 Feb 2022 11:58:35 +0000 (12:58 +0100)]
[CodeGen] Regenerate test checks (NFC)

2 years ago[MLIR][Presburger] Factor out space information to PresburgerSpace
Groverkss [Thu, 10 Feb 2022 12:54:40 +0000 (18:24 +0530)]
[MLIR][Presburger] Factor out space information to PresburgerSpace

This patch factors out space information from IntegerPolyhedron, PresburgerSet
and PWMAFunction to PresburgerSpace and its extension with local variables,
PresburgerLocalSpace.

Generally any new data structure additions in Presburger library will require
space information. This patch removes the need to duplicate the space
information.

Reviewed By: arjunp

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

2 years ago[clang][NFC] Standard substitution checking cleanup
Nathan Sidwell [Wed, 9 Feb 2022 14:09:35 +0000 (06:09 -0800)]
[clang][NFC] Standard substitution checking cleanup

In preparing for module mangling changes I noticed some issues with
the way we check for std::basic_string instantiations and friends.

*) there's a single routine for std::basic_{i,o,io}stream but it is
 templatized on the length of the name.  Really?  just use a
 StringRef, rather than clone the entire routine just for
 'basic_iostream'.

*) We have a helper routine to check for char type, and call it from
 several places.  But given all the instantiations are of the form
 TPL<char, Other<char> ...> we could just check the first arg is char
 and the later templated args are instantiating that same type.  A
 simpler type comparison.

*) Because basic_string has a third allocator parameter, it is open
 coded, which I found a little confusing.  But otherwise it's exactly
 the same pattern as the iostream ones.  Just tell that checker about
 whether there's an expected allocator argument.[*]

*) We may as well return in each block of mangleStandardSubstitution
 once we determine it is not one of the entities of interest -- it
 certainly cannot be one of the other kinds of entities.

FWIW this shaves about 500 bytes off the executable.

[*] I suppose we could also have this routine a tri-value, with one to
indicat 'it is this name, but it's not the one you're looking for', to
avoid later calls trying different names?

Reviewd By: ChuanqiXu

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

2 years ago[libc++][NFC] Reformat and modernize compressed_pair.h
Nikolas Klauser [Wed, 9 Feb 2022 20:40:11 +0000 (21:40 +0100)]
[libc++][NFC] Reformat and modernize compressed_pair.h

Reviewed By: Quuxplusone, ldionne, Mordante, #libc

Spies: libcxx-commits

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

2 years ago[demangler] Fix new/delete demangling
Nathan Sidwell [Fri, 28 Jan 2022 15:09:38 +0000 (07:09 -0800)]
[demangler] Fix new/delete demangling

I discovered some demangler problems:

a) parsing of new expressions was broken, ignoring any 'gs' prefix
b) (when #a is fixed) badly formatted global new expressions
c) formatting of new and delete failed to correctly add whitespace

(a) happens as parseExpr swallows the 'gs' prefix but doesn't pass it
 to 'parseNewExpr'.  It seems simpler to me to just code the new
 expression parsing directly in parseExpr, as is done for delete
 expressions.

(b) global new should be rendered something like '::new T' not
 '::operator new T'

(c) is resolved by being a bit more careful with whitespace.

Best shown with some examples (don't worry that these symbols are for
impossible instantiations, that's not the point):

Old behaviour:
build/bin/llvm-cxxfilt _ZN2FnIXgsnw_iEEXna_ipiLi4EEEEEvv _ZN2FnIXnwLj4E_iEEXgsnaLj4E_ipiLi4EEEEEvv _ZN2FnIXgsdlLi4EEXdaLi4EEEEvv _ZN2FnIXdlLj4EEXgsdaLj4EEEEvv
void Fn<new int, new[] int(4)>()   // No ::new
void Fn<new (4u)int, new[] (4u)int(4)>() // No ::new, poor whitespace
void Fn<::delete4, delete[] 4>()  // missing necessary space
void Fn<delete4u, ::delete[] 4u>() // missing necessary space

New behaviour:
build/bin/llvm-cxxfilt _ZN2FnIXgsnw_iEEXna_ipiLi4EEEEEvv _ZN2FnIXnwLj4E_iEEXgsnaLj4E_ipiLi4EEEEEvv _ZN2FnIXgsdlLi4EEXdaLi4EEEEvv _ZN2FnIXdlLj4EEXgsdaLj4EEEEvv
void Fn<::new int, new[] int(4)>()
void Fn<new(4u) int, ::new[](4u) int(4)>()
void Fn<::delete 4, delete[] 4>()
void Fn<delete 4u, ::delete[] 4u>()

Binutils' behaviour:
c++filt _ZN2FnIXgsnw_iEEXna_ipiLi4EEEEEvv _ZN2FnIXnwLj4E_iEEXgsnaLj4E_ipiLi4EEEEEvv _ZN2FnIXgsdlLi4EEXdaLi4EEEEvv _ZN2FnIXdlLj4EEXgsdaLj4EEEEvv
void Fn<::new int, new int(4)>()
void Fn<new (4u) int, ::new (4u) int(4)>()
void Fn<::delete (4), delete[] (4)>()
void Fn<delete (4u), ::delete[] (4u)>()

The new and binutils demanglings are the same modulo some whitespace and optional parens.

Reviewed By: ChuanqiXu

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

2 years ago[ConstraintElimination] Remove unnecessary recursion (NFC).
Florian Hahn [Thu, 10 Feb 2022 12:26:35 +0000 (12:26 +0000)]
[ConstraintElimination] Remove unnecessary recursion (NFC).

Perform predicate normalization in a single switch, rather then going
through recursions.

2 years ago[AArch64][SVE] Fix selection failure during lowering of shuffle_vector
Bradley Smith [Tue, 8 Feb 2022 16:01:13 +0000 (16:01 +0000)]
[AArch64][SVE] Fix selection failure during lowering of shuffle_vector

The lowering code for shuffle_vector has a code path that looks through
extract_subvector, this code path did not properly account for the
potential presense of larger than Neon vector types and could produce
unselectable DAG nodes.

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

2 years ago[LoopVectorize] Regenerate reduction-predselect.ll test checks
Simon Pilgrim [Thu, 10 Feb 2022 12:03:10 +0000 (12:03 +0000)]
[LoopVectorize] Regenerate reduction-predselect.ll test checks

2 years ago[Driver] Use libatomic for 32-bit SPARC atomics support
Rainer Orth [Thu, 10 Feb 2022 11:40:32 +0000 (12:40 +0100)]
[Driver] Use libatomic for 32-bit SPARC atomics support

Even after D86621 <https://reviews.llvm.org/D86621>, `clang -m32` on
Solaris/sparcv9 doesn't inline atomics with 8-byte operands, unlike `gcc`.
This leads to many link failures in the testsuite (undefined references to
`__atomic_load_8` and `__sync_val_compare_and_swap_8`.  Until a proper
codegen fix can be implemented, this patch works around the first of those
by linking with `-latomic`.

Tested on `sparcv9-sun-solaris2.11`.

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

2 years ago[DebugInfo][InstrRef] Don't fire assertions if debug-info is faulty
Jeremy Morse [Thu, 10 Feb 2022 11:07:15 +0000 (11:07 +0000)]
[DebugInfo][InstrRef] Don't fire assertions if debug-info is faulty

It's inevitable that optimisation passes will fail to update debug-info:
when that happens, it's best if the compiler doesn't crash as a result.
Therefore, downgrade a few assertions / failure modes that would crash
when illegal debug-info was seen, to instead drop variable locations. In
practice this means that an instruction reference to a nonexistant or
illegal operand should be tolerated.

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

2 years ago[LLParser][OpaquePtr] Support forward reference to unnamed function
Nikita Popov [Thu, 10 Feb 2022 11:20:34 +0000 (12:20 +0100)]
[LLParser][OpaquePtr] Support forward reference to unnamed function

With opaque pointers, we always create forward references as i8
globals, so it will not be Function here.

2 years ago[NVPTX] Use align attribute for kernel pointer arg alignment
Nikita Popov [Tue, 8 Feb 2022 15:24:36 +0000 (16:24 +0100)]
[NVPTX] Use align attribute for kernel pointer arg alignment

Instead of determining the alignment based on the pointer element
type (which is incompatible with opaque pointers), make use of
alignment annotations added by the frontend.

In particular, clang will add alignment attributes to OpenCL kernels
since D118894. Other frontends might need to be adjusted to add
the attribute as well.

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

2 years ago[cross-project-tests] Add REQUIRES: compiler-rt to tests that use asan
OCHyams [Wed, 9 Feb 2022 17:08:43 +0000 (17:08 +0000)]
[cross-project-tests] Add REQUIRES: compiler-rt to tests that use asan

And XFAIL debuginfo-tests/llgdb-tests/asan-deque.cpp on !system-darwin.
On non-darwin systems these tests use gdb and this one fails because gdb
doesn't pretty-print std::deque (the elements of the deque are not printed so
the CHECK lines fail).

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

2 years agoReland "[lldb] Remove non address bits when looking up memory regions"
David Spickett [Wed, 1 Dec 2021 16:14:54 +0000 (16:14 +0000)]
Reland "[lldb] Remove non address bits when looking up memory regions"

This reverts commit 0df522969a7a0128052bd79182c8d58e00556e2f.

Additional checks are added to fix the detection of the last memory region
in GetMemoryRegions or repeating the "memory region" command when the
target has non-address bits.

Normally you keep reading from address 0, looking up each region's end
address until you get LLDB_INVALID_ADDR as the region end address.
(0xffffffffffffffff)

This is what the remote will return once you go beyond the last mapped region:
[0x0000fffffffdf000-0x0001000000000000) rw- [stack]
[0x0001000000000000-0xffffffffffffffff) ---

Problem is that when we "fix" the lookup address, we remove some bits
from it. On an AArch64 system we have 48 bit virtual addresses, so when
we fix the end address of the [stack] region the result is 0.
So we loop back to the start.

[0x0000fffffffdf000-0x0001000000000000) rw- [stack]
[0x0000000000000000-0x0000000000400000) ---

To fix this I added an additional check for the last range.
If the end address of the region is different once you apply
FixDataAddress, we are at the last region.

Since the end of the last region will be the last valid mappable
address, plus 1. That 1 will be removed by the ABI plugin.

The only side effect is that on systems with non-address bits, you
won't get that last catch all unmapped region from the max virtual
address up to 0xf...f.

[0x0000fffff8000000-0x0000fffffffdf000) ---
[0x0000fffffffdf000-0x0001000000000000) rw- [stack]
<ends here>

Though in some way this is more correct because that region is not
just unmapped, it's not mappable at all.

No extra testing is needed because this is already covered by
TestMemoryRegion.py, I simply forgot to run it on system that had
both top byte ignore and pointer authentication.

This change has been tested on a qemu VM with top byte ignore,
memory tagging and pointer authentication enabled.

Reviewed By: omjavaid

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

2 years ago[flang] Add FIRInlinerInterface
Valentin Clement [Thu, 10 Feb 2022 10:37:53 +0000 (11:37 +0100)]
[flang] Add FIRInlinerInterface

This patch introduces the FIRInlinerInterface.
This class defines the interface for handling inlining of FIR calls.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[ArgPromotion] Transfer metadata to promoted loads
Nikita Popov [Thu, 10 Feb 2022 10:26:26 +0000 (11:26 +0100)]
[ArgPromotion] Transfer metadata to promoted loads

Also transfer selected non-AA metadata to the promoted load.
Only metadata from guaranteed to execute loads is transferred.

2 years ago[ArgPromotion] Add test for metadata on promoted loads (NFC)
Nikita Popov [Thu, 10 Feb 2022 10:23:09 +0000 (11:23 +0100)]
[ArgPromotion] Add test for metadata on promoted loads (NFC)

2 years ago[LoongArch][test] (6/6) Add encoding and mnemonics tests
Lu Weining [Thu, 10 Feb 2022 09:16:06 +0000 (09:16 +0000)]
[LoongArch][test] (6/6) Add encoding and mnemonics tests

With the benefit of D88392, instruction encoding and mnemonic testing can be
achieved within MIR files before AsmParser is ready. This patch adds such
tests which cover all basic integer instructions we defined in previous patch.
Similarly those tests will be rewrote by .s and moved to test/MC/LoongArch.

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

2 years ago[Utils][LoongArch](5/6) Add a --bits-endian option to extract-section.py
Lu Weining [Thu, 10 Feb 2022 09:15:10 +0000 (09:15 +0000)]
[Utils][LoongArch](5/6) Add a --bits-endian option to extract-section.py

This is a split patch of D115862 which adds a --bits-endian option to
extract-section to make it possible to print bits in specified endianness.
It means that we can print instruction encoding of some targets like LoongArch
as bits[0] to bits[31] from right to left by specifing --bits-endian little.

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

2 years ago[LoongArch 4/6] Add basic tablegen infra for LoongArch
Lu Weining [Thu, 10 Feb 2022 09:14:18 +0000 (09:14 +0000)]
[LoongArch 4/6] Add basic tablegen infra for LoongArch

This patch introduces basic tablegen infra such as
LoongArch{InstrFormats,InstrInfo,RegisterInfo,CallingConv,}.td.

For now, only add instruction definitions for LoongArch basic integer
operations.
Our initial target is a working MC layer rather than codegen,
so appropriate SelectionDAG patterns will come later.

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

2 years ago[LoongArch 3/6] Add target stub for LoongArch
Lu Weining [Thu, 10 Feb 2022 09:12:09 +0000 (09:12 +0000)]
[LoongArch 3/6] Add target stub for LoongArch

This patch registers the 'loongarch32' and 'loongarch64' targets. Also adds a
simple testcase to check the output of llc --vesion containing the targets.

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

2 years ago[LoongArch 2/6] Add ELF machine flag and relocs for upcoming LoongArch target
Lu Weining [Thu, 10 Feb 2022 09:11:11 +0000 (09:11 +0000)]
[LoongArch 2/6] Add ELF machine flag and relocs for upcoming LoongArch target

This patch adds necessary definitions for LoongArch ELF files, including
relocation types. Also adds initial support to ELFYaml, llvm-objdump,
and llvm-readobj in order to work with LoongArch ELFs.

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

2 years ago[LoongArch 1/6] Add triples loongarch{32,64} for the upcoming LoongArch target
Lu Weining [Thu, 10 Feb 2022 09:09:32 +0000 (09:09 +0000)]
[LoongArch 1/6] Add triples loongarch{32,64} for the upcoming LoongArch target

This is the first patch to incrementally add an MC layer for LoongArch to LLVM.
This patch also adds unit testcases for these new triples.

RFC for adding this new backend:
https://lists.llvm.org/pipermail/llvm-dev/2021-December/154371.html

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

2 years ago[mlir][vector][NFC] Use CombiningKindAttr instead of StringAttr
Matthias Springer [Thu, 10 Feb 2022 10:12:46 +0000 (19:12 +0900)]
[mlir][vector][NFC] Use CombiningKindAttr instead of StringAttr

This makes the op consistent with other ops in vector dialect.

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

2 years ago[RISCV] Pre-process FP SPLAT_VECTOR to RISCVISD::VFMV_V_F_VL
Fraser Cormack [Wed, 19 Jan 2022 13:54:11 +0000 (13:54 +0000)]
[RISCV] Pre-process FP SPLAT_VECTOR to RISCVISD::VFMV_V_F_VL

This patch builds on top of D119197 to canonicalize floating-point
SPLAT_VECTOR as RISCVISD::VFMV_V_F_VL as a pre-process ISel step.

This primarily benefits scalable-vector VP code, where our VP patterns
only match VFMV_V_F_VL to reduce the burden on our ISel patterns, but
where at the same time, scalable-vector code doesn't custom-legalize
SPLAT_VECTOR.

Reviewed By: craig.topper

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

2 years ago[ARM] Patterns for vector conversion between half and float
Oliver Stannard [Wed, 9 Feb 2022 17:43:42 +0000 (17:43 +0000)]
[ARM] Patterns for vector conversion between half and float

These patterns were omitted because clang only allows converting between
these types using intrinsics, but other front-ends or optimisation
passes may want to use them.

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

2 years ago[clang-format] Move FormatToken::opensBlockOrBlockTypeList to source file. NFC.
Marek Kurdej [Thu, 10 Feb 2022 09:14:36 +0000 (10:14 +0100)]
[clang-format] Move FormatToken::opensBlockOrBlockTypeList to source file. NFC.