platform/upstream/llvm.git
2 years ago[X86] Use CMOVNS for abs instead of CMOVGE.
Craig Topper [Thu, 14 Oct 2021 18:23:42 +0000 (11:23 -0700)]
[X86] Use CMOVNS for abs instead of CMOVGE.

CMOVGE reads SF and OF. CMOVNS only reads SF. This matches with
other recent changes to use a single flag where possible. It also
matches gcc codegen.

I believe this technically changes whether the conditioanl move happens
on INT_MIN, but for INT_MIN both registers are the same so it doesn't
matter.

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

2 years ago[Polly] Remove support for code generated by gfortran+DragonEgg.
Michael Kruse [Thu, 14 Oct 2021 19:06:20 +0000 (14:06 -0500)]
[Polly] Remove support for code generated by gfortran+DragonEgg.

DragonEgg is not maintained anymore, hence there is no need for this
functionality.

Fixes llvm.org/PR52173

2 years ago[Polly][docs] Fix itemize list for release notes.
Michael Kruse [Thu, 14 Oct 2021 18:47:12 +0000 (13:47 -0500)]
[Polly][docs] Fix itemize list for release notes.

Make the changes top-level items, instead of subitems of the
"Changes..." placeholder.

2 years agoFix a rejects-valid with consteval on overloaded operators
Aaron Ballman [Thu, 14 Oct 2021 18:44:37 +0000 (14:44 -0400)]
Fix a rejects-valid with consteval on overloaded operators

It seems that Clang 11 regressed functionality that was working in
Clang 10 regarding calling a few overloaded operators in an immediate
context. Specifically, we were not checking for immediate invocations
of array subscripting and the arrow operators, but we properly handle
the other overloaded operators.

This fixes the two problematic operators and adds some test coverage to
show they're equivalent to calling the operator directly.

This addresses PR50779.

2 years ago[lldb] Remove logging from Platform::~Platform
Raphael Isemann [Thu, 14 Oct 2021 18:41:58 +0000 (20:41 +0200)]
[lldb] Remove logging from Platform::~Platform

Platform instances are stored in a function-local static list. However, the
logging code involves locking a function-local static mutex. This only works on
some implementations where the Log mutex is by accident destroyed *after* the
Platform list is destroyed.

This fixes randomly failing tests due to `recursive_mutex lock failed: Invalid
argument`.

Reviewed By: kastiglione

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

2 years ago[mlir][tosa] Fix tosa.cast UiToFp32 for tosa-to-linalg
Rob Suderman [Thu, 14 Oct 2021 02:21:09 +0000 (19:21 -0700)]
[mlir][tosa] Fix tosa.cast UiToFp32 for tosa-to-linalg

Part of the arith update broke UiToFp32. Fixed the lowering and included a new
test to detect a regression.

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

2 years ago[lldb] Rewrite TestDiamond and document some bugs.
Raphael Isemann [Wed, 13 Oct 2021 16:55:32 +0000 (18:55 +0200)]
[lldb] Rewrite TestDiamond and document some bugs.

2 years ago[libc++][AIX] Add scripts and config for building with the libcxx CI infrastructure
David Tenty [Wed, 13 Oct 2021 15:41:47 +0000 (11:41 -0400)]
[libc++][AIX] Add scripts and config for building with the libcxx CI infrastructure

This initial change adds the AIX configuration to run-buildbot, an AIX
CMake cache file, and appropriate compiler and linker flags for testing
AIX to the lit "from scratch" configuration files. Either of the 32-bit or 64-bit configurations
can be built by setting `OBJECT_MODE` in the build environment (as is
typical for AIX).

Reviewed By: ldionne, #libc, #libc_abi

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

2 years ago[BasicAA] Improve scalable vector handling
Nikita Popov [Sun, 26 Sep 2021 20:20:53 +0000 (22:20 +0200)]
[BasicAA] Improve scalable vector handling

Currently, DecomposeGEP() bails out on the whole decomposition if
it encounters a scalable GEP type anywhere. However, it is fine to
still analyze other GEPs that we look through before hitting the
scalable GEP. This does mean that the decomposed GEP base is no
longer required to be the same as the underlying object. However,
I don't believe this property is necessary for correctness anymore.

This allows us to compute slightly more precise aliasing results
for GEP chains containing scalable vectors, though my primary
interest here is simplifying the code.

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

2 years ago[llvm-mca][timeline] Indicate output was stopped due to cycle limit.
Daniel Sanders [Tue, 12 Oct 2021 22:44:35 +0000 (15:44 -0700)]
[llvm-mca][timeline] Indicate output was stopped due to cycle limit.

It can be a bit confusing to stop with no explanation so we should indicate
when further output was prevented by the cycle limit.

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

2 years ago[AIX] Ignore case when comparing output from od
Kai Nacke [Thu, 14 Oct 2021 17:50:05 +0000 (13:50 -0400)]
[AIX] Ignore case when comparing output from od

POSIX does not define the exact output from od tool.
While most implementations use lower case characters in hex output,
the z/OS USS implementation uses upper case characters.
To avoid LIT failures, the FileCheck option to ignore the case must
be used when checking hex bytes.

Reviewed By: abhina.sreeskantharajan

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

2 years ago[TTI][X86] Merge getInterleavedMemoryOpCostAVX2 into getInterleavedMemoryOpCost. NFC
Simon Pilgrim [Thu, 14 Oct 2021 17:40:23 +0000 (18:40 +0100)]
[TTI][X86] Merge getInterleavedMemoryOpCostAVX2 into getInterleavedMemoryOpCost. NFC

This a NFC refactor patch to merge the AVX2 interleaved cost handling back into the getInterleavedMemoryOpCost base method - while getInterleavedMemoryOpCostAVX512 uses instruction and patterns very specific to AVX512+, much of the costs analysis for AVX2 can be reused for all SSE targets.

This is the first step towards improving SSE and AVX1 costs that will reuse the relevant AVX2 costs by splitting some of the tables - for instance AVX1 has very similar costs for most vXi64/vXf64 interleave patterns and many sub-128bit vector costs are the same all the way down to SSE2 (or at least SSSE3).

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

2 years ago[Driver][WebAssembly] Use ToolChain reference instead of getToolChain().
Frederic Cambus [Thu, 14 Oct 2021 17:43:59 +0000 (19:43 +0200)]
[Driver][WebAssembly] Use ToolChain reference instead of getToolChain().

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

2 years ago[Polly] Clean up Polly's getting started docs.
Michael Kruse [Thu, 14 Oct 2021 17:24:09 +0000 (12:24 -0500)]
[Polly] Clean up Polly's getting started docs.

This patch removes the broken bash scipt (polly.sh) and fixes the broken setup
instructions in get_started.html. It also adds instructions for using Ninja and
links to the LLVM getting started page.

Reviewed By: Meinersbur, InnovativeInventor

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

2 years ago[TTI][X86] Swap getInterleavedMemoryOpCostAVX2/getInterleavedMemoryOpCostAVX512 imple...
Simon Pilgrim [Thu, 14 Oct 2021 17:09:49 +0000 (18:09 +0100)]
[TTI][X86] Swap getInterleavedMemoryOpCostAVX2/getInterleavedMemoryOpCostAVX512 implementations. NFC.

I have some upcoming refactoring for SSE/AVX1 interleaving cost support, and the diff is a lot nicer if the (unaltered) AVX512 implementation isn't stuck between getInterleavedMemoryOpCost and getInterleavedMemoryOpCostAVX2

2 years ago[Transforms] eliminateDeadStores - remove unused variable. NFC.
Simon Pilgrim [Thu, 14 Oct 2021 12:35:25 +0000 (13:35 +0100)]
[Transforms] eliminateDeadStores - remove unused variable. NFC.

The initial MemoryAccess *Current assignment is never used, and all other uses are initialized/used within the worklist loop (and not across multiple iterations) - so move the variable internal to the loop.

Fixes scan-build unused assignment warning.

2 years ago[libTooling] Add "switch"-like Stencil combinator
Yitzhak Mandelbaum [Wed, 13 Oct 2021 12:30:10 +0000 (12:30 +0000)]
[libTooling] Add "switch"-like Stencil combinator

Adds `selectBound`, a `Stencil` combinator that allows the user to supply multiple alternative cases, discriminated by bound node IDs.

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

2 years ago[FPEnv][InstSimplify] Fold fadd X, 0 ==> X, when we know X is not -0
Kevin P. Neal [Thu, 14 Oct 2021 16:31:31 +0000 (12:31 -0400)]
[FPEnv][InstSimplify] Fold fadd X, 0 ==> X, when we know X is not -0

Currently the fadd optimizations in InstSimplify don't know how to do this
NoSignedZeros "X + 0.0 ==> X" fold when using the constrained intrinsics.
This adds the support.

This review is derived from D106362 with some improvements from D107285
and is a follow-on to D111085.

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

2 years ago[RISCV] Update Zba, Zbb, Zbc, and Zbs version from 0.93 to 1.0.
Craig Topper [Thu, 14 Oct 2021 16:08:31 +0000 (09:08 -0700)]
[RISCV] Update Zba, Zbb, Zbc, and Zbs version from 0.93 to 1.0.

I've removed the Zbs W instructions that are not part of the frozen spec.

References to B as an extension name have been removed. Tests are updated or split accordingly.

Reviewed By: luismarques

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

2 years ago[sanitizer] Move out stack trace pointer from header StackDepot
Vitaly Buka [Tue, 12 Oct 2021 05:59:58 +0000 (22:59 -0700)]
[sanitizer] Move out stack trace pointer from header StackDepot

Trace pointers accessed very rarely and don't need to
be in hot data.

Depends on D111613.

Reviewed By: dvyukov

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

2 years ago[ValueTracking] Simplify getKnowledgeValidInContext() call (NFC)
Nikita Popov [Thu, 14 Oct 2021 16:17:28 +0000 (18:17 +0200)]
[ValueTracking] Simplify getKnowledgeValidInContext() call (NFC)

This accepts an ArrayRef, there's no need to create a SmallVector.

2 years ago[llvm-profgen] Allow generating AutoFDO profile from CSSPGO binary
Wenlei He [Thu, 14 Oct 2021 05:27:08 +0000 (22:27 -0700)]
[llvm-profgen] Allow generating AutoFDO profile from CSSPGO binary

Add `-use-dwarf-correlation` switch to allow llvm-profgen to generate AutoFDO profile for binaries built with CSSPGO (pseudo-probe).

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

2 years ago[libc++] LWG3480: make (recursive_)directory_iterator C++20 ranges
Joe Loser [Thu, 14 Oct 2021 15:53:43 +0000 (11:53 -0400)]
[libc++] LWG3480: make (recursive_)directory_iterator C++20 ranges

Implement LWG3480 which enables `directory_iterator` and
`recursive_directory_iterator` to be both a `borrowed_range` and a
`view`.

Reviewed By: ldionne, #libc

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

2 years ago[AMDGPU] Add more tests for build_vector
Julien Pages [Thu, 14 Oct 2021 15:44:09 +0000 (11:44 -0400)]
[AMDGPU] Add more tests for build_vector

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

2 years ago[analyzer][solver] Handle simplification to ConcreteInt
Gabor Marton [Thu, 30 Sep 2021 13:34:06 +0000 (15:34 +0200)]
[analyzer][solver] Handle simplification to ConcreteInt

The solver's symbol simplification mechanism was not able to handle cases
when a symbol is simplified to a concrete integer. This patch adds the
capability.

E.g., in the attached lit test case, the original symbol is `c + 1` and
it has a `[0, 0]` range associated with it. Then, a new condition `c == 0`
is assumed, so a new range constraint `[0, 0]` comes in for `c` and
simplification kicks in. `c + 1` becomes `0 + 1`, but the associated
range is `[0, 0]`, so now we are able to realize the contradiction.

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

2 years ago[libc++][NFC] Fixes placement of the return type.
Mark de Wever [Thu, 14 Oct 2021 15:40:45 +0000 (17:40 +0200)]
[libc++][NFC] Fixes placement of the return type.

2 years ago[lldb] Fix 'frame diagnose' docstring typo
Dave Lee [Tue, 5 Oct 2021 18:10:45 +0000 (11:10 -0700)]
[lldb] Fix 'frame diagnose' docstring typo

2 years ago[mlir][Linalg] Tighten canonicalization of InsertSliceOp that triggers infinite loop
Nicolas Vasilache [Thu, 14 Oct 2021 15:20:43 +0000 (15:20 +0000)]
[mlir][Linalg] Tighten canonicalization of InsertSliceOp that triggers infinite loop

I am unclear this is reproducible with correct IR but atm the verifier for InsertSliceOp
is not powerful enough and this triggers an infinite loop that is worth fixing independently.

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

2 years ago[mlir][Linalg] Fix insertion point in comprehensive bufferization
Nicolas Vasilache [Thu, 14 Oct 2021 15:20:31 +0000 (15:20 +0000)]
[mlir][Linalg] Fix insertion point in comprehensive bufferization

2 years ago[JITLink][NFC] Add TableManager to replace PerGraph...Builder pass
luxufan [Thu, 14 Oct 2021 15:06:43 +0000 (23:06 +0800)]
[JITLink][NFC] Add TableManager to replace PerGraph...Builder pass

This patch add a TableManager which reponsible for fixing edges that need entries to reference the target symbol and constructing such entries.

In the past, the PerGraphGOTAndPLTStubsBuilder pass was used to build GOT and PLT entry, and the PerGraphTLSInfoEntryBuilder pass was used to build TLSInfo entry. By generalizing the behavior of building entry, I added a TableManager which could be reused when built GOT, PLT and TLSInfo entries.

If this patch makes sense and can be accepted, I will apply the TableManager to other targets(MachO_x86_64, MachO_arm64, ELF_riscv), and delete the file PerGraphGOTAndPLTStubsBuilder.h

Reviewed By: lhames

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

2 years ago[NFC][compiler-rt][profile] Remove non-Posix -h option from test
Jinsong Ji [Thu, 14 Oct 2021 14:52:17 +0000 (14:52 +0000)]
[NFC][compiler-rt][profile] Remove non-Posix -h option from test

We are running `ls -lh` in gcov-execlp.c test in Posix folder.
However `-h` is not a POSIX option,ls on some POSIX system (eg: AIX)
may not support it.

This patch remove this option to avoid break.

Reviewed By: anhtuyen

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

2 years ago[RISCV][test] Add tests of (add (shl r, c0), c1)
Ben Shi [Mon, 4 Oct 2021 15:38:52 +0000 (15:38 +0000)]
[RISCV][test] Add tests of (add (shl r, c0), c1)

Reviewed By: craig.topper, luismarques

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

2 years ago[mlir][linalg] Fix FusionOnTensors header and make local method static (NFC).
Tobias Gysi [Thu, 14 Oct 2021 14:08:37 +0000 (14:08 +0000)]
[mlir][linalg] Fix FusionOnTensors header and make local method static (NFC).

Reviewed By: nicolasvasilache

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

2 years ago[DebugInfo][InstrRef] Place variable-values PHI using LLVM utilities
Jeremy Morse [Thu, 14 Oct 2021 13:21:49 +0000 (14:21 +0100)]
[DebugInfo][InstrRef] Place variable-values PHI using LLVM utilities

This patch is very similar to D110173 / a3936a6c19c, but for variable
values rather than machine values. This is for the second instr-ref
problem, calculating the correct variable value on entry to each block.
The previous lattice based implementation was broken; we now use LLVMs
existing PHI placement utilities to work out where values need to merge,
then eliminate un-necessary ones through value propagation.

Most of the deletions here happen in vlocJoin: it was trying to pick a
location for PHIs to happen in, badly, leading to an infinite loop in the
MIR test added, where it would repeatedly switch between register
locations. The new approach is simpler: either PHIs can be eliminated, or
they can't, and the location of the value is a different problem.

Various bits and pieces move to the header so that they can be tested in
the unit tests. The DbgValue class grows a "VPHI" kind to represent
variable value PHIS that haven't been eliminated yet.

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

2 years ago[hexagon] Add system register, transfer support
Brian Cain [Mon, 22 Feb 2021 15:17:23 +0000 (09:17 -0600)]
[hexagon] Add system register, transfer support

This commit adds the system reg/regpair definitions and the corresponding
register transfer instructions.

2 years agoFixup [NVPTX] Add VRFrame and VRFrameLocal to integer register classes
Andrew Savonichev [Thu, 14 Oct 2021 13:32:16 +0000 (16:32 +0300)]
Fixup [NVPTX] Add VRFrame and VRFrameLocal to integer register classes

2 years ago[NVPTX] Add VRFrame and VRFrameLocal to integer register classes
Andrew Savonichev [Thu, 14 Oct 2021 13:18:34 +0000 (16:18 +0300)]
[NVPTX] Add VRFrame and VRFrameLocal to integer register classes

These registers are used as operands for instructions that expect an
integer register, so they should be added to Int32Regs or Int64Regs
register classes. Otherwise the machine verifier emits an error for
the following LIT tests when LLVM_ENABLE_MACHINE_VERIFIER=1
environment variable is set:

*** Bad machine code: Illegal physical register for instruction ***
- function:    kernel_func
- basic block: %bb.0 entry (0x55c8903d5438)
- instruction: %3:int64regs = LEA_ADDRi64 $vrframelocal, 0
- operand 1:   $vrframelocal
$vrframelocal is not a Int64Regs register.

    CodeGen/NVPTX/call-with-alloca-buffer.ll
    CodeGen/NVPTX/disable-opt.ll
    CodeGen/NVPTX/lower-alloca.ll
    CodeGen/NVPTX/lower-args.ll
    CodeGen/NVPTX/param-align.ll
    CodeGen/NVPTX/reg-types.ll
    DebugInfo/NVPTX/dbg-declare-alloca.ll
    DebugInfo/NVPTX/dbg-value-const-byref.ll

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

2 years ago[VectorCombine] Add test showing issue when running VectorCombine early.
Florian Hahn [Thu, 14 Oct 2021 10:54:04 +0000 (11:54 +0100)]
[VectorCombine] Add test showing issue when running VectorCombine early.

Running -vector-combine early can introduce new vector operations,
blocking loop/SLP vectorization. The added test case could be better
optimized by the SLPVectorizer if no new vector operations are added
early.

2 years ago[SystemZ] Remove some now unused ISD XXX_LOOP opcodes.
Jonas Paulsson [Thu, 14 Oct 2021 12:42:58 +0000 (14:42 +0200)]
[SystemZ] Remove some now unused ISD XXX_LOOP opcodes.

2 years ago[ARM] Simplify address calculation for NEON load/store
Andrew Savonichev [Wed, 8 Sep 2021 15:19:57 +0000 (18:19 +0300)]
[ARM] Simplify address calculation for NEON load/store

The patch attempts to optimize a sequence of SIMD loads from the same
base pointer:

    %0 = gep float*, float* base, i32 4
    %1 = bitcast float* %0 to <4 x float>*
    %2 = load <4 x float>, <4 x float>* %1
    ...
    %n1 = gep float*, float* base, i32 N
    %n2 = bitcast float* %n1 to <4 x float>*
    %n3 = load <4 x float>, <4 x float>* %n2

For AArch64 the compiler generates a sequence of LDR Qt, [Xn, #16].
However, 32-bit NEON VLD1/VST1 lack the [Wn, #imm] addressing mode, so
the address is computed before every ld/st instruction:

    add r2, r0, #32
    add r0, r0, #16
    vld1.32 {d18, d19}, [r2]
    vld1.32 {d22, d23}, [r0]

This can be improved by computing address for the first load, and then
using a post-indexed form of VLD1/VST1 to load the rest:

    add r0, r0, #16
    vld1.32 {d18, d19}, [r0]!
    vld1.32 {d22, d23}, [r0]

In order to do that, the patch adds more patterns to DAGCombine:

  - (load (add ptr inc1)) and (add ptr inc2) are now folded if inc1
    and inc2 are constants.

  - (or ptr inc) is now recognized as a pointer increment if ptr is
    sufficiently aligned.

In addition to that, we now search for all possible base updates and
then pick the best one.

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

2 years ago[Codegen] TargetLowering::getCanonicalIndexType - early out scaled MVT::i8 indices...
Simon Pilgrim [Thu, 14 Oct 2021 12:08:40 +0000 (13:08 +0100)]
[Codegen] TargetLowering::getCanonicalIndexType - early out scaled MVT::i8 indices. NFCI.

Avoids unused assignment scan-build warning.

2 years ago[clang][sema] instantiateOMPDeclareVariantAttr - merge repeated VariantFuncRef.get...
Simon Pilgrim [Thu, 14 Oct 2021 11:51:23 +0000 (12:51 +0100)]
[clang][sema] instantiateOMPDeclareVariantAttr - merge repeated VariantFuncRef.get() calls. NFCI.

Fixes scan-build warning about dead initialization

2 years ago[clangd] IncludeCleaner: Handle macros coming from ScratchBuffer
Kirill Bobyrev [Thu, 14 Oct 2021 11:36:25 +0000 (13:36 +0200)]
[clangd] IncludeCleaner: Handle macros coming from ScratchBuffer

Reviewed By: sammccall

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

2 years ago[mlir] NFC - Avoid unused symbol in opt mode.
Nicolas Vasilache [Thu, 14 Oct 2021 11:26:11 +0000 (11:26 +0000)]
[mlir] NFC - Avoid unused symbol in opt mode.

2 years ago[CostModel][X86] Pre-SSE41 targets can use PMADDWD for sext sub-i16 -> i32
Simon Pilgrim [Thu, 14 Oct 2021 11:17:28 +0000 (12:17 +0100)]
[CostModel][X86] Pre-SSE41 targets can use PMADDWD for sext sub-i16 -> i32

Without SSE41 sext/zext instructions the extensions will be split, meaning that the MUL->PMADDWD fold will split the sext_i32(x) into zext_i32(sext_i16(x))

2 years ago[Orc] ELFNixPlatform::setupJITDylib - remove dead return. NFCI.
Simon Pilgrim [Thu, 14 Oct 2021 11:05:35 +0000 (12:05 +0100)]
[Orc] ELFNixPlatform::setupJITDylib - remove dead return. NFCI.

2 returns, one after the other - reported by coverity

2 years ago[mlir][python] Better support for variadic regions in Python bindings
Alex Zinenko [Thu, 14 Oct 2021 09:15:44 +0000 (11:15 +0200)]
[mlir][python] Better support for variadic regions in Python bindings

Improve support for variadic regions in ODS-generated operation view classes.
In particular, make generated constructors take an extra argument that
specifies the number of variadic regions if the operation has them. Previously,
there was no mechanism to specify a non-zero number of variadic regions. Also
generate named accessors to regions.

Reviewed By: gysit

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

2 years ago[mlir][python] Fix MemRefType IsAFunction in Python bindings
Alex Zinenko [Thu, 14 Oct 2021 09:33:28 +0000 (11:33 +0200)]
[mlir][python] Fix MemRefType IsAFunction in Python bindings

MemRefType was using a wrong `isa` function in the bindings code, which
could lead to invalid IR being constructed. Also run the verifier in
memref dialect tests.

Reviewed By: nicolasvasilache

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

2 years agoFollow up to a3936a6c19c, correctly select LiveDebugValues implementation
Jeremy Morse [Thu, 14 Oct 2021 09:58:33 +0000 (10:58 +0100)]
Follow up to a3936a6c19c, correctly select LiveDebugValues implementation

Some functions get opted out of instruction referencing if they're being
compiled with no optimisations, however the LiveDebugValues pass picks one
implementation and then sticks with it through the rest of compilation.
This leads to a segfault if we encounter a function that doesn't use
instr-ref (because it's optnone, for example), but we've already decided
to use InstrRefBasedLDV which expects to be passed a DomTree.

Solution: keep both implementations around in the pass, and pick whichever
one is appropriate to the current function.

2 years ago[MLIR] Fix assert crash when an unregistered dialect op is encountered
Uday Bondhugula [Tue, 12 Oct 2021 09:34:17 +0000 (15:04 +0530)]
[MLIR] Fix assert crash when an unregistered dialect op is encountered

Fix assert crash when an unregistered dialect op is encountered during
parsing and `-allow-unregistered-dialect' isn't on. Instead, emit an
error.

While on this, clean up "registered" vs "loaded" on `getDialect()` and
local clang-tidy warnings.

https://llvm.discourse.group/t/assert-behavior-on-unregistered-dialect-ops/4402

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

2 years ago[mlir][linalg] Expose flag to control nofold attribute when padding.
Tobias Gysi [Thu, 14 Oct 2021 09:38:21 +0000 (09:38 +0000)]
[mlir][linalg] Expose flag to control nofold attribute when padding.

Setting the nofold attribute enables packing an operand. At the moment, the attribute is set by default. The pack introduces a callback to control the flag.

Reviewed By: nicolasvasilache

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

2 years ago[Flang] flang-omp-report replace std::vector's with llvm::SmallVector
Josh Mottley [Wed, 13 Oct 2021 18:19:33 +0000 (19:19 +0100)]
[Flang] flang-omp-report replace std::vector's with llvm::SmallVector

This patch replaces all uses of std::vector with llvm::SmallVector in the flang-omp-report plugin.
This is a one of several patches focusing on switching containers from STL to LLVM's ADT library.

Reviewed By: Leporacanthicus

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

2 years ago[mlir][linalg] Verify every LinalgOp has a body.
Tobias Gysi [Thu, 14 Oct 2021 09:08:39 +0000 (09:08 +0000)]
[mlir][linalg] Verify every LinalgOp has a body.

After removing the last LinalgOps that have no region attached we can verify there is a region. The patch performs the following changes:
- Move the SingleBlockImplicitTerminator trait further up the the structured op base class.
- Adapt the LinalgOp verification since the trait only check if there is 0 or 1 block.
- Introduce a getBlock method on the LinalgOp interface.
- Access the LinalgOp body using either getBlock() or getBody() if the concrete operation type is known.

This patch is a follow up to https://reviews.llvm.org/D111233.

Reviewed By: nicolasvasilache

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

2 years ago[lldb] Fix TestStackCorefile.py for ca0ce99fc8
Pavel Labath [Thu, 14 Oct 2021 08:38:00 +0000 (10:38 +0200)]
[lldb] Fix TestStackCorefile.py for ca0ce99fc8

2 years ago[SystemZ] Reapply memcmp and memcpy patches.
Jonas Paulsson [Tue, 12 Oct 2021 10:35:01 +0000 (12:35 +0200)]
[SystemZ] Reapply memcmp and memcpy patches.

This reverts 3562076 and includes some refactoring as well.

Review: Ulrich Weigand

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

2 years ago[SystemZ] Bugfix and refactorization of mem-mem operations
Jonas Paulsson [Sat, 9 Oct 2021 16:13:09 +0000 (18:13 +0200)]
[SystemZ] Bugfix and refactorization of mem-mem operations

This patch fixes the bug that consisted of treating variable / immediate
length mem operations (such as memcpy, memset, ...) differently. The variable
length case needs to have the length minus 1 passed due to the use of EXRL
target instructions. However, the DAGCombiner can convert a register length
argument into a constant one, and whenever that happened one byte too little
would end up being performed.

This is also a refactorization by reducing the number of opcodes and variants
involved. For any opcode (variable or constant length), only the length minus
one is passed on to the ISD node. The rest of the logic is now instead
handled during isel pseudo expansion.

Review: Ulrich Weigand

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

2 years ago[lldb] Make the thread_local g_global_boundary accessed from a single file
Martin Storsjö [Fri, 8 Oct 2021 08:41:02 +0000 (11:41 +0300)]
[lldb] Make the thread_local g_global_boundary accessed from a single file

This makes the compiler generated code for accessing the thread local
variable much simpler (no need for wrapper functions and weak pointers
to potential init functions), and can avoid toolchain bugs regarding how
to access TLS variables.

In particular, this fixes LLDB when built with current GCC/binutils for
MinGW, see https://github.com/msys2/MINGW-packages/issues/8868.

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

2 years ago[lldb] Print embedded nuls in char arrays (PR44649)
Pavel Labath [Tue, 12 Oct 2021 12:32:34 +0000 (14:32 +0200)]
[lldb] Print embedded nuls in char arrays (PR44649)

When we know the bounds of the array, print any embedded nuls instead of
treating them as terminators. An exception to this rule is made for the
nul character at the very end of the string. We don't print that, as
otherwise 99% of the strings would end in \0. This way the strings
usually come out the same as how the user typed it into the compiler
(char foo[] = "with\0nuls"). It also matches how they come out in gdb.

This resolves a FIXME left from D111399, and leaves another FIXME for dealing
with nul characters in "escape-non-printables=false" mode. In this mode the
characters cause the entire summary string to be terminated prematurely.

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

2 years ago[SCEV][NFC] Simplify check with CI->isZero() exit condition
Max Kazantsev [Thu, 14 Oct 2021 07:06:52 +0000 (14:06 +0700)]
[SCEV][NFC] Simplify check with CI->isZero() exit condition

Replace check with
    if ((ExitIfTrue && CI->isZero()) || (!ExitIfTrue && CI->isOne()))
with equivalent and simpler version
    if (ExitIfTrue == CI->isZero())

2 years ago[SCEV][NFC] Reorder checks to delay call of all_of
Max Kazantsev [Thu, 14 Oct 2021 06:29:05 +0000 (13:29 +0700)]
[SCEV][NFC] Reorder checks to delay call of all_of

Check lightweight getter condition before calling all_of.

2 years agoSet LLVM_HAS_RVALUE_REFERENCE_THIS when __GNUC__ is defined
Arthur Eubanks [Thu, 14 Oct 2021 06:13:55 +0000 (23:13 -0700)]
Set LLVM_HAS_RVALUE_REFERENCE_THIS when __GNUC__ is defined

gcc does not support __has_feature(), so this was accidentally changed
in D111581 when compiling with gcc.

2 years ago[fir] Remove unused variable in FIRBuilder.h
Valentin Clement [Thu, 14 Oct 2021 05:04:40 +0000 (07:04 +0200)]
[fir] Remove unused variable in FIRBuilder.h

Remove unsused variable that break Werror on some buildbots

2 years ago[RISCV] Optimize immediate materialisation with BSETI/BCLRI
Ben Shi [Thu, 14 Oct 2021 03:10:33 +0000 (03:10 +0000)]
[RISCV] Optimize immediate materialisation with BSETI/BCLRI

Opitimize immediate materialisation in the following way if profitable:
1. Use BCLRI for upper 32 bits if the lower 32 bits are negative int32.
2. Use BSETI for upper 32 bits if the lower 32 bits are positive int32.

Reviewed By: craig.topper

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

2 years ago[clang] Use llvm::is_contained (NFC)
Kazu Hirata [Thu, 14 Oct 2021 03:41:54 +0000 (20:41 -0700)]
[clang] Use llvm::is_contained (NFC)

2 years ago[AMDGPU] Fix 24-bit mul intrinsic generation for > 32-bit result.
Abinav Puthan Purayil [Sun, 10 Oct 2021 15:43:24 +0000 (21:13 +0530)]
[AMDGPU] Fix 24-bit mul intrinsic generation for > 32-bit result.

The 24-bit mul intrinsics yields the low-order 32 bits. We should only
do the transformation if the operands are known to be not wider than 24
bits and the result is known to be not wider than 32 bits.

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

2 years agodocs: Document workaround for arcanist failures
Tom Stellard [Thu, 14 Oct 2021 03:25:31 +0000 (03:25 +0000)]
docs: Document workaround for arcanist failures

Reviewed By: smeenai

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

2 years ago[RISCV] Optimize immediate materialisation with SLLI.UW
Ben Shi [Wed, 13 Oct 2021 10:37:56 +0000 (10:37 +0000)]
[RISCV] Optimize immediate materialisation with SLLI.UW

Use LUI+SLLI.UW to compose the upper bits instead of LUI+SLLI.

Reviewed By: craig.topper

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

2 years ago[RISCV][test] Add more tests of immediate materialisation
Ben Shi [Wed, 13 Oct 2021 10:00:58 +0000 (10:00 +0000)]
[RISCV][test] Add more tests of immediate materialisation

Reviewed By: craig.topper

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

2 years ago[mlir] Ability to build CAPI dylibs from out of tree projects against installed LLVM.
Stella Laurenzo [Sun, 10 Oct 2021 04:16:29 +0000 (21:16 -0700)]
[mlir] Ability to build CAPI dylibs from out of tree projects against installed LLVM.

* Incorporates a reworked version of D106419 (which I have closed but has comments on it).
* Extends the standalone example to include a minimal CAPI (for registering its dialect) and a test which, from out of tree, creates an aggregate dylib and links a little sample program against it. This will likely only work today in *static* MLIR builds (until the TypeID fiasco is finally put to bed). It should work on all platforms, though (including Windows - albeit I haven't tried this exact incarnation there).
* This is the biggest pre-requisite to being able to build out of tree MLIR Python-based projects from an installed MLIR/LLVM.
* I am rather nauseated by the CMake shenanigans I had to endure to get this working. The primary complexity, above and beyond the previous patch is because (with no reason given), it is impossible to export target properties that contain generator expressions... because, of course it isn't. In this case, the primary reason we use generator expressions on the individual embedded libraries is to support arbitrary ordering. Since that need doesn't apply to out of tree (which import everything via FindPackage at the outset), we fall back to a more imperative way of doing the same thing if we detect that the target was imported. Gross, but I don't expect it to need a lot of maintenance.
* There should be a relatively straight-forward path from here to rebase libMLIR.so on top of this facility and also make it include the CAPI.

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

2 years ago[examples] Fix LLJITWithRemoteDebugging example after 4fcc0ac15e0.
Lang Hames [Thu, 14 Oct 2021 01:19:53 +0000 (18:19 -0700)]
[examples] Fix LLJITWithRemoteDebugging example after 4fcc0ac15e0.

2 years ago[llvm-profgen] Ignore the whole trace with the leading external branch
wlei [Wed, 13 Oct 2021 06:42:07 +0000 (23:42 -0700)]
[llvm-profgen] Ignore the whole trace with the leading external branch

The first LBR entry can be an external branch, we should ignore the whole trace.

```
     7f7448e889e4 0x7f7448e889e4/0x7f7448e88826/P/-/-/1  0x7f7448e8899f/0x7f7448e889d8/P/-/-/4  ...
```

Reviewed By: wenlei, hoy

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

2 years ago[llvm-profgen] Ignore stack samples before aggregation
wlei [Mon, 11 Oct 2021 20:40:22 +0000 (13:40 -0700)]
[llvm-profgen] Ignore stack samples before aggregation

With `ignore-stack-samples`, We can ignore the call stack before the samples aggregation which could reduce some redundant computations.

Reviewed By: hoy, wenlei

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

2 years ago[ORC] Use a Setup object for SimpleRemoteEPC construction.
Lang Hames [Wed, 13 Oct 2021 23:22:28 +0000 (16:22 -0700)]
[ORC] Use a Setup object for SimpleRemoteEPC construction.

SimpleRemoteEPC notionally allowed subclasses to override the
createMemoryManager and createMemoryAccess methods to use custom objects, but
could not actually be subclassed in practice (The construction process in
SimpleRemoteEPC::Create could not be re-used).

Instead of subclassing, this commit adds a SimpleRemoteEPC::Setup class that
can be used by clients to set up the memory manager and memory access members.
A default-constructed Setup object results in no change from previous behavior
(EPCGeneric* memory manager and memory access objects used by default).

2 years ago[ORC] Add a missing definition.
Lang Hames [Wed, 13 Oct 2021 23:22:07 +0000 (16:22 -0700)]
[ORC] Add a missing definition.

2 years ago[mlir][sparse] Misc code cleanup
wren romano [Wed, 13 Oct 2021 23:08:35 +0000 (16:08 -0700)]
[mlir][sparse] Misc code cleanup

Depends On D111763

Reviewed By: aartbik

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

2 years ago[mlir][sparse] Factoring out helper functions for generating constants
wren romano [Wed, 13 Oct 2021 23:03:26 +0000 (16:03 -0700)]
[mlir][sparse] Factoring out helper functions for generating constants

Reviewed By: aartbik

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

2 years ago[gn build] (manually) port 6c76d0101193
Nico Weber [Wed, 13 Oct 2021 22:43:16 +0000 (18:43 -0400)]
[gn build] (manually) port 6c76d0101193

2 years ago[InstCombine] Remove attributes after hoisting free above null check
Shoaib Meenai [Sun, 10 Oct 2021 21:06:49 +0000 (14:06 -0700)]
[InstCombine] Remove attributes after hoisting free above null check

If the parameter had been annotated as nonnull because of the null
check, we want to remove the attribute, since it may no longer apply and
could result in miscompiles if left. Similarly, we also want to remove
undef-implying attributes, since they may not apply anymore either.

Fixes PR52110.

Reviewed By: nikic

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

2 years ago[mlgo][aot] requrie the model is autogenerated for test determinism
Mircea Trofin [Wed, 13 Oct 2021 17:36:08 +0000 (10:36 -0700)]
[mlgo][aot] requrie the model is autogenerated for test determinism

The tests that exercise the 'release' mode, where the model is AOT-ed,
check the output has certain properties, to validate that, indeed, a
different policy from the default one was exercised. For determinism, we
can't reliably check that output for an arbitrary learned policy, since
it could be that policy happens to mimic the default one in that
particular case.

This patch adds a requirement that those tests run only when the model
is autogenerated (e.g. on build bots).

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

2 years ago[sanitizer] Cleanup benchmark
Vitaly Buka [Wed, 13 Oct 2021 20:53:15 +0000 (13:53 -0700)]
[sanitizer] Cleanup benchmark

2 years ago[instcombine] PRE freeze to only potentially posion/undef operand of phi
Philip Reames [Wed, 13 Oct 2021 20:55:54 +0000 (13:55 -0700)]
[instcombine] PRE freeze to only potentially posion/undef operand of phi

This extends the foldOpIntoPhi code used when visiting a freeze user of a phi to allow any non-undef/poison operand as opposed to only non-undef/poison constants.  This lets us hoist a freeze in the increment of an IV into the preheader in many cases.

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

2 years ago[Support] [Path] Move function declarations to the right doxygen group in the header...
Martin Storsjö [Wed, 13 Oct 2021 06:06:49 +0000 (06:06 +0000)]
[Support] [Path] Move function declarations to the right doxygen group in the header. NFC.

They were in the doxygen group Observers, while they are about
mutating paths.

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

2 years ago[Support] [Path] Use std::replace instead of an explicit comparison loop. NFC.
Martin Storsjö [Mon, 4 Oct 2021 13:48:07 +0000 (16:48 +0300)]
[Support] [Path] Use std::replace instead of an explicit comparison loop. NFC.

After 8fc7a907b93a8e9eef96e872f8f926db3ebfe9b6, this loop does
the same as a plain `std::replace`.

Also clarify the comment about what this function does.

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

2 years ago[clang][Tooling] Use Windows command lines on all Windows, except Cygwin
Jeremy Drake [Wed, 13 Oct 2021 19:49:29 +0000 (22:49 +0300)]
[clang][Tooling] Use Windows command lines on all Windows, except Cygwin

Previously it only used Windows command lines for MSVC triples, but this
was causing issues for windows-gnu.  In fact, everything 'native' Windows
(ie, not Cygwin) should use Windows command line parsing.

Reviewed By: mstorsjo

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

2 years ago[libcxx] [test] Generalize the conditions for testing bitcasts between long double...
Martin Storsjö [Tue, 12 Oct 2021 19:36:33 +0000 (19:36 +0000)]
[libcxx] [test] Generalize the conditions for testing bitcasts between long double, double and int128

MSVC targets also have a 64 bit long double, as do MinGW targets on ARM.
This hasn't been noticed in CI because the MSVC configurations there run
with _LIBCPP_HAS_NO_INT128 defined.

This avoids assuming that either __int128_t or double is equal in size to
long double. i386 MinGW targets have sizeof(long double) == 10, which
doesn't match any of the tested types.

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

2 years ago[clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64
Martin Storsjö [Wed, 13 Oct 2021 10:38:17 +0000 (13:38 +0300)]
[clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64

This doesn't practically affect the code generation.

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

2 years ago[fir] Add the DoLoopHelper
Eric Schweitz [Wed, 13 Oct 2021 19:46:18 +0000 (21:46 +0200)]
[fir] Add the DoLoopHelper

Add the DoLoopHelper. Some helpers functions
to create fir.do_loop operations.

This code was part of D111337 and was extracted in order to
make the patch easier to review.

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

Reviewed By: kiranchandramohan

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

Co-authored-by: Valentin Clement <clementval@gmail.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[NFC][X86][LV] Autogenerate checklines in cost-model.ll to simplify further updates
Roman Lebedev [Wed, 13 Oct 2021 19:47:43 +0000 (22:47 +0300)]
[NFC][X86][LV] Autogenerate checklines in cost-model.ll to simplify further updates

2 years ago[NFC][Costmodel][X86] Fix broken `CHECK-NOT`'s in interleave costmodel tests
Roman Lebedev [Wed, 13 Oct 2021 19:44:57 +0000 (22:44 +0300)]
[NFC][Costmodel][X86] Fix broken `CHECK-NOT`'s in interleave costmodel tests

2 years ago[X86][Costmodel] Fix `X86TTIImpl::getGSScalarCost()`
Roman Lebedev [Wed, 13 Oct 2021 19:35:39 +0000 (22:35 +0300)]
[X86][Costmodel] Fix `X86TTIImpl::getGSScalarCost()`

`X86TTIImpl::getGSScalarCost()` has (at least) two issues:
* it naively computes the cost of sequence of `insertelement`/`extractelement`.
  If we are operating not on the XMM (but YMM/ZMM),
  this widely overestimates the cost of subvector insertions/extractions.
* Gather/scatter takes a vector of pointers, and scalarization results in us performing
  scalar memory operation for each of these pointers, but we never account for the cost
  of extracting these pointers out of the vector of pointers.

Reviewed By: RKSimon

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

2 years ago[sanitizer] Add trivial StackDepot benchmark
Vitaly Buka [Wed, 13 Oct 2021 06:56:38 +0000 (23:56 -0700)]
[sanitizer] Add trivial StackDepot benchmark

2 years ago[HIP] Fix test rcom-detect.hip
Yaxun (Sam) Liu [Wed, 13 Oct 2021 15:18:18 +0000 (11:18 -0400)]
[HIP] Fix test rcom-detect.hip

This patches fixes https://bugs.llvm.org/show_bug.cgi?id=51404

Some builds use custom resource directory for clang, therefore the test
cannot assume default resource directory for clang. Use -resource-dir
to force it.

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

2 years ago[Builtins] Remove stale comment. NFC
Craig Topper [Wed, 13 Oct 2021 18:31:31 +0000 (11:31 -0700)]
[Builtins] Remove stale comment. NFC

The header name was made a separate string more than 12.5 years ago.
I think it was part of the attribute string for less than a week.

2 years ago[clang] Delete unused class DiagsUninitializedSeveretyRAII
Nico Weber [Wed, 13 Oct 2021 18:27:16 +0000 (14:27 -0400)]
[clang] Delete unused class DiagsUninitializedSeveretyRAII

2 years ago[FuncSpec] Don't run the solver if there's nothing to do
Sjoerd Meijer [Tue, 12 Oct 2021 14:37:21 +0000 (15:37 +0100)]
[FuncSpec] Don't run the solver if there's nothing to do

Even if there are no interesting functions, the SCCP solver would still run
before bailing. Now bail earlier, avoid running the solver for nothing.

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

2 years ago[OpenMP] libomp: add atomic functions for new OpenMP 5.1 atomics.
AndreyChurbanov [Wed, 13 Oct 2021 18:02:18 +0000 (21:02 +0300)]
[OpenMP] libomp: add atomic functions for new OpenMP 5.1 atomics.

Added functions those implement "atomic compare".
Though clang does not use library interfaces to implement OpenMP atomics,
the functions added for consistency.
Also added missed functions for 80-bit floating min/max atomics.

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

2 years ago[CMake] Add optional libCURL dependency to llvm build configuration
Noah Shutty [Wed, 13 Oct 2021 07:38:40 +0000 (00:38 -0700)]
[CMake] Add optional libCURL dependency to llvm build configuration

This finds the curl libraries if LLVM_ENABLE_CURL is set. This is needed
to implement the debuginfod client library in LLVM.

Patch By: noajshu

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

2 years ago[OpenMP] libomp: fix ittnotify usage.
AndreyChurbanov [Wed, 13 Oct 2021 17:49:05 +0000 (20:49 +0300)]
[OpenMP] libomp: fix ittnotify usage.

Replaced storing of ittnotify domain array index into
location info structure (which is now read-only) with storing of
(location info address + ittnotify domain + team size) into hash map.
Replaced __kmp_itt_barrier_domains and __kmp_itt_imbalance_domains arrays with
__kmp_itt_barrier_domains hash map; __kmp_itt_region_domains and
__kmp_itt_region_team_size arrays with __kmp_itt_region_domains hash map.
Basic functionality did not change (at least tried to not change).

The patch fixes https://bugs.llvm.org/show_bug.cgi?id=48644.

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

2 years agoMake various assume bundle data structures use uint64_t
Arthur Eubanks [Wed, 13 Oct 2021 17:22:57 +0000 (10:22 -0700)]
Make various assume bundle data structures use uint64_t

Following D110451, we need to make sure to support 64 bit values.

2 years ago[mlir][sparse] emergency fix after constant -> arith.constant change
Aart Bik [Wed, 13 Oct 2021 17:13:44 +0000 (10:13 -0700)]
[mlir][sparse] emergency fix after constant -> arith.constant change

Reviewed By: Mogball

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