platform/upstream/llvm.git
3 years ago[Canonicalizer] Process regions top-down instead of bottom up & reuse existing constants.
Chris Lattner [Sat, 20 Mar 2021 04:22:15 +0000 (21:22 -0700)]
[Canonicalizer] Process regions top-down instead of bottom up & reuse existing constants.

This reapplies b5d9a3c / https://reviews.llvm.org/D98609 with a one line fix in
processExistingConstants to skip() when erasing a constant we've already seen.

Original commit message:

 1) Change the canonicalizer to walk the function in top-down order instead of
    bottom-up order.  This composes well with the "top down" nature of constant
    folding and simplification, reducing iterations and re-evaluation of ops in
    simple cases.
 2) Explicitly enter existing constants into the OperationFolder table before
    canonicalizing.  Previously we would "constant fold" them and rematerialize
    them, wastefully recreating a bunch fo constants, which lead to pointless
    memory traffic.

Both changes together provide a 33% speedup for canonicalize on some mid-size
CIRCT examples.

One artifact of this change is that the constants generated in normal pattern
application get inserted at the top of the function as the patterns are applied.
Because of this, we get "inverted" constants more often, which is an aethetic
change to the IR but does permute some testcases.

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

3 years agoRevert "[IRSim] Adding basic implementation of llvm-sim."
Andrew Litteken [Sat, 20 Mar 2021 23:03:02 +0000 (18:03 -0500)]
Revert "[IRSim] Adding basic implementation of llvm-sim."

Causing build errors on the Windows Buildbots.

This reverts commit 5155dff2784a47583d432d796b7cf47a0bed9f20.

3 years ago[RISCV] Update comment in RISCVInstrInfoM.td
Jessica Clarke [Sat, 20 Mar 2021 22:35:40 +0000 (22:35 +0000)]
[RISCV] Update comment in RISCVInstrInfoM.td

Missed in 07ed62b7d551.

3 years ago[RISCV] Disable (mul (and X, 0xffffffff), (and Y, 0xffffffff)) optimization when...
Craig Topper [Sat, 20 Mar 2021 22:14:46 +0000 (15:14 -0700)]
[RISCV] Disable (mul (and X, 0xffffffff), (and Y, 0xffffffff)) optimization when Zba is enabled.

This optimization is trying to save SRLI instructions needed to
implement the ANDs. If we have zext.w we won't save anything.
Because we don't check that the multiply is the only user of the
AND we might even increase instruction count.

3 years ago[RISCV] Add Zba command lines to xaluo.ll. NFC
Craig Topper [Sat, 20 Mar 2021 22:09:15 +0000 (15:09 -0700)]
[RISCV] Add Zba command lines to xaluo.ll. NFC

Some of the patterns end up with 32 to 64 bit zero extends on RV64
which can be handled by zext.w.

3 years ago[test] Delete "-internal-isystem" "/usr/local/include"
Fangrui Song [Sat, 20 Mar 2021 22:24:02 +0000 (15:24 -0700)]
[test] Delete "-internal-isystem" "/usr/local/include"

3 years ago[RISCV] Add isel pattern to optimize (mul (and X, 0xffffffff), (and Y, 0xffffffff...
Craig Topper [Sat, 20 Mar 2021 19:34:06 +0000 (12:34 -0700)]
[RISCV] Add isel pattern to optimize (mul (and X, 0xffffffff), (and Y, 0xffffffff)) on RV64

This patterns computes the full 64 bit product of a 32x32 unsigned
multiply. This requires a two pairs of SLLI+SRLI to zero the
upper 32 bits of the inputs.

We can do better than this by using two SLLI to move the lower
bits to the upper bits then use MULHU to compute the product. This
is the high half of a full 64x64 product. Since we put 32 0s in the lower
bits of the inputs we know the 128-bit product will have zeros in the
lower 64 bits. So the upper 64 bits, which MULHU computes, will contain
the original 64 bit product we were after.

The same trick would work for (mul (sext_inreg X, i32), (sext_inreg Y, i32))
using MULHS, but sext_inreg is sext.w which is already one instruction so we
wouldn't save anything.

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

3 years ago[IRSim] Adding basic implementation of llvm-sim.
Andrew Litteken [Thu, 17 Sep 2020 20:43:40 +0000 (15:43 -0500)]
[IRSim] Adding basic implementation of llvm-sim.

This is a similarity visualization tool that accepts a Module and
passes it to the IRSimilarityIdentifier.  The resulting SimilarityGroups
are output in a JSON file.

Tests are found in test/tools/llvm-sim and check for the file not found,
a bad module, and that the JSON is created correctly.

Reviewers: paquette, jroelofs, MaskRay

Recommit of: 15645d044bcfe2a0f63156048b302f997a717688 to fix linking
errors.

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

3 years ago[AIX] Update rpath for BUILD_SHARED_LIBS
Jinsong Ji [Sat, 20 Mar 2021 03:48:48 +0000 (03:48 +0000)]
[AIX] Update rpath for BUILD_SHARED_LIBS

BUILD_SHARED_LIBS build llvm component as shared library,
which can reduce the size a lot.

Normally, the binary use ORIGIN../lib to load component libraries,
unfortunatly, ORIGIN is not supported by AIX ld.

We hardcoded the build lib and install lib path in rpath for now
to enable BUILD_SHARED_LIBS build.

Understand that this is not perfect solution,
we can update this when we find better solution.

Reviewed By: hubert.reinterpretcast

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

3 years ago[test] Fix Driver/gcc-toolchain.cpp if CLANG_DEFAULT_RTLIB is compiler-rt
Fangrui Song [Sat, 20 Mar 2021 20:24:49 +0000 (13:24 -0700)]
[test] Fix Driver/gcc-toolchain.cpp if CLANG_DEFAULT_RTLIB is compiler-rt

3 years ago[BranchProbability] move options for 'likely' and 'unlikely'
Sanjay Patel [Sat, 20 Mar 2021 18:45:56 +0000 (14:45 -0400)]
[BranchProbability] move options for 'likely' and 'unlikely'

This makes the settings available for use in other passes by housing
them within the Support lib, but NFC otherwise.

See D98898 for the proposed usage in SimplifyCFG
(where this change was originally included).

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

3 years ago[lld-macho] Minor touch-up to objc.s
Jez Ng [Sat, 20 Mar 2021 05:03:50 +0000 (01:03 -0400)]
[lld-macho] Minor touch-up to objc.s

3 years ago[AST] Ensure that an empty json file is generated if compile errors
Stephen Kelly [Wed, 17 Mar 2021 23:22:31 +0000 (23:22 +0000)]
[AST] Ensure that an empty json file is generated if compile errors

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

3 years ago[test] Fix Driver/gcc-toolchain.cpp if CLANG_DEFAULT_CXX_STDLIB is libc++
Fangrui Song [Sat, 20 Mar 2021 18:06:44 +0000 (11:06 -0700)]
[test] Fix Driver/gcc-toolchain.cpp if CLANG_DEFAULT_CXX_STDLIB is libc++

3 years ago[VE] Fix types of multiclass template arguments in TableGen files
Fangrui Song [Sat, 20 Mar 2021 17:36:51 +0000 (10:36 -0700)]
[VE] Fix types of multiclass template arguments in TableGen files

There were not properly checked before `[TableGen] Improve handling of template arguments`.

3 years agoRevert "Revert "[Driver] Drop obsoleted Ubuntu 11.04 gcc detection""
Fangrui Song [Sat, 20 Mar 2021 16:57:05 +0000 (09:57 -0700)]
Revert "Revert "[Driver] Drop obsoleted Ubuntu 11.04 gcc detection""

This reverts commit 243333ef3ec6c1e3910eb442177c2e2e927e6a87.

3 years ago[OCaml] Add (get/set)_module_identifer functions
Vaivaswatha Nagaraj [Fri, 19 Mar 2021 14:05:13 +0000 (19:35 +0530)]
[OCaml] Add (get/set)_module_identifer functions

Also:

- Fix a bug that crept in when fixing a buildbot failure in
https://github.com/llvm/llvm-project/commit/f7be9db6220cb39f0eaa12d2af3abedf0d86c303
- Use mlsize_t for cstr_to_string as that is what
caml_alloc_string specifies.

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

3 years ago[lit] Sort testing summary output
David Zarzycki [Sat, 20 Mar 2021 11:52:08 +0000 (07:52 -0400)]
[lit] Sort testing summary output

As fallout from from the record-and-reorder work, people asked that the
summary output be sorted to aid diffing.

3 years agoRevert "[Driver] Drop obsoleted Ubuntu 11.04 gcc detection"
David Zarzycki [Sat, 20 Mar 2021 11:29:01 +0000 (07:29 -0400)]
Revert "[Driver] Drop obsoleted Ubuntu 11.04 gcc detection"

This reverts commit bdf39e6b0ed4b41a1842ac0193f30a726f8d9f63.

The change is failing on Fedora 33 (x86-64).

3 years ago[clang-tidy] Fix bugprone-terminating-continue when continue appears inside a switch
Nathan James [Sat, 20 Mar 2021 10:59:36 +0000 (10:59 +0000)]
[clang-tidy] Fix bugprone-terminating-continue when continue appears inside a switch

Don't emit a warning if the `continue` appears in a switch context as changing it to `break` will break out of the switch rather than a do loop containing the switch.
Fixes https://llvm.org/PR49492.

Reviewed By: aaron.ballman

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

3 years ago[mlir] Additional folding for SelectOp
Butygin [Fri, 12 Mar 2021 14:39:43 +0000 (17:39 +0300)]
[mlir] Additional folding for SelectOp

* Fold SelectOp when both true and false args are same SSA value
* Fold some cmp + select patterns

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

3 years agoRevert of D49126 [PredicateInfo] Use custom mangling to support ssa_copy with unnamed...
Jeroen Dobbelaere [Sat, 20 Mar 2021 10:37:09 +0000 (11:37 +0100)]
Revert of D49126 [PredicateInfo] Use custom mangling to support ssa_copy with unnamed types.

Now that intrinsic name mangling can cope with unnamed types, the custom name mangling in PredicateInfo (introduced by D49126) can be removed.
(See D91250, D48541)

Reviewed By: fhahn

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

3 years ago[X86] Fix a bug when calculating the ldtilecfg insertion points.
Wang, Pengfei [Sat, 20 Mar 2021 04:55:46 +0000 (12:55 +0800)]
[X86] Fix a bug when calculating the ldtilecfg insertion points.

The BB we initialized the ldtilecfg is special. We don't need to check
if its predecessor BBs need to insert ldtilecfg for calls.

We reused the flag HasCallBeforeAMX, so that the predecessors won't be
added to CfgNeedInsert.

This case happens only when the entry BB is in a loop. We need to hoist
the first tile config point out of the loop in future.

Reviewed By: LuoYuanke

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

3 years ago[mlir] Canonicalize IfOp with trivial `then` and `else` bodies to list of SelectOp's
Butygin [Fri, 12 Mar 2021 14:39:43 +0000 (17:39 +0300)]
[mlir] Canonicalize IfOp with trivial `then` and `else` bodies to list of SelectOp's

* Do we need a threshold on maximum number of Yeild arguments processed (maximum number of SelectOp's to be generated)?
* Had to modify some old IfOp tests to not get optimized by this pattern

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

3 years ago[CFLGraph] Fix a crash due to missing handling of freeze
Juneyoung Lee [Sat, 20 Mar 2021 17:14:06 +0000 (02:14 +0900)]
[CFLGraph] Fix a crash due to missing handling of freeze

https://reviews.llvm.org/D85534#2636321

3 years ago[Driver][test] Fix gcc-toolchain.cpp on non-x86_64
Fangrui Song [Sat, 20 Mar 2021 06:50:22 +0000 (23:50 -0700)]
[Driver][test] Fix gcc-toolchain.cpp on non-x86_64

3 years agoTitle: Remove a redundant parameter in clang/unittests/AST/CMakeLists.txt Reviewed...
joker881 [Sat, 20 Mar 2021 04:37:30 +0000 (12:37 +0800)]
Title: Remove a redundant parameter in clang/unittests/AST/CMakeLists.txt Reviewed by: MaskRay Differential Revision: https://reviews.llvm.org/D98922

3 years ago[Driver] Drop obsoleted Ubuntu 11.04 gcc detection
Fangrui Song [Sat, 20 Mar 2021 06:23:28 +0000 (23:23 -0700)]
[Driver] Drop obsoleted Ubuntu 11.04 gcc detection

It has a very broken gcc installation path (usr/lib/i386-linux-gnu/gcc/i686-linux-gnu).

3 years ago[Driver] Delete toplevel i386-gnu/gcc detection in favor of i386-gnu alias triple...
Fangrui Song [Sat, 20 Mar 2021 05:50:35 +0000 (22:50 -0700)]
[Driver] Delete toplevel i386-gnu/gcc detection in favor of i386-gnu alias triple detection

This is used by hurd.c (usr/lib/gcc/i386-gnu/4.6.0) but we can leverage
the existing alias triple detection.

3 years ago[Driver] Drop unneeded $triple/gcc/$triple detection
Fangrui Song [Sat, 20 Mar 2021 05:45:50 +0000 (22:45 -0700)]
[Driver] Drop unneeded $triple/gcc/$triple detection

3 years ago[NFC][ValueTypes] Align code by column
Shao-Ce Sun [Sat, 20 Mar 2021 05:43:07 +0000 (13:43 +0800)]
[NFC][ValueTypes] Align code by column

Adjusted some whitespaces.

Reviewed By: craig.topper

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

3 years ago[mlir][tosa] Add tosa.reverse lowering to linalg.generic
Rob Suderman [Sat, 20 Mar 2021 00:47:39 +0000 (17:47 -0700)]
[mlir][tosa] Add tosa.reverse lowering to linalg.generic

Reverse lowers to a linalg.generic op by reversing the read order
in the index map.

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

3 years ago[AMDGPU] Add MDT update missing from D98915
Carl Ritson [Sat, 20 Mar 2021 04:38:26 +0000 (13:38 +0900)]
[AMDGPU] Add MDT update missing from D98915

3 years ago[libc] Use add_library in add_entrypoint_library instead of invoking ar.
Siva Chandra [Sat, 20 Mar 2021 04:12:33 +0000 (04:12 +0000)]
[libc] Use add_library in add_entrypoint_library instead of invoking ar.

3 years agoUpdate syntax for amx.tile_muli to use two Unit attr to mark the zext case
Mehdi Amini [Sat, 20 Mar 2021 01:23:12 +0000 (01:23 +0000)]
Update syntax for amx.tile_muli to use two Unit attr to mark the zext case

This makes the annotation tied to the operand and the use of a keyword
more explicit/readable on what it means.

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

3 years ago[PowerPC][NFC] Do not produce i64 constants in 32-bit mode
Nemanja Ivanovic [Sat, 20 Mar 2021 03:52:40 +0000 (22:52 -0500)]
[PowerPC][NFC] Do not produce i64 constants in 32-bit mode

There are some instances where we produce constants of type MVT::i64
unconditionally in the target DAG combines. This is not actually
valid in 32-bit mode.

3 years ago[RISCV] Rename WriteShift/ReadShift scheduler classes to WriteShiftImm/ReadShiftImm...
Craig Topper [Sat, 20 Mar 2021 03:39:48 +0000 (20:39 -0700)]
[RISCV] Rename WriteShift/ReadShift scheduler classes to WriteShiftImm/ReadShiftImm. Move variable shifts from WriteIALU/ReadIALU to new WriteShiftReg/ReadShiftReg.

Previously only immediate shifts were in WriteShift. Register
shifts were grouped with IALU. Seems likely that immediate shifts
would be as fast or faster than register shifts. And that immediate
shifts wouldn't be any faster than IALU. So if any deserved to be in
their own group it should be register shifts not immediate shifts.

Rather than try to flip them let's just add more granularity
and give each kind their own class. I've used new names for both to
make them unambiguous and to force any downstream implementations to
be forced to put correct information in their scheduler models.

Reviewed By: evandro

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

3 years ago[Driver] Stop searching other prefixes once a GCC installation is found in one prefix
Fangrui Song [Sat, 20 Mar 2021 03:35:59 +0000 (20:35 -0700)]
[Driver] Stop searching other prefixes once a GCC installation is found in one prefix

so that when --sysroot is specified, the detected GCC installation will not be
overridden by another from /usr which happens to have a larger version.

This behavior is particularly inconvenient when the system has a larger version
GCC while the user wants to try out an older sysroot.

Delete some tests from linux-ld.c which overlap with cross-linux.c

3 years ago[AMDGPU] Rename SIInsertSkips Pass
Carl Ritson [Sat, 20 Mar 2021 02:27:52 +0000 (11:27 +0900)]
[AMDGPU] Rename SIInsertSkips Pass

Pass no longer handles skips.  Pass now removes unnecessary
unconditional branches and lowers early termination branches.
Hence rename to SILateBranchLowering.

Move code to handle returns to epilog from SIPreEmitPeephole
into SILateBranchLowering. This means SIPreEmitPeephole only
contains optional optimisations, and all required transforms
are in SILateBranchLowering.

Reviewed By: arsenm

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

3 years ago[AMDGPU] Merge SIRemoveShortExecBranches into SIPreEmitPeephole
Carl Ritson [Sat, 20 Mar 2021 01:29:08 +0000 (10:29 +0900)]
[AMDGPU] Merge SIRemoveShortExecBranches into SIPreEmitPeephole

SIRemoveShortExecBranches is an optimisation so fits well in the
context of SIPreEmitPeephole.

Test changes relate to early termination from kills which have now
been lowered prior to considering branches for removal.
As these use s_cbranch the execz skips are now retained instead.
Currently either behaviour is valid as kill with EXEC=0 is a nop;
however, if early termination is used differently in future then
the new behaviour is the correct one.

Reviewed By: foad

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

3 years ago[llvm-jitlink] Scan input files for first object to determine triple.
Lang Hames [Sat, 20 Mar 2021 02:13:50 +0000 (19:13 -0700)]
[llvm-jitlink] Scan input files for first object to determine triple.

The previous logic would crash if the first input file was an archive rather
than an object.

3 years ago[Utils][vim] Highlight `poison` keyword
Senran Zhang [Sat, 20 Mar 2021 02:09:11 +0000 (19:09 -0700)]
[Utils][vim] Highlight `poison` keyword

Reviewed By: awarzynski, MaskRay

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

3 years ago[mlir][python] Adapt to `segment_sizes` attribute type change.
Stella Laurenzo [Sat, 20 Mar 2021 01:44:51 +0000 (18:44 -0700)]
[mlir][python] Adapt to `segment_sizes` attribute type change.

* Broken by https://reviews.llvm.org/rG1a75be0023cd80fd8560d689999a63d4368c90e6

3 years ago[JITLink] Remove redundant local variable definitions from a unit test.
Lang Hames [Sat, 20 Mar 2021 00:31:29 +0000 (17:31 -0700)]
[JITLink] Remove redundant local variable definitions from a unit test.

3 years ago[mlir][python] Function decorator for capturing a FuncOp from a python function.
Stella Laurenzo [Fri, 19 Mar 2021 22:43:42 +0000 (15:43 -0700)]
[mlir][python] Function decorator for capturing a FuncOp from a python function.

* Moves this out of a test case where it was being developed to good effect and generalizes it.
* Having tried a number of things like this, I think this balances concerns reasonably well.

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

3 years ago[AMDGPU] Allow index optimisation in SIPreEmitPeephole for bundles
Carl Ritson [Sat, 20 Mar 2021 01:03:26 +0000 (10:03 +0900)]
[AMDGPU] Allow index optimisation in SIPreEmitPeephole for bundles

Add code so duplication index register changes can be removed from
inside bundles.

Reviewed By: rampitec, foad

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

3 years ago[NFC] [PowerPC] Determine Endianness in PPCTargetMachine
Anshil Gandhi [Sat, 20 Mar 2021 00:59:45 +0000 (19:59 -0500)]
[NFC] [PowerPC] Determine Endianness in PPCTargetMachine

The TargetMachine uses the triple to determine endianness. Just
use that logic rather than replicating it in PPCSubtarget.

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

3 years ago[mlir][docs] Remove the BuiltinDialect documentation from langref and generate it...
River Riddle [Sat, 20 Mar 2021 01:19:16 +0000 (18:19 -0700)]
[mlir][docs] Remove the BuiltinDialect documentation from langref and generate it from ODS

Now that all of the builtin dialect is generated from ODS, its documentation in LangRef can be split out and replaced with references to Dialects/Builtin.md. LangRef is quite crusty right now and should really have a full cleanup done in a followup.

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

3 years ago[testsuite] Make testsuite more stable vs canonicalization change. NFC.
Chris Lattner [Sat, 20 Mar 2021 00:57:47 +0000 (17:57 -0700)]
[testsuite] Make testsuite more stable vs canonicalization change.  NFC.

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

3 years agoRevert "[lldb] Make the API, Shell and Unit tests independent lit test suites"
Jonas Devlieghere [Sat, 20 Mar 2021 00:57:17 +0000 (17:57 -0700)]
Revert "[lldb] Make the API, Shell and Unit tests independent lit test suites"

This reverts commit 6c52d4fd4c24a0cf738e44516ca8378d65dcf019.

3 years ago[Driver] Delete compatibility aliases -mpie-copy-relocations and -mno-pie-copy-reloca...
Fangrui Song [Sat, 20 Mar 2021 00:47:29 +0000 (17:47 -0700)]
[Driver] Delete compatibility aliases -mpie-copy-relocations and -mno-pie-copy-relocations

They should be unused everywhere.

3 years agoEmpty test commit, verifying commit access
Dhruva Chakrabarti [Sat, 20 Mar 2021 00:40:37 +0000 (17:40 -0700)]
Empty test commit, verifying commit access

3 years ago[mlir][NFC] Use the native range instead of APInt when computing operand ranges
River Riddle [Sat, 20 Mar 2021 00:11:23 +0000 (17:11 -0700)]
[mlir][NFC] Use the native range instead of APInt when computing operand ranges

This removes the need to construct an APInt for each value, given that it is guaranteed to contain 32 bit elements.

BEGIN_PUBLIC
    ...text exposed to open source public git repo...
END_PUBLIC

3 years ago[mlir] Update `simplifyRegions` to use RewriterBase for erasure notifications
River Riddle [Fri, 19 Mar 2021 23:19:23 +0000 (16:19 -0700)]
[mlir] Update `simplifyRegions` to use RewriterBase for erasure notifications

This allows for notifying callers when operations/blocks get erased, which is especially useful for the greedy pattern driver. The current greedy pattern driver "throws away" all information on constants in the operation folder because it doesn't know if they get erased or not. By passing in RewriterBase, we can directly track this and prevent the need for the pattern driver to rediscover all of the existing constants. In some situations this cuts the compile time of the canonicalizer in half.

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

3 years agogn build: Unbreak Android cross-compilation.
Peter Collingbourne [Fri, 19 Mar 2021 23:23:30 +0000 (16:23 -0700)]
gn build: Unbreak Android cross-compilation.

- D96404 defaulted to libunwind which isn't provided by NDK r21
  (or r22), so specify -rtlib=libgcc on non-arm32.
- D97993 means that we need to use --gcc-toolchain instead of -B
  to let the driver find libgcc.

3 years agoPort D97640 to llvm/include/llvm/ProfileData/InstrProfData.inc
Ellis Hoag [Fri, 19 Mar 2021 23:24:16 +0000 (16:24 -0700)]
Port D97640 to llvm/include/llvm/ProfileData/InstrProfData.inc

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

3 years ago[JITLink] Don't issue lookups for empty symbol sets.
Lang Hames [Fri, 19 Mar 2021 21:54:07 +0000 (14:54 -0700)]
[JITLink] Don't issue lookups for empty symbol sets.

Issuing a lookup for an empty symbol set is legal, but can actually result in
unrelated work being done if there was a work queue left over from the previous
lookup. We can avoid doing this unrelated work (reducing stack depth and
interleaving of debugging output) by not issuing these no-op lookups in the
first place.

3 years agoAdd type attributes to LLVM C API
Christoffer Lernö [Fri, 19 Mar 2021 22:55:52 +0000 (18:55 -0400)]
Add type attributes to LLVM C API

The LLVM C API is missing type attributes as is needed by attributes
such as sret and byval. This patch adds three missing wrapper
functions.

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

https://reviews.llvm.org/D97763

3 years ago[lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY (reapply)
Vedant Kumar [Thu, 18 Mar 2021 18:12:17 +0000 (11:12 -0700)]
[lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY (reapply)

In general, it seems like the debugger should allow programs to load & run with
libraries as far as possible, instead of defaulting to being super-picky about
unavailable symbols.

This is critical on macOS/Darwin, as libswiftCore.dylib may 1) export a version
symbol using @available markup and then 2) expect that other exported APIs are
only dynamically used once the version symbol is checked. We can't open a
version of the library built with a bleeding-edge SDK on an older OS without
RTLD_LAXY (or pervasive/expensive @available markup added to dyld APIs).

This was previously committed as cb8c1ee269da and reverted due to
unknown failures on the Linux bots. This version adds additional asserts
to check that the shared objects are where we expect them & that calling
f1() from libt1 produces the expected value. The Linux failure is
tracked by https://bugs.llvm.org/show_bug.cgi?id=49656.

See: https://lists.llvm.org/pipermail/lldb-dev/2021-March/016796.html

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

3 years ago[docs] Improve documentation of -B and --gcc-toolchain
Fangrui Song [Fri, 19 Mar 2021 22:42:37 +0000 (15:42 -0700)]
[docs] Improve documentation of -B and --gcc-toolchain

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

3 years ago[Driver] Suppress GCC detection under -B
Fangrui Song [Fri, 19 Mar 2021 22:42:18 +0000 (15:42 -0700)]
[Driver] Suppress GCC detection under -B

In GCC, if `-B $prefix` is specified, `$prefix` is used to find executable files and startup files.
`$prefix/include` is added as an include search directory.

Clang overloads -B with GCC installation detection semantics which make the
behavior less predictable (due to the "largest GCC version wins" rule) and
interact poorly with --gcc-toolchain (--gcc-toolchain can be overridden by -B).

* `clang++ foo.cpp` detects GCC installation under `/usr`.
* `clang++ --gcc-toolchain=Inputs foo.cpp` detects GCC installation under `Inputs`.
* `clang++ -BA --gcc-toolchain=B foo.cpp` detects GCC installation under A and B and the larger version wins. With this patch, only B is used for detection.
* `clang++ -BA foo.cpp` detects GCC installation under `A` and `/usr`, and the larger GCC version wins. With this patch `A` is not used for detection.

This patch changes -B to drop the GCC detection semantics.  Its executable
searching semantics are preserved.  --gcc-toolchain is the recommended option to
specify the GCC installation detection directory.

(
Note: Clang detects GCC installation in various target dependent directories.
`$sysroot/usr` (sysroot defaults to "") is a common directory used by most targets.
Such a directory is expected to contain something like `lib{,32,64}/gcc{,-cross}/$triple`.
Clang will then construct library/include paths from the directory.
)

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

3 years agoRevert "[lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY"
Vedant Kumar [Fri, 19 Mar 2021 22:26:16 +0000 (15:26 -0700)]
Revert "[lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY"

This reverts commit cb8c1ee269da72eb6e2c18800cd8ab0a74050785. The test
is failing on Debian for unknown reasons.

https://lab.llvm.org/buildbot/#/builders/68/builds/8990

3 years ago[lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY
Vedant Kumar [Thu, 18 Mar 2021 18:12:17 +0000 (11:12 -0700)]
[lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY

In general, it seems like the debugger should allow programs to load & run with
libraries as far as possible, instead of defaulting to being super-picky about
unavailable symbols.

This is critical on macOS/Darwin, as libswiftCore.dylib may 1) export a version
symbol using @available markup and then 2) expect that other exported APIs are
only dynamically used once the version symbol is checked. We can't open a
version of the library built with a bleeding-edge SDK on an older OS without
RTLD_LAXY (or pervasive/expensive @available markup added to dyld APIs).

See: https://lists.llvm.org/pipermail/lldb-dev/2021-March/016796.html

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

3 years ago[NewPM] Verify LoopAnalysisResults after a loop pass
Arthur Eubanks [Fri, 19 Mar 2021 21:30:48 +0000 (14:30 -0700)]
[NewPM] Verify LoopAnalysisResults after a loop pass

All loop passes should preserve all analyses in LoopAnalysisResults. Add
checks for those when the checks are enabled (which is by default with
expensive checks on).

Note that due to PR44815, we don't check LAR's ScalarEvolution.
Apparently calling SE.verify() can change its results.

This is a reland of https://reviews.llvm.org/D98820 which was reverted
due to unacceptably large compile time regressions in normal debug
builds.

3 years ago[GlobalISel] Add G_SBFX + G_UBFX (bitfield extraction opcodes)
Jessica Paquette [Thu, 11 Mar 2021 23:36:01 +0000 (15:36 -0800)]
[GlobalISel] Add G_SBFX + G_UBFX (bitfield extraction opcodes)

There is a bunch of similar bitfield extraction code throughout *ISelDAGToDAG.

E.g, ARMISelDAGToDAG, AArch64ISelDAGToDAG, and AMDGPUISelDAGToDAG all contain
code that matches a bitfield extract from an and + right shift.

Rather than duplicating code in the same way, this adds two opcodes:

- G_UBFX (unsigned bitfield extract)
- G_SBFX (signed bitfield extract)

They work like this

```
%x = G_UBFX %y, %lsb, %width
```

Where `lsb` and `width` are

- The least-significant bit of the extraction
- The width of the extraction

This will extract `width` bits from `%y`, starting at `lsb`. G_UBFX zero-extends
the result, while G_SBFX sign-extends the result.

This should allow us to use the combiner to match the bitfield extraction
patterns rather than duplicating pattern-matching code in each target.

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

3 years ago[mlir][Pass] Coalesce dynamic pass pipelines before running
River Riddle [Fri, 19 Mar 2021 21:20:14 +0000 (14:20 -0700)]
[mlir][Pass] Coalesce dynamic pass pipelines before running

This was missed when dynamic pass pipelines were added, and is necessary for maximizing the performance/parallelism potential of the pass pipeline.

3 years ago[llvm-readobj] Remove legacy GNU_PROPERTY_X86_ISA_1_{NEEDED,USED} and dump new GNU_PR...
Fangrui Song [Fri, 19 Mar 2021 21:35:22 +0000 (14:35 -0700)]
[llvm-readobj] Remove legacy GNU_PROPERTY_X86_ISA_1_{NEEDED,USED} and dump new GNU_PROPERTY_X86_ISA_1_{NEEDED,USED}

https://sourceware.org/bugzilla/show_bug.cgi?id=26703 deprecated the
previous GNU_PROPERTY_X86_ISA_1_{CMOV,SSE,*} values (renamed to `COMPAT`)
and added new values.

Since the legacy values are not used by compilers, having dumping support in
llvm-readobj is unnecessary. So just drop the legacy feature.

The new values are used by GCC 11
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97250) `-march=x86-64-v[234]` to
indicate the micro-architecture ISA levels.

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

3 years ago[lldb] Update assert.test to be less strict
Jonas Devlieghere [Fri, 19 Mar 2021 21:31:22 +0000 (14:31 -0700)]
[lldb] Update assert.test to be less strict

Be less strict when checking for the assert substring.

3 years agoRevert "[NewPM] Verify LoopAnalysisResults after a loop pass"
Arthur Eubanks [Fri, 19 Mar 2021 21:31:08 +0000 (14:31 -0700)]
Revert "[NewPM] Verify LoopAnalysisResults after a loop pass"

This reverts commit 94c269baf58330a5e303a4f86f64681f2f7a858b.

Still causes too large of compile time regression in normal debug
builds. Will put under expensive checks instead.

3 years ago[lldb] Call os_log_fault on lldb_assert
Jonas Devlieghere [Fri, 19 Mar 2021 21:20:26 +0000 (14:20 -0700)]
[lldb] Call os_log_fault on lldb_assert

Call `os_log_fault` when an lldb assert fails. We piggyback off
`LLVM_SUPPORT_XCODE_SIGNPOSTS`, which also depends on `os_log`, to avoid
having to introduce another CMake check and corresponding define.

This patch also adds a small test using lldb-test that verifies we abort
with a "regular" assertion when asserts are enabled.

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

3 years ago[llvm] Add assertions for the smart pointers with the possibility to be null in Modul...
Ella Ma [Fri, 19 Mar 2021 04:14:13 +0000 (21:14 -0700)]
[llvm] Add assertions for the smart pointers with the possibility to be null in ModuleLazyLoaderCache::operator()

Split from D91844.

The return value of function `ModuleLazyLoaderCache::operator()` in file llvm/tools/llvm-link/llvm-link.cpp. According to the bug report of my static analyzer, the std::function variable `ModuleLazyLoaderCache::createLazyModule` points to function `loadFile`, which may return `nullptr` when error. And the pointer is dereferenced without a check.

Reviewed By: tejohnson

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

3 years agoNFC: Break up the mlir python bindings into individual sources.
Stella Laurenzo [Fri, 19 Mar 2021 18:57:01 +0000 (11:57 -0700)]
NFC: Break up the mlir python bindings into individual sources.

* IRModules.cpp -> (IRCore.cpp, IRAffine.cpp, IRAttributes.cpp, IRTypes.cpp).
* The individual pieces now compile in the 5-15s range whereas IRModules.cpp was starting to approach a minute (didn't capture a before time).
* More fine grained splitting is possible, but this represents the most obvious.

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

3 years ago[NewPM] Verify LoopAnalysisResults after a loop pass
Arthur Eubanks [Wed, 17 Mar 2021 21:53:57 +0000 (14:53 -0700)]
[NewPM] Verify LoopAnalysisResults after a loop pass

    All loop passes should preserve all analyses in LoopAnalysisResults. Add
    checks for those.

    Note that due to PR44815, we don't check LAR's ScalarEvolution.
    Apparently calling SE.verify() can change its results.

    Only verify MSSA when VerifyMemorySSA, normally it's very expensive.

Reviewed By: asbirlea

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

3 years ago[MLIR] Test pattern benefit sorting between operation specific and operation agnostic...
Butygin [Fri, 12 Mar 2021 14:39:43 +0000 (17:39 +0300)]
[MLIR] Test pattern benefit sorting between operation specific and operation agnostic patterns.

Previously low benefit op-specific patterns never had a chance to match
even if high benefit op-agnostic pattern failed to match.

This was already fixed upstream, this commit just adds testscase

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

3 years ago[mlir][Linalg] Make LLVM_DEBUG region bigger to avoid warnings in Release builds
Benjamin Kramer [Fri, 19 Mar 2021 19:56:59 +0000 (20:56 +0100)]
[mlir][Linalg] Make LLVM_DEBUG region bigger to avoid warnings in Release builds

Transforms.cpp:586:16: error: unused variable 'v' [-Werror,-Wunused-variable]
    for (Value v : operands)
               ^

3 years ago[CodeGen] Don't crash on for loops with cond variables and no increment
Benjamin Kramer [Fri, 19 Mar 2021 19:35:17 +0000 (20:35 +0100)]
[CodeGen] Don't crash on for loops with cond variables and no increment

This looks like an oversight from a875721d8a2d, creating IR that refers
to `for.inc` even if it doesn't exist.

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

3 years agoRevert "Make the stop-on-sharedlibrary-events setting work."
Jim Ingham [Fri, 19 Mar 2021 19:38:41 +0000 (12:38 -0700)]
Revert "Make the stop-on-sharedlibrary-events setting work."

This reverts commit 9406d43138811ac4dfd0ab31434f65a649bc882e.

I messed up a test, and when I got it right it was failing.  The changed logic
doesn't work quite right (now the async callback called at sync time is
forcing us to stop.  I need to be a little more careful about that.

3 years agoRevert "Skip all the tests for Windows."
Jim Ingham [Fri, 19 Mar 2021 19:38:23 +0000 (12:38 -0700)]
Revert "Skip all the tests for Windows."

This reverts commit a8d62fc8ff1c836e16cfb1a510ee8063ac2652ff.

3 years ago[SLP] remove unnecessary characters in test; NFC
Sanjay Patel [Fri, 19 Mar 2021 19:09:53 +0000 (15:09 -0400)]
[SLP] remove unnecessary characters in test; NFC

Glitch that crept in with 62f9c3358b81

3 years ago[SLP] add tests for min/max reductions that use intrinsics; NFC
Sanjay Patel [Fri, 19 Mar 2021 19:05:52 +0000 (15:05 -0400)]
[SLP] add tests for min/max reductions that use intrinsics; NFC

3 years agoSkip all the tests for Windows.
Jim Ingham [Fri, 19 Mar 2021 19:05:16 +0000 (12:05 -0700)]
Skip all the tests for Windows.

3 years agoMake the stop-on-sharedlibrary-events setting work.
Jim Ingham [Fri, 19 Mar 2021 18:56:46 +0000 (11:56 -0700)]
Make the stop-on-sharedlibrary-events setting work.

We weren't taking into account the "m_should_stop" setting that the
synchronous breakpoint callback had already set when we did PerformAction
in the StopInfoBreakpoint.  So we didn't obey its instructions when it
told us to stop.  Fixed that and added some tests both for when we
just have the setting, and when we have the setting AND other breakpoints
at the shared library load notification breakpoint address.

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

3 years ago[libc++] NFCI: Remove dead code in the Lit configuration
Louis Dionne [Thu, 18 Mar 2021 21:05:25 +0000 (14:05 -0700)]
[libc++] NFCI: Remove dead code in the Lit configuration

I was trying to fix something else and I stumbled upon several methods
that are not used anymore in target_info.py.

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

3 years ago[Flang][OpenMP] Add more sema checks for ordered construct
Arnamoy Bhattacharyya [Fri, 19 Mar 2021 18:54:06 +0000 (14:54 -0400)]
[Flang][OpenMP] Add more sema checks for ordered construct

This patch fixes a bug to allow ordered construct within a non-worksharing loop, also adds more sema checks.

Reviewed By: kiranchandramohan

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

3 years ago[AArch64] Fix LowerMGATHER to return the chain result for floating point gathers.
Craig Topper [Fri, 19 Mar 2021 18:23:27 +0000 (11:23 -0700)]
[AArch64] Fix LowerMGATHER to return the chain result for floating point gathers.

Found by adding asserts to LegalizeDAG to make sure custom legalized
results had the right types.

Reviewed By: kmclaughlin

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

3 years ago[mlir][tosa] Add tosa.cast to linalg lowering
Rob Suderman [Fri, 19 Mar 2021 18:42:22 +0000 (11:42 -0700)]
[mlir][tosa] Add tosa.cast to linalg lowering

Handles lowering from the tosa CastOp to the equivalent linalg lowering. It
includes support for interchange between bool, int, and floating point.

Reviewed By: antiagainst

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

3 years ago[mlir][tosa] Add tosa.logical_* to linalg lowerings
Rob Suderman [Fri, 19 Mar 2021 18:24:52 +0000 (11:24 -0700)]
[mlir][tosa] Add tosa.logical_* to linalg lowerings

Adds lowerings for logical_* boolean operations. Each of these ops only operate
on booleans allowing simple lowerings.

Reviewed By: NatashaKnk

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

3 years ago[ARM] Tone down the MVE scalarization overhead
David Green [Fri, 19 Mar 2021 18:30:11 +0000 (18:30 +0000)]
[ARM] Tone down the MVE scalarization overhead

The scalarization overhead was set deliberately high for MVE, whilst the
codegen was new. It helps protect us against the negative ramifications
of mixing scalar and vector instructions. This decreases that,
especially for floating point where the cost of extracting/inserting
lane elements can be low. For integer the cost is still fairly high due
to the cross-register-bank copy, but is no longer n^2 in the length of
the vector.

In general, this will decrease the cost of scalarizing floats and long
integer vectors. i64 increase in cost, having a high cost before and
after this patch. For floats this allows up to start doing things like
vectorizing fdiv instructions, even if they are scalarized.

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

3 years ago[mlir][linalg] Add structured op builders from python opdsl.
Stella Laurenzo [Wed, 17 Mar 2021 01:05:19 +0000 (18:05 -0700)]
[mlir][linalg] Add structured op builders from python opdsl.

* Makes the wrapped functions of the `@linalg_structured_op` decorator callable such that they emit IR imperatively when invoked.
* There are numerous TODOs that I will keep working through to achieve generality.
* Will true up exception handling tests as the feature progresses (for things that are actually errors once everything is implemented).
* Includes the addition of an `isinstance` method on concrete types in the Python API.

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

3 years ago[lld-macho][nfc] Fixed typo in comment
Vy Nguyen [Fri, 19 Mar 2021 18:17:51 +0000 (14:17 -0400)]
[lld-macho][nfc] Fixed typo in comment

Missed this one from https://reviews.llvm.org/D97007?id=331759#inline-930034

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

3 years agoUpdate basic deref API to account for possiblity of free [NFC]
Philip Reames [Fri, 19 Mar 2021 18:15:29 +0000 (11:15 -0700)]
Update basic deref API to account for possiblity of free [NFC]

This patch is plumbing to support work towards the goal outlined in the recent llvm-dev post "[llvm-dev] RFC: Decomposing deref(N) into deref(N) + nofree".

The point of this change is purely to simplify iteration on other pieces on way to making the switch. Rebuilding with a change to Value.h is slow and painful, so I want to get the API change landed. Once that's done, I plan to more closely audit each caller, add the inference rules in their own patch, then post a patch with the langref changes and test diffs. The value of the command line flag is that we can exercise the inference logic in standalone patches without needing the whole switch ready to go just yet.

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

3 years ago [lld-macho] Define __mh_*_header synthetic symbols.
Vy Nguyen [Thu, 18 Mar 2021 22:49:45 +0000 (18:49 -0400)]
[lld-macho] Define __mh_*_header synthetic symbols.

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

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

3 years ago[lldb] Make the API, Shell and Unit tests independent lit test suites
Jonas Devlieghere [Fri, 19 Mar 2021 18:11:59 +0000 (11:11 -0700)]
[lldb] Make the API, Shell and Unit tests independent lit test suites

Make the API, Shell and Unit tests independent lit test suites. This
allows us to specify different dependencies and skip rebuilding all the
unit test (which is particularly expensive) when running check-lldb-api
or check-lldb-shell.

This does not change the autogenerated targets such as
check-lldb-shell-driver or the top level check-lldb target, which all
continue to work as before.

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

3 years ago[Cost]Canonicalize the cost for logical or/and reductions.
Alexey Bataev [Tue, 2 Mar 2021 18:53:49 +0000 (10:53 -0800)]
[Cost]Canonicalize the cost for logical or/and reductions.

The generic cost of logical or/and reductions should be cost of bitcast
<ReduxWidth x i1> to iReduxWidth + cmp eq|ne iReduxWidth.

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

3 years ago[LangRef] Describe memory layout for vectors types
Bjorn Pettersson [Tue, 16 Mar 2021 11:47:16 +0000 (12:47 +0100)]
[LangRef] Describe memory layout for vectors types

There are a couple of caveats when it comes to how vectors are
stored to memory, and thereby also how bitcast between vector
and integer types work, in LLVM IR. Specially in relation to
endianess. This patch is an attempt to document such things.

Reviewed By: nlopes

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

3 years ago[RISCV] Add missing bitcasts to the results of lowerINSERT_SUBVECTOR and lowerEXTRACT...
Craig Topper [Fri, 19 Mar 2021 17:47:47 +0000 (10:47 -0700)]
[RISCV] Add missing bitcasts to the results of lowerINSERT_SUBVECTOR and lowerEXTRACT_SUBVECTOR when handling mask vectors.

Found by adding asserts to LegalizeDAG to catch incorrect result
types being returned.

Reviewed By: frasercrmck

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

3 years ago[Hexagon] Return an i64 for result 0 from LowerREADCYCLECOUNTER instead of an i32.
Craig Topper [Fri, 19 Mar 2021 17:47:32 +0000 (10:47 -0700)]
[Hexagon] Return an i64 for result 0 from LowerREADCYCLECOUNTER instead of an i32.

As far as I can tell, the node coming in has an i64 result so the
return should have the same type. The HexagonISD node used for
this has a type profile that says the result is i64.

Found while trying to add assserts to LegalizeDAG to catch
result type mismatches.

Reviewed By: kparzysz

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

3 years ago[dfsan] Turn on testing origin tracking at atomics.ll
Jianzhou Zhao [Fri, 19 Mar 2021 17:53:13 +0000 (17:53 +0000)]
[dfsan] Turn on testing origin tracking at atomics.ll

3 years ago[NFC][VPlan] Guard print routines with "#if !defined(NDEBUG) || defined(LLVM_ENABLE_D...
Andrei Elovikov [Fri, 19 Mar 2021 16:41:44 +0000 (09:41 -0700)]
[NFC][VPlan] Guard print routines with "#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)"

Reviewed By: mehdi_amini

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

3 years ago[VPlan] Add plain text (not DOT's digraph) dumps
Andrei Elovikov [Thu, 18 Mar 2021 18:32:34 +0000 (11:32 -0700)]
[VPlan] Add plain text (not DOT's digraph) dumps

I foresee two uses for this:
1) It's easier to use those in debugger.
2) Once we start implementing more VPlan-to-VPlan transformations (especially
   inner loop massaging stuff), using the vectorized LLVM IR as CHECK targets in
   LIT test would become too obscure. I can imagine that we'd want to CHECK
   against VPlan dumps after multiple transformations instead. That would be
   easier with plain text dumps than with DOT format.

Reviewed By: fhahn

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