platform/upstream/llvm.git
2 years ago[Scalarizer] Do not insert instructions between PHI nodes and debug intrinsics.
Daniele Vettorel [Tue, 2 Nov 2021 13:52:46 +0000 (09:52 -0400)]
[Scalarizer] Do not insert instructions between PHI nodes and debug intrinsics.

The scalarizer pass seems to be inserting instructions in-between PHI nodes or debug intrinsics that end up staying at the end of the pass, resulting in malformed IR and violating assumptions.

This patch adds a check to make sure the `extractelement` instructions that it adds are correctly placed after all PHI nodes and debug intrinsics.

Patch by vettoreldaniele.

Reviewed By: bjope

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

2 years ago[gn build] Port 9b5c9c469d90
LLVM GN Syncbot [Tue, 2 Nov 2021 13:45:10 +0000 (13:45 +0000)]
[gn build] Port 9b5c9c469d90

2 years ago[analyzer] Dump checker name if multiple checkers evaluate the same call
Balazs Benics [Tue, 2 Nov 2021 13:42:14 +0000 (14:42 +0100)]
[analyzer] Dump checker name if multiple checkers evaluate the same call

Previously, if accidentally multiple checkers `eval::Call`-ed the same
`CallEvent`, in debug builds the analyzer detected this and crashed
with the message stating this. Unfortunately, the message did not state
the offending checkers violating this invariant.
This revision addresses this by printing a more descriptive message
before aborting.

Reviewed By: martong

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

2 years ago[AST] injected-class-name is not a redecl, even in template specializations
Sam McCall [Thu, 28 Oct 2021 22:48:42 +0000 (00:48 +0200)]
[AST] injected-class-name is not a redecl, even in template specializations

Back in the mists of time, the CXXRecordDecl for the injected-class-name was
a redecl of the outer class itself.
This got changed in 470c454a6176ef31474553e408c90f5ee630df89, but only for plain
classes: class template instantation was still detecting the injected-class-name
in the template body and marking its instantiation as a redecl.

This causes some subtle inconsistent behavior between the two, e.g.
hasDefinition() returns true for Foo<int>::Foo but false for Bar::Bar.
This is the root cause of PR51912.

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

2 years agoFix building with GCC 12:
Martin Liska [Tue, 2 Nov 2021 08:34:09 +0000 (09:34 +0100)]
Fix building with GCC 12:

Fixes: https://bugs.llvm.org/show_bug.cgi?id=52380

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

2 years ago[AMDGPU] More robust checks in extract_vector_dynelt.ll
Jay Foad [Tue, 2 Nov 2021 13:19:43 +0000 (13:19 +0000)]
[AMDGPU] More robust checks in extract_vector_dynelt.ll

2 years ago[mlir] provide C API and Python bindings for symbol tables
Alex Zinenko [Tue, 2 Nov 2021 11:39:36 +0000 (12:39 +0100)]
[mlir] provide C API and Python bindings for symbol tables

Symbol tables are a largely useful top-level IR construct, for example, they
make it easy to access functions in a module by name instead of traversing the
list of module's operations to find the corresponding function.

Depends On D112886

Reviewed By: mehdi_amini

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

2 years ago[mlir] return the updated symbol table after inserting into SymbolTable
Alex Zinenko [Tue, 2 Nov 2021 11:38:01 +0000 (12:38 +0100)]
[mlir] return the updated symbol table after inserting into SymbolTable

Inserting a symbol into a SymbolTable may lead to the name of the symbol being
changed in order to ensure uniqueness of symbol names in the table. Return this
new name to spare the caller the need to extract it from the symbol operation.

Depends On D112700

Reviewed By: mehdi_amini

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

2 years ago[DAGCombiner] Teach combineShiftToMULH to handle constant and const splat vector.
jacquesguan [Tue, 2 Nov 2021 11:13:04 +0000 (11:13 +0000)]
[DAGCombiner] Teach combineShiftToMULH to handle constant and const splat vector.

Fold (srl (mul (zext i32:$a to i64), i64:c), 32) -> (mulhu $a, $b),
if c can truncate to i32 without loss.

Reviewed By: frasercrmck, craig.topper, RKSimon

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

2 years ago[RISCV] Fix invalid kill on callee save
David Callahan [Tue, 2 Nov 2021 11:55:12 +0000 (11:55 +0000)]
[RISCV] Fix invalid kill on callee save

A callee save may be live (specifically X1) on entry and so a spill
should not mark it killed.

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

2 years ago[lldb] Fix a use-after-free in FindFileTest.cpp
Raphael Isemann [Tue, 2 Nov 2021 11:39:25 +0000 (12:39 +0100)]
[lldb] Fix a use-after-free in FindFileTest.cpp

ArrayRef doesn't take ownership.

2 years ago[SelectionDAG] Optimize expansion for rotates/funnel shifts
Simon Pilgrim [Tue, 2 Nov 2021 11:38:25 +0000 (11:38 +0000)]
[SelectionDAG] Optimize expansion for rotates/funnel shifts

If the type of a funnel shift needs to be expanded, expand it to two funnel shifts instead of regular shifts. For constant shifts, this doesn't make much difference, but for variable shifts it allows a more optimal lowering.

Also use the optimized funnel shift lowering for rotates.

Alive2: https://alive2.llvm.org/ce/z/TvHDB- / https://alive2.llvm.org/ce/z/yzPept

(Branched from D108058 as getting this completed should help unlock some other WIP patches).

Original Patch: @efriedma (Eli Friedman)

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

2 years ago[DAG] MatchRotate - remove (redundant) legal type check.
Simon Pilgrim [Tue, 2 Nov 2021 11:24:35 +0000 (11:24 +0000)]
[DAG] MatchRotate - remove (redundant) legal type check.

Rely on the hasOperation() instead - as commented on D77804, the mid-term intention is to recognise rotate/funnel-by-constant pre-legalization to help avoid SimplifyDemandedBits regressions.

2 years ago[bazel] Update BUILD file for llvm-reduce
Tres Popp [Tue, 2 Nov 2021 11:00:32 +0000 (12:00 +0100)]
[bazel] Update BUILD file for llvm-reduce

This is needed after fd41738e2ca975b6d3bea021ef38e6d49f27a71b

2 years ago[libc] Add more robust compile time architecture detection
Guillaume Chatelet [Tue, 2 Nov 2021 11:00:32 +0000 (11:00 +0000)]
[libc] Add more robust compile time architecture detection

We may want to restrict the detected platforms to only `x86_64` and `aarch64`.
There are still custom detection in api.td but I don't think we can handle these:
 - config/linux/api.td:205
 - config/linux/api.td:199

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

2 years ago[sanitizers] remove extra comma for sha2 interceptors
David Carlier [Tue, 2 Nov 2021 10:35:26 +0000 (10:35 +0000)]
[sanitizers] remove extra comma for sha2 interceptors

2 years ago[ARM] Some extra gather/scatter tests. NFC
David Green [Tue, 2 Nov 2021 10:32:22 +0000 (10:32 +0000)]
[ARM] Some extra gather/scatter tests. NFC

2 years ago[clang-tidy] Add check 'cert-err33-c'.
Balázs Kéri [Tue, 2 Nov 2021 09:30:14 +0000 (10:30 +0100)]
[clang-tidy] Add check 'cert-err33-c'.

The CERT rule ERR33-C can be modeled partially by the existing check
'bugprone-unused-return-value'. The existing check is reused with
a fixed set of checked functions.

Reviewed By: aaron.ballman

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

2 years ago[mlir][linalg][bufferize] Move BufferizableOpInterface implementations
Matthias Springer [Tue, 2 Nov 2021 07:05:53 +0000 (16:05 +0900)]
[mlir][linalg][bufferize] Move BufferizableOpInterface implementations

This commit moves parts of the existing bufferization code into external op interface implementations. Furthermore, Comprehensive Bufferize is adapted to use the new interface.

Future commits will decouple the interface and its op implementations from Comprehensive Bufferize and the Linalg dialect, as well as split them into multiple files with their own build targets. This commit leaves the file structure and build rules mostly unchanged.

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

2 years ago[gn build] Port fd41738e2ca9
LLVM GN Syncbot [Tue, 2 Nov 2021 09:21:12 +0000 (09:21 +0000)]
[gn build] Port fd41738e2ca9

2 years ago[mlir][linalg][bufferize] Add BufferizableOpInterface
Matthias Springer [Tue, 2 Nov 2021 07:05:27 +0000 (16:05 +0900)]
[mlir][linalg][bufferize] Add BufferizableOpInterface

This commit adds a new op interface: BufferizableOpInterface. In the future, ops that implement this interface can be bufferized using Comprehensive Bufferize.

Note: The interface methods of this interface correspond to the "op interface" in ComprehensiveBufferize.cpp.

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

2 years ago[llvm-readobj] Add support for reading OpenBSD ELF core notes.
Frederic Cambus [Mon, 1 Nov 2021 21:46:30 +0000 (22:46 +0100)]
[llvm-readobj] Add support for reading OpenBSD ELF core notes.

Notes generated in OpenBSD core files provide additional information
about the kernel state and CPU registers. These notes are described
in core.5, which can be viewed here: https://man.openbsd.org/core.5

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

2 years agoRecommit "[llvm-reduce] Add MIR support"
Markus Lavin [Tue, 2 Nov 2021 09:11:54 +0000 (10:11 +0100)]
Recommit "[llvm-reduce] Add MIR support"

(Second try. Need to link against CodeGen and MC libs.)

The llvm-reduce tool has been extended to operate on MIR (import, clone and
export). Current limitation is that only a single machine function is
supported. A single reducer pass that operates on machine instructions (while
on SSA-form) has been added. Additional MIR specific reducer passes can be
added later as needed.

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

2 years ago[lldb][gmodules] Fix TestDataFormatterGlobals under gmodules
Raphael Isemann [Tue, 2 Nov 2021 09:08:03 +0000 (10:08 +0100)]
[lldb][gmodules] Fix TestDataFormatterGlobals under gmodules

Same reason as in 548dbfaf447cc5fdfc26d34e60e3da08eb609531 -> macOS has a
struct called 'Point' in the libc module. Just remove the redundant includes
here.

2 years ago[LoopVectorize] Propagate fast-math flags for inloop reductions
Rosie Sumpter [Tue, 26 Oct 2021 11:58:18 +0000 (12:58 +0100)]
[LoopVectorize] Propagate fast-math flags for inloop reductions

This patch updates VPReductionRecipe::execute so that the fast-math
flags associated with the underlying instruction of the VPRecipe are
propagated through to the reductions which are created.

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

2 years agoFix inline builtin handling in case of redefinition
serge-sans-paille [Tue, 19 Oct 2021 09:23:27 +0000 (11:23 +0200)]
Fix inline builtin handling in case of redefinition

Basically, inline builtin definition are shadowed by externally visible
redefinition. This matches GCC behavior.

The implementation has to workaround the fact that:

1. inline builtin are renamed at callsite during codegen, but
2. they may be shadowed by a later external definition

As a consequence, during codegen, we need to walk redecls and eventually rewrite
some call sites, which is totally inelegant.

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

2 years ago[lldb] Unbreak the macOS build after dfd499a61c45778b7f01458d50ccc384343f53d5
Benjamin Kramer [Tue, 2 Nov 2021 08:47:44 +0000 (09:47 +0100)]
[lldb] Unbreak the macOS build after dfd499a61c45778b7f01458d50ccc384343f53d5

2 years ago[gn build] Port aee7f3384b40
LLVM GN Syncbot [Tue, 2 Nov 2021 08:41:58 +0000 (08:41 +0000)]
[gn build] Port aee7f3384b40

2 years agoRevert "[llvm-reduce] Add MIR support"
Markus Lavin [Tue, 2 Nov 2021 08:38:57 +0000 (09:38 +0100)]
Revert "[llvm-reduce] Add MIR support"

This reverts commit bc2773cb1bdfacfda773eb492e7b0cc65a78cda6.

Broke the clang-ppc64le-linux-multistage build. Reverting while I
investigate.

2 years ago[gn build] Port bc2773cb1bdf
LLVM GN Syncbot [Tue, 2 Nov 2021 08:28:36 +0000 (08:28 +0000)]
[gn build] Port bc2773cb1bdf

2 years agoRevert "[NFC][sanitizer] Disable a test with large stderr output"
Vitaly Buka [Tue, 2 Nov 2021 08:24:51 +0000 (01:24 -0700)]
Revert "[NFC][sanitizer] Disable a test with large stderr output"

This reverts commit 6eb38e517159f1fa5686d661d2aceb0a4002d8f0.

The test was not the reason of sanitizer-x86_64-linux-android failures.

2 years ago[llvm-reduce] Add MIR support
Markus Lavin [Tue, 2 Nov 2021 08:10:34 +0000 (09:10 +0100)]
[llvm-reduce] Add MIR support

The llvm-reduce tool has been extended to operate on MIR (import, clone and
export). Current limitation is that only a single machine function is
supported. A single reducer pass that operates on machine instructions (while
on SSA-form) has been added. Additional MIR specific reducer passes can be
added later as needed.

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

2 years ago[clang-tidy] Fix lint warnings in clang-tidy source code (NFC)
Salman Javed [Tue, 2 Nov 2021 07:14:25 +0000 (20:14 +1300)]
[clang-tidy] Fix lint warnings in clang-tidy source code (NFC)

Run clang-tidy on all source files under `clang-tools-extra/clang-tidy`
with `-header-filter=clang-tidy.*` and make suggested corrections.

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

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