platform/upstream/llvm.git
2 years ago[Clang] Add a warning on invalid UTF-8 in comments.
Corentin Jabot [Fri, 17 Jun 2022 14:23:41 +0000 (16:23 +0200)]
[Clang] Add a warning on invalid UTF-8 in comments.

Introduce an off-by default `-Winvalid-utf8` warning
that detects invalid UTF-8 code units sequences in comments.

Invalid UTF-8 in other places is already diagnosed,
as that cannot appear in identifiers and other grammar constructs.

The warning is off by default as its likely to be somewhat disruptive
otherwise.

This warning allows clang to conform to the yet-to be approved WG21
"P2295R5 Support for UTF-8 as a portable source file encoding"
paper.

Reviewed By: aaron.ballman, #clang-language-wg

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

2 years ago[CMake] Set the common link flags for memprof tests
Petr Hosek [Sat, 9 Jul 2022 08:59:58 +0000 (08:59 +0000)]
[CMake] Set the common link flags for memprof tests

This was missed in ba007f20bb4acf95262f49ab527ce35c4a1f5a19 by mistake.

2 years ago[C++20][Modules] Build module static initializers per P1874R1.
Iain Sandoe [Sun, 15 May 2022 13:47:54 +0000 (14:47 +0100)]
[C++20][Modules] Build module static initializers per P1874R1.

Currently we only implement this for the Itanium ABI since the correct
mangling for the initializers in other ABIs is not yet known.

Intended result:

For a module interface [which includes partition interface and implementation
units] (instead of the generic CXX initializer) we emit a module init that:

 - wraps the contained initializations in a control variable to ensure that
   the inits only happen once, even if a module is imported many times by
   imports of the main unit.

 - calls module initializers for imported modules first.  Note that the
   order of module import is not significant, and therefore neither is the
   order of imported module initializers.

 - We then call initializers for the Global Module Fragment (if present)
 - We then call initializers for the current module.
 - We then call initializers for the Private Module Fragment (if present)

For a module implementation unit, or a non-module TU that imports at least one
module we emit a regular CXX init that:

 - Calls the initializers for any imported modules first.
 - Then proceeds as normal with remaining inits.

For all module unit kinds we include a global constructor entry, this allows
for the (in most cases unusual) possibility that a module object could be
included in a final binary without a specific call to its initializer.

Implementation:

 - We provide the module pointer in the AST Context so that CodeGen can act
   on it and its sub-modules.

 - We need to account for module build lines like this:
  ` clang -cc1 -std=c++20 Foo.pcm -emit-obj -o Foo.o` or
  ` clang -cc1 -std=c++20 -xc++-module Foo.cpp -emit-obj -o Foo.o`

 - in order to do this, we add to ParseAST to set the module pointer in
   the ASTContext, once we establish that this is a module build and we
   know the module pointer. To be able to do this, we make the query for
   current module public in Sema.

 - In CodeGen, we determine if the current build requires a CXX20-style module
   init and, if so, we defer any module initializers during the "Eagerly
   Emitted" phase.

 - We then walk the module initializers at the end of the TU but before
   emitting deferred inits (which adds any hidden and static ones, fixing
   https://github.com/llvm/llvm-project/issues/51873 ).

 - We then proceed to emit the deferred inits and continue to emit the CXX
   init function.

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

2 years ago[clang] Add a fixit for warn-self-assign if LHS is a field with the same name as...
Nathan James [Sat, 9 Jul 2022 07:28:07 +0000 (08:28 +0100)]
[clang] Add a fixit for warn-self-assign if LHS is a field with the same name as parameter on RHS

Add a fix-it for the common case of setters/constructors using parameters with the same name as fields
```lang=c++
struct A{
  int X;
  A(int X) { /*this->*/X = X; }
  void setX(int X) { /*this->*/X = X;
};
```

Reviewed By: aaron.ballman

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

2 years ago[mlir][bufferization] Do not canonicalize to_tensor(to_memref(x))
Matthias Springer [Sat, 9 Jul 2022 07:15:36 +0000 (09:15 +0200)]
[mlir][bufferization] Do not canonicalize to_tensor(to_memref(x))

This is a partial revert of D128615.

to_memref(to_tensor(x)) always be folded to x. But to_tensor(to_memref(x)) cannot be folded in the general case because writes to the intermediary memref may go unnoticed.

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

2 years ago[AMDGPU][NFC] Harmonize decl&def of R600TargetLowering::OptimizeSwizzle
serge-sans-paille [Sat, 9 Jul 2022 07:05:22 +0000 (09:05 +0200)]
[AMDGPU][NFC] Harmonize decl&def of R600TargetLowering::OptimizeSwizzle

The freshly baked -Warray-parameter warning discovered an inconsistency in
argument declaration, use the stricter one.

This fixes build issues like https://lab.llvm.org/buildbot#builders/18/builds/5305

2 years ago[clang-format] Fix an assertion failure on -lines=0:n
owenca [Fri, 8 Jul 2022 06:34:44 +0000 (23:34 -0700)]
[clang-format] Fix an assertion failure on -lines=0:n

Also fixed the error message for start line > end line and added test cases.

Fixes #56438.

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

2 years ago[CMake] Use explicit header path when using in-tree libc++ for tests
Petr Hosek [Fri, 17 Jun 2022 08:11:32 +0000 (08:11 +0000)]
[CMake] Use explicit header path when using in-tree libc++ for tests

This is a follow up to D118200 which applies a similar cleanup to
headers when using in-tree libc++ to avoid accidentally picking up
the system headers.

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

2 years ago[Inliner] Make recusive inlinee stack size limit tunable
Wenlei He [Sat, 9 Jul 2022 00:17:11 +0000 (17:17 -0700)]
[Inliner] Make recusive inlinee stack size limit tunable

For recursive callers, we want to be conservative when inlining callees with large stack size. We currently have a limit `InlineConstants::TotalAllocaSizeRecursiveCaller`, but that is hard coded.

We found the current limit insufficient to suppress problematic inlining that bloats stack size for deep recursion. This change adds a switch to make the limit tunable as a mitigation.

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

2 years agoRevert "[CMake] Use explicit header path when using in-tree libc++ for tests"
Petr Hosek [Sat, 9 Jul 2022 04:27:16 +0000 (04:27 +0000)]
Revert "[CMake] Use explicit header path when using in-tree libc++ for tests"

This reverts commit 61b410cb8b9af0aa265e730a3070b3154d869803 as this
appears to have broken some sanitizer tests.

2 years ago[CMake] Use explicit header path when using in-tree libc++ for tests
Petr Hosek [Fri, 17 Jun 2022 08:11:32 +0000 (08:11 +0000)]
[CMake] Use explicit header path when using in-tree libc++ for tests

This is a follow up to D118200 which applies a similar cleanup to
headers when using in-tree libc++ to avoid accidentally picking up
the system headers.

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

2 years ago[clangd] Support "usedAsMutableReference" in member initializations
Christian Kandeler [Fri, 8 Jul 2022 08:12:31 +0000 (04:12 -0400)]
[clangd] Support "usedAsMutableReference" in member initializations

That is, mark constructor parameters being used to initialize
non-const reference members.

Reviewed By: nridge

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

2 years ago[libcxx] Uglify __support/openbsd
Brad Smith [Sat, 9 Jul 2022 01:33:57 +0000 (21:33 -0400)]
[libcxx] Uglify __support/openbsd

Uglify __support/openbsd

Reviewed By: philnik

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

2 years ago[NFC][OpenMP][Offloading] Fix compilation warning caused by misuse of `static_cast`
Shilei Tian [Sat, 9 Jul 2022 00:59:37 +0000 (20:59 -0400)]
[NFC][OpenMP][Offloading] Fix compilation warning caused by misuse of `static_cast`

2 years ago[mlir:LSP] Drop potentialy annoying completion commit characters
River Riddle [Sat, 9 Jul 2022 00:56:48 +0000 (17:56 -0700)]
[mlir:LSP] Drop potentialy annoying completion commit characters

These can result in accidentally accepting a completion when it isn't intended.

2 years ago[mlir:LSP] Add code completions for builtin signed/unsigned integers
River Riddle [Sat, 9 Jul 2022 00:55:30 +0000 (17:55 -0700)]
[mlir:LSP] Add code completions for builtin signed/unsigned integers

2 years ago[mlir:LSP] Add support for code completing attributes and types
River Riddle [Thu, 7 Jul 2022 05:54:36 +0000 (22:54 -0700)]
[mlir:LSP] Add support for code completing attributes and types

This required changing a bit of how attributes/types are parsed. A new
`KeywordSwitch` class was added to AsmParser that provides a StringSwitch
like API for parsing keywords with a set of potential matches. It intends to
both provide a cleaner API, and enable injection for code completion. This
required changing the API of `generated(Attr|Type)Parser` to handle the
parsing of the keyword, instead of having the user do it. Most upstream
dialects use the autogenerated handling and didn't require a direct update.

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

2 years ago[mlir:LSP] Add support for keyword code completions
River Riddle [Wed, 6 Jul 2022 09:49:58 +0000 (02:49 -0700)]
[mlir:LSP] Add support for keyword code completions

This commit adds code completion results to the MLIR LSP when
parsing keywords. Keyword support is currently limited to the
case where the expected keyword is provided, but a followup will
work on expanding the set of keyword cases we handle (e.g. to
allow capturing attribute/type mnemonics).

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

2 years ago[libc] add printf hexadecimal float conversion
Michael Jones [Wed, 6 Jul 2022 23:53:34 +0000 (16:53 -0700)]
[libc] add printf hexadecimal float conversion

This patch adds the %a/A conversions to printf, as well as the compiler
flag to disable floating point handling entirely. This will allow our
printf implementation to display every type of argument allowed by
printf, although some formats are still incomplete.

Reviewed By: sivachandra

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

2 years agoReplace hard coded number with regex so the test passes on downstream projects that...
Douglas Yung [Fri, 8 Jul 2022 22:47:03 +0000 (15:47 -0700)]
Replace hard coded number with regex so the test passes on downstream projects that may define additional opcodes.

2 years ago[libc] add dependencies to generic sqrt tests
Michael Jones [Fri, 8 Jul 2022 18:35:29 +0000 (11:35 -0700)]
[libc] add dependencies to generic sqrt tests

This adds dependencies on the corresponding sqrt function to each
generic sqrt test. This is so that on platforms that don't support the
math functions, the tests are not run.

Reviewed By: lntue

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

2 years ago[AIX][clang/test] Set/propagate AIXTHREAD_STK for AIX
Hubert Tong [Fri, 8 Jul 2022 22:30:48 +0000 (18:30 -0400)]
[AIX][clang/test] Set/propagate AIXTHREAD_STK for AIX

Some tests perform deep recursion, which requires a larger pthread stack
size than the relatively low default of 192 KiB for 64-bit processes on
AIX. The `AIXTHREAD_STK` environment variable provides a non-intrusive
way to request a larger pthread stack size for the tests. The required
pthread stack size depends on the build configuration.

A 4 MiB default is generous compared to the 512 KiB of macOS; however,
it is known that some compilers on AIX produce code that uses
comparatively more stack space.

This patch expands the solution from D65688 to apply to all Clang LIT
tests.

This also reverts commit c3c75d805c2174388417080f762230961b3433d6,
"[clang][test] Mark test arm-float-abi-lto.c unsupported on AIX".

The problem was caused by the test running up against the per-thread
stack limit on AIX. This is resolved by having the tests run with
`AIXTHREAD_STK` set for 4 MiB.

Reviewed By: xingxue

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

2 years ago[BOLT][Runtime] Fix memset definition
Vladislav Khmelevsky [Thu, 7 Jul 2022 11:48:47 +0000 (14:48 +0300)]
[BOLT][Runtime] Fix memset definition

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

2 years agojGetLoadedDynamicLibrariesInfos can inspect machos not yet loaded
Jason Molenda [Fri, 8 Jul 2022 21:01:15 +0000 (14:01 -0700)]
jGetLoadedDynamicLibrariesInfos can inspect machos not yet loaded

jGetLoadedDynamicLibrariesInfos normally checks with dyld to find
the list of binaries loaded in the inferior, and getting the filepath,
before trying to parse the Mach-O binary in inferior memory.
This allows for debugserver to parse a Mach-O binary present in memory,
but not yet registered with dyld.  This patch also adds some simple
sanity checks that we're reading a Mach-O header before we begin
stepping through load commands, because we won't have the sanity check
of consulting dyld for the list of loaded binaries before parsing.
Also adds a testcase.

Differential Revision: https://reviews.llvm.org/D128956
rdar://95737734

2 years ago[CMake] Option to select C++ library for runtimes that use it
Petr Hosek [Thu, 2 Jun 2022 21:52:56 +0000 (21:52 +0000)]
[CMake] Option to select C++ library for runtimes that use it

We currently have an option to select C++ ABI and C++ library for tests
but there are runtimes that use C++ library, specifically ORC and XRay,
which aren't covered by existing options. This change introduces a new
option to control the use of C++ libray for these runtimes.

Ideally, this option should become the default way to select C++ library
for all of compiler-rt replacing the existing options (the C++ ABI
option could remain as a hidden internal option).

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

2 years agoRemove unnecessary braces
David Blaikie [Fri, 8 Jul 2022 21:37:24 +0000 (21:37 +0000)]
Remove unnecessary braces

2 years agollvm-dwarfdump: Don't crash if DW_AT_{decl,call}_{file,line} uses signed form
Pedro Alves [Fri, 8 Jul 2022 21:15:52 +0000 (21:15 +0000)]
llvm-dwarfdump: Don't crash if DW_AT_{decl,call}_{file,line} uses signed form

The DWARF spec says:

 Any debugging information entry representing the declaration of an object,
 module, subprogram or type may have DW_AT_decl_file, DW_AT_decl_line and
 DW_AT_decl_column attributes, each of whose value is an unsigned integer
 ^^^^^^^^
 constant.

If however, a producer happens to emit DW_AT_decl_file /
DW_AT_decl_line using a signed integer form, llvm-dwarfdump crashes,
like so:

     (... snip ...)
     0x000000b4:   DW_TAG_structure_type
                     DW_AT_name      ("test_struct")
                     DW_AT_byte_size (136)
                     DW_AT_decl_file (llvm-dwarfdump: (... snip ...)/llvm/include/llvm/ADT/Optional.h:197: T& llvm::optional_detail::OptionalStorage<T, true>::getValue() &
 [with T = long unsigned int]: Assertion `hasVal' failed.
     PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
     Stack dump:
     0.      Program arguments: /opt/rocm/llvm/bin/llvm-dwarfdump ./testsuite/outputs/gdb.rocm/lane-pc-vega20/lane-pc-vega20-kernel.so
      #0 0x000055cc8e78315f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
      #1 0x000055cc8e780d3d SignalHandler(int) Signals.cpp:0:0
      #2 0x00007f8f2cae8420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
      #3 0x00007f8f2c58d00b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
      #4 0x00007f8f2c56c859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
      #5 0x00007f8f2c56c729 get_sysdep_segment_value /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:509:8
      #6 0x00007f8f2c56c729 _nl_load_domain /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:970:34
      #7 0x00007f8f2c57dfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
      #8 0x000055cc8e58ceb9 llvm::DWARFDie::dump(llvm::raw_ostream&, unsigned int, llvm::DIDumpOptions) const (/opt/rocm/llvm/bin/llvm-dwarfdump+0x2e0eb9)
      #9 0x000055cc8e58bec3 llvm::DWARFDie::dump(llvm::raw_ostream&, unsigned int, llvm::DIDumpOptions) const (/opt/rocm/llvm/bin/llvm-dwarfdump+0x2dfec3)
     #10 0x000055cc8e5b28a3 llvm::DWARFCompileUnit::dump(llvm::raw_ostream&, llvm::DIDumpOptions) (.part.21) DWARFCompileUnit.cpp:0:0

Likewise with DW_AT_call_file / DW_AT_call_line.

The problem is that the code in llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
dumping these attributes assumes that
FormValue.getAsUnsignedConstant() returns an armed optional.  If in
debug mode, we get an assertion line the above.  If in release mode,
and asserts are compiled out, then we proceed as if the optional had a
value, running into undefined behavior, printing whatever random
value.

Fix this by checking whether the optional returned by
FormValue.getAsUnsignedConstant() has a value, like done in other
places.

In addition, DWARFVerifier.cpp is validating DW_AT_call_file /
DW_AT_decl_file, but not AT_call_line / DW_AT_decl_line.  This commit
fixes that too.

The llvm-dwarfdump/X86/verify_file_encoding.yaml testcase is extended
to cover these cases.  Current llvm-dwarfdump crashes running the
newly-extended test.

"make check-llvm-tools-llvm-dwarfdump" shows no regressions, on x86-64
GNU/Linux.

Reviewed By: dblaikie

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

2 years ago[Sanitizer][Darwin] Cleanup MaybeReexec() function and usage
Julian Lettner [Fri, 1 Jul 2022 18:05:40 +0000 (11:05 -0700)]
[Sanitizer][Darwin] Cleanup MaybeReexec() function and usage

While investigating another issue, I noticed that `MaybeReexec()` never
actually "re-executes via `execv()`" anymore.  `DyldNeedsEnvVariable()`
only returned true on macOS 10.10 and below.

Usually, I try to avoid "unnecessary" cleanups (it's hard to be certain
that there truly is no fallout), but I decided to do this one because:

* I initially tricked myself into thinking that `MaybeReexec()` was
  relevant to my original investigation (instead of being dead code).
* The deleted code itself is quite complicated.
* Over time a few other things were mushed into `MaybeReexec()`:
  initializing `MonotonicNanoTime()`, verifying interceptors are
  working, and stripping the `DYLD_INSERT_LIBRARIES` env var to avoid
  problems when forking.
* This platform-specific thing leaked into `sanitizer_common.h`.
* The `ReexecDisabled()` config nob relies on the "strong overrides weak
  pattern", which is now problematic and can be completely removed.
* `ReexecDisabled()` actually hid another issue with interceptors not
  working in unit tests.  I added an explicit `verify_interceptors`
  (defaults to `true`) option instead.

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

2 years ago[Clang] Fix the wrong features being derivec in the offload packager
Joseph Huber [Fri, 8 Jul 2022 19:59:10 +0000 (15:59 -0400)]
[Clang] Fix the wrong features being derivec in the offload packager

The offload packager embeds the features in the offloading binary when
performing LTO. This had an incorrect interaction with the
`--cuda-feature` option because we weren't deriving the features from
the CUDA toolchain arguments when it was being specified. This patch
fixes this so the features are correctly overrideen when using this
argument.

However, this brings up a question of how best to handle conflicting
target features. The user could compile many libraries with different
features, in this case we do not know which one to pick. This was not
previously a problem when we simply passed the features in from the CUDA
installation at link-link because we just defaulted to whatever was
current on the system.

Reviewed By: ye-luo

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

2 years ago[LinkerWrapper] Fix use of string savers and correctly pass bitcode libraries
Joseph Huber [Fri, 8 Jul 2022 17:33:46 +0000 (13:33 -0400)]
[LinkerWrapper] Fix use of string savers and correctly pass bitcode libraries

This patch removes some uses of string savers that are no-longer needed.
We also create a new string saver when linking bitcode files. It seems
that occasionally the symbol string references can go out of scope when
they are added to the LTO input so we need to save these names that are
used for symbol resolution. Additionally, a previous patch added new
logic for handling bitcode libraries, but failed to actually add them to
the input. This bug has been fixed.

Fixes #56445

Reviewed By: ye-luo

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

2 years ago[clang] [Serialization] Fix swapped PPOpts/ExistingPPOpts parameters. NFC.
Martin Storsjö [Wed, 25 May 2022 12:07:18 +0000 (15:07 +0300)]
[clang] [Serialization] Fix swapped PPOpts/ExistingPPOpts parameters. NFC.

The two first parameters of checkPreprocessorOptions are "PPOpts, ExistingPPOpts".
All other callers of the function pass them consistently.

This avoids confusion when working on the code.

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

2 years ago[ELF] Refactor ELFCOMPRESS_ZLIB handling and improve diagnostics
Fangrui Song [Fri, 8 Jul 2022 21:04:19 +0000 (14:04 -0700)]
[ELF] Refactor ELFCOMPRESS_ZLIB handling and improve diagnostics

And add some tests.

2 years ago[gn build] Port c945bd0da652
LLVM GN Syncbot [Fri, 8 Jul 2022 20:59:26 +0000 (20:59 +0000)]
[gn build] Port c945bd0da652

2 years ago[libc++] Always build c++experimental.a
Louis Dionne [Thu, 30 Jun 2022 15:24:43 +0000 (11:24 -0400)]
[libc++] Always build c++experimental.a

This is the first part of a plan to ship experimental features
by default while guarding them behind a compiler flag to avoid
users accidentally depending on them. Subsequent patches will
also encompass incomplete features (such as <format> and <ranges>)
in that categorization. Basically, the idea is that we always
build and ship the c++experimental library, however users can't
use what's in it unless they pass the `-funstable` flag to Clang.

Note that this patch intentionally does not start guarding
existing <experimental/FOO> content behind the flag, because
that would merely break users that might be relying on such
content being in the headers unconditionally. Instead, we
should start guarding new TSes behind the flag, and get rid
of the existing TSes we have by shipping their Standard
counterpart.

Also, this patch must jump through a few hoops like defining
_LIBCPP_ENABLE_EXPERIMENTAL because we still support compilers
that do not implement -funstable yet.

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

2 years ago[libc++][ranges] Implement modifying heap algorithms:
Konstantin Varlamov [Fri, 8 Jul 2022 20:46:27 +0000 (13:46 -0700)]
[libc++][ranges] Implement modifying heap algorithms:

- `ranges::make_heap`;
- `ranges::push_heap`;
- `ranges::pop_heap`;
- `ranges::sort_heap`.

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

2 years agoRevert "[llvm] cmake config groundwork to have ZSTD in LLVM"
Leonard Chan [Fri, 8 Jul 2022 20:48:05 +0000 (13:48 -0700)]
Revert "[llvm] cmake config groundwork to have ZSTD in LLVM"

This reverts commit f07caf20b9d35e45501c9d5d903fa182b3bdb95a which seems to break upstream https://lab.llvm.org/buildbot/#/builders/109/builds/42253.

2 years agoRevert "[llvm] cmake config groundwork to have ZSTD in LLVM"
Leonard Chan [Fri, 8 Jul 2022 20:46:44 +0000 (13:46 -0700)]
Revert "[llvm] cmake config groundwork to have ZSTD in LLVM"

This reverts commit adf1ffe95854a245cbc48bbaea55f60b003d5f76 and f07caf20b9d35e45501c9d5d903fa182b3bdb95a
which seem to break upstream https://lab.llvm.org/buildbot/#/builders/109/builds/42253.

2 years ago[clang] Introduce -Warray-parameter
serge-sans-paille [Thu, 23 Jun 2022 14:20:09 +0000 (16:20 +0200)]
[clang] Introduce -Warray-parameter

This warning exist in GCC[0] and warns about re-declarations of functions
involving arguments of array or pointer types of inconsistent kinds or forms.

This is not the exact same implementation as GCC's : there's no warning level
and that flag has no effect on -Warray-bounds.

[0] https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gcc/Warning-Options.html#index-Wno-array-parameter

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

2 years ago[llvm] cmake config groundwork to have ZSTD in LLVM
Cole Kissane [Fri, 8 Jul 2022 19:36:27 +0000 (12:36 -0700)]
[llvm] cmake config groundwork to have ZSTD in LLVM

- added `FindZSTD.cmake`
- added a CMake option `LLVM_ENABLE_ZSTD` with behavior mirroring that of `LLVM_ENABLE_ZLIB`
- likewise added have_zstd to compiler-rt/test/lit.common.cfg.py, clang-tools-extra/clangd/test/lit.cfg.py, and several lit.site.cfg.py.in files mirroring have_zlib behavior

Reviewed By: leonardchan, MaskRay

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

2 years ago[llvm] cmake config groundwork to have ZSTD in LLVM
Cole Kissane [Fri, 8 Jul 2022 18:46:51 +0000 (11:46 -0700)]
[llvm] cmake config groundwork to have ZSTD in LLVM

- added `FindZSTD.cmake`
- added a CMake option `LLVM_ENABLE_ZSTD` with behavior mirroring that of `LLVM_ENABLE_ZLIB`
- likewise added have_zstd to compiler-rt/test/lit.common.cfg.py, clang-tools-extra/clangd/test/lit.cfg.py, and several lit.site.cfg.py.in files mirroring have_zlib behavior

Reviewed By: leonardchan, MaskRay

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

2 years ago[Libomptarget][NFC] Move legacy functions to a separate file
Joseph Huber [Thu, 7 Jul 2022 18:46:49 +0000 (14:46 -0400)]
[Libomptarget][NFC] Move legacy functions to a separate file

This patch moves the old legacy interfaces into `libomptarget` to a
separate file. These do not need to be included anywhere and are simply
provided for backwards compatibility with the ABI. This cleans up the
interface greatly.

Depends on D128817

Reviewed By: JonChesterfield

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

2 years ago[Libomptarget] Use new tripcount argument in the runtime.
Joseph Huber [Mon, 27 Jun 2022 16:26:58 +0000 (12:26 -0400)]
[Libomptarget] Use new tripcount argument in the runtime.

The previous patch added an argument to the `__tgt_target_kernel`
runtime function which includes the tripcount used for the loop clause.
This was originally passed in via the `__kmpc_push_target_tripcount`
function. Now we move this logic to the kernel launch itself and remove
the need for the push function.

Depends on D128816

Reviewed By: jdoerfert

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

2 years ago[OpenMP] Add loop tripcount argument to kernel launch and remove push function
Joseph Huber [Mon, 27 Jun 2022 16:23:50 +0000 (12:23 -0400)]
[OpenMP] Add loop tripcount argument to kernel launch and remove push function

Previously we added the `push_target_tripcount` function to send the
loop tripcount to the device runtime so we knew how to configure the
teams / threads for execute the loop for a teams distribute construct.
This was implemented as a separate function mostly to avoid changing the
interface for backwards compatbility. Now that we've changed it anyway
and the new interface can take an arbitrary number of arguments via the
struct without changing the ABI, we can move this to the new interface.
This will simplify the runtime by removing unnecessary state between
calls.

Depends on D128550

Reviewed By: jdoerfert

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

2 years ago[OpenMP] Change OpenMP code generation for target region entries
Joseph Huber [Fri, 24 Jun 2022 13:13:53 +0000 (09:13 -0400)]
[OpenMP] Change OpenMP code generation for target region entries

This patch changes the code we generate to enter a target region on the
device. This is in-line with the new definition in the runtime that was
added previously. Additionally we implement this in the OpenMPIRBuilder
so that this code can be shared with Flang in the future.

Reviewed By: ABataev

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

2 years ago[Libomptarget] Implement a unified kernel entry function
Joseph Huber [Thu, 23 Jun 2022 18:57:59 +0000 (14:57 -0400)]
[Libomptarget] Implement a unified kernel entry function

This patch implements a unified kernel entry function that will be
targeted from both teams and non-teams clauses. We introduce a new
interface and make the old functions call in using the new one. A
following patch will include the necessary changes to Clang to call
these new functions instead.

Reviewed By: jdoerfert

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

2 years ago[gn build] Port 23c7328bad92
LLVM GN Syncbot [Fri, 8 Jul 2022 18:34:42 +0000 (18:34 +0000)]
[gn build] Port 23c7328bad92

2 years ago[mlir] Add method to populate default attributes
Jacques Pienaar [Fri, 8 Jul 2022 18:31:12 +0000 (11:31 -0700)]
[mlir] Add method to populate default attributes

Previously default attributes were only usable by way of the ODS generated
accessors, but this was undesirable as
1. The ODS getters could construct Attribute each get request;
2. For non-C++ uses this would require either duplicating some of tee default
   attribute generating or generating additional bindings to generate methods;
3. Accessing op.getAttr("foo") and op.getFoo() would return different results;
Generate method to populate default attributes that can be used to address
these.

This merely adds this facility but does not employ by default on any path.

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

2 years ago[Clang][Docs] Update the clang-linker-wrapper documentation.
Joseph Huber [Fri, 8 Jul 2022 18:29:04 +0000 (14:29 -0400)]
[Clang][Docs] Update the clang-linker-wrapper documentation.

2 years ago[llvm-objdump] Fix alignment issues when dumping offloading sections
Joseph Huber [Fri, 8 Jul 2022 18:15:18 +0000 (14:15 -0400)]
[llvm-objdump] Fix alignment issues when dumping offloading sections

Summary:
The `.llvm.offloading` section should always be aligned by `8`. However,
we may want to show the offloading data stored in a static library. In
this case, even though the section's alignment is correct, the offset
inside the archive will result in the memory buffer being misaligned. TO
combat this we simply check if the buffer does not have the proper
alignment and copies it to a new buffer if not. This copy should have
the proper alignment.

2 years ago[objcxx] Fix `std::addressof` for `id`.
zoecarver [Fri, 8 Jul 2022 17:42:29 +0000 (10:42 -0700)]
[objcxx] Fix `std::addressof` for `id`.

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

2 years ago[libc++][ranges] Implement `ranges::nth_element`.
Konstantin Varlamov [Fri, 8 Jul 2022 03:35:51 +0000 (20:35 -0700)]
[libc++][ranges] Implement `ranges::nth_element`.

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

2 years ago[llvm] Remove unused and redundant crc32 funcction from llvm::compression::zlib namespace
Cole Kissane [Fri, 8 Jul 2022 18:24:45 +0000 (11:24 -0700)]
[llvm] Remove unused and redundant crc32 funcction from llvm::compression::zlib namespace

* Remove crc32 from zlib compression namespace, people should use the `llvm::crc32` instead.

Reviewed By: MaskRay, leonardchan

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

2 years ago[NFC] Fix cvt_f32_ubyte.ll test.
Daniil Fukalov [Fri, 8 Jul 2022 18:19:10 +0000 (21:19 +0300)]
[NFC] Fix cvt_f32_ubyte.ll test.

Remove (unintended) infinite loop in the test.

Reviewed By: vangthao

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

2 years ago[NFC] Refactor llvm::zlib namespace
Cole Kissane [Fri, 8 Jul 2022 18:19:05 +0000 (11:19 -0700)]
[NFC] Refactor llvm::zlib namespace

* Refactor compression namespaces across the project, making way for a possible
  introduction of alternatives to zlib compression.
  Changes are as follows:
  * Relocate the `llvm::zlib` namespace to `llvm::compression::zlib`.

Reviewed By: MaskRay, leonardchan, phosek

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

2 years agoUpdate references to Discourse instead of the mailing lists.
tlattner [Fri, 1 Jul 2022 21:07:48 +0000 (14:07 -0700)]
Update references to Discourse instead of the mailing lists.

Update the references to the old Mailman mailing lists to point to Discourse forums.

Reviewed By: aaron.ballman

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

2 years agoFix test: LLVMGetBitcodeModule takes ownership of memory buffer
Nicolai Hähnle [Mon, 4 Jul 2022 11:35:26 +0000 (13:35 +0200)]
Fix test: LLVMGetBitcodeModule takes ownership of memory buffer

Clarify this behavior in the C interface header file and fix a related
bug in a test.

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

2 years ago[C++20][Modules] Allow for redeclarations in partitions.
Iain Sandoe [Mon, 13 Jun 2022 09:15:50 +0000 (10:15 +0100)]
[C++20][Modules] Allow for redeclarations in partitions.

The existing provision is not sufficient, it did not allow for the cases
where an implementation partition includes the primary module interface,
or for the case that an exported interface partition is contains a decl
that is then implemented in a regular implementation unit.

It is somewhat unfortunate that we have to compare top level module names
to achieve this, since built modules are not necessarily available.

TODO: It might be useful to cache a hash of the primary module name if
this test proves to be a  significant load.

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

2 years ago[vscode-mlir] add tablegen <> bracket colorization
Ryan Thomas Lynch (@emosy) [Fri, 8 Jul 2022 17:58:20 +0000 (10:58 -0700)]
[vscode-mlir] add tablegen <> bracket colorization

Add support for colorizing angle brackets "<>" in TableGen files.

Reviewed By: rriddle

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

2 years ago[mlir][tosa] Enable decomposing Conv2D also where 1 input dim is dynamic
Jacques Pienaar [Fri, 8 Jul 2022 17:57:04 +0000 (10:57 -0700)]
[mlir][tosa] Enable decomposing Conv2D also where 1 input dim is dynamic

Restricted to just 1 dynamic input dim as that worked all the way through to
codegen.

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

2 years ago[RISCV] Switch to using get.active.lane.mask when tail folding
Philip Reames [Fri, 8 Jul 2022 17:19:49 +0000 (10:19 -0700)]
[RISCV] Switch to using get.active.lane.mask when tail folding

The motivation here is to a) bring us closer into alignment with AArch64 under the assumption that codepath is better tested, and b) simplify pattern matching in an upcoming change.

The immediate impact is a significant IR reduction but a fairly minimal change in the generated assembly. Due to a difference in expansion behavior we get a saturating add vs an unsaturating one for the old code, but that's about it. This difference comes down to different handling of overflow, which doesn't seem to be possible here anyways, so the assembly codegen is arguably a minor regression. I don't expect that to matter in practice.

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

2 years ago[RISCV] Mark fminnum_vl and fmaxnum_vl as commutable.
Craig Topper [Fri, 8 Jul 2022 17:14:27 +0000 (10:14 -0700)]
[RISCV] Mark fminnum_vl and fmaxnum_vl as commutable.

2 years ago[RISCV] Add commuted fixed vector vfmax.vf and vfmin.vf tests. NFC
Craig Topper [Fri, 8 Jul 2022 17:11:44 +0000 (10:11 -0700)]
[RISCV] Add commuted fixed vector vfmax.vf and vfmin.vf tests. NFC

The ISD opcodes aren't marked commutable so we don't match these
properly.

2 years ago[RISCV] Mark vsadd(u)_vl as commutable
Philip Reames [Fri, 8 Jul 2022 17:09:49 +0000 (10:09 -0700)]
[RISCV] Mark vsadd(u)_vl as commutable

This allows fixed length vectors involving splats on the LHS to commute into the _vx form of the instruction. Oddly, the generic canonicalization rules appear to catch the scalable vector cases. I haven't fully dug in to understand why, but I suspect it's because of a difference in how we represent splats (splat_vector vs build_vector).

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

2 years ago[DWARF] Add linkagename to hash
Alexander Yermolovich [Thu, 7 Jul 2022 18:41:51 +0000 (11:41 -0700)]
[DWARF] Add linkagename to hash

Originally encountered with RUST, but also there are cases with distributed LTO
where debug info dwo units contain structurally the same debug information, with
difference in DW_AT_linkage_name. This causes collision on DWO ID.

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

2 years ago[mlir] Fixed double-free bug in SymbolUserMap
Nandor Licker [Fri, 8 Jul 2022 05:57:37 +0000 (08:57 +0300)]
[mlir] Fixed double-free bug in SymbolUserMap

`SymbolUserMap` relied on `try_emplace` and `std::move` to relocate an entry to another key.  However, if this triggered the resizing of the `DenseMap`, the value was destroyed before it could be moved to the new storage location, leading to a dangling `users` reference to be inserted into the map. On destruction, since a new entry was created from one that was already freed, a double-free error occurred.

Fixed issue by re-fetching the iterator after the mutation of the container.

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

2 years ago[RISCV] Mark (s/u)min_vl and (s/u)max_vl as commutable.
Craig Topper [Fri, 8 Jul 2022 16:54:48 +0000 (09:54 -0700)]
[RISCV] Mark (s/u)min_vl and (s/u)max_vl as commutable.

2 years ago[RISCV] Add fixed vector vmin(u).vx and vmax(u).vx tests. NFC
Craig Topper [Fri, 8 Jul 2022 16:47:43 +0000 (09:47 -0700)]
[RISCV] Add fixed vector vmin(u).vx and vmax(u).vx tests. NFC

2 years ago[X86] Regenerate vec_shift6.ll to remove superfluous whitespace. NFC
Simon Pilgrim [Fri, 8 Jul 2022 16:59:10 +0000 (17:59 +0100)]
[X86] Regenerate vec_shift6.ll to remove superfluous whitespace. NFC

2 years ago[gn build] Manually port d2ead9e3
Arthur Eubanks [Fri, 8 Jul 2022 16:48:41 +0000 (09:48 -0700)]
[gn build] Manually port d2ead9e3

2 years ago[flang] Changed lowering for allocatable assignment to make array-value-copy correct.
Slava Zakharin [Fri, 1 Jul 2022 21:22:29 +0000 (14:22 -0700)]
[flang] Changed lowering for allocatable assignment to make array-value-copy correct.

Array-value-copy fails to generate a temporary array for case like this:
subroutine bug(b)
  real, allocatable :: b(:)
  b = b(2:1:-1)
end subroutine

Since LHS may need to be reallocated, lowering produces the following FIR:
%rhs_load = fir.array_load %b %slice

%lhs_mem = fir.if %b_is_allocated_with_right_shape {
   fir.result %b
} else {
   %new_storage = fir.allocmem %rhs_shape
   fir.result %new_storage
}

%lhs = fir.array_load %lhs_mem
%loop = fir.do_loop {
 ....
}
fir.array_merge_store %lhs, %loop to %lhs_mem
// deallocate old storage if reallocation occured,
// and update b descriptor if needed.

Since %b in array_load and %lhs_mem in array_merge_store are not the same SSA
values, array-value-copy does not detect the conflict and does not produce
a temporary array. This causes incorrect result in runtime.

The suggested change in lowering is to generate this:
%rhs_load = fir.array_load %b %slice
%lhs_mem = fir.if %b_is_allocated_with_right_shape {
   %lhs = fir.array_load %b
   %loop = fir.do_loop {
      ....
   }
   fir.array_merge_store %lhs, %loop to %b
   fir.result %b
} else {
   %new_storage = fir.allocmem %rhs_shape
   %lhs = fir.array_load %new_storage
   %loop = fir.do_loop {
      ....
   }
   fir.array_merge_store %lhs, %loop to %new_storage
   fir.result %new_storage
}
// deallocate old storage if reallocation occured,
// and update b descriptor if needed.

Note that there are actually 3 branches in FIR, so the assignment loops
are currently produced in three copies, which is a code-size issue.
It is possible to generate just two branches with two copies of the loops,
but it is not addressed in this change-set.

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

2 years ago[VPlan] Move VPWidenSelectRecipe::execute to VPlanRecipes.cpp (NFC).
Florian Hahn [Fri, 8 Jul 2022 16:33:17 +0000 (09:33 -0700)]
[VPlan] Move VPWidenSelectRecipe::execute to VPlanRecipes.cpp (NFC).

Depends on D127968.

Reviewed By: Ayal

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

2 years ago[libc++] Make parameter names consistent and enforce the naming style using readabili...
Nikolas Klauser [Fri, 8 Jul 2022 16:17:26 +0000 (18:17 +0200)]
[libc++] Make parameter names consistent and enforce the naming style using readability-identifier-naming

Ensure that parameter names have the style `__lower_case`

Reviewed By: ldionne, #libc

Spies: aheejin, sstefan1, libcxx-commits, miyuki

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

2 years agoAArch64/GlobalISel: Stop using legal s1 values
Matt Arsenault [Tue, 12 Apr 2022 16:41:16 +0000 (12:41 -0400)]
AArch64/GlobalISel: Stop using legal s1 values

As far as I can tell treating s1 values as legal makes no sense. There
are no allocatable 1-bit registers. SelectionDAG legalizes the usual
set of boolean operations to 32-bits, and this should do the
same. This avoids some special case handling in the selector of s1
values, and some extra code to look through truncates.

This makes some code worse at -O0, since nothing cleans up the and 1
the artifact combiner inserts. We could probably add some
non-essential combines or teach the artifact combiner to elide
intermediates betweeen boolean uses and defs.

2 years agoGlobalISel: Add buildBoolExtInReg helper
Matt Arsenault [Tue, 12 Apr 2022 13:27:33 +0000 (09:27 -0400)]
GlobalISel: Add buildBoolExtInReg helper

2 years agoGlobalISel: Allow forming atomic/volatile G_SEXTLOAD
Matt Arsenault [Sat, 9 Apr 2022 18:22:31 +0000 (14:22 -0400)]
GlobalISel: Allow forming atomic/volatile G_SEXTLOAD

Mirror the change to G_ZEXTLOAD.

2 years agoGlobalISel: Allow forming atomic/volatile G_ZEXTLOAD
Matt Arsenault [Sat, 9 Apr 2022 18:06:04 +0000 (14:06 -0400)]
GlobalISel: Allow forming atomic/volatile G_ZEXTLOAD

SelectionDAG has a target hook, getExtendForAtomicOps, which it uses
in the computeKnownBits implementation for ATOMIC_LOAD. This is pretty
ugly (as is having a separate load opcode for atomics), so instead
allow making use of atomic zextload. Enable this for AArch64 since the
DAG path defaults in to the zext behavior.

The tablegen changes are pretty ugly, but partially helps migrate
SelectionDAG from using ISD::ATOMIC_LOAD to regular ISD::LOAD with
atomic memory operands. For now the DAG emitter will emit matchers for
patterns which the DAG will not produce.

I'm still a bit confused by the intent of the isLoad/isStore/isAtomic
bits. The DAG implementation rejects trying to use any of these in
combination. For now I've opted to make the isLoad checks also check
isAtomic, although I think having isLoad and isAtomic set on these
makes most sense.

2 years ago[Clang] Fix test failing due to renamed arg
Joseph Huber [Fri, 8 Jul 2022 15:50:41 +0000 (11:50 -0400)]
[Clang] Fix test failing due to renamed arg

2 years ago[ConstantFolding] Guard against unfolded FP binop
Nikita Popov [Fri, 8 Jul 2022 15:43:55 +0000 (17:43 +0200)]
[ConstantFolding] Guard against unfolded FP binop

Check that the operation actually folded before trying to flush
denormals. A minor variation of the pr33453 test exposed this
with the FP binops marked as undesirable.

2 years ago[LinkerWrapper] Fix save-temps and argument name
Joseph Huber [Fri, 8 Jul 2022 15:37:15 +0000 (11:37 -0400)]
[LinkerWrapper] Fix save-temps and argument name

Summary:
The previous path reworked some handling of temporary files which
exposed some bugs related to capturing local state by reference in the
callback labmda. Squashing this by copying in everything instead. There
was also a problem where the argument name was changed for
`--bitcode-library=` but clang still used `--target-library=`.

2 years ago[InstCombine] Avoid ConstantExpr::get() in vector binop fold (NFCI)
Nikita Popov [Fri, 8 Jul 2022 15:19:04 +0000 (17:19 +0200)]
[InstCombine] Avoid ConstantExpr::get() in vector binop fold (NFCI)

Use the ConstantFoldBinaryOpOperands() API instead. This case
would bail out on a non-folded result anyway.

2 years ago[LinkerWrapper][NFC] Move error handling to a common function
Joseph Huber [Fri, 8 Jul 2022 15:00:14 +0000 (11:00 -0400)]
[LinkerWrapper][NFC] Move error handling to a common function

Summary:
This patch merges all the error handling functions to a single function
call so we don't define the same lambda many times.

2 years ago[LinkerWrapper][NFC] Rework command line argument handling in the linker wrapper
Joseph Huber [Thu, 7 Jul 2022 02:58:52 +0000 (22:58 -0400)]
[LinkerWrapper][NFC] Rework command line argument handling in the linker wrapper

Summary:
This patch reworks the command line argument handling in the linker
wrapper from using the LLVM `cl` interface to using the `Option`
interface with TableGen. This has several benefits compared to the old
method.

We use arguments from the linker arguments in the linker
wrapper, such as the libraries and input files, this allows us to
properly parse these. Additionally we can now easily set up aliases to
the linker wrapper arguments and pass them in the linker input directly.
That is, pass an option like `cuda-path=` as `--offload-arg=cuda-path=`
in the linker's inputs. This will allow us to handle offloading
compilation in the linker itself some day. Finally, this is also a much
cleaner interface for passing arguments to the individual device linking
jobs.

2 years ago[InstCombine] Avoid ConstantExpr::get() call
Nikita Popov [Fri, 8 Jul 2022 15:11:08 +0000 (17:11 +0200)]
[InstCombine] Avoid ConstantExpr::get() call

Avoid calling ConstantExpr::get() for associative/commutative
binops, call ConstantFoldBinaryOpOperands() instead. We only
want to perform the reassociation of the constants actually fold.

2 years ago[DAG] SimplifyDemandedBits - fold AND(INSERT_SUBVECTOR(C,X,I),M) -> INSERT_SUBVECTOR...
Simon Pilgrim [Fri, 8 Jul 2022 15:08:22 +0000 (16:08 +0100)]
[DAG] SimplifyDemandedBits - fold AND(INSERT_SUBVECTOR(C,X,I),M) -> INSERT_SUBVECTOR(AND(C,M),X,I)

If all the demanded bits of the AND mask covering the inserted subvector 'X' are known to be one, then the mask isn't affecting the subvector at all.

In which case, if the base vector 'C' is undef/constant, then move the AND mask up to just (constant) fold it directly.

Addresses some of the regressions from D129150, particularly the cases where we're attempting to zero the upper elements of a widened vector.

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

2 years ago[libomptarget] compile DeviceRTL bc files with -O3
Ye Luo [Fri, 8 Jul 2022 13:52:08 +0000 (08:52 -0500)]
[libomptarget] compile DeviceRTL bc files with -O3

bc files of DeviceRTL are compiled with -O3, the same as the static library.

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

2 years ago[ConstantExpr] Don't create float binop expressions
Nikita Popov [Fri, 8 Jul 2022 14:37:34 +0000 (16:37 +0200)]
[ConstantExpr] Don't create float binop expressions

Mark the fadd, fsub, fmul, fdiv, and frem expressions as
undesirable, so they are not created automatically. This is in
preparation for their removal.

2 years ago[InstCombine] Avoid creating float binop ConstantExprs
Nikita Popov [Fri, 8 Jul 2022 14:04:21 +0000 (16:04 +0200)]
[InstCombine] Avoid creating float binop ConstantExprs

Replace ConstantExpr:getFAdd etc with call to
ConstantFoldBinaryOpOperands(). I'm using the constant folding API
rather than IRBuilder here to ensure that this does actually
constant fold. These transforms don't use m_ImmConstant(), so this
would not otherwise be guaranteed (and apparently, they can't use
m_ImmConstant because they want to handle scalable vector splats).

There is an opportunity here to further migrate these to the
ConstantFoldFPInstOperands() API, which would respect the denormal
mode. I've held off on doing so here, because some of this code
explicitly checks for denormal results, and I don't want to touch
it in a mostly NFC change.

2 years ago[InstCombine] enhance fold for subtract-from-constant -> xor
Sanjay Patel [Fri, 8 Jul 2022 13:52:57 +0000 (09:52 -0400)]
[InstCombine] enhance fold for subtract-from-constant -> xor

A low-bit mask is not required:
https://alive2.llvm.org/ce/z/yPShss

This matches the SDAG implementation that was updated at:
8b756713140f

2 years ago[InstCombine] add tests for masked sub; NFC
Sanjay Patel [Fri, 8 Jul 2022 12:35:36 +0000 (08:35 -0400)]
[InstCombine] add tests for masked sub; NFC

2 years ago[flang][openacc][NFC] Extract device_type parser to its own
Valentin Clement [Fri, 8 Jul 2022 14:01:34 +0000 (16:01 +0200)]
[flang][openacc][NFC] Extract device_type parser to its own

Move the device_type parser to a separate parser AccDeviceTypeExprList. Preparatory work for D106968.

Reviewed By: kiranchandramohan

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

2 years ago[flang][openacc][NFC] Make self clause value optional in ACC.td and extract the parser
Valentin Clement [Fri, 8 Jul 2022 13:44:48 +0000 (15:44 +0200)]
[flang][openacc][NFC] Make self clause value optional in ACC.td and extract the parser

Set the isOptional flag for the self clause. Move the optional and parenthesis part of the parser. Update the rest of the code to deal with the optional value.

Preparatory work for D106968.

Reviewed By: kiranchandramohan

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

2 years ago[AArch64] Use Neoverse N2 sched model as default for:
Cullen Rhodes [Fri, 8 Jul 2022 12:55:52 +0000 (12:55 +0000)]
[AArch64] Use Neoverse N2 sched model as default for:

  - Cortex-A710
  - Cortex-X2
  - Neoverse-V1
  - Neoverse-512tvb

Reviewed By: dmgreen

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

2 years ago[LiveIntervals] Fix incorrect range (re)construction from subranges.
Daniil Fukalov [Fri, 8 Jul 2022 13:06:45 +0000 (16:06 +0300)]
[LiveIntervals] Fix incorrect range (re)construction from subranges.

After D82916 `updateAllRanges()` started to fix holes in main range with
subranges but it fails on instructions with two subregs def which are parts of
one reg. The main range constructed with //all// subranges of subregs just after
processing the first operand. So the main range gets intervals from subranges
those are not updated yet.

The patch takes into account lane mask to update the main range.

Reviewed By: rampitec, arsenm

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

2 years ago[gn build] Port 1cdec6c96e85
LLVM GN Syncbot [Fri, 8 Jul 2022 12:39:02 +0000 (12:39 +0000)]
[gn build] Port 1cdec6c96e85

2 years ago[libc++] Re-apply the use of ABI tags to provide per-TU insulation
Louis Dionne [Thu, 7 Jul 2022 18:07:37 +0000 (14:07 -0400)]
[libc++] Re-apply the use of ABI tags to provide per-TU insulation

This commit re-applies 9ee97ce3b830, which was reverted by 61d417ce
because it broke the LLDB data formatter tests. It also re-applies
6148c79a (the manual GN change associated to it).

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

2 years ago[X86][FP16] Add constrained FP support for scalar emulation
Phoebe Wang [Fri, 8 Jul 2022 11:11:33 +0000 (19:11 +0800)]
[X86][FP16] Add constrained FP support for scalar emulation

This is a follow up patch to support constrained FP in FP16 emulation.

Reviewed By: skan

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

2 years ago[libcxx][ranges] implement `std::ranges::set_difference`
Hui Xie [Sun, 26 Jun 2022 15:13:43 +0000 (16:13 +0100)]
[libcxx][ranges] implement `std::ranges::set_difference`

implement `std::ranges::set_difference`
reused classic std::set_difference
added unit tests

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

2 years ago[SDAG] try to replace subtract-from-constant with xor
Sanjay Patel [Fri, 8 Jul 2022 12:13:14 +0000 (08:13 -0400)]
[SDAG] try to replace subtract-from-constant with xor

This is almost the same as the abandoned D48529, but it
allows splat vector constants too.

This replaces the x86-specific code that was added with
the alternate patch D48557 with the original generic
combine.

This transform is a less restricted form of an existing
InstCombine and the proposed SDAG equivalent for that
in D128080:
https://alive2.llvm.org/ce/z/OUm6N_

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

2 years agoDisable clang-format entirely for test directories
Aaron Ballman [Fri, 8 Jul 2022 11:34:18 +0000 (07:34 -0400)]
Disable clang-format entirely for test directories

See discussion here:

https://github.com/llvm/llvm-project/issues/55982

And the RFC here:
https://discourse.llvm.org/t/rfc-disable-clang-format-in-the-clang-test-tree/63498/2

We don't generally expect test files to be formatted according to the
style guide. Indeed, some tests may require specific formatting for the
purposes of the test.

When tests intentionally do not conform to the "correct" formatting,
this causes errors in the CI, which can drown out real errors and causes
people to stop trusting the CI over time.

From the history of the clang/test/.clang-format file, it looks as if
there have been attempts to make clang-format do a subset of formatting
that would be useful for tests. However, it looks as if it's hard to
make clang-format do exactly the right thing -- see the back-and-forth
between
13316a7
and
7b5bddf.

These changes disable the .clang-format file for clang/test, llvm/test,
and clang-tools-extra/test.

Fixes #55982
Differential Revision: https://reviews.llvm.org/D128706

2 years agoFix the Clang sphinx bot
Aaron Ballman [Fri, 8 Jul 2022 11:23:40 +0000 (07:23 -0400)]
Fix the Clang sphinx bot

This should resolve the issues with:
https://lab.llvm.org/buildbot/#/builders/92/builds/29439