platform/upstream/llvm.git
2 years agoFix a few unitialized class members in MLIR (NFC)
Mehdi Amini [Sat, 1 Jan 2022 01:39:04 +0000 (01:39 +0000)]
Fix a few unitialized class members in MLIR (NFC)

Flagged by Coverity.

2 years ago[SelectionDAG] Use KnownBits::countMinSignBits() to simplify the end of ComputeNumSig...
Craig Topper [Sat, 1 Jan 2022 01:29:57 +0000 (17:29 -0800)]
[SelectionDAG] Use KnownBits::countMinSignBits() to simplify the end of ComputeNumSignBits.

This matches what is done in ValueTracking.cpp

Reviewed By: RKSimon, foad

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

2 years ago[RISCV][LegalizeIntegerTypes] Teach PromoteSetCCOperands not to sext i32 comparisons...
Craig Topper [Sat, 1 Jan 2022 01:13:36 +0000 (17:13 -0800)]
[RISCV][LegalizeIntegerTypes] Teach PromoteSetCCOperands not to sext i32 comparisons for RV64 if the promoted values are already zero extended.

This is similar to what is done for targets that prefer zero extend
where we avoid using a zero extend if the promoted values are sign
extended.

We'll also check for zero extended operands for ugt, ult, uge, and ule when the
target prefers sign extend. This is different than preferring zero extend, where
we only check for sign bits on equality comparisons.

Reviewed By: RKSimon

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

2 years agoRemove redundant return after return in CodegenStrategy (NFC)
Mehdi Amini [Sat, 1 Jan 2022 01:14:27 +0000 (01:14 +0000)]
Remove redundant return after return in CodegenStrategy (NFC)

Reported by Coverity

2 years ago[mlir][LLVMIR] Add `llvm.eh.typeid.for` intrinsic
Markus Böck [Sat, 1 Jan 2022 01:03:00 +0000 (02:03 +0100)]
[mlir][LLVMIR] Add `llvm.eh.typeid.for` intrinsic

MLIR already exposes landingpads, the invokeop and the personality function on LLVM functions. With this intrinsic it should be possible to implement exception handling via the exception handling mechanisms provided by the Itanium ABI.

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

2 years ago[AMDGPU] Remove unused declarations fold_exp* and fold_log* (NFC)
Kazu Hirata [Sat, 1 Jan 2022 00:50:18 +0000 (16:50 -0800)]
[AMDGPU] Remove unused declarations fold_exp* and fold_log* (NFC)

2 years ago[AMDGPU] Remove replaceWithNative (NFC)
Kazu Hirata [Sat, 1 Jan 2022 00:43:06 +0000 (16:43 -0800)]
[AMDGPU] Remove replaceWithNative (NFC)

The function was introduced without any use on Aug 11, 2017 in commit
7f37794ebd2c6c36224597800e4d1e5a99ad80e9.

2 years ago[X86] Remove unused declaration getTileStoreShape (NFC)
Kazu Hirata [Sat, 1 Jan 2022 00:06:19 +0000 (16:06 -0800)]
[X86] Remove unused declaration getTileStoreShape (NFC)

2 years ago[Hexagon] Use range-based for loops (NFC)
Kazu Hirata [Fri, 31 Dec 2021 23:17:25 +0000 (15:17 -0800)]
[Hexagon] Use range-based for loops (NFC)

2 years agofix test so it doesn't use nonnull assumes on non-pointers
Nuno Lopes [Fri, 31 Dec 2021 23:04:46 +0000 (23:04 +0000)]
fix test so it doesn't use nonnull assumes on non-pointers
The IR verifier should probably catch this. Alive2 did, though.

2 years ago[CodeGen] Remove unused forward declarations (NFC)
Kazu Hirata [Fri, 31 Dec 2021 22:10:30 +0000 (14:10 -0800)]
[CodeGen] Remove unused forward declarations (NFC)

2 years ago[Scalar] Remove a redundant declaration (NFC)
Kazu Hirata [Fri, 31 Dec 2021 22:02:29 +0000 (14:02 -0800)]
[Scalar] Remove a redundant declaration (NFC)

InitializePasses.h contains the proper declaration.

Identified with readability-redundant-declaration.

2 years ago[clang-tidy] Use nullptr instead of 0 or NULL (NFC)
Kazu Hirata [Fri, 31 Dec 2021 21:54:34 +0000 (13:54 -0800)]
[clang-tidy] Use nullptr instead of 0 or NULL (NFC)

Identified with modernize-use-nullptr.

2 years ago[InstSimplify] fold or-nand-xor
Sanjay Patel [Fri, 31 Dec 2021 20:10:19 +0000 (15:10 -0500)]
[InstSimplify] fold or-nand-xor

~(A & B) | (A ^ B) --> ~(A & B)

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

2 years ago[InstSimplify] add tests for or-nand-xor; NFC
Sanjay Patel [Fri, 31 Dec 2021 20:06:23 +0000 (15:06 -0500)]
[InstSimplify] add tests for or-nand-xor; NFC

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

Extracted from D99484. My new plan is to start from the outside and work
inward.

Reviewed By: stephenneuendorffer

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

2 years ago[lld][CMake] Use `GNUInstallDirs` to support custom installation dirs
John Ericson [Thu, 30 Dec 2021 06:22:48 +0000 (06:22 +0000)]
[lld][CMake] Use `GNUInstallDirs` to support custom installation dirs

Extracted from D99484. My new plan is to start from the outside and work
inward.

Reviewed By: stephenneuendorffer

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

2 years ago[clang-tools-extra] Remove unused using (NFC)
Kazu Hirata [Fri, 31 Dec 2021 18:51:10 +0000 (10:51 -0800)]
[clang-tools-extra] Remove unused using (NFC)

Identified by misc-unused-using-decls.

2 years ago[Analysis] Remove unused forward declarations (NFC)
Kazu Hirata [Fri, 31 Dec 2021 18:25:16 +0000 (10:25 -0800)]
[Analysis] Remove unused forward declarations (NFC)

2 years ago[ARM] Introduce an empty "armv8.8-a" architecture.
Simon Tatham [Thu, 11 Feb 2021 11:11:55 +0000 (11:11 +0000)]
[ARM] Introduce an empty "armv8.8-a" architecture.

This is the first commit in a series that implements support for
"armv8.8-a" architecture. This should contain all the necessary
boilerplate to make the 8.8-A architecture exist from LLVM and Clang's
point of view: it adds the new arch as a subtarget feature, a definition
in TargetParser, a name on the command line, an appropriate set of
predefined macros, and adds appropriate tests. The new architecture name
is supported in both AArch32 and AArch64.

However, in this commit, no actual _functionality_ is added as part of
the new architecture. If you specify -march=armv8.8a, the compiler
will accept it and set the right predefines, but generate no code any
differently.

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

2 years ago[NFC][SVE] Minor reorder of some AArch64ISD nodes and ISel patterns.
Paul Walker [Fri, 24 Dec 2021 18:10:58 +0000 (18:10 +0000)]
[NFC][SVE] Minor reorder of some AArch64ISD nodes and ISel patterns.

2 years ago[LV] Turn check for unexpected VF into assertion (NFC).
Florian Hahn [Fri, 31 Dec 2021 13:19:03 +0000 (13:19 +0000)]
[LV] Turn check for unexpected VF into assertion (NFC).

VF should always be non-zero in widenIntOrFpInduction. Turn check into
assertion.

2 years ago[MIPS] Add -mfix4300 flag to enable vr4300 mulmul bugfix pass
Random [Mon, 27 Dec 2021 13:12:26 +0000 (16:12 +0300)]
[MIPS] Add -mfix4300 flag to enable vr4300 mulmul bugfix pass

Early revisions of the VR4300 have a hardware bug where two consecutive
multiplications can produce an incorrect result in the second multiply.
This revision adds the `-mfix4300` flag to llvm (and clang) which, when
passed, provides a software fix for this issue.

More precise description of the "mulmul" bug:
```
mul.[s,d] fd,fs,ft
mul.[s,d] fd,fs,ft  or  [D]MULT[U] rs,rt
```

When the above sequence is executed by the CPU, if at least one of the
source operands of the first mul instruction happens to be `sNaN`, `0`
or `Infinity`, then the second mul instruction may produce an incorrect
result. This can happen both if the two mul instructions are next to each
other and if the first one is in a delay slot and the second is the first
instruction of the branch target.

Description of the fix:
This fix adds a backend pass to llvm which scans for mul instructions in
each basic block and inserts a nop whenever the following conditions are
met:

 - The current instruction is a single or double-precision floating-point
   mul instruction.
 - The next instruction is either a mul instruction (any kind) or a branch
   instruction.

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

2 years ago[AMDGPU] Regenerate checks for waitcnt-overflow.mir
Jay Foad [Fri, 31 Dec 2021 11:27:15 +0000 (11:27 +0000)]
[AMDGPU] Regenerate checks for waitcnt-overflow.mir

2 years ago[lldb/qemu] Support setting arg0 of the debugged program
Pavel Labath [Thu, 30 Dec 2021 14:29:00 +0000 (15:29 +0100)]
[lldb/qemu] Support setting arg0 of the debugged program

Just what it says on the box.

2 years ago[RISCV] Use MxListW instead of MxList[0-5]. NFC
Craig Topper [Fri, 31 Dec 2021 08:22:52 +0000 (00:22 -0800)]
[RISCV] Use MxListW instead of MxList[0-5]. NFC

Better to use the named list instead of assuming the size of MxList.

2 years ago[RISCV] Use defvar to simplify some code. NFC
Craig Topper [Fri, 31 Dec 2021 07:47:55 +0000 (23:47 -0800)]
[RISCV] Use defvar to simplify some code. NFC

Rather than wrapping a def around a list, we can just make a defvar
of the list.

2 years ago[RISCV] Use constant pool for large integers
wangpc [Fri, 31 Dec 2021 06:01:53 +0000 (14:01 +0800)]
[RISCV] Use constant pool for large integers

For large integers (for example, magic numbers generated by
TargetLowering::BuildSDIV when dividing by constant), we may
need about 4~8 instructions to build them.
In the same time, it just takes two instructions to load
constants (with extra cycles to access memory), so it may be
profitable to put these integers into constant pool.

Reviewed By: asb, craig.topper

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

2 years ago[RISCV] Fix incorrect cases of vmv.s.f in the VSETVLI insert pass.
jacquesguan [Fri, 31 Dec 2021 02:59:24 +0000 (10:59 +0800)]
[RISCV] Fix incorrect cases of vmv.s.f in the VSETVLI insert pass.

Fix incorrect cases of vmv.s.f and add test cases for it.

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

2 years ago[mlir] Allow IntegerAttr to parse zero width integers.
Stella Laurenzo [Fri, 31 Dec 2021 04:32:49 +0000 (20:32 -0800)]
[mlir] Allow IntegerAttr to parse zero width integers.

https://reviews.llvm.org/D109555 added support to APInt for this, so the special case to disable it is no longer valid. It is in fact legal to construct these programmatically today, and they print properly but do not parse.

Justification: zero bit integers arise naturally in various bit reduction optimization problems, and having them defined for MLIR reduces special casing.

I think there is a solid case for i0 and ui0 being supported. I'm less convinced about si0 and opted to just allow the parser to round-trip values that already verify. The counter argument is that the proper singular value for an si0 is -1. But the counter to this counter is that the sign bit is N-1, which does not exist for si0 and it is not unreasonable to consider this non-existent bit to be 0. Various sources consider it having the singular value "0" to be the least surprising.

Reviewed By: lattner

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

2 years ago[asan] Additionnal prologue decoding for WinSDK 10.0.22000
Alexandre Ganea [Thu, 30 Dec 2021 15:33:25 +0000 (10:33 -0500)]
[asan] Additionnal prologue decoding for WinSDK 10.0.22000

Fixes interception of atoi() entry point.

2 years ago[Sema] a[x] has type T when a has type T* or T[], even when T is dependent
Sam McCall [Mon, 2 Aug 2021 13:56:00 +0000 (15:56 +0200)]
[Sema] a[x] has type T when a has type T* or T[], even when T is dependent

This more precise type is useful for tools, e.g.
fixes https://github.com/clangd/clangd/issues/831

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

2 years ago[ELF] Switch cNamedSections to SmallVector. NFC
Fangrui Song [Fri, 31 Dec 2021 00:08:26 +0000 (16:08 -0800)]
[ELF] Switch cNamedSections to SmallVector. NFC

Make it smaller

2 years ago[LegalizeIntegerTypes] Rename NewLHS/NewRHS arguments to DAGTypeLegalizer::PromoteSet...
Craig Topper [Thu, 30 Dec 2021 23:27:45 +0000 (15:27 -0800)]
[LegalizeIntegerTypes] Rename NewLHS/NewRHS arguments to DAGTypeLegalizer::PromoteSetCCOperands. NFC

The 'New' only makes sense in the context of these being
output arguments, but they are also used as inputs first.
Drop the 'New' and just call them LHS/RHS.

Factored out of D116421.

2 years ago[InstrProf] Mark counters as used in debug correlation mode
Ellis Hoag [Thu, 30 Dec 2021 22:49:50 +0000 (14:49 -0800)]
[InstrProf] Mark counters as used in debug correlation mode

In debug info correlation mode we do not emit the data globals so we
need to explicitly mark the counter globals as used so they don't get
stripped.

Reviewed By: kyulee

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

2 years ago[mlir][Linalg] Change signature of `get(Parallel/Reduce/Window)Dims` method.
MaheshRavishankar [Thu, 30 Dec 2021 22:01:38 +0000 (14:01 -0800)]
[mlir][Linalg] Change signature of `get(Parallel/Reduce/Window)Dims` method.

These method currently takes a SmallVector<AffineExpr> & as an
argument to return the dims as AffineExpr. This creation of
AffineExpr objects is unnecessary.

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

2 years ago[lld][docs] Update _templates/indexsidebar.html after Bugzilla->GitHub issue migration
Fangrui Song [Thu, 30 Dec 2021 21:34:45 +0000 (13:34 -0800)]
[lld][docs] Update _templates/indexsidebar.html after Bugzilla->GitHub issue migration

2 years ago[SLP][NFC]Fix non-determinism in reordering, NFC.
Alexey Bataev [Thu, 30 Dec 2021 21:08:36 +0000 (13:08 -0800)]
[SLP][NFC]Fix non-determinism in reordering, NFC.

Need to clear CurrentOrder order mask if it is determined that
extractelements form identity order and need to use a vector-like
construct when iterating over ordered entries in the reorderTopToBottom
function.

2 years ago[Hexagon] Generate HVX/FP arithmetic instructions
Krzysztof Parzyszek [Thu, 30 Dec 2021 20:38:36 +0000 (12:38 -0800)]
[Hexagon] Generate HVX/FP arithmetic instructions

Co-authored-by: Anirudh Sundar Subramaniam <quic_sanirudh@quicinc.com>
Co-authored-by: Sumanth Gundapaneni <sgundapa@quicinc.com>
Co-authored-by: Joshua Herrera <joshherr@quicinc.com>
2 years ago[libc++][NFC] Fix incorrect synopsis in transform_view test
Louis Dionne [Thu, 30 Dec 2021 20:43:07 +0000 (15:43 -0500)]
[libc++][NFC] Fix incorrect synopsis in transform_view test

2 years ago[mlir][arith] fixing dependencies on memref/arith
Mogball [Thu, 30 Dec 2021 20:39:22 +0000 (20:39 +0000)]
[mlir][arith] fixing dependencies on memref/arith

2 years ago[Hexagon] Generate HVX/FP compare instructions
Krzysztof Parzyszek [Thu, 30 Dec 2021 19:44:48 +0000 (11:44 -0800)]
[Hexagon] Generate HVX/FP compare instructions

Co-authored-by: Anirudh Sundar Subramaniam <quic_sanirudh@quicinc.com>
2 years ago[ELF][LTO] Cache symbol table of lazy BitcodeFile
Fangrui Song [Thu, 30 Dec 2021 20:03:29 +0000 (12:03 -0800)]
[ELF][LTO] Cache symbol table of lazy BitcodeFile

Similar to D62188: a BitcodeFile's symbol table may be iterated twice, once in
--start-lib (lazy) state, and once in the non-lazy state. This patch
makes `parseLazy` save `symbols[i]` so that the non-lazy state does not need to
re-insert to the global symbol table. Avoiding a redundant `saver.save` may save
memory.

`Maximum resident set size (kbytes)` for a large --thinlto-index-only link:

* without the patch: 10164000
* with the patch: 10095716 (0.6% decrease)

Note: we can remove `saver.save` if `BitcodeCompiler::add` does not transfer the ownership
of `f.obj` in `checkError(ltoObj->add(std::move(f.obj), resols));`.

Reviewed By: tejohnson

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

2 years ago[RISCV] Add support for STRICT_LRINT/LLRINT/LROUND/LLROUND. Tests for other strict...
Craig Topper [Thu, 30 Dec 2021 19:41:59 +0000 (11:41 -0800)]
[RISCV] Add support for STRICT_LRINT/LLRINT/LROUND/LLROUND. Tests for other strict intrinsics.

This patch adds isel support for STRICT_LRINT/LLRINT/LROUND/LLROUND.

It also adds test cases for f32 and f64 constrained intrinsics that
correspond to the intrinsics in float-intrinsics.ll and
double-intrinsics.ll. Support for promoting the integer argument of
STRICT_FPOWI was added.

I've skipped adding tests for f16 intrinsics, since we don't have libcalls
for them and we have inconsistent support for promoting them in LegalizeDAG.
This will need to be examined more closely.

Reviewed By: asb

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

2 years ago[Bazel] Make mlir:MemRefOpsTdFiles depend on :ArithmeticOpsTdFiles
Fangrui Song [Thu, 30 Dec 2021 19:47:54 +0000 (11:47 -0800)]
[Bazel] Make mlir:MemRefOpsTdFiles depend on :ArithmeticOpsTdFiles

2 years ago[MLIR] Add explicit `using` to disambiguate between multiple implementations from...
long.chen [Thu, 30 Dec 2021 07:56:09 +0000 (07:56 +0000)]
[MLIR] Add explicit `using` to disambiguate between multiple implementations from base classes (NFC)

Both of DenseElementsAttr and ElementsAttrTrait define the method of
getElementType, this commit makes it available on
DenseIntOrFPElementsAttr and DenseStringElementsAttr.

Reviewed By: mehdi_amini

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

2 years ago[InferAttrs] Give strnlen the same attributes as strlen
Benjamin Kramer [Thu, 30 Dec 2021 19:35:45 +0000 (20:35 +0100)]
[InferAttrs] Give strnlen the same attributes as strlen

This moves the only string function out of the big list of math funcs.
And let's us CSE strnlen calls.

2 years ago[ELF][LTO] Call madvise(MADV_DONTNEED) on MemoryBuffer instances
Fangrui Song [Thu, 30 Dec 2021 19:36:57 +0000 (11:36 -0800)]
[ELF][LTO] Call madvise(MADV_DONTNEED) on MemoryBuffer instances

@tejohnson noticed that freeing MemoryBuffer instances right before
`lto->compile` can save RSS, likely because the memory can be reused by
LTO indexing (e.g. ThinLTO import/export lists).).

For ELFFileBase instances, symbol and section names are backed by MemoryBuffer,
so destroying MemoryBuffer would make some infrequent passes (parseSymbolVersion,
reportBackrefs) crash and make debugging difficult.
For a BitcodeFile, its content is completely unused, but destroying its
MemoryBuffer makes the buffer identifier inaccessible and may introduce
constraints for future changes.
This patch leverages madvise(MADV_DONTNEED) which achieves the major gain
without the latent issues.

`Maximum resident set size (kbytes): ` for a large --thinlto-index-only link:

* current behavior: 10146104KiB
* destroy MemoryBuffer instances: 8555240KiB
* madvise(MADV_DONTNEED) just bitcodeFiles  and lazyBitcodeFiles: 8737372KiB
* madvise(MADV_DONTNEED) all MemoryBuffers: 8739796KiB  (16% decrease)

Depends on D116366

Reviewed By: tejohnson

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

2 years ago[MLIR] Move AtomicRMW into MemRef dialect and enum into Arith
William S. Moses [Thu, 30 Dec 2021 05:59:58 +0000 (00:59 -0500)]
[MLIR] Move AtomicRMW into MemRef dialect and enum into Arith

Per the discussion in https://reviews.llvm.org/D116345 it makes sense
to move AtomicRMWOp out of the standard dialect. This was accentuated by the
need to add a fold op with a memref::cast. The only dialect
that would permit this is the memref dialect (keeping it in the standard dialect
or moving it to the arithmetic dialect would require those dialects to have a
dependency on the memref dialect, which breaks linking).

As the AtomicRMWKind enum is used throughout, this has been moved to Arith.

Reviewed By: Mogball

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

2 years ago[Support] Expand `<CFGDIR>` as the base directory in configuration files.
Jack Andersen [Thu, 30 Dec 2021 18:42:13 +0000 (13:42 -0500)]
[Support] Expand `<CFGDIR>` as the base directory in configuration files.

Extends response file expansion to recognize `<CFGDIR>` and expand to the
current file's directory. This makes it much easier to author clang config
files rooted in portable, potentially not-installed SDK directories.

A typical use case may be something like the following:

```
# sample_sdk.cfg
--target=sample
-isystem <CFGDIR>/include
-L <CFGDIR>/lib
-T <CFGDIR>/ldscripts/link.ld
```

Reviewed By: sepavloff

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

2 years ago[Support] Add MemoryBuffer::dontNeedIfMmap
Fangrui Song [Thu, 30 Dec 2021 18:42:28 +0000 (10:42 -0800)]
[Support] Add MemoryBuffer::dontNeedIfMmap

On *NIX systems, this API calls madvise(MADV_DONTNEED) on read-only file mappings.
It should not be used on a writable buffer.
The API is used to implement ld.lld LTO memory saving trick (D116367).

Note: on read-only file mappings, Linux's MADV_DONTNEED semantics match POSIX
POSIX_MADV_DONTNEED and BSD systems' MADV_DONTNEED.

On Windows, VirtualAllocEx MEM_COMMIT/MEM_RESET have similar semantics
but are unfortunately not drop-in replacements. dontNeedIfMmap is currently a no-op.

Reviewed By: aganea

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

2 years ago[docs][llvm-profdata] Prefer double-dash long options
Fangrui Song [Thu, 30 Dec 2021 18:37:17 +0000 (10:37 -0800)]
[docs][llvm-profdata] Prefer double-dash long options

To match the `--help` message and most other utilities.

While here, change `option:: -output=output` to `option:: --output=<output>` and
omit the value name for the short options (convention of other utilities).

Reviewed By: snehasish

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

2 years ago[Hexagon] Explicitly use integer types when rescaling a mask
Krzysztof Parzyszek [Sat, 12 Dec 2020 17:14:08 +0000 (11:14 -0600)]
[Hexagon] Explicitly use integer types when rescaling a mask

2 years ago[Hexagon] Handle HVX/FP {masked,wide} loads/stores
Krzysztof Parzyszek [Thu, 30 Dec 2021 17:03:31 +0000 (09:03 -0800)]
[Hexagon] Handle HVX/FP {masked,wide} loads/stores

Co-authored-by: Rahul Utkoor <quic_rutkoor@quicinc.com>
Co-authored-by: Anirudh Sundar Subramaniam <quic_sanirudh@quicinc.com>
2 years agoRevert "[lld] Add support for other demanglers other than Itanium"
Luís Ferreira [Thu, 30 Dec 2021 18:04:21 +0000 (18:04 +0000)]
Revert "[lld] Add support for other demanglers other than Itanium"

This reverts commit e60d6dfd5acdc821d391ad5af2c706397bdfd36a.

clang-ppc64le-rhel buildbot failed (https://lab.llvm.org/buildbot#builders/57/builds/13424):

    tools/lld/MachO/CMakeFiles/lldMachO.dir/Symbols.cpp.o: In function `lld::demangle(llvm::StringRef, bool)':
    Symbols.cpp:(.text._ZN3lld8demangleEN4llvm9StringRefEb[_ZN3lld8demangleEN4llvm9StringRefEb]+0x90): undefined reference to `llvm::demangle(std::string const&)'

2 years ago[Hexagon] Fix isTypeForHVX to recognize floating point types
Krzysztof Parzyszek [Thu, 30 Dec 2021 17:55:44 +0000 (09:55 -0800)]
[Hexagon] Fix isTypeForHVX to recognize floating point types

Co-authored-by: Sumanth Gundapaneni <sgundapa@quicinc.com>
2 years ago[mlir] Change SCF/Complex to prefixed (NFC)
Jacques Pienaar [Thu, 30 Dec 2021 17:57:51 +0000 (09:57 -0800)]
[mlir] Change SCF/Complex to prefixed (NFC)

See
https://llvm.discourse.group/t/psa-ods-generated-accessors-will-change-to-have-a-get-prefix-update-you-apis/4476

2 years ago[lld] Add support for other demanglers other than Itanium
Luís Ferreira [Thu, 30 Dec 2021 17:43:23 +0000 (17:43 +0000)]
[lld] Add support for other demanglers other than Itanium

LLVM core library supports demangling other mangled symbols other than itanium,
such as D and Rust. LLD should use those demanglers in order to output pretty
demangled symbols on error messages.

Reviewed By: MaskRay

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

2 years ago[InstCombine] fold opposite shifts around an add
Sanjay Patel [Thu, 30 Dec 2021 17:01:06 +0000 (12:01 -0500)]
[InstCombine] fold opposite shifts around an add

((X << C) + Y) >>u C --> (X + (Y >>u C)) & (-1 >>u C)

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

This replaces a shift with an 'and', and in the case
where the add has a constant operand, it eliminates
both shifts.

As noted in the TODO comment, we already have this fold when
the shifts are in the opposite order (and that code handles
bitwise logic ops too).

Fixes #52851

2 years agoRevert "[InstCombine] fold opposite shifts around an add"
Sanjay Patel [Thu, 30 Dec 2021 16:54:55 +0000 (11:54 -0500)]
Revert "[InstCombine] fold opposite shifts around an add"

This reverts commit 2e3e0a5c288041745f88a06e66a831c236a3bb1f.
Some unintended diffs snuck into this patch.

2 years ago[InstCombine] fold opposite shifts around an add
Sanjay Patel [Thu, 30 Dec 2021 16:29:27 +0000 (11:29 -0500)]
[InstCombine] fold opposite shifts around an add

((X << C) + Y) >>u C --> (X + (Y >>u C)) & (-1 >>u C)

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

This replaces a shift with an 'and', and in the case
where the add has a constant operand, it eliminates
both shifts.

As noted in the TODO comment, we already have this fold when
the shifts are in the opposite order (and that code handles
bitwise logic ops too).

Fixes #52851

2 years ago[Hexagon] Handle HVX/FP shuffles, insertion and extraction
Krzysztof Parzyszek [Thu, 30 Dec 2021 16:40:49 +0000 (08:40 -0800)]
[Hexagon] Handle HVX/FP shuffles, insertion and extraction

Co-authored-by: Anirudh Sundar Subramaniam <quic_sanirudh@quicinc.com>
2 years agoRevert "[Hexagon] Don't build two halves of HVX vector in parallel"
Krzysztof Parzyszek [Thu, 30 Dec 2021 15:57:11 +0000 (07:57 -0800)]
Revert "[Hexagon] Don't build two halves of HVX vector in parallel"

This reverts commit ba07f300c6d67a2c6dde8eef216b7a77ac4600bb.

A build-vector sequence is made of pairs: rotate+insert. When constructing
a single vector, this results in a chain of 2*N instructions. The rotate
operation is a permute operation, but the insert uses a multiplication
resource: insert and rotate can execute in the same cycle, but obviously
they cannot operate on the same vector. The original halving idea is still
beneficial since it does allow for insert/rotate overlap, and for hiding
insert's latency.

2 years ago[NFC] Pre-commit NewGVN tests for wrong phi(undef, X) optimization
Nuno Lopes [Thu, 30 Dec 2021 15:41:44 +0000 (15:41 +0000)]
[NFC] Pre-commit NewGVN tests for wrong phi(undef, X) optimization

2 years ago[mlir][vector] Fix illegal vector.transfer + tensor.insert/extract_slice folding
Nicolas Vasilache [Thu, 30 Dec 2021 12:41:18 +0000 (12:41 +0000)]
[mlir][vector] Fix illegal vector.transfer + tensor.insert/extract_slice folding

vector.transfer operations do not have rank-reducing semantics.

Bail on illegal rank-reduction: we need to check that the rank-reduced
dims are exactly the leading dims. I.e. the following is illegal:
```
   %0 = vector.transfer_write %v, %t[0,0], %cst :
     vector<2x4xf32>, tensor<2x4xf32>
   %1 = tensor.insert_slice %0 into %tt[0,0,0][2,1,4][1,1,1] :
     tensor<2x4xf32> into tensor<2x1x4xf32>
```

Cannot fold into:
```
   %0 = vector.transfer_write %v, %t[0,0,0], %cst :
     vector<2x4xf32>, tensor<2x1x4xf32>
```
For this, check the trailing `vectorRank` dims of the insert_slice result
tensor match the trailing dims of the inferred result tensor.

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

2 years ago[GVN] Set phi entries of unreachable predecessors to poison instead of undef
Nuno Lopes [Thu, 30 Dec 2021 13:25:57 +0000 (13:25 +0000)]
[GVN] Set phi entries of unreachable predecessors to poison instead of undef
This matches NewGVN's behavior.

2 years ago[lldb/qemu] More flexible emulator specification
Pavel Labath [Thu, 30 Dec 2021 14:02:23 +0000 (15:02 +0100)]
[lldb/qemu] More flexible emulator specification

This small patch adds two useful improvements:
- allows one to specify the emulator path as a bare filename, and have
  it be looked up in the PATH
- allows one to leave the path empty and have the filename be derived
  from the architecture.

2 years ago[NFC] Pre-commit test for InstSimplify phi(poison)
Nuno Lopes [Thu, 30 Dec 2021 12:33:27 +0000 (12:33 +0000)]
[NFC] Pre-commit test for InstSimplify phi(poison)

2 years ago[LoopFlatten] Move it to a LoopPassManager
Sjoerd Meijer [Thu, 30 Dec 2021 11:17:22 +0000 (11:17 +0000)]
[LoopFlatten] Move it to a LoopPassManager

In D109958 it was noticed that we could optimise the pipeline and avoid
rerunning LoopSimplify/LCSSA for LoopFlatten by moving it to a LoopPassManager.

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

2 years ago[NewGVN][NFC] Add test for x + poison -> poison
Nuno Lopes [Thu, 30 Dec 2021 12:08:07 +0000 (12:08 +0000)]
[NewGVN][NFC] Add test for x + poison -> poison

2 years ago[InstSimplify] add 'x + poison -> poison' (needed for NewGVN)
Nuno Lopes [Thu, 30 Dec 2021 11:44:51 +0000 (11:44 +0000)]
[InstSimplify] add 'x + poison -> poison' (needed for NewGVN)

2 years ago[lldb] Remove lldbtest.getBuildFlags
Pavel Labath [Thu, 30 Dec 2021 10:22:26 +0000 (11:22 +0100)]
[lldb] Remove lldbtest.getBuildFlags

It was being used only in some very old tests (which pass even without
it) and its implementation is highly questionable.

These days we have different mechanisms for requesting a build with a
particular kind of c++ library (USE_LIB(STD)CPP in the makefile).

2 years ago[Opaqueptrs][IR Serialization] Improve inlineasm [de]serialization
Roman Lebedev [Thu, 30 Dec 2021 10:42:11 +0000 (13:42 +0300)]
[Opaqueptrs][IR Serialization] Improve inlineasm [de]serialization

The bitcode reader expected that the pointers are typed,
so that it can extract the function type for the assembly
so `bitc::CST_CODE_INLINEASM` did not explicitly store said function type.

I'm not really sure how the upgrade path will look for existing bitcode,
but i think we can easily support opaque pointers going forward,
by simply storing the function type.

Reviewed By: #opaque-pointers, nikic

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

2 years ago[BitcodeReader] `bitc::CST_CODE_INLINEASM`: un-hardcode offsets
Roman Lebedev [Thu, 30 Dec 2021 10:39:39 +0000 (13:39 +0300)]
[BitcodeReader] `bitc::CST_CODE_INLINEASM`: un-hardcode offsets

2 years ago[RISCV] Teach VSETVLInsert to eliminate redundant vsetvli for vmv.s.x and vfmv.s.f.
jacquesguan [Mon, 27 Dec 2021 13:13:24 +0000 (21:13 +0800)]
[RISCV] Teach VSETVLInsert to eliminate redundant vsetvli for vmv.s.x and vfmv.s.f.

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

2 years agoRevert "[AArch64] Add a tablegen pattern for UZP2."
Sjoerd Meijer [Thu, 30 Dec 2021 09:13:04 +0000 (09:13 +0000)]
Revert "[AArch64] Add a tablegen pattern for UZP2."

This reverts commit ada028c32f47ca84a0b7be5d1ab4e3c943f859a3.

A performance regression was reported that we need to investigate:

https://github.com/llvm/llvm-project/issues/52919

2 years ago[IROutliner] Move global namespace cl::opt inside llvm::
Fangrui Song [Thu, 30 Dec 2021 09:12:55 +0000 (01:12 -0800)]
[IROutliner] Move global namespace cl::opt inside llvm::

2 years ago[RISCV] Pre-commit test for Teach VSETVLInsert to eliminate redundant vsetvli for...
jacquesguan [Mon, 27 Dec 2021 13:03:45 +0000 (21:03 +0800)]
[RISCV] Pre-commit test for Teach VSETVLInsert to eliminate redundant vsetvli for vmv.s.x and vfmv.s.f.

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

2 years ago[MC][test] Improve section_names.s
Fangrui Song [Thu, 30 Dec 2021 08:30:47 +0000 (00:30 -0800)]
[MC][test] Improve section_names.s

Add missing coverage like .tdata/.data1/.rodata1

2 years ago[ELFAsmParser] Optimize hasPrefix with StringRef::consume_front
Fangrui Song [Thu, 30 Dec 2021 08:16:03 +0000 (00:16 -0800)]
[ELFAsmParser] Optimize hasPrefix with StringRef::consume_front

2 years ago[ConstantFolding] Use ICmpInst::Predicate instead of plain integer
Serge Pavlov [Wed, 29 Dec 2021 04:40:03 +0000 (11:40 +0700)]
[ConstantFolding] Use ICmpInst::Predicate instead of plain integer

The function `ConstantFoldCompareInstruction` uses `unsigned short` to
represent compare predicate, although all usesrs of the respective
include file use definition of CmpInst also. This change replaces
predicate argument type in this function to `ICmpInst::Predicate`,
which allows to make code a bit clearer and simpler.

No functional changes.

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

2 years ago[cmake] Tweak warning in `extend_path` helper function
John Ericson [Thu, 30 Dec 2021 07:00:50 +0000 (07:00 +0000)]
[cmake] Tweak warning in `extend_path` helper function

There was one more reference the word "install" I forgot to remove.

Follow-up to bde561c4813952847112600e5efe72d9015556f7 /
https://reviews.llvm.org/D115746

2 years ago[compiler-rt][cmake] Factor out extend_install_path function
John Ericson [Tue, 14 Dec 2021 19:52:02 +0000 (14:52 -0500)]
[compiler-rt][cmake] Factor out extend_install_path function

It is likely to become used again, if other projects want their own per-project
install directory variables. `install` is removed from the name since it is not inherently about installing.

Reviewed By: stephenneuendorffer

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

2 years ago[OpenMP] Add missing `tt_hidden_helper_task_encountered` along with `tt_found_proxy_t...
Shilei Tian [Thu, 30 Dec 2021 04:22:37 +0000 (23:22 -0500)]
[OpenMP] Add missing `tt_hidden_helper_task_encountered` along with `tt_found_proxy_tasks`

In most cases, hidden helper task behave similar as detached tasks. That means,
for example, if we have to wait for detached tasks, we have to do the same thing
for hidden helper tasks as well. This patch adds the missing condition for hidden
helper task accordingly along with detached task.

Reviewed By: AndreyChurbanov

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

2 years ago[RISCV] Use vmv.s.x instead of vfmv.s.f when the floating point scalar is 0.
jacquesguan [Wed, 29 Dec 2021 07:29:40 +0000 (15:29 +0800)]
[RISCV] Use vmv.s.x instead of vfmv.s.f when the floating point scalar is 0.

Use integer vector scalar move instruction when move 0 to avoid add a integer-float move instruction.

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

2 years ago[NFC] Specify targets for clang stack-protector-guard.c
Qiu Chaofan [Thu, 30 Dec 2021 02:13:41 +0000 (10:13 +0800)]
[NFC] Specify targets for clang stack-protector-guard.c

The run line of stack-protector-guard.c doesn't specify the triple,
which means it depends on the platform running the test. This makes
some failure hidden.

Reviewed By: nickdesaulniers

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

2 years ago[RISCV] Refactor immediate comparison instructions patterns
Chenbing.Zheng [Thu, 30 Dec 2021 01:31:01 +0000 (09:31 +0800)]
[RISCV] Refactor immediate comparison instructions patterns

The patterns of the immediate comparison instruction is rewrite here, and put similar code to a class.
Do not change any function of the original code, making the code more concise.

Reviewed By: craig.topper

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

2 years agoCouple of post-commit tweaks on 4d58d1d5af31 based on maskray's feedback
David Blaikie [Thu, 30 Dec 2021 00:45:00 +0000 (16:45 -0800)]
Couple of post-commit tweaks on 4d58d1d5af31 based on maskray's feedback

2 years agoFix build of llvm-prettyprinters/gdb/mlir-support.cpp test
Mehdi Amini [Wed, 29 Dec 2021 23:08:37 +0000 (23:08 +0000)]
Fix build of llvm-prettyprinters/gdb/mlir-support.cpp test

This is just fixing the build itself, the test won't pass right now.

2 years agoDWARFVerifier: fix remaining tests and compact/rephrase the output
David Blaikie [Wed, 29 Dec 2021 22:47:43 +0000 (14:47 -0800)]
DWARFVerifier: fix remaining tests and compact/rephrase the output

2 years agoDWARFDie: don't try to compute a full template name for a template parameter packs
David Blaikie [Wed, 29 Dec 2021 22:04:38 +0000 (14:04 -0800)]
DWARFDie: don't try to compute a full template name for a template parameter packs

Otherwise these look a lot like actual templates (they have a name and
they have template parameters) but they don't participate in naming
(this doesn't come up in practice because a template parameter pack DIE
is never referenced from another DIE (so we don't do full name
rebuilding for it) or the subject of simplified template name rebuilding
(never has the _STN prefix)) - it could be tested with some hand crafted
DWARF but doesn't seem important/useful to do so.

This change is just for performance - to avoid trying to parse more
DIEs, etc, when it's not needed when computing the name in the DWARF
verifier.

2 years agoDWARFVerifier: Print the CU name and CU count to help visualize progress
David Blaikie [Wed, 29 Dec 2021 22:00:40 +0000 (14:00 -0800)]
DWARFVerifier: Print the CU name and CU count to help visualize progress

2 years ago[libc++] [NFC] Remove an unused parameter from `__sift_down`.
Arthur O'Dwyer [Wed, 29 Dec 2021 19:17:26 +0000 (14:17 -0500)]
[libc++] [NFC] Remove an unused parameter from `__sift_down`.

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

2 years agoDWARFVerifier: Delay loading nested types in type dumping to improve performance
David Blaikie [Wed, 29 Dec 2021 21:11:16 +0000 (13:11 -0800)]
DWARFVerifier: Delay loading nested types in type dumping to improve performance

Avoid trying to resolve nested types that may not be needed because the name is
already provided by the outer DIE.

2 years ago[InstCombine] add more folds for unsigned overflow checks
Sanjay Patel [Wed, 29 Dec 2021 20:53:56 +0000 (15:53 -0500)]
[InstCombine] add more folds for unsigned overflow checks

 ((Op1 + C) & C) u<  Op1 --> Op1 != 0
 ((Op1 + C) & C) u>= Op1 --> Op1 == 0
 Op0 u>  ((Op0 + C) & C) --> Op0 != 0
 Op0 u<= ((Op0 + C) & C) --> Op0 == 0

https://alive2.llvm.org/ce/z/iUfXJN
https://alive2.llvm.org/ce/z/caAtjj

  define i1 @src(i8 %x, i8 %y) {
    ; the add/mask must be with a low-bit mask (0x01ff...)
    %y1 = add i8 %y, 1
    %pop = call i8 @llvm.ctpop.i8(i8 %y1)
    %ismask = icmp eq i8 %pop, 1
    call void @llvm.assume(i1 %ismask)

    %a = add i8 %x, %y
    %m = and i8 %a, %y
    %r = icmp ult i8 %m, %x
    ret i1 %r
  }

  define i1 @tgt(i8 %x, i8 %y) {
    %r = icmp ne i8 %x, 0
    ret i1 %r
  }

I suspect this can be generalized in some way, but this
is the pattern I'm seeing in a motivating test based on
issue #52851.

2 years ago[InstCombine] add tests for unsigned overflow of bitmask offset; NFC
Sanjay Patel [Wed, 29 Dec 2021 20:16:11 +0000 (15:16 -0500)]
[InstCombine] add tests for unsigned overflow of bitmask offset; NFC

2 years ago[InstCombine] add tests for lshr(add(shl())); NFC
Sanjay Patel [Tue, 28 Dec 2021 21:59:53 +0000 (16:59 -0500)]
[InstCombine] add tests for lshr(add(shl())); NFC

2 years ago[mlir][MemRef] Deprecate unspecified trailing offset, size, and strides semantics...
MaheshRavishankar [Wed, 29 Dec 2021 18:48:02 +0000 (10:48 -0800)]
[mlir][MemRef] Deprecate unspecified trailing offset, size, and strides semantics of `OffsetSizeAndStrideOpInterface`.

The semantics of the ops that implement the
`OffsetSizeAndStrideOpInterface` is that if the number of offsets,
sizes or strides are less than the rank of the source, then some
default values are filled along the trailing dimensions (0 for offset,
source dimension of sizes, and 1 for strides). This is confusing,
especially with rank-reducing semantics. Immediate issue here is that
the methods of `OffsetSizeAndStridesOpInterface` assumes that the
number of values is same as the source rank. This cause out-of-bounds
errors.

So simplifying the specification of `OffsetSizeAndStridesOpInterface`
to make it invalid to specify number of offsets/sizes/strides not
equal to the source rank.

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

2 years ago[Hexagon] Don't build two halves of HVX vector in parallel
Krzysztof Parzyszek [Wed, 29 Dec 2021 19:00:01 +0000 (11:00 -0800)]
[Hexagon] Don't build two halves of HVX vector in parallel

There can only be one permute operations per packet, so this actually
pessimizes the code (due to the extra "or").

2 years ago[Hexagon] Improve BUILD_VECTOR codegen
Joshua Herrera [Wed, 29 Dec 2021 18:18:21 +0000 (10:18 -0800)]
[Hexagon] Improve BUILD_VECTOR codegen

For vectors with repeating values, old codegen would rotate and insert
every duplicate element. This patch replaces that behavior with a splat
of the most common element, vinsert/vror only occur when needed.