platform/upstream/llvm.git
2 years ago[VPlan] Verify that header only contains header phi recipes.
Florian Hahn [Sat, 27 Aug 2022 21:06:11 +0000 (22:06 +0100)]
[VPlan] Verify that header only contains header phi recipes.

Add verification that VPHeaderPHIRecipes are only in header VPBBs. Also
adds missing checks for VPPointerInductionRecipe to
VPHeaderPHIRecipe::classof.

Split off from D119661.

Reviewed By: Ayal

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

2 years ago[compiler-rt][builtins] Pass -Werror to check_cxx_compiler_flag
Akira Hatanaka [Sat, 27 Aug 2022 20:39:28 +0000 (13:39 -0700)]
[compiler-rt][builtins] Pass -Werror to check_cxx_compiler_flag

This is needed to avoid passing flags that are supported by the compiler
but cause warnings to be emitted.

2 years ago[libc++] Mark everything in <deque> as _LIBCPP_HIDE_FROM_ABI and replace _LIBCPP_INLI...
Nikolas Klauser [Sun, 21 Aug 2022 00:03:35 +0000 (02:03 +0200)]
[libc++] Mark everything in <deque> as _LIBCPP_HIDE_FROM_ABI and replace _LIBCPP_INLINE_VISIBILITY

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[clang-tidy] Add missing header from 6bd98b4f2d
Nathan James [Sat, 27 Aug 2022 18:59:16 +0000 (19:59 +0100)]
[clang-tidy] Add missing header from 6bd98b4f2d

2 years ago[clang-tidy] Fix a false positive in bugprone-assignment-in-if-condition
Nathan James [Sat, 27 Aug 2022 18:55:08 +0000 (19:55 +0100)]
[clang-tidy] Fix a false positive in bugprone-assignment-in-if-condition

Fixed a false positive where a lambda expression in the condition which contained an assignement would trigger a warning.
Fixes #56729

Reviewed By: gribozavr2

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

2 years ago[LazyCallGraph] Update libcall list when replacing a libcall node's function
Arthur Eubanks [Fri, 26 Aug 2022 22:06:51 +0000 (15:06 -0700)]
[LazyCallGraph] Update libcall list when replacing a libcall node's function

Otherwise when we visit all libcalls in
updateCGAndAnalysisManagerForPass(), the old libcall is dead and doesn't
have a node.

We treat libcalls conservatively in LazyCallGraph because any function
may introduce calls to them out of thin air.

It is weird to change the signature of a libcall since introducing calls
to the libcall with a different signature may break, but other passes
like deadargelim already do it, so let's preserve this behavior for now.

Fixes an issue found in D128830.

Reviewed By: psamolysov

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

2 years ago[GlobalISel] Use std::lcm (NFC)
Kazu Hirata [Sat, 27 Aug 2022 16:53:16 +0000 (09:53 -0700)]
[GlobalISel] Use std::lcm (NFC)

This patch replaces getLCMSize with std::lcm, a C++17 feature.

Note that all the arguments are of unsigned with no implicit type
conversion as they are passed to getLCMSize.

2 years ago[mlir] Use std::lcm (NFC)
Kazu Hirata [Sat, 27 Aug 2022 16:53:14 +0000 (09:53 -0700)]
[mlir] Use std::lcm (NFC)

This patch replaces mlir::lcm with std::lcm, a C++17 feature.

Note that all the arguments to mlir::lcm are of int64_t with no
implicit type conversion as they are passed to mlir::lcm, which I've
verified by modifying mlir::lcm as:

  template <typename TA, typename TB>
  inline int64_t lcm(TA a, TB b) {
    static_assert(std::is_same_v<TA, int64_t>);
    static_assert(std::is_same_v<TB, int64_t>);
    :

2 years agoUse std::clamp (NFC)
Kazu Hirata [Sat, 27 Aug 2022 16:53:13 +0000 (09:53 -0700)]
Use std::clamp (NFC)

This patch replaces clamp idioms with std::clamp where the range is
obviously valid from the source code (that is, low <= high) to avoid
introducing undefined behavior.

2 years agoUse llvm::is_contained (NFC)
Kazu Hirata [Sat, 27 Aug 2022 16:53:11 +0000 (09:53 -0700)]
Use llvm::is_contained (NFC)

2 years agoUse llvm::all_equal (NFC)
Kazu Hirata [Sat, 27 Aug 2022 16:53:09 +0000 (09:53 -0700)]
Use llvm::all_equal (NFC)

2 years ago[flang] Don't emit faulty warnings for illegal COMMON blocks
Emil Kieri [Sat, 27 Aug 2022 06:37:19 +0000 (08:37 +0200)]
[flang] Don't emit faulty warnings for illegal COMMON blocks

SAVE statements referencing COMMON block names are not allowed in BLOCK
constructs. If they occur, an error is correctly emitted, but then flang
gets confused by the illegal SAVE and produces a faulty warning. This
patch removes that warning.

Consider this piece of Fortran (from the test blockconstruct02.f90):

program  main
  real r, s, t
  common /argmnt2/ r, s, t
  block
    save /argmnt2/
  end block
end program

Here flang (in addition to the error about the illegal SAVE) emits a
portability warning saying that the two definitions of argmnt2 have
different size, which does not make much sense.

This patch is a prerequisite for D125804, which in turn will make
blockconstruct02.f90 test this patch.

Reviewed By: jeanPerier

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

2 years ago[InstCombine] allow poison (undef) element in vector signbit transforms
Sanjay Patel [Sat, 27 Aug 2022 14:15:30 +0000 (10:15 -0400)]
[InstCombine] allow poison (undef) element in vector signbit transforms

If the shift constant has undefined lanes, we can assume those
are the same as the defined lanes in these transforms:
https://alive2.llvm.org/ce/z/t6TTJ2

Replace undef with poison in the test while here to support
the transition away from undef.

2 years ago[InstCombine] add tests for signbit splat mask; NFC
Sanjay Patel [Sat, 27 Aug 2022 13:30:26 +0000 (09:30 -0400)]
[InstCombine] add tests for signbit splat mask; NFC

issue #57381

2 years agoAvoid else-if after return, NFC
Jun Zhang [Sat, 27 Aug 2022 15:14:48 +0000 (23:14 +0800)]
Avoid else-if after return, NFC

Signed-off-by: Jun Zhang <jun@junz.org>
2 years ago[CodeGen] Track DeferredDecls that have been emitted
Jun Zhang [Sat, 27 Aug 2022 14:32:47 +0000 (22:32 +0800)]
[CodeGen] Track DeferredDecls that have been emitted

If we run into a first usage or definition of a mangled name, and
there's a DeferredDecl that associated with it, we should remember it we
need to emit it later on.

Without this patch, clang-repl hits a JIT symbol not found error:
clang-repl> extern "C" int printf(const char *, ...);
clang-repl> auto l1 = []() { printf("ONE\n"); return 42; };
clang-repl> auto l2 = []() { printf("TWO\n"); return 17; };
clang-repl> auto r1 = l1();
ONE
clang-repl> auto r2 = l2();
TWO
clang-repl> auto r3 = l2();
JIT session error: Symbols not found: [ l2 ]
error: Failed to materialize symbols: { (main,
{ r3, orc_init_func.incr_module_5, $.incr_module_5.inits.0 }) }

Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D130831

2 years agoUse std::uninitialized_move where appropriate. NFCI.
Benjamin Kramer [Sat, 27 Aug 2022 12:47:19 +0000 (14:47 +0200)]
Use std::uninitialized_move where appropriate. NFCI.

2 years ago[InstCombine] fold signbit splat pattern that uses negate
Sanjay Patel [Sat, 27 Aug 2022 11:59:48 +0000 (07:59 -0400)]
[InstCombine] fold signbit splat pattern that uses negate

0 - (zext (i8 X u>> 7) to iN) --> sext (i8 X s>> 7) to iN

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

This is part of solving issue #57381.

2 years ago[InstCombine] add tests for signbit-smear; NFC
Sanjay Patel [Fri, 26 Aug 2022 20:03:10 +0000 (16:03 -0400)]
[InstCombine] add tests for signbit-smear; NFC

issue #57381

2 years ago[libc++][CI] Increases the Clang version used.
Mark de Wever [Thu, 4 Aug 2022 15:29:25 +0000 (17:29 +0200)]
[libc++][CI] Increases the Clang version used.

Changes the CI to use the Clang 16 nightly builds instead of Clang 14.
(The libc++15 branch was accidentally build using Clang 14 instead of
Clang 15; hence the skipping of a number.)

Also adds a Clang 15 build to the test matrix.

Based on the private discussion with @ldionne we decided to move
the configuration parameters from the `run-buildbot` script to the
CI configuration `buildkite-pipeline.yml`. Other hard-coded values
from the Dockerfile should be move to the CI configuration too. That
will be done in another commit.

C++17 will use Clang-15 since D131479 causes a test to fail.

Reviewed By: ldionne, #libc

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

2 years ago[clang-tidy] Move bugprone-assignment-in-if-condition check to correct folder
Nathan James [Sat, 27 Aug 2022 10:24:57 +0000 (11:24 +0100)]
[clang-tidy] Move bugprone-assignment-in-if-condition check to correct folder

2 years ago[MachO] Fix dead-stripping __eh_frame
Shoaib Meenai [Mon, 22 Aug 2022 19:55:41 +0000 (22:55 +0300)]
[MachO] Fix dead-stripping __eh_frame

This section is marked S_ATTR_LIVE_SUPPORT in input files, which meant
that on arm64, we were unnecessarily preserving FDEs if we e.g. had
multiple weak definitions for a function. Worse, we would actually
produce an invalid `__eh_frame` section in that case, because the CIE
associated with the unnecessary FDE would still get dead-stripped and
we'd end up with a dangling FDE. We set up associations from functions
to their FDEs, so dead-stripping will just work naturally, and we can
clear S_ATTR_LIVE_SUPPORT from our input `__eh_frame` sections to fix
dead-stripping.

Reviewed By: #lld-macho, int3

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

2 years ago[tblgen] Use std::variant to simplify code. NFCI.
Benjamin Kramer [Sat, 27 Aug 2022 08:50:28 +0000 (10:50 +0200)]
[tblgen] Use std::variant to simplify code. NFCI.

2 years ago[libTooling] Simplify code with constexpr if. NFCI.
Benjamin Kramer [Sat, 27 Aug 2022 08:50:06 +0000 (10:50 +0200)]
[libTooling] Simplify code with constexpr if. NFCI.

2 years ago[libc++] Simplify type_traits a bit more
Nikolas Klauser [Sat, 27 Aug 2022 06:47:31 +0000 (08:47 +0200)]
[libc++] Simplify type_traits a bit more

Reviewed By: ldionne, #libc

Spies: STL_MSFT, CaseyCarter, huixie90, libcxx-commits

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

2 years ago[AMDGPU] Detect uniformness of TID / wavefrontsize
Stanislav Mekhanoshin [Tue, 23 Aug 2022 19:28:54 +0000 (12:28 -0700)]
[AMDGPU] Detect uniformness of TID / wavefrontsize

A value of 'workitemid / wavefrontize' or 'workitemid & (wavefrontize - 1)'
is wave uniform.

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

2 years ago[asan][test] Fix typo in Unit/lit.site.cfg.py.in
Rainer Orth [Sat, 27 Aug 2022 05:50:18 +0000 (07:50 +0200)]
[asan][test] Fix typo in Unit/lit.site.cfg.py.in

I noticed that `test/asan/Unit/lit.site.cfg.py.in` contains two typos,
using the FreeBSD forms of the `LD_*LIBRARY_PATH*` variables on Solaris.

Tested on `amd64-pc-solaris2.11`.

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

2 years ago[Orc] Use MapperJITLinkMemoryManager with InProcessMapper in llvm-jitlink tool
Anubhab Ghosh [Sat, 20 Aug 2022 20:32:51 +0000 (02:02 +0530)]
[Orc] Use MapperJITLinkMemoryManager with InProcessMapper in llvm-jitlink tool

MapperJITLinkMemoryManager has slab allocation. Combined with
InProcessMapper, it can replace InProcessMemoryManager.

It can also replace JITLinkSlabAllocator through the InProcessDeltaMapper
that adds an offset to the executor addresses for use in tests.

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

2 years ago[mlgo] Fix flaky test
Mircea Trofin [Sat, 27 Aug 2022 04:29:25 +0000 (21:29 -0700)]
[mlgo] Fix flaky test

The source of the flakyness is internal uninitialized buffers due to
a dangling variable in the model.

2 years ago[lldb][docs] Fix formatting in fuzzing doc
Chelsea Cassanova [Sat, 27 Aug 2022 01:06:44 +0000 (20:06 -0500)]
[lldb][docs] Fix formatting in fuzzing doc

The page for fuzzing LLDB had incorrectly formatted code,
this commit fixes that.

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

2 years ago[Orc] Take offset inside slab into account in SharedMemoryMapper
Anubhab Ghosh [Fri, 26 Aug 2022 13:28:21 +0000 (18:58 +0530)]
[Orc] Take offset inside slab into account in SharedMemoryMapper

SharedMemoryMapper assumed each reservation will have its corresponding
allocations starting from the beginning. However with the introduction
of the slab allocator, there can be a possible offset from the start
from where the initialization is being performed.

This commit also simplifies the logic for finding the parent reservation
and makes the assert messages consistent.

2 years ago[BOLT][UTILS] Stash including untracked in nfc-check-setup
Amir Ayupov [Sat, 27 Aug 2022 02:12:17 +0000 (19:12 -0700)]
[BOLT][UTILS] Stash including untracked in nfc-check-setup

The command to detect whether the stash is needed is `git status --porcelain`
which includes untracked files by default. We want to stash untracked files
as well as they may affect compilation (LLVM CMake checks that all source files
should be included in CMakeLists).

Update the stash command to include untracked files as well.

Reviewed By: #bolt, rafauler

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

2 years ago[Clang][Driver] Temporarily disable failing DriverKit test
Julian Lettner [Sat, 27 Aug 2022 01:26:32 +0000 (18:26 -0700)]
[Clang][Driver] Temporarily disable failing DriverKit test

2 years ago[ORC-RT] Remove __orc_rt::apply_tuple.
Lang Hames [Sat, 27 Aug 2022 00:06:56 +0000 (17:06 -0700)]
[ORC-RT] Remove __orc_rt::apply_tuple.

This utility was a substitute for std::apply, which is now available.

2 years ago[RISCV] Pre-commit tests for D132771. NFC
Craig Topper [Fri, 26 Aug 2022 19:50:06 +0000 (12:50 -0700)]
[RISCV] Pre-commit tests for D132771. NFC

2 years ago[lldb][docs] Add documentation for LLDB fuzzers
Chelsea Cassanova [Fri, 26 Aug 2022 23:27:35 +0000 (18:27 -0500)]
[lldb][docs] Add documentation for LLDB fuzzers

This commit adds a new page to the LLDB HTML documentation for the LLDB
fuzzers. The page primarily explains what the fuzzers are as well as how
to build them, run them and investigate and reproduce bugs.

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

2 years ago[msan] Enable msan-check-constant-shadow by default
Vitaly Buka [Fri, 26 Aug 2022 21:52:39 +0000 (14:52 -0700)]
[msan] Enable msan-check-constant-shadow by default

Depends on D132761.

Reviewed By: eugenis

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

2 years ago[TSan] Fix pointer/type-mismatch bug in test that has turned into a compile error
Julian Lettner [Fri, 26 Aug 2022 23:29:30 +0000 (16:29 -0700)]
[TSan] Fix pointer/type-mismatch bug in test that has turned into a compile error

Fixes this test compile error:
```
<path>/compiler-rt/test/tsan/debug_alloc_stack.cpp:54:7: error: no matching function for call to '__tsan_get_alloc_stack'
      __tsan_get_alloc_stack(mem, trace, num_frames, &thread_id, &thread_os_id);
      ^~~~~~~~~~~~~~~~~~~~~~
<path>/compiler-rt/test/tsan/debug_alloc_stack.cpp:17:16: note: candidate function not viable: no known conversion from 'uint64_t **' (aka 'unsigned long long **') to 'uint64_t *' (aka 'unsigned long long *') for 5th argument; remove &
extern "C" int __tsan_get_alloc_stack(void *addr, void **trace, size_t size,
               ^
<path>/compiler-rt/test/tsan/debug_alloc_stack.cpp:61:46: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t *' (aka 'unsigned long long *') [-Wformat]
  fprintf(stderr, "thread os id = 0x%llx\n", thread_os_id);
                                    ~~~~     ^~~~~~~~~~~~
1 warning and 1 error generated.
```

2 years ago[Clang][Driver] Refine/refactor DriverKit support
Julian Lettner [Fri, 26 Aug 2022 22:25:37 +0000 (15:25 -0700)]
[Clang][Driver] Refine/refactor DriverKit support

Add special Framework header search path for DriverKit.

2 years ago[ORC-RT] Add "wrap" and "unwrap" steps to __orc_rt::ExecutorAddr toPtr/fromPtr.
Lang Hames [Fri, 26 Aug 2022 22:36:37 +0000 (15:36 -0700)]
[ORC-RT] Add "wrap" and "unwrap" steps to __orc_rt::ExecutorAddr toPtr/fromPtr.

The wrap/unwrap operations are applied to pointers after/before conversion to/from
raw addresses. They can be used to tag, untag, sign, or strip signing from
pointers. They currently default to 'rawPtr' (identity) on all platforms, but it
is expected that the default will be set based on the host architecture, e.g.
they would default to signing/stripping for arm64e.

This is the ORC runtime counterpart to f14cb494a34:

2 years ago[ORC-RT] Add a std::identity substitute.
Lang Hames [Fri, 26 Aug 2022 22:32:17 +0000 (15:32 -0700)]
[ORC-RT] Add a std::identity substitute.

The __orc_rt::identity utility is intended to serve as a substitute for
c++20's std::identity until we can use the latter (when LLVM moves to c++20).

2 years ago[msan] Fix handling of constant shadow
Vitaly Buka [Fri, 26 Aug 2022 20:51:18 +0000 (13:51 -0700)]
[msan] Fix handling of constant shadow

If constant shadown enabled we had false reports because
!isZeroValue() does not guaranty that the values is actually not zero.

Reviewed By: eugenis

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

2 years agoRevert "[clang][dataflow] Extend transfer functions for other `CFGElement`s"
Wei Yi Tee [Fri, 26 Aug 2022 22:40:47 +0000 (22:40 +0000)]
Revert "[clang][dataflow] Extend transfer functions for other `CFGElement`s"

This reverts commit 4b815eb4fde0202434c6395973578349767b3f15.

2 years ago[clang] Better warning-fix follow-up to D131632
Nico Weber [Fri, 26 Aug 2022 22:29:18 +0000 (18:29 -0400)]
[clang] Better warning-fix follow-up to D131632

Not all host compilers understand gnu:: attributes. Just remove the
variable until it's used.

2 years ago[clang][dataflow] Extend transfer functions for other `CFGElement`s
Wei Yi Tee [Fri, 26 Aug 2022 22:00:45 +0000 (22:00 +0000)]
[clang][dataflow] Extend transfer functions for other `CFGElement`s

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

2 years ago[clang] Add __is_target_variant_{os,environment} builtins
Nico Weber [Fri, 26 Aug 2022 18:40:59 +0000 (14:40 -0400)]
[clang] Add __is_target_variant_{os,environment} builtins

Xcode 13's clang has them. For the included testcase, Xcode's clang
behaves like the implementation in this patch.

Availability.h in the macOS 12.0 SDK (part of Xcode 13, and the current
stable version of the macOS SDK) does something like:

   #if defined(__has_builtin)
     ...
     #if __has_builtin(__is_target_os)
      #if __has_builtin(__is_target_environment)
       #if __has_builtin(__is_target_variant_os)
        #if __has_builtin(__is_target_variant_environment)
         #if (... && ((__is_target_os(ios) && __is_target_environment(macabi)) || (__is_target_variant_os(ios) && __is_target_variant_environment(macabi))))
           #define __OSX_AVAILABLE_STARTING(_osx, _ios) ...
           #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) ...
           #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) ...

So if __has_builtin(__is_target_variant_os) or
__has_builtin(__is_target_variant_environment) are false, these defines are not
defined.

Most of the time, this doesn't matter. But open-source clang currently fails
to commpile a file containing only `#include <Security/cssmtype.h>` when
building for catalyst by adding a `-target arm64-apple-ios13.1-macabi` triple,
due to those __OSX_AVAILABLE macros not being set correctly.

If a potential future SDK version were to include cssmtype.h transitively
from a common header such as `<Foundation/Foundation.h>`, then it would become
close to impossible to build Catalyst binaries with open-source clang.

To fix this for normal catalyst builds, it's only necessary that
__has_builtin() evaluates to true for these two built-ins -- the implementation
of them doesn't matter. But as a courtesy, a correct (at least on the test
cases I tried) implementation is provided. (This should also help people who
try to build zippered code, where having the correct implementation does
matter.)

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

2 years ago[NFC][msan] Clang-format the file
Vitaly Buka [Fri, 26 Aug 2022 22:09:01 +0000 (15:09 -0700)]
[NFC][msan] Clang-format the file

2 years ago[test] Add msan-check-constant-shadow=0 tests
Vitaly Buka [Fri, 26 Aug 2022 22:03:58 +0000 (15:03 -0700)]
[test] Add msan-check-constant-shadow=0 tests

2 years agoReapply "[ORC] Add "wrap" and "unwrap" steps to ExecutorAddr..." with fixes.
Lang Hames [Fri, 26 Aug 2022 20:56:25 +0000 (13:56 -0700)]
Reapply "[ORC] Add "wrap" and "unwrap" steps to ExecutorAddr..." with fixes.

Reapplies f14cb494a34 (which was reverted in 2f08f8426c5) with a fix for UB in
the ExecutorAddr::Unwrap::Unwrap constructor (which caused failures on some
bots).

2 years ago[RISCV] Enable fixed length vectors and loop vectorization with same
Philip Reames [Fri, 26 Aug 2022 21:36:18 +0000 (14:36 -0700)]
[RISCV] Enable fixed length vectors and loop vectorization with same

This change enables the use of RISCV's variable length vector registers for fixed length vectors in the IR, and implicitly enables various IR transforms which generate fixed length vectors if legal (e.g. LoopVectorize). Specifically, this enables fixed length vectors which are known to be inbounds of the underlying variable hardware size.

For context, remember that the +V extension provides a minimum VLEN of 128. The embedded variants provide lower minimums. The analogy here is essentially vectorizing for SSE on a machine which may or may not include AVX2/AVX512. We won't get full utilization by default, but we will get some benefit. And of course, with an explicit mcpu we can vectorize to the exact target hardware.

The LV impact is mostly related to vectorizer robustness. In cases we haven't yet fully implemented scalable vectorization support, we can fall back to fixed length vectorization.

SLP has been disabled for now, even when fixed vectors are enabled.  See a310637 and associated review.  There are a few addiitional code quality issues which need worked through before turning SLP on would be reasonable.

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

2 years ago[Tests][TSan] Remove bash-ism `|&`, which is unsupported on other shells
Julian Lettner [Fri, 26 Aug 2022 21:34:36 +0000 (14:34 -0700)]
[Tests][TSan] Remove bash-ism `|&`, which is unsupported on other shells

2 years ago[InstCombine] Canonicalize "and, add", "or, add", "xor, add"
Eric Gullufsen [Fri, 26 Aug 2022 19:37:38 +0000 (15:37 -0400)]
[InstCombine] Canonicalize "and, add", "or, add", "xor, add"

Canonicalize
```
((x + C1) & C2) --> ((x & C2) + C1)
((x + C1) ^ C2) --> ((x ^ C2) + C1)
((x + C1) | C2) --> ((x | C2) + C1)
```
for suitable constants `C1` and `C2`.

Alive2 proofs: [[ https://alive2.llvm.org/ce/z/BqMDVZ | add, or --> or, add ]]
[[ https://alive2.llvm.org/ce/z/BhAeCl | add, xor --> xor, add ]]
[[ https://alive2.llvm.org/ce/z/jYRHEt | add, and --> and, add ]]

Reviewed By: spatel

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

2 years ago[RISCV] Disable SLP vectorization by default due to unresolved profitability issues
Philip Reames [Fri, 26 Aug 2022 21:06:40 +0000 (14:06 -0700)]
[RISCV] Disable SLP vectorization by default due to unresolved profitability issues

This change implements a TTI query with the goal of disabling slp vectorization on RISCV. The current default configuration disables SLP already, but its current tied to the ability to lower fixed length vectors. Over in D131508, I want to enable fixed length vectors for purposes of LoopVectorizer, but preliminary analysis has revealed a couple of SLP specific issues we need to resolve before enabling it by default. This change exists to allow us to enable LV without SLP.

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

2 years ago[clang][NFC] silences warnings
Abraham Corea Diaz [Fri, 26 Aug 2022 21:06:46 +0000 (21:06 +0000)]
[clang][NFC] silences warnings

* removes unused data member `OS` from `SARIFDiagnostic`
* flags `Filename` variable as currently unused

This is a follow-up to D131632.

2 years agoRevert "[ORC] Add "wrap" and "unwrap" steps to ExecutorAddr toPtr/fromPtr."
Lang Hames [Fri, 26 Aug 2022 20:54:30 +0000 (13:54 -0700)]
Revert "[ORC] Add "wrap" and "unwrap" steps to ExecutorAddr toPtr/fromPtr."

This reverts commit f14cb494a34db6df9853d713c6027a476f030dbf.

Reverting while I investigate bot failures, e.g.
https://lab.llvm.org/buildbot#builders/117/builds/8701

2 years ago[test][msan] Simplify test with implicit-check-not
Vitaly Buka [Fri, 26 Aug 2022 20:49:03 +0000 (13:49 -0700)]
[test][msan] Simplify test with implicit-check-not

2 years ago[mlir] Add bytecode encoding for the remaining builtin types
River Riddle [Wed, 24 Aug 2022 20:11:34 +0000 (13:11 -0700)]
[mlir] Add bytecode encoding for the remaining builtin types

After this commit we will have an efficient bytecode representation for all
of the builtin types.

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

2 years ago[mlir][NFC] Cleanup builtin dialect bytecode encoding
River Riddle [Wed, 24 Aug 2022 18:29:02 +0000 (11:29 -0700)]
[mlir][NFC] Cleanup builtin dialect bytecode encoding

Group the readers and writers for individual attributes/types together,
which makes the encoding more readable.

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

2 years ago[mlir:Bytecode] Add encoding support for builtin location attributes
River Riddle [Wed, 24 Aug 2022 07:16:38 +0000 (00:16 -0700)]
[mlir:Bytecode] Add encoding support for builtin location attributes

This provides a significantly more efficient encoding for locations.

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

2 years ago[mlir:Bytecode] Add encoding support for a majority of the builtin attributes
River Riddle [Wed, 24 Aug 2022 06:39:18 +0000 (23:39 -0700)]
[mlir:Bytecode] Add encoding support for a majority of the builtin attributes

This adds support for the non-location, non-elements, non-affine
builtin attributes.

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

2 years ago[CUDA] Fix arguments after removing unused private variable
Joseph Huber [Fri, 26 Aug 2022 20:26:32 +0000 (15:26 -0500)]
[CUDA] Fix arguments after removing unused private variable

Summary:
A previous patch removed the use of the `OK` private variable in CUDA
which resulted in usused variable warnings. this was fixed in
f886f7e8ef7aa4f54298db792a656373af90440c but did not change the
constructor to accurately represent its removal. This patch removes it
from the interface entirely.

2 years ago[llvm][ir][NFC] Clean up "if after return" in ProfDataUtils.cpp
Paul Kirth [Fri, 26 Aug 2022 20:25:07 +0000 (20:25 +0000)]
[llvm][ir][NFC] Clean up "if after return" in ProfDataUtils.cpp

Reviewed By: tejohnson

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

2 years ago[llvm][misexpect] Re-enable MisExpect for SampleProfiling
Paul Kirth [Fri, 26 Aug 2022 18:14:39 +0000 (18:14 +0000)]
[llvm][misexpect] Re-enable MisExpect for SampleProfiling

MisExpect was occasionally crashing under SampleProfiling, due to a division by zero.
We worked around that in D124302 by changing the assert to an early return.
This patch is intended to add a test case for the crashing scenario and
re-enable MisExpect for SampleProfiling.

Reviewed By: tejohnson

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

2 years ago[mlir][sparse] move sparse2sparse conversion to own test file
Aart Bik [Fri, 26 Aug 2022 19:31:22 +0000 (12:31 -0700)]
[mlir][sparse] move sparse2sparse conversion to own test file

Rationale:
We were running *all* conversion tests two times, just to check the
difference of one indidivual test in that file. By splitting that test
out, we have a much more focused testing setup.

Reviewed By: bixia

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

2 years ago[libc++] Remove __deque_base
Nikolas Klauser [Fri, 26 Aug 2022 15:51:35 +0000 (17:51 +0200)]
[libc++] Remove __deque_base

This patch simplifies the implementation of `deque` by removing the `__deque_base` class which results in a lot less indirections and removes the need for `__base::`.

Reviewed By: ldionne, #libc

Spies: AdvenamTacet, libcxx-commits

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

2 years ago[libc++][NFC] Remove some of the code duplication in the string tests
Nikolas Klauser [Fri, 26 Aug 2022 15:48:11 +0000 (17:48 +0200)]
[libc++][NFC] Remove some of the code duplication in the string tests

Reviewed By: ldionne, #libc, huixie90

Spies: huixie90, libcxx-commits, arphaman

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

2 years ago[clang-tidy] Adding the missing handling of "noreturn" attributes for Obj-C nodes...
ziqingluo-90 [Fri, 26 Aug 2022 19:35:25 +0000 (12:35 -0700)]
[clang-tidy] Adding the missing handling of "noreturn" attributes for Obj-C nodes in `InfiniteLoopChecker`

With this commit, the `InfiniteLoopChecker` now recognizes message
expressions to "noreturn" methods as well as calls to "noreturn"
blocks.

Reviewed by NoQ, njames93
Differential Revision: https://reviews.llvm.org/D128314

2 years agoRemove unused private variable.
Sterling Augustine [Fri, 26 Aug 2022 19:43:05 +0000 (12:43 -0700)]
Remove unused private variable.

2 years agoEliminate unused-variable warning.
Sterling Augustine [Fri, 26 Aug 2022 19:39:29 +0000 (12:39 -0700)]
Eliminate unused-variable warning.

2 years ago[LAA] Require AddRecs to be in the innermost loop for diff-checks.
Florian Hahn [Fri, 26 Aug 2022 19:39:52 +0000 (20:39 +0100)]
[LAA] Require AddRecs to be in the innermost loop for diff-checks.

The simpler diff-checks require pointers with add-recs from the same
innermost loop, but this property wasn't check completely. Add the
missing check to ensure both addrecs are in the innermost loop.

Fixes #57315.

2 years ago[ORC] Add "wrap" and "unwrap" steps to ExecutorAddr toPtr/fromPtr.
Lang Hames [Fri, 26 Aug 2022 16:46:02 +0000 (09:46 -0700)]
[ORC] Add "wrap" and "unwrap" steps to ExecutorAddr toPtr/fromPtr.

The wrap/unwrap operations are applied to pointers after/before conversion to/from
raw addresses. They can be used to tag, untag, sign, or strip signing from
pointers. They currently default to 'rawPtr' (identity) on all platforms, but it
is expected that the default will be set based on the host architecture, e.g.
they would default to signing/stripping for arm64e.

2 years ago[flang][runtime] Corrections for byte-swapped I/O
Peter Klausler [Fri, 26 Aug 2022 17:17:59 +0000 (10:17 -0700)]
[flang][runtime] Corrections for byte-swapped I/O

Unformatted I/O with byte swapping was reversing bytes in badly-sized
frames for character, complex, and some default derived type transfers.

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

2 years ago[libc] Implement POSIX truncate and ftruncate functions for Linux.
Siva Chandra Reddy [Thu, 25 Aug 2022 20:04:50 +0000 (20:04 +0000)]
[libc] Implement POSIX truncate and ftruncate functions for Linux.

Reviewed By: michaelrj

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

2 years ago[gn build] Port 82e893c47c77
LLVM GN Syncbot [Fri, 26 Aug 2022 19:20:51 +0000 (19:20 +0000)]
[gn build] Port 82e893c47c77

2 years ago[analyzer] Fixing a bug raising false positives of stack block object
ziqingluo-90 [Fri, 26 Aug 2022 19:16:20 +0000 (12:16 -0700)]
[analyzer] Fixing a bug raising false positives of stack block object
leaking in ARC mode

When ARC (automatic reference count) is enabled, (objective-c) block
objects are automatically retained and released thus they do not leak.
Without ARC, they still can leak from an expiring stack frame like
other stack variables.
With this commit, the static analyzer now puts a block object in an
"unknown" region if ARC is enabled because it is up to the
implementation to choose whether to put the object on stack initially
(then move to heap when needed) or in heap directly under ARC.
Therefore, the `StackAddrEscapeChecker` has no need to know
specifically about ARC at all and it will not report errors on objects
in "unknown" regions.

Reviewed By: NoQ (Artem Dergachev)

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

2 years ago[libc] Add Linux implementation of GNU extension function sendfile.
Siva Chandra Reddy [Thu, 25 Aug 2022 22:30:30 +0000 (22:30 +0000)]
[libc] Add Linux implementation of GNU extension function sendfile.

Reviewed By: michaelrj

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

2 years ago[gn build] port 47166968db5c (no more clang-offload-wrapper)
Nico Weber [Fri, 26 Aug 2022 19:11:45 +0000 (15:11 -0400)]
[gn build] port 47166968db5c (no more clang-offload-wrapper)

2 years ago[bazel] Drop clang-offload-wrapper. It was deleted in 47166968db5c5c677bda996e0c5e40e...
Benjamin Kramer [Fri, 26 Aug 2022 18:59:16 +0000 (20:59 +0200)]
[bazel] Drop clang-offload-wrapper. It was deleted in 47166968db5c5c677bda996e0c5e40e94d8ef09f

2 years ago[AMDGPU][MC][GFX11][NFC] Add missing asm tests for VOPCX and VOPCX.DPP instructions
Dmitry Preobrazhensky [Fri, 26 Aug 2022 19:01:30 +0000 (22:01 +0300)]
[AMDGPU][MC][GFX11][NFC] Add missing asm tests for VOPCX and VOPCX.DPP instructions

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

2 years ago[AMDGPU][MC][GFX11][NFC] Add missing asm tests for VOP2 and VOP2.DPP instructions
Dmitry Preobrazhensky [Fri, 26 Aug 2022 18:55:38 +0000 (21:55 +0300)]
[AMDGPU][MC][GFX11][NFC] Add missing asm tests for VOP2 and VOP2.DPP instructions

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

2 years ago[AMDGPU][MC][GFX11][NFC] Add missing asm tests for VOP1 DPP instructions
Dmitry Preobrazhensky [Fri, 26 Aug 2022 18:49:47 +0000 (21:49 +0300)]
[AMDGPU][MC][GFX11][NFC] Add missing asm tests for VOP1 DPP instructions

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

2 years ago[clang] Enable output of SARIF diagnostics
Abraham Corea Diaz [Fri, 26 Aug 2022 18:31:38 +0000 (18:31 +0000)]
[clang] Enable output of SARIF diagnostics

Enables Clang to emit diagnostics in SARIF format when
`-fdiagnostics-format=sarif`. Adds a new DiagnosticConsumer named
SARIFDiagnosticPrinter and a new DiagnosticRenderer named SARIFDiagnostic
to constuct and emit a SARIF object containing the run's basic diagnostic info.

Reviewed By: cjdb, denik, aaron.ballman

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

2 years ago[OpenMP] Deprecate the old driver for OpenMP offloading
Joseph Huber [Wed, 24 Aug 2022 14:16:08 +0000 (09:16 -0500)]
[OpenMP] Deprecate the old driver for OpenMP offloading

Recently OpenMP has transitioned to using the "new" driver which
primarily merges the device and host linking phases into a single
wrapper that handles both at the same time. This replaced a few tools
that were only used for OpenMP offloading, such as the
`clang-offload-wrapper` and `clang-nvlink-wrapper`. The new driver
carries some marked benefits compared to the old driver that is now
being deprecated. Things like device-side LTO, static library
support, and more compatible tooling. As such, we should be able to
completely deprecate the old driver, at least for OpenMP. The old driver
support will still exist for CUDA and HIP, although both of these can
currently be compiled on Linux with `--offload-new-driver` to use the new
method.

Note that this does not deprecate the `clang-offload-bundler`, although
it is unused by OpenMP now, it is still used by the HIP toolchain both
as their device binary format and object format.

When I proposed deprecating this code I heard some vendors voice
concernes about needing to update their code in their fork. They should
be able to just revert this commit if it lands.

Reviewed By: jdoerfert, MaskRay, ye-luo

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

2 years ago[AMDGPU][MC][GFX11][NFC] Add missing asm tests for VOP1 instructions
Dmitry Preobrazhensky [Fri, 26 Aug 2022 18:44:31 +0000 (21:44 +0300)]
[AMDGPU][MC][GFX11][NFC] Add missing asm tests for VOP1 instructions

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

2 years ago[AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOPC and VOPC.DPP instructions
Dmitry Preobrazhensky [Fri, 26 Aug 2022 18:37:40 +0000 (21:37 +0300)]
[AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOPC and VOPC.DPP instructions

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

2 years ago[libc] add compile option for printf arg type array
Michael Jones [Wed, 15 Jun 2022 23:08:28 +0000 (16:08 -0700)]
[libc] add compile option for printf arg type array

This patch allows for adjusting the size of the array that printf uses
to track the types of arguments in index mode. This is useful for
optimizing the tradeoff between memory usage and performance.

Reviewed By: sivachandra

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

2 years ago[AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP2 and VOP2.DPP instructions
Dmitry Preobrazhensky [Fri, 26 Aug 2022 18:32:55 +0000 (21:32 +0300)]
[AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP2 and VOP2.DPP instructions

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

2 years ago[AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP1 and VOP1.DPP instructions
Dmitry Preobrazhensky [Fri, 26 Aug 2022 18:28:46 +0000 (21:28 +0300)]
[AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP1 and VOP1.DPP instructions

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

2 years ago[clang] Do not instrument the rtti_proxies under hwasan
Leonard Chan [Fri, 26 Aug 2022 18:22:17 +0000 (18:22 +0000)]
[clang] Do not instrument the rtti_proxies under hwasan

We run into a duplicate symbol error when instrumenting the rtti_proxies
generated as part of the relative vtables ABI with hwasan:

```
ld.lld: error: duplicate symbol: typeinfo for icu_71::UObject
(.rtti_proxy)
>>> defined at brkiter.cpp
>>>
arm64-hwasan-shared/obj/third_party/icu/source/common/libicuuc.brkiter.cpp.o:(typeinfo
for icu_71::UObject (.rtti_proxy))
>>> defined at locavailable.cpp
>>>
arm64-hwasan-shared/obj/third_party/icu/source/common/libicuuc.locavailable.cpp.o:(.data.rel.ro..L_ZTIN6icu_717UObjectE.rtti_proxy.hwasan+0xE00000000000000)
```

The issue here is that the hwasan alias carries over the visibility and
linkage of the original proxy, so we have duplicate external symbols
that participate in linking. Similar to D132425 we can just disable
hwasan for the proxies for now.

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

2 years ago[clang] Do not instrument relative vtables under hwasan
Leonard Chan [Fri, 26 Aug 2022 18:20:34 +0000 (18:20 +0000)]
[clang] Do not instrument relative vtables under hwasan

Full context in
https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=107017.

Instrumenting hwasan with globals results in a linker error under the
relative vtables abi:

```
ld.lld: error:
libunwind.cpp:(.rodata..L_ZTVN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_15Registers_arm64EEE.hwasan+0x8):
relocation R_AARCH64_PLT32 out of range: 6845471433603167792 is not in
[-21474836482147483647]; references
libunwind::AbstractUnwindCursor::~AbstractUnwindCursor()
>>> defined in
libunwind/src/CMakeFiles/unwind_shared.dir/libunwind.cpp.obj
```

This is because the tag is included in the vtable address when
calculating the offset between the vtable and virtual function. A
temporary solution until we can resolve this is to just disable hwasan
instrumentation on relative vtables specifically, which can be done in
the frontend.

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

2 years agoRevert "[InstCombine] Canonicalize "and, add", "or, add", "xor, add""
Philip Reames [Fri, 26 Aug 2022 18:13:53 +0000 (11:13 -0700)]
Revert "[InstCombine] Canonicalize "and, add", "or, add", "xor, add""

This reverts commit d2f110c693c88d1bb7caee4f72ebb14766f85239.  test/Transforms/InstCombine/freeze.ll fails on ninja check-llvm on x86_64.

2 years ago[LV] Consistently use vputils::isUniformAfterVectorization [mostly nfc]
Philip Reames [Fri, 26 Aug 2022 17:59:17 +0000 (10:59 -0700)]
[LV] Consistently use vputils::isUniformAfterVectorization [mostly nfc]

I'd extracted isUniform, and Florian moved isUniformAfterVectorization out of VPlan at basically the same time. Let's go ahead and merge them.

For the VPTransformState::get path, a VPValue without a def (which corresponds to an external IR value outside of VPLan) is explicitly handled above the uniform check.  On the scalarizeInstruction path, I'm less sure why the change isn't visible, but test cases which would seem likely to hit it were already being handled as uniform through some other mechanism.  It would be correct to consider values defined outside of vplan uniform here.

2 years ago[InstCombine] Canonicalize "and, add", "or, add", "xor, add"
Eric Gullufsen [Wed, 24 Aug 2022 15:58:47 +0000 (11:58 -0400)]
[InstCombine] Canonicalize "and, add", "or, add", "xor, add"

Canonicalize
```
((x + C1) & C2) --> ((x & C2) + C1)
((x + C1) ^ C2) --> ((x ^ C2) + C1)
((x + C1) | C2) --> ((x | C2) + C1)
```
for suitable constants `C1` and `C2`.

Alive2 proofs: [[ https://alive2.llvm.org/ce/z/BqMDVZ | add, or --> or, add ]]
[[ https://alive2.llvm.org/ce/z/BhAeCl | add, xor --> xor, add ]]
[[ https://alive2.llvm.org/ce/z/jYRHEt | add, and --> and, add ]]

Reviewed By: spatel

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

2 years ago[NFC][InstCombine] Add baseline tests for canonicalizing "and, add", "or, add", ...
Eric Gullufsen [Wed, 24 Aug 2022 14:44:04 +0000 (10:44 -0400)]
[NFC][InstCombine] Add baseline tests for canonicalizing "and, add", "or, add", "xor, add"

Baseline tests for canonicalizing "logic op, add"
```
((x + C1) & C2) --> ((x & C2) + C1)
((x + C1) ^ C2) --> ((x ^ C2) + C1)
((x + C1) | C2) --> ((x | C2) + C1)
```
for suitable constants `C1` and `C2`.

Reviewed By: spatel

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

2 years ago[InstCombine] fold test of equality to 0.0 with bitcast operand
Sanjay Patel [Fri, 26 Aug 2022 15:15:09 +0000 (11:15 -0400)]
[InstCombine] fold test of equality to 0.0 with bitcast operand

fcmp oeq/une (bitcast X), 0.0 --> (and X, SignMaskC) ==/!= 0
https://alive2.llvm.org/ce/z/ZKATGN

2 years ago[InstCombine] add tests for fcmp with bitcast operand; NFC
Sanjay Patel [Fri, 26 Aug 2022 14:20:37 +0000 (10:20 -0400)]
[InstCombine] add tests for fcmp with bitcast operand; NFC

2 years ago[CostModel][X86] Add CodeSize handling for and/or/xor ops
Simon Pilgrim [Fri, 26 Aug 2022 17:42:42 +0000 (18:42 +0100)]
[CostModel][X86] Add CodeSize handling for and/or/xor ops

Eventually this will be part of the cost table lookup

2 years ago[VPlan] Move isUniformAfterVectorization from VPlan to vputils (NFC).
Florian Hahn [Fri, 26 Aug 2022 17:26:32 +0000 (18:26 +0100)]
[VPlan] Move isUniformAfterVectorization from VPlan to vputils (NFC).

This allows re-using the utility without a VPlan object. The helper also
doesn't access any data from VPlan.

2 years ago[SLP][NFC]Add a test for vectorization of stores with float constants,
Alexey Bataev [Fri, 26 Aug 2022 17:21:35 +0000 (10:21 -0700)]
[SLP][NFC]Add a test for vectorization of stores with float constants,
NFC.

2 years ago[bazel] Port a235562c0a051d0786cdb7da8e2af93e56e849c3
Benjamin Kramer [Fri, 26 Aug 2022 17:17:05 +0000 (19:17 +0200)]
[bazel] Port a235562c0a051d0786cdb7da8e2af93e56e849c3