platform/upstream/llvm.git
2 years agoAdd new choices dot-cfg and dot-cfg-quiet to print-changed.
Jamie Schmeiser [Tue, 2 Nov 2021 16:03:05 +0000 (12:03 -0400)]
Add new choices dot-cfg and dot-cfg-quiet to print-changed.

Summary:
Add new options -print-changed=[dot-cfg | dot-cfg-quiet] which create
a website of DOT files showing colourized changes as the IR is changed
by passes in the new pass manager pipeline.

A new change reporter is introduced that creates a website of changes made
by passes in the opt pipeline that change the IR. The hidden option
-dot-cfg-dir=<dir> specifies a directory (defaulting to "./") into which the
website will be created.

A file passes.html is created that contains a list of all the passes that
act on the IR. Those that do not change the IR are listed as omitted
because of no change, ignored or filtered out (using -filter-print-func
and -filter-passes) or not listed in quiet mode. Those that
do change the IR are listed as a link to a DOT file which contains a
CFG depiction of the IR (ala -dot-cfg) except that the instructions,
basic blocks and links that are only in the IR before the pass (ie, removed)
and those that are only in the IR after the pass (ie, added) are shown in
red and green, respectively, while the aspects of the CFG that do not change
are shown in black. Additional hidden options
-dot-cfg-before-color=<dot named color>,
-dot-cfg-after-color=<dot named color> and
-dot-cfg-common-color=<dot named color> are defined that allow the
customization of the colors used in colorizing the CFG.
-change-printer-dot-path=<path to dot exe> is also added.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: aeubanks (Arthur Eubanks)
Differential Revision: https://reviews.llvm.org/D87202

2 years ago[fir] Add fir.zero_bits conversion pattern to LLVM IR dialect
Valentin Clement [Tue, 2 Nov 2021 15:53:18 +0000 (16:53 +0100)]
[fir] Add fir.zero_bits conversion pattern to LLVM IR dialect

This patch adds the ZeroOpConversion pattern to LLVM IR dialect.
Conversion of aggregate types is not implemented yet and will trigger a
failure to legalize the operation. This is tested in the
convert-to-llvm-invalid.fir test file.

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

Reviewed By: kiranchandramohan

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[llvm-reduce] Reduce more GlobalValue properties
Arthur Eubanks [Sun, 31 Oct 2021 04:31:41 +0000 (21:31 -0700)]
[llvm-reduce] Reduce more GlobalValue properties

Reviewed By: hans

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

2 years ago[llvm-reduce] Reduce some GlobalObject properties
Arthur Eubanks [Sun, 31 Oct 2021 02:27:35 +0000 (19:27 -0700)]
[llvm-reduce] Reduce some GlobalObject properties

Specifically, the section and the alignment.

Reviewed By: hans

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

2 years ago[gn build] Add missing llvm-reduce dependency
Arthur Eubanks [Tue, 2 Nov 2021 15:46:46 +0000 (08:46 -0700)]
[gn build] Add missing llvm-reduce dependency

2 years ago[NFC] Remove LinkAll*.h
Arthur Eubanks [Mon, 1 Nov 2021 23:45:21 +0000 (16:45 -0700)]
[NFC] Remove LinkAll*.h

These were added to prevent functions from being removed by WPO.

But that doesn't make sense, correct WPO will not remove functions we actually use.

I noticed these because compiling cc1_main.cpp was pulling in random LLVM pass headers.

Reviewed By: MaskRay

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

2 years ago[gn build] Manually port 6fd2db04
Arthur Eubanks [Tue, 2 Nov 2021 15:42:24 +0000 (08:42 -0700)]
[gn build] Manually port 6fd2db04

2 years ago[Hexagon] Add machine verification to some tests
Jay Foad [Wed, 27 Oct 2021 09:19:47 +0000 (10:19 +0100)]
[Hexagon] Add machine verification to some tests

2 years ago[lld-macho][nfc][cleanup] Fix a few code style lints and clang-tidy findings
Vy Nguyen [Tue, 26 Oct 2021 19:14:25 +0000 (15:14 -0400)]
[lld-macho][nfc][cleanup] Fix a few code style lints and clang-tidy findings

- Use .empty() instead of `size() == 0` when possible.
- Use const-ref to avoid copying

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

2 years ago[lldb] Remove ConstString from TypeSystem and REPL plugin names
Pavel Labath [Tue, 2 Nov 2021 15:09:14 +0000 (16:09 +0100)]
[lldb] Remove ConstString from TypeSystem and REPL plugin names

2 years ago[mlir][gpuTonvvm] Remove hardcoded values in MMAType to llvm struct
thomasraoux [Tue, 2 Nov 2021 15:03:07 +0000 (08:03 -0700)]
[mlir][gpuTonvvm] Remove hardcoded values in MMAType to llvm struct

Also relax the types allowed in GPU wmma ops

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

2 years ago[Test] Regenerate IndVars test's checks
Dmitry Makogon [Tue, 2 Nov 2021 15:01:22 +0000 (22:01 +0700)]
[Test] Regenerate IndVars test's checks

This just regenerates a certain IndVars test's checks.

2 years ago[AMDGPU] Really preserve LiveVariables in SILowerControlFlow
Jay Foad [Wed, 27 Oct 2021 15:05:40 +0000 (16:05 +0100)]
[AMDGPU] Really preserve LiveVariables in SILowerControlFlow

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

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

2 years ago[mlir][VectorToGPU] Add support for elementwise mma to vector to GPU
thomasraoux [Tue, 2 Nov 2021 14:41:16 +0000 (07:41 -0700)]
[mlir][VectorToGPU] Add support for elementwise mma to vector to GPU

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

2 years ago[HWASan] Print short tags in tag mismatch description.
Matt Morehouse [Tue, 2 Nov 2021 15:00:27 +0000 (08:00 -0700)]
[HWASan] Print short tags in tag mismatch description.

I recently spent some extra time debugging a false positive because I
didn't realize the "real" tag was in the short granule.  Adding the
short tag here makes it more obvious that we could be dealing with a
short granule.

Reviewed By: hctim, eugenis

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

2 years ago[HWASan] Print short tags in __hwasan_print_shadow.
Matt Morehouse [Tue, 2 Nov 2021 14:59:16 +0000 (07:59 -0700)]
[HWASan] Print short tags in __hwasan_print_shadow.

Reviewed By: eugenis

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

2 years ago[Test] Fix tests showing generation of already existent PHIs by GVN
Dmitry Makogon [Tue, 2 Nov 2021 14:56:07 +0000 (21:56 +0700)]
[Test] Fix tests showing generation of already existent PHIs by GVN

Add target triple to the test module, so IndVars has a TTI to perform
congruent IVs elimination.

2 years ago[LangRef][VP] Correct mask type in vp.slice documentation
Fraser Cormack [Mon, 1 Nov 2021 11:39:01 +0000 (11:39 +0000)]
[LangRef][VP] Correct mask type in vp.slice documentation

The mask type for the llvm.experimental.vp.splice intrinsics must have
the same number of elements as the result type.

Reviewed By: simoll

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

2 years agoRevert "[AArch64][SVE] Combine predicated FMUL/FADD into FMA"
Matt [Tue, 2 Nov 2021 14:43:34 +0000 (14:43 +0000)]
Revert "[AArch64][SVE] Combine predicated FMUL/FADD into FMA"

This reverts commit fc28a2f8ced4ff3565f2c47fead824a017c25d21.

2 years ago[Test] Add tests showing congruent IVs not removed by IndVars
Dmitry Makogon [Tue, 2 Nov 2021 14:43:03 +0000 (21:43 +0700)]
[Test] Add tests showing congruent IVs not removed by IndVars

In the added cases we have two congruent IVs. IndVars widens at least one of them.
If they are both widened, then one of them is erased as they stay congruent after
widening. However if only one IV is widened, the other one stays in the loop.
We can simply erase the narrow IV and replace its uses with truncates of the
widest IV.

2 years ago[RISCV][VP] Add tests for "unmasked" VP loads
Fraser Cormack [Tue, 2 Nov 2021 14:04:08 +0000 (14:04 +0000)]
[RISCV][VP] Add tests for "unmasked" VP loads

These aren't currently matched against unmasked vector load
instructions. A patch to fix that will come later.

2 years ago[Sema] Avoid crash in CheckEnumConstant with contains-error expressions
Sam McCall [Fri, 20 Aug 2021 08:01:45 +0000 (10:01 +0200)]
[Sema] Avoid crash in CheckEnumConstant with contains-error expressions

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

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

2 years agoUse `GNUInstallDirs` to support custom installation dirs. -- LLVM
John Ericson [Sun, 4 Apr 2021 17:02:18 +0000 (13:02 -0400)]
Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

This is a new draft of D28234. I previously did the unorthodox thing of
pushing to it when I wasn't the original author, but since this version

- Uses `GNUInstallDirs`, rather than mimics it, as the original author
  was hesitant to do but others requested.

- Is much broader, effecting many more projects than LLVM itself.

I figured it was time to make a new revision.

I am using this patch (and many back-ports) as the basis of
https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS). It
looked like people were generally on board in D28234, but I make note of
this here in case extra motivation is useful.

---

As pointed out in the original issue, a central tension is that LLVM
already has some partial support for these sorts of things. For example
`LLVM_LIBDIR_SUFFIX`, or `COMPILER_RT_INSTALL_PATH`. Because it's not
quite clear yet what to do about those, we are holding off on changing
libdirs and `compiler-rt`. for this initial PR.

---

On the advice of @lebedev.ri, I am splitting this up a bit per
subproject, starting with LLVM. To allow it to be more easily reviewed. This and the subsequent patch must be landed together, as this will not build alone. But the rest can be landed on their own.

Reviewed By: compnerd

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

2 years ago[SimpleLoopUnswitch] Remove duplicate include.
Youngsuk Kim [Tue, 2 Nov 2021 14:05:54 +0000 (15:05 +0100)]
[SimpleLoopUnswitch] Remove duplicate include.

Header "llvm/Transforms/Scalar/SimpleLoopUnswitch.h" is currently
included twice. This commit removes the duplicate 'include' line.

Previous commit 693eedb13833245e2670308fa0e6fe47324ce553
seems to have mistakenly added the duplicate 'include'.

Reviewed By: fhahn

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

2 years ago[mlir] replace class with struct in a forward declaration
Alex Zinenko [Tue, 2 Nov 2021 14:05:45 +0000 (15:05 +0100)]
[mlir] replace class with struct in a forward declaration

Silence the warning.

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

2 years ago[InstCombine] change 'not' match for bitwise select
Sanjay Patel [Tue, 2 Nov 2021 13:42:41 +0000 (09:42 -0400)]
[InstCombine] change 'not' match for bitwise select

The tests diffs are logically equivalent, and so this is
generally NFC, but this makes the code match the code
comment.

It should also be more efficient. If we choose the 'not'
operand (rather than the 'not' instruction) as the select
condition, then we don't have to invert the select
condition/operands as a subsequent transform.

2 years ago[mlir] drop spurious semicolon
Alex Zinenko [Tue, 2 Nov 2021 14:15:03 +0000 (15:15 +0100)]
[mlir] drop spurious semicolon

2 years ago[X86][AVX] SimplifyDemandedVectorEltsForTargetNode - use getBROADCAST_LOAD helper...
Simon Pilgrim [Tue, 2 Nov 2021 13:07:36 +0000 (13:07 +0000)]
[X86][AVX] SimplifyDemandedVectorEltsForTargetNode - use getBROADCAST_LOAD helper. NFCI.

Reduce width of X86ISD::SUBV_BROADCAST_LOAD node.

2 years ago[X86][AVX] lowerV2X128Shuffle - use getBROADCAST_LOAD helper. NFCI.
Simon Pilgrim [Tue, 2 Nov 2021 12:52:05 +0000 (12:52 +0000)]
[X86][AVX] lowerV2X128Shuffle - use getBROADCAST_LOAD helper. NFCI.

2 years ago[Clang] Add min/max reduction builtins.
Florian Hahn [Tue, 2 Nov 2021 14:01:41 +0000 (15:01 +0100)]
[Clang] Add min/max reduction builtins.

This patch implements __builtin_reduce_max and __builtin_reduce_min as
specified in D111529.

The order of operations does not matter for min or max reductions and
they can be directly lowered to the corresponding
llvm.vector.reduce.{fmin,fmax,umin,umax,smin,smax} intrinsic calls.

Reviewed By: aaron.ballman

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

2 years ago[mlir][linalg] Rewrite `linalg.conv_2d_nhwc_hwcf` into 1-D
Lei Zhang [Tue, 2 Nov 2021 13:55:34 +0000 (09:55 -0400)]
[mlir][linalg] Rewrite `linalg.conv_2d_nhwc_hwcf` into 1-D

We'd like to take a progressive approach towards Fconvolution op
CodeGen, by 1) tiling it to fit compute hierarchy first, and then
2) tiling along window dimensions with size 1 to reduce the problem
to be matmul-like. After that, we can 3) downscale high-D convolution
ops to low-D by removing the size-1 window dimensions. The final
step would be 4) vectorizing the low-D convolution op directly.

We have patterns for 1), 2), and 4). This commit adds a pattern for
3) for `linalg.conv_2d_nhwc_hwcf` ops as a starter. Supporting other
high-D convolution ops should be similar and mechanical.

Reviewed By: nicolasvasilache

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

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