platform/upstream/llvm.git
2 years ago[sanitizer] Restore trivial posix_spawn init in test
Vitaly Buka [Tue, 2 Nov 2021 06:57:13 +0000 (23:57 -0700)]
[sanitizer] Restore trivial posix_spawn init in test

It's still needed on Darwin.

2 years agoCheck if an attribute is in the builtin dialect before going through all the possible...
Mehdi Amini [Tue, 2 Nov 2021 05:51:38 +0000 (05:51 +0000)]
Check if an attribute is in the builtin dialect before going through all the possible combinations (NFC)

This is just a "micro-optimization" noticed through code review.

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

2 years ago[CodeGen] Use make_early_inc_range (NFC)
Kazu Hirata [Tue, 2 Nov 2021 05:38:48 +0000 (22:38 -0700)]
[CodeGen] Use make_early_inc_range (NFC)

2 years agoRevert "[sanitizer] Fix compilation of the test"
Vitaly Buka [Tue, 2 Nov 2021 05:21:17 +0000 (22:21 -0700)]
Revert "[sanitizer] Fix compilation of the test"
Revert "[sanitizer] Fix PosixSpawnImpl which fails exitcode test"

This reverts commit 8cabd8f0d26c3cff03faec9b1cea974f08618d6d and part of 9213202abd275c26c51cc46e2a34c678051bd179.

It is not enough for Android.

2 years ago[lldb][NFC] avoid unnecessary roundtrips between different string types
Xu Jun [Tue, 2 Nov 2021 05:14:48 +0000 (22:14 -0700)]
[lldb][NFC] avoid unnecessary roundtrips between different string types

The amount of roundtrips between StringRefs, ConstStrings and std::strings is
getting a bit out of hand, this patch avoid the unnecessary roundtrips.

Reviewed By: wallace, aprantl

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

2 years agonormalize file path when searching the source map
Xu Jun [Tue, 2 Nov 2021 05:13:30 +0000 (22:13 -0700)]
normalize file path when searching the source map

The key stored in the source map is a normalized path string with host's
path style, so it is also necessary to normalize the file path during
searching the map

Reviewed By: wallace, aprantl

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

2 years ago[sanitizer] Fix compilation of the test
Vitaly Buka [Tue, 2 Nov 2021 04:50:21 +0000 (21:50 -0700)]
[sanitizer] Fix compilation of the test

2 years ago[IR] Replace *all* uses of a constant expression by corresponding instruction
hsmahesha [Tue, 2 Nov 2021 04:31:36 +0000 (10:01 +0530)]
[IR] Replace *all* uses of a constant expression by corresponding instruction

When a constant expression CE is being converted into a corresponding instruction I,
CE is supposed to be replaced by I. However, it is possible that CE is being used multiple
times within a parent instruction PI. Make sure that *all* the uses of CE within PI are
replaced by I.

Reviewed By: rampitec, arsenm

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

2 years ago[SamplePGO] Fix callsite sample lookup to use dwarf names when dwarf linkage name...
Hongtao Yu [Mon, 1 Nov 2021 19:24:00 +0000 (12:24 -0700)]
[SamplePGO] Fix callsite sample lookup to use dwarf names when dwarf linkage name isn't available.

When linkage name isn't available in dwarf (ususally the case of C code),  looking up callee samples should be based on the dwarf name instead of using an empty string.

Also fixing a test issue where using empty string to look up callee samples accidentally returns the correct samples because it is treated as indirect call.

Reviewed By: wenlei

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

2 years ago[sanitizer] Add test for 9213202abd275c26c51cc46e2a34c678051bd179
Vitaly Buka [Tue, 2 Nov 2021 04:13:51 +0000 (21:13 -0700)]
[sanitizer] Add test for 9213202abd275c26c51cc46e2a34c678051bd179

2 years ago[sanitizer] Fix PosixSpawnImpl which fails exitcode test
Vitaly Buka [Tue, 2 Nov 2021 04:02:13 +0000 (21:02 -0700)]
[sanitizer] Fix PosixSpawnImpl which fails exitcode test

2 years ago[Bazel] Get `//clang` building on Windows with clang-cl.
Chandler Carruth [Tue, 2 Nov 2021 02:52:38 +0000 (02:52 +0000)]
[Bazel] Get `//clang` building on Windows with clang-cl.

This required substantially more invasive changes.

We need to handle some of the LLVM `config.h` changes differently from
the old pattern. These aren't always safe on the commandline, and the
Windows ones specifically break Clang. Instead, use conditional defines
in the header itself. This more closely matches how CMake builds see the
definitions. I think this is also just cleaner and we should maybe move
more of the macros out of Bazel.

The config defines for Windows that I've kept in Bazel are the ones that
LLVM's CMake does at the commandline as well. I've also added numerous
ones that CMake uses and we didn't replicate in Bazel.

I also needed a different approach to get `libclang` working well. This,
IMO, improves things on all platforms. Now we build the plugin and
actually wrap it back up with `cc_import`. We have to use a collection
of manually tagged `cc_binary` rules to get the naming to work out the
right way, but this isn't too different from the prior approach. By
directly having a `cc_binary` rule for each platform spelling of
`libclang`, we can actually extract the interface library from it and
correctly depend on it with `cc_import`. I think the result now is much
closer to the intent and to the CMake build for libclang.

Sadly, some tests also needed disabling. This is actually narrower than
what CMake does. The issue isn't indicative of anything serious -- the
test just assumes Unix-style paths.

I also have cleaned up the Windows flags in `.bazelrc` to much more
closely match what CMake does.

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

2 years ago[RISCV][test] Precommit tests for D108129.
jacquesguan [Tue, 2 Nov 2021 02:29:47 +0000 (02:29 +0000)]
[RISCV][test] Precommit tests for D108129.

Reviewed By: frasercrmck, RKSimon

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

2 years agoRe-introduce `copts` hacks for lib/AST includes.
Chandler Carruth [Sun, 31 Oct 2021 03:19:20 +0000 (03:19 +0000)]
Re-introduce `copts` hacks for lib/AST includes.

Sadly, these are necessary AFAICT. There is a file `lib/AST/CXXABI.h`.
On case insensitive file systems like macOS this will collide with
`cxxabi.h` on the system if we use the `includes` trick to allow
file-relative `#include` of generated files.

I've tested this on both Linux and Windows to make sure it remains
reasonably portable.

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

2 years agoDebugInfo: workaround for context-sensitive use of non-type-template-parameter intege...
David Blaikie [Mon, 20 Sep 2021 03:58:47 +0000 (20:58 -0700)]
DebugInfo: workaround for context-sensitive use of non-type-template-parameter integer suffixes

There's a nuanced check about when to use suffixes on these integer
non-type-template-parameters, but when rebuilding names for
-gsimple-template-names there isn't enough data in the DWARF to
determine when to use suffixes or not. So turn on suffixes always to
make it easy to match up names in llvm-dwarfdump --verify.

I /think/ if we correctly modelled auto non-type-template parameters
maybe we could put suffixes only on those. But there's also some logic
in Clang that puts the suffixes on overloaded functions - at least
that's what the parameter says (see D77598 and printTemplateArguments
"TemplOverloaded" parameter) - but I think maybe it's for anything that
/can/ be overloaded, not necessarily only the things that are overloaded
(the argument value is hardcoded at the various callsites, doesn't seem
to depend on overload resolution/searching for overloaded functions). So
maybe with "auto" modeled more accurately, and differentiating between
function templates (always using type suffixes there) and class/variable
templates (only using the suffix for "auto" types) we could correctly
use integer type suffixes only in the minimal set of cases.

But that seems all too much fuss, so let's just put integer type
suffixes everywhere always in the debug info of integer non-type
template parameters in template names.

(more context:
* https://reviews.llvm.org/D77598#inline-1057607
* https://groups.google.com/g/llvm-dev/c/ekLMllbLIZg/m/-dhJ0hO1AAAJ )

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

2 years ago[sanitizer] Fix test include on Darwin
Vitaly Buka [Mon, 1 Nov 2021 23:49:12 +0000 (16:49 -0700)]
[sanitizer] Fix test include on Darwin

2 years ago[ORC] Run incoming jit-dispatch calls via the TaskDispatcher in SimpleRemoteEPC.
Lang Hames [Mon, 1 Nov 2021 17:48:52 +0000 (10:48 -0700)]
[ORC] Run incoming jit-dispatch calls via the TaskDispatcher in SimpleRemoteEPC.

Handlers for jit-dispatch calls are allowed to make their own EPC calls, so we
don't want to run these on the handler thread.

2 years ago[WebAssembly] support "return" and unreachable code in asm type checker
Wouter van Oortmerssen [Mon, 1 Nov 2021 20:09:47 +0000 (13:09 -0700)]
[WebAssembly] support "return" and unreachable code in asm type checker

To support return (it not being supported well was the ground cause for
https://github.com/WebAssembly/wasi-sdk/issues/200) we also have to have
at least a basic notion of unreachable, which in this case just means to stop
type checking until there is an end_block (an incoming control flow edge).
This is conservative (may miss on some type checking opportunities) but is
simple and an improvement over what we had before.

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

2 years ago[InstCombine] Precommit updated and-xor-or.ll tests. NFC.
Stanislav Mekhanoshin [Mon, 1 Nov 2021 22:20:41 +0000 (15:20 -0700)]
[InstCombine] Precommit updated and-xor-or.ll tests. NFC.

2 years ago[mlir] Fix flang build error due to gpu dialect enums
thomasraoux [Mon, 1 Nov 2021 22:13:35 +0000 (15:13 -0700)]
[mlir] Fix flang build error due to gpu dialect enums

2 years agoBPF: Workaround an InstCombine ICmp transformation with llvm.bpf.compare builtin
Yonghong Song [Sat, 30 Oct 2021 23:37:26 +0000 (16:37 -0700)]
BPF: Workaround an InstCombine ICmp transformation with llvm.bpf.compare builtin

Commit acabad9ff6bf ("[InstCombine] try to canonicalize icmp with
trunc op into mask and cmp") added a transformation to
convert "(conv)a < power_2_const" to "a & <const>" in certain
cases and bpf kernel verifier has to handle the resulted code
conservatively and this may reject otherwise legitimate program.

This commit tries to prevent such a transformation. A bpf backend
builtin llvm.bpf.compare is added. The ICMP insn, which is subject to
above InstCombine transformation, is converted to the builtin
function. The builtin function is later lowered to original ICMP insn,
certainly after InstCombine pass.

With this change, all affected bpf strobemeta* selftests are
passed now.

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

2 years ago[RISCV] Restore tests for vf(w)redusum.
Craig Topper [Mon, 1 Nov 2021 21:07:00 +0000 (14:07 -0700)]
[RISCV] Restore tests for vf(w)redusum.

When D105690 changed the mnemonic from vf(w)redsum to vf(w)redusum,
several tests were deleted instead of being renamed.

This commit also consistently renames the other tests that weren't
deleted.

2 years ago[lld] Add test suite mode for running LLD main twice
Shoaib Meenai [Sun, 31 Oct 2021 23:55:12 +0000 (16:55 -0700)]
[lld] Add test suite mode for running LLD main twice

LLD_IN_TEST determines how many times each port's `main` function is
run in each LLD process, and setting LLD_IN_TEST=2 (or higher) is useful
for checking if we're cleaning up and resetting global state correctly.
Add a test suite parameter to enable this easily. There's work in
progress to remove global state (e.g. D108850), but this seems useful in
the interim.

Reviewed By: rnk

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

2 years ago[InstCombine] Precommit updated and-xor-or.ll tests. NFC.
Stanislav Mekhanoshin [Mon, 1 Nov 2021 20:25:09 +0000 (13:25 -0700)]
[InstCombine] Precommit updated and-xor-or.ll tests. NFC.

2 years ago[LazyCallGraph] Skip blockaddresses
Arthur Eubanks [Wed, 20 Oct 2021 19:05:53 +0000 (12:05 -0700)]
[LazyCallGraph] Skip blockaddresses

blockaddresses do not participate in the call graph since the only
instructions that use them must all return to someplace within the
current function. And passes cannot retrieve a function address from a
blockaddress.

This was suggested by efriedma in D58260.

Fixes PR50881.

Reviewed By: nickdesaulniers

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

2 years ago[clang][deps] Keep #pragma push_macro, pop_macro and include_alias when minimizing...
Sylvain Audi [Tue, 19 Oct 2021 17:38:49 +0000 (13:38 -0400)]
[clang][deps] Keep #pragma push_macro, pop_macro and include_alias when minimizing source code.

The #pragma directives push_macro/pop_macro and include_alias may influence the #include / import directives encountered by dependency scanning tools like clang-scan-deps.

This patch ensures that those directives are not removed during source code minimization.

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

2 years ago Add a Bazel build file for mlir/python.
Peter Hawkins [Mon, 1 Nov 2021 20:01:33 +0000 (13:01 -0700)]
 Add a Bazel build file for mlir/python.

This BUILD file:
* generates machine-generated Python files using tblgen, and
* exports both generated and handwritten Python files via filegroup() rules.

This allows downstream users to use Bazel to build Python wheels that incorporate the MLIR Python bindings.

Reviewed By: GMNGeoffrey

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

2 years ago[libc] add strndup
Michael Jones [Fri, 29 Oct 2021 20:43:05 +0000 (13:43 -0700)]
[libc] add strndup

add an implementation of strndup

Reviewed By: sivachandra

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

2 years agoRevert "[clang] Fortify warning for scanf calls with field width too big."
Michael Benfield [Mon, 1 Nov 2021 19:36:45 +0000 (19:36 +0000)]
Revert "[clang] Fortify warning for scanf calls with field width too big."

This reverts commit 5a8c1736289f2b1df10df38e7a9e4d208a7586a6.

The warning needs to correctly handle * specifiers (which are to be
ignored).

2 years ago[mlir][gpu] Add basic support to do elementwise ops on mma matrix type
thomasraoux [Mon, 1 Nov 2021 18:43:54 +0000 (11:43 -0700)]
[mlir][gpu] Add basic support to do elementwise ops on mma matrix type

In order to support fusion with mma matrix type we need to be able to
execute elementwise operations on them. This add an op to be able to
support some basic elementwise operations. This is a is not a full
solution as it only supports a limited scope or operations. Ideally we would
want to be able to fuse with more kind of operations.

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

2 years agoRemove an unused parameter; NFC
Aaron Ballman [Mon, 1 Nov 2021 18:42:00 +0000 (14:42 -0400)]
Remove an unused parameter; NFC

2 years ago[libc++] Add missing annotations for TEST_HAS_NO_WIDE_CHARACTERS
Louis Dionne [Mon, 1 Nov 2021 15:32:42 +0000 (11:32 -0400)]
[libc++] Add missing annotations for TEST_HAS_NO_WIDE_CHARACTERS

Those tests would pass when run on a C Standard Library that actually
provides wide characters, but fail when run on top of one that doesn't.
It's really difficult to test this 100% perfectly in the CI without
introducing an actual platform that doesn't provide these declarations.

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

2 years ago[mlir][python] Add test for tensor dialect.
MaheshRavishankar [Mon, 1 Nov 2021 17:14:33 +0000 (10:14 -0700)]
[mlir][python] Add test for tensor dialect.

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

2 years ago[SCEV] Only add direct loop users (NFC)
Nikita Popov [Sat, 30 Oct 2021 19:56:30 +0000 (21:56 +0200)]
[SCEV] Only add direct loop users (NFC)

It it now sufficient to track only direct addrec users of a loop,
and let the SCEVUsers mechanism track and invalidate transitive users.

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

2 years ago[lldb][gmodules] Fix TestDataFormatterCpp with gmodules on macOS
Raphael Isemann [Mon, 1 Nov 2021 17:43:58 +0000 (18:43 +0100)]
[lldb][gmodules] Fix TestDataFormatterCpp with gmodules on macOS

'Point' is actually a system type defined on macOS.

2 years ago[SVE] Fix VLS FMA matching for CodeGenOpt::Aggressive.
Cameron McInally [Mon, 1 Nov 2021 16:51:16 +0000 (09:51 -0700)]
[SVE] Fix VLS FMA matching for CodeGenOpt::Aggressive.

For NEON, FMA matching is done in the MachineCombiner, and not the
DAGCombiner. That causes problems with VLS lowering, since the
vectors are fixed width at the DAGCombiner, but are scalable in
the MachineCombiner. This patch corrects it by matching FMAs for
VLS vectors in the DAGCombiner.

Reviewed By: paulwalker-arm

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

2 years ago[mlir][nvvm] Generalize wmma ops to handle more types and shapes
thomasraoux [Thu, 28 Oct 2021 05:43:10 +0000 (22:43 -0700)]
[mlir][nvvm] Generalize wmma ops to handle more types and shapes

wmma intrinsics have a large number of combinations, ideally we want to be able
to target all the different variants. To avoid a combinatorial explosion in the
number of mlir op we use attributes to represent the different variation of
load/store/mma ops. We also can generate with tablegen helpers to know which
combinations are available. Using this we can avoid having too hardcode a path
for specific shapes and can support more types.
This patch also adds boiler plates for tf32 op support.

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

2 years ago[lldb][NFC] Inclusive Language: Replace master with main
Quinn Pham [Mon, 1 Nov 2021 17:15:37 +0000 (12:15 -0500)]
[lldb][NFC] Inclusive Language: Replace master with main

[NFC] This patch fixes a URL within a git repo whose master branch was renamed
to main.

2 years ago[clang] Fortify warning for scanf calls with field width too big.
Michael Benfield [Thu, 14 Oct 2021 20:02:28 +0000 (20:02 +0000)]
[clang] Fortify warning for scanf calls with field width too big.

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

2 years ago[llvm-profgen] Fill zero count for all function ranges
wlei [Fri, 29 Oct 2021 23:33:31 +0000 (16:33 -0700)]
[llvm-profgen] Fill zero count for all function ranges

Allow filling zero count for all the function ranges even there is no samples hitting that function. Add a switch for this.

Reviewed By: hoy, wenlei

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

2 years ago[fir][NFC] Address post commit comments on D112845
Valentin Clement [Mon, 1 Nov 2021 16:34:59 +0000 (17:34 +0100)]
[fir][NFC] Address post commit comments on D112845

Address some of the comments on D112845 after
it was committed.

Reviewed By: mehdi_amini

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

2 years ago[test] Add missing pass name to new-pm-defaults.ll
Arthur Eubanks [Mon, 1 Nov 2021 16:47:56 +0000 (09:47 -0700)]
[test] Add missing pass name to new-pm-defaults.ll

2 years ago[lldb] Only specify LLVM_ENABLE_RUNTIMES in the libcxx error message.
Jonas Devlieghere [Mon, 1 Nov 2021 16:38:52 +0000 (09:38 -0700)]
[lldb] Only specify LLVM_ENABLE_RUNTIMES in the libcxx error message.

Now that passing libcxx via LLVM_ENABLE_PROJECTS has been deprecated,
update the error message and recommend using LLVM_ENABLE_RUNTIMES
instead. This patch also remove the error message for the old layout.

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

2 years ago[CodeGen] Tweak coding style in LivePhysRegs::stepForward. NFC.
Jay Foad [Mon, 1 Nov 2021 15:56:31 +0000 (15:56 +0000)]
[CodeGen] Tweak coding style in LivePhysRegs::stepForward. NFC.

2 years ago[lldb-vscode] Fix coredump load source mapping for first file
Ted Woodward [Mon, 1 Nov 2021 15:42:44 +0000 (10:42 -0500)]
[lldb-vscode] Fix coredump load source mapping for first file

SetSourceMapFromArguments is called after the core is loaded. This means
that the source file for the crashing code won't have the source map applied.
Move the call to SetSourceMapFromArguments in request_attach to just after
the call to RunInitCommands, matching request_launch behavior.

Reviewed By: clayborg, wallace

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

2 years ago[InstCombine] allow vector splat matching for bitwise logic fold
Sanjay Patel [Mon, 1 Nov 2021 15:35:41 +0000 (11:35 -0400)]
[InstCombine] allow vector splat matching for bitwise logic fold

Similar to 54e969cffddb (and with cosmetic updates to hopefully
make that easier to read), this fold has been around since early
in LLVM history.

Intermediate folds have been added subsequently, so extra uses
are required to exercise this code.

The test example actually shows an unintended consequence with
extra uses - we end up with an extra instruction compared to what
we started with. But this at least makes scalar/vector consistent.

General proof:
https://alive2.llvm.org/ce/z/tmuBza

2 years ago[InstCombine] add tests for bitwise logic folds; NFC
Sanjay Patel [Mon, 1 Nov 2021 14:46:54 +0000 (10:46 -0400)]
[InstCombine] add tests for bitwise logic folds; NFC

2 years ago[NFC][PowerPC] Update testcases using script
Jinsong Ji [Mon, 1 Nov 2021 15:36:42 +0000 (15:36 +0000)]
[NFC][PowerPC] Update testcases using script

For D106555.

2 years ago[X86] Remove X86ELFObjectWriter in X86AsmBackend.cpp (NFC)
Kazu Hirata [Mon, 1 Nov 2021 15:31:54 +0000 (08:31 -0700)]
[X86] Remove X86ELFObjectWriter in X86AsmBackend.cpp (NFC)

Note that the identically named class is defined in an anonymous
namespace in X86ELFObjectWriter.cpp.

2 years ago[AMDGPU] Use MachineInstrBuilder::addReg. NFC.
Jay Foad [Mon, 1 Nov 2021 15:29:35 +0000 (15:29 +0000)]
[AMDGPU] Use MachineInstrBuilder::addReg. NFC.

2 years ago[mlir][SPIRVToLLVM] Add shufflevector conversion
Weiwei Li [Mon, 1 Nov 2021 14:47:47 +0000 (22:47 +0800)]
[mlir][SPIRVToLLVM] Add shufflevector conversion

Add the shufflevector conversion. It only handles the static, i.e., IntegerAttr, index.

Co-authored: Xinyi Liu <xyliuhelen@gmail.com>

Reviewed by: antiagainst

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

2 years ago[lldb] Add a test for class loading via member typedefs
Raphael Isemann [Mon, 1 Nov 2021 14:55:16 +0000 (15:55 +0100)]
[lldb] Add a test for class loading via member typedefs

This is currently only tested indirectly in the huge stdlibc++ formatter tests.

2 years ago[AMDGPU] Add tests for legacy multiply-add with immediate
Jay Foad [Mon, 1 Nov 2021 14:23:58 +0000 (14:23 +0000)]
[AMDGPU] Add tests for legacy multiply-add with immediate

2 years ago[libc++] Refactor num_put::do_put to reduce duplication
Louis Dionne [Fri, 29 Oct 2021 15:12:21 +0000 (11:12 -0400)]
[libc++] Refactor num_put::do_put to reduce duplication

I was going to make a change in that area of the code and I noticed that
we basically duplicated the same code 5 times to handle integral types
and floating point types. This commit simply pulls the duplication into
a function.

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

2 years ago[AMDGPU] Shrink v_mac_legacy_f32 and v_fmac_legacy_f32
Jay Foad [Mon, 1 Nov 2021 09:45:46 +0000 (09:45 +0000)]
[AMDGPU] Shrink v_mac_legacy_f32 and v_fmac_legacy_f32

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

2 years ago[AIX][NFC] Unsupported object-c test
Jinsong Ji [Mon, 1 Nov 2021 13:44:23 +0000 (13:44 +0000)]
[AIX][NFC] Unsupported object-c test

2 years ago[HWASan] Apply TagMaskByte to every global tag.
Matt Morehouse [Mon, 1 Nov 2021 13:29:34 +0000 (06:29 -0700)]
[HWASan] Apply TagMaskByte to every global tag.

Previously we only applied it to the first one, which could allow
subsequent global tags to exceed the valid number of bits.

Reviewed By: hctim

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

2 years ago[sanitizer] Disable posix_spawn.c test on Android.
Matt Morehouse [Mon, 1 Nov 2021 13:22:48 +0000 (06:22 -0700)]
[sanitizer] Disable posix_spawn.c test on Android.

2 years ago[InstCombine] allow vector splat matching for bitwise logic folds
Sanjay Patel [Sun, 31 Oct 2021 16:50:05 +0000 (12:50 -0400)]
[InstCombine] allow vector splat matching for bitwise logic folds

This fold was added long ago (part of fixing PR4216),
and it matched scalars only. Intermediate folds have
been added subsequently, so extra uses are required
to exercise this code.

General proof:
https://alive2.llvm.org/ce/z/G6BBhB

One of the specific tests:
https://alive2.llvm.org/ce/z/t0JhEB

2 years ago[InstCombine] reduce code duplication with commutative matcher; NFC
Sanjay Patel [Sun, 31 Oct 2021 16:12:37 +0000 (12:12 -0400)]
[InstCombine] reduce code duplication with commutative matcher; NFC

2 years ago[InstCombine] add tests for bitwise logic folds; NFC
Sanjay Patel [Sun, 31 Oct 2021 15:46:18 +0000 (11:46 -0400)]
[InstCombine] add tests for bitwise logic folds; NFC

The extra uses are needed to prevent intermediate folds.
Without that, there would be no coverage currently.
The vector tests show an artificial limitation in the code.

2 years ago[Test] Fix tests showing generation of already existent PHIs by GVN
Dmitry Makogon [Mon, 1 Nov 2021 11:51:30 +0000 (18:51 +0700)]
[Test] Fix tests showing generation of already existent PHIs by GVN

This is a fix for tests added by 96591a14cd25bc30519c293efa8e01b4c7e869f6.
A function which was called in tests wasn't marked as 'readonly', and the
GVN performed PRE for the loads, but they were supposed to be non-local.
So added 'readonly' to the called function.

2 years ago[AArch64] Enablement of Cortex-X2
Mubashar Ahmad [Mon, 1 Nov 2021 11:55:24 +0000 (11:55 +0000)]
[AArch64] Enablement of Cortex-X2

Enables support for Cortex-X2 cores.

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

2 years ago[CostModel][X86] Remove old FIXME comments for AVX512F vector splitting
Simon Pilgrim [Mon, 1 Nov 2021 11:11:00 +0000 (11:11 +0000)]
[CostModel][X86] Remove old FIXME comments for AVX512F vector splitting

Similar to AVX1, the cost of splitting/merging 512-bit -> 256-bits vectors for arithmetic operations are typically hidden due to different used ports etc.

2 years ago[llvm-dwarfdump] Improve testing of --summarize-types
gbreynoo [Mon, 1 Nov 2021 11:04:37 +0000 (11:04 +0000)]
[llvm-dwarfdump] Improve testing of --summarize-types

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

2 years ago[X86][AVX] Prefer VINSERTF128 over VPERM2F128 for 128->256 subvector concatenations
Simon Pilgrim [Mon, 1 Nov 2021 10:45:50 +0000 (10:45 +0000)]
[X86][AVX] Prefer VINSERTF128 over VPERM2F128 for 128->256 subvector concatenations

The VINSERTF128 instruction is often much quicker, and never slower, than the more general VPERM2F128 instruction, so we should try to use that in more circumstances.

This requires a fallback to a commuted VPERM2F128 for the case where we need to fold the 256-bit vector source instead of the 128-bit subvector source.

There is one interesting side effect - DAGCombine's narrowExtractedVectorLoad combine gets called in a number of locations, this often creates an extracted subvector load without regard to other uses of the original wider load. I'm expecting AVX cpus to be capable of merging such aliased loads, but I do wonder whether narrowExtractedVectorLoad's call to X86TargetLowering::shouldReduceLoadWidth needs to be altered to check for more partial uses?

Noticed while investigating the quality of interleaved load/store codegen.

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

2 years ago[LoopVectorize] Change getRuntimeVFAsFloat to use unsigned int->FP conversion
David Sherwood [Wed, 27 Oct 2021 10:40:01 +0000 (11:40 +0100)]
[LoopVectorize] Change getRuntimeVFAsFloat to use unsigned int->FP conversion

We never expect the runtime VF to be negative so we should use
the uitofp instruction instead of sitofp.

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

2 years ago[flang] Implement GET_ENVIRONMENT_VARIABLE(VALUE)
Diana Picus [Wed, 27 Oct 2021 09:09:31 +0000 (09:09 +0000)]
[flang] Implement GET_ENVIRONMENT_VARIABLE(VALUE)

Implement the second entry point for GET_ENVIRONMENT_VARIABLE. Reuse
existing bits and pieces wherever possible.

This patch also increases CFI_* error codes in order to avoid conflicts.
GET_ENVIRONMENT_VARIABLE is required to return a status of 1 if an
environment variable does not exist and 2 if environment variables are
not supported. However, if we add status codes for that they will
conflict with CFI_ERROR_BASE_ADDR_NULL and CFI_ERROR_BASE_ADDR_NOT_NULL,
which are also 1 and 2 at the moment. We therefore move all CFI error
codes up (an arbitrary) 10 spots to make room. Hopefully this isn't
a problem, since we weren't matching the CFI error codes that gfortran
uses anyway. It may still be an issue if any other runtime functions
will need to return a status of 1 or 2, but we should probably deal with
that when/if it occurs.

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

2 years agoRevert "[opt-viewer] Use safe yaml load_all"
Yi Kong [Mon, 1 Nov 2021 09:14:19 +0000 (17:14 +0800)]
Revert "[opt-viewer] Use safe yaml load_all"

This reverts commit 1123e03a9d9401c5203ae55bff533dd4d133d8d2.

Broken on the AIX platform.

2 years ago[CVP] Canonicalize signed relational comparisons of scalar integers to unsigned compa...
Roman Lebedev [Fri, 6 Nov 2020 11:06:00 +0000 (14:06 +0300)]
[CVP] Canonicalize signed relational comparisons of scalar integers to unsigned comparison predicates

Now that the reasoning was added to ConstantRange in D90924,
this replicates IndVars variant of this transform (D111836)
in a pass that uses value range reasoning for the transform.

Reviewed By: nikic

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

2 years ago[XCOFF] [llvm-readobj] replace tests using binary as input
Esme-Yi [Mon, 1 Nov 2021 08:43:32 +0000 (08:43 +0000)]
[XCOFF] [llvm-readobj] replace tests using binary as input
with tests generated by yaml2obj.

Summary: Because yaml2obj supports basic transforming for XCOFF,
         some of the binary inputs used in the tests of llvm-readobj
         can be replaced with yaml files.

Reviewed By: shchenz

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

2 years ago[ADT] Add Compare template param to EquivalenceClasses
Matthias Springer [Mon, 1 Nov 2021 08:15:12 +0000 (17:15 +0900)]
[ADT] Add Compare template param to EquivalenceClasses

This makes the class usable with types that do not provide their own operator<.

Update MLIR Linalg ComprehensiveBufferize to take advantage of the new template param.

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

2 years ago[Taildup] Don't tail-duplicate loop header with multiple successors as its latches
Jun Ma [Tue, 28 Sep 2021 08:53:27 +0000 (16:53 +0800)]
[Taildup] Don't tail-duplicate loop header with multiple successors as its latches

when Taildup hit loop with multiple latches like:
  //    1 -> 2 <-> 3                 |
  //          \  <-> 4               |
  //           \   <-> 5             |
  //            \---> rest           |
it may transform this loop into multiple loops by duplicate loop header.
However, this change may has little benefit while makes cfg much complex.
In some uncommon cases, it causes large compile time regression (offered by
@alexfh in D106056).

This patch disable tail-duplicate of such cases.

TestPlan: check-llvm

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

2 years ago[TailDup] Add testcase for interpreter switch loop, NFC.
Jun Ma [Wed, 29 Sep 2021 02:28:29 +0000 (10:28 +0800)]
[TailDup] Add testcase for interpreter switch loop, NFC.

2 years agoRevert "Revert "Recommit "Revert "[CVP] processSwitch: Remove default case when switc...
Jun Ma [Tue, 28 Sep 2021 01:44:00 +0000 (09:44 +0800)]
Revert "Revert "Recommit "Revert "[CVP] processSwitch: Remove default case when switch cover all possible values.""""

This reverts commit 3a998c06a8e93989319238e12b56a731198cc1c2.

2 years ago[sanitizer] msan build fix on non linux platforms
David Carlier [Mon, 1 Nov 2021 07:18:43 +0000 (07:18 +0000)]
[sanitizer] msan build fix on non linux platforms

2 years ago[AArch64] Remove unused declaration hasSwiftExtendedFrame (NFC)
Kazu Hirata [Mon, 1 Nov 2021 05:58:56 +0000 (22:58 -0700)]
[AArch64] Remove unused declaration hasSwiftExtendedFrame (NFC)

2 years ago[mlir][arith] `traits` need to be passed to parent op
Mogball [Fri, 29 Oct 2021 16:26:08 +0000 (16:26 +0000)]
[mlir][arith] `traits` need to be passed to parent op

Reviewed By: rriddle

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

2 years ago[SCEV][NFC] Factor out common API for getting unique operands of a SCEV
Max Kazantsev [Mon, 1 Nov 2021 04:36:47 +0000 (11:36 +0700)]
[SCEV][NFC] Factor out common API for getting unique operands of a SCEV

This function is used at least in 2 places, to it makes sense to make it separate.

Differential Revision: https://reviews.llvm.org/D112516
Reviewed By: reames

2 years ago[PowerPC] turn off chain commoning by default.
Chen Zheng [Mon, 1 Nov 2021 04:07:17 +0000 (04:07 +0000)]
[PowerPC] turn off chain commoning by default.

2 years ago[ELF] Simplify R_DTPREL. NFC
Fangrui Song [Mon, 1 Nov 2021 03:30:00 +0000 (20:30 -0700)]
[ELF] Simplify R_DTPREL. NFC

2 years ago[Verifier] Add verification logic for GlobalIFuncs
Itay Bookstein [Mon, 1 Nov 2021 03:00:57 +0000 (20:00 -0700)]
[Verifier] Add verification logic for GlobalIFuncs

Verify that the resolver exists, that it is a defined
Function, and that its return type matches the ifunc's
type. Add corresponding check to BitcodeReader, change
clang to emit the correct type, and fix tests to comply.

Reviewed By: MaskRay

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

2 years ago[CSKY] First patch to construct codegen infra and generate first add instruction
Zi Xuan Wu [Mon, 1 Nov 2021 02:06:56 +0000 (10:06 +0800)]
[CSKY] First patch to construct codegen infra and generate first add instruction

Ooops. It constructs codegen infra and provide only basic code to generate first add instruction successfully.

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

2 years ago[MachO] Use error instead of fatal for missing -arch
Shoaib Meenai [Sat, 30 Oct 2021 23:45:06 +0000 (16:45 -0700)]
[MachO] Use error instead of fatal for missing -arch

`fatal` should only be used for malformed inputs according to
ErrorHandler.h; `error` is more appropriate for missing arguments,
accompanied by a check to bail out early in case of the error. Some
tests need to be adjusted accordingly.

Makes `lld/test/MachO/arch.s` pass with `LLD_IN_TEST=2`.

Reviewed By: #lld-macho, int3

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

2 years ago[TimeProfiler] Reset variable to nullptr
Shoaib Meenai [Sat, 30 Oct 2021 23:49:20 +0000 (16:49 -0700)]
[TimeProfiler] Reset variable to nullptr

Otherwise we'll hit a spurious assert failure when we reset and then
reinitialize TimeProfiler on the same thread, as can happen when e.g.
using LLD as a library and running it multiple times in the same
process.

Makes `lld/test/MachO/time-trace.s` pass with `LLD_IN_TEST=2`, which
runs the linker twice in the same process and exposed the issue.

Reviewed By: MaskRay, mehdi_amini

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

2 years ago[MachO] Properly reset global state
Shoaib Meenai [Sat, 30 Oct 2021 23:35:30 +0000 (16:35 -0700)]
[MachO] Properly reset global state

We need to reset global state between runs, similar to the other ports.
There's some file-static state which needs to be reset as well and we
need to add some new helpers for that.

With this change, most LLD Mach-O tests pass with `LLD_IN_TEST=2` (which
runs the linker twice on each test). Some tests will be fixed by the
remainder of this stack, and the rest are fundamentally incompatible
with that mode (e.g. they intentionally throw fatal errors).

Fixes PR52070.

Reviewed By: #lld-macho, int3

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

2 years ago[lld/coff] Add parsing for /pdbpagesize: flag
Nico Weber [Sat, 30 Oct 2021 15:22:55 +0000 (11:22 -0400)]
[lld/coff] Add parsing for /pdbpagesize: flag

It's not used for anything yet, but we now accept `/pdbpagesize:4096`
(the default behavior) and we give arguably more useful diagnostics
for other values.

It's plumbed through to the MSF layer, so just uncommenting out
the bit in DriverUtils.cpp that rejects args other than 4096 is enough
to try other values.

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

2 years ago[ELF] Replace "symbol '...' has no type" diagnostic with "relocation ... cannot be...
Fangrui Song [Sun, 31 Oct 2021 20:12:26 +0000 (13:12 -0700)]
[ELF] Replace "symbol '...' has no type" diagnostic with "relocation ... cannot be used against symbol '...'"

The "symbol 'foo' has no type" diagnostic tries to inform that copy
relocation/canonical PLT entry cannot be used, but the diagnostic is often
incorrect and confusing.

2 years ago[ConstantRange] Sign-flipping of signedness-invariant comparisons
Roman Lebedev [Fri, 6 Nov 2020 11:06:00 +0000 (14:06 +0300)]
[ConstantRange] Sign-flipping of signedness-invariant comparisons

For certain combination of LHS and RHS constant ranges,
the signedness of the relational comparison predicate is irrelevant.

This implements complete and precise model for all predicates,
as confirmed by the brute-force tests. I'm not sure if there are
some more cases that we can handle here.

In a follow-up, CVP will make use of this.

Reviewed By: nikic

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

2 years ago[ELF] Untangle R_GOT style TLS IE and processRelocAux. NFC
Fangrui Song [Sun, 31 Oct 2021 19:38:36 +0000 (12:38 -0700)]
[ELF] Untangle R_GOT style TLS IE and processRelocAux. NFC

2 years ago[NFC][sanitizer] Atomix relaxed in TwoLevelMap
Vitaly Buka [Mon, 25 Oct 2021 00:17:39 +0000 (17:17 -0700)]
[NFC][sanitizer] Atomix relaxed in TwoLevelMap

This is NOOP in x86_64.
On arch64 it avoids Data Memory Barrier with visible improvements on micro benchmarks.

Reviewed By: dvyukov

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

2 years ago[sanitizer] Add posix_spawn interceptor
Vitaly Buka [Fri, 29 Oct 2021 08:39:03 +0000 (01:39 -0700)]
[sanitizer] Add posix_spawn interceptor

To make pid initialized for Msan.

Reviewed By: eugenis

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

2 years ago[ELF] Remove -Wl,-z,notext hint
Fangrui Song [Sun, 31 Oct 2021 19:10:42 +0000 (12:10 -0700)]
[ELF] Remove -Wl,-z,notext hint

The hint does not pull its weight:

* adding -Wl,-z,notext often won't work (relocation types other than `symbolRel`, e.g. `R_AARCH64_LDST32_ABS_LO12_NC`)
* for pure (no assembly) C/C++ projects, the "-fPIC" hint is sufficient

2 years ago[ORC-RT] Add missing file that was left out of ff846fcb64c.
Lang Hames [Sun, 31 Oct 2021 17:52:43 +0000 (10:52 -0700)]
[ORC-RT] Add missing file that was left out of ff846fcb64c.

2 years ago[ELF] Simplify isStaticLinkTimeConstant. NFC
Fangrui Song [Sun, 31 Oct 2021 17:46:42 +0000 (10:46 -0700)]
[ELF] Simplify isStaticLinkTimeConstant. NFC

2 years ago[ORC][ORC-RT] Switch MachO EH/TLV registration from EPC-calls to alloc actions.
Lang Hames [Sun, 31 Oct 2021 17:07:14 +0000 (10:07 -0700)]
[ORC][ORC-RT] Switch MachO EH/TLV registration from EPC-calls to alloc actions.

MachOPlatform used to make an EPC-call (registerObjectSections) to register the
eh-frame and thread-data sections for each linked object with the ORC runtime.

Now that JITLinkMemoryManager supports allocation actions we can use these
instead of an EPC call. This saves us one EPC-call per object linked, and
manages registration/deregistration in the executor, rather than the controller
process. In the future we may use this to allow JIT'd code in the executor to
outlive the controller object while still being able to be cleanly destroyed.

Since the code for allocation actions must be available when the actions are
run, and since the eh-frame registration code lives in the ORC runtime itself,
this change required that MachO eh-frame support be split out of
macho_platform.cpp and into its own macho_ehframe_registration.cpp file that has
no other dependencies. During bootstrap we start by forcing emission of
macho_ehframe_registration.cpp so that eh-frame registration is guaranteed to be
available for the rest of the bootstrap process. Then we load the rest of the
MachO-platform runtime support, erroring out if there is any attempt to use
TLVs. Once the bootstrap process is complete all subsequent code can use all
features.

2 years ago[JITLink] Fix alloc action call signature in InProcessMemoryManager.
Lang Hames [Sun, 31 Oct 2021 05:10:47 +0000 (22:10 -0700)]
[JITLink] Fix alloc action call signature in InProcessMemoryManager.

Alloc actions should return a CWrapperFunctionResult. JITLink does not have
access to this type yet, due to library layering issues, so add a cut-down
version with a fixme.

2 years ago[RISCV] Expand scalable vector bswap. Fix crash for bitreverse.
Craig Topper [Fri, 29 Oct 2021 16:52:36 +0000 (09:52 -0700)]
[RISCV] Expand scalable vector bswap. Fix crash for bitreverse.

Fix LegalizeVectorOps to not try shuffle or unrolling expansions for
scalable vectors.

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

2 years ago[CodeGen] Use make_early_inc_range (NFC)
Kazu Hirata [Sun, 31 Oct 2021 14:57:36 +0000 (07:57 -0700)]
[CodeGen] Use make_early_inc_range (NFC)

2 years ago[CodeGen, Target] Use MachineBasicBlock::terminators (NFC)
Kazu Hirata [Sun, 31 Oct 2021 14:57:34 +0000 (07:57 -0700)]
[CodeGen, Target] Use MachineBasicBlock::terminators (NFC)