platform/upstream/llvm.git
3 years ago[X86][SLM] Fix PBLENDVB uops and throughput
Simon Pilgrim [Thu, 2 Sep 2021 17:07:40 +0000 (18:07 +0100)]
[X86][SLM] Fix PBLENDVB uops and throughput

SLM PBLENDVB is just as bad as BLENDVPD/PS - so model it as such, fixing the rr vs rm uops diff as well. The Intel AoM appears to have a copy+paste typo with PBLENDW, it doesn't match Agner or InstLatX64.

Noticed while investigating some of the weird discrepancies reported by the D103695 helper script (SLM had much better vector shift throughputs than it should).

3 years ago[OptTable] Reapply Improve error message output for grouped short options
gbreynoo [Fri, 3 Sep 2021 10:08:39 +0000 (11:08 +0100)]
[OptTable] Reapply Improve error message output for grouped short options

This reapplies 71d7fed3bc2ad6c22729d446526a59fcfd99bd03 which was
reverted by 3e2bd82f02c6cbbfb0544897c7645867f04b3a7e. This change
includes the fix for breaking the sanitizer bots.

As seen in https://bugs.llvm.org/show_bug.cgi?id=48880 the current
implementation for parsing grouped short options can return unclear
error messages. This change fixes the example given in the ticket in
which a flag is incorrectly given an argument. Also when parsing a
group we now keep reading past the first incorrect option and output
errors for all incorrect options in the group.

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

3 years ago[AMDGPU][MC][NFC][DOC] Updated description of registers
Dmitry Preobrazhensky [Fri, 3 Sep 2021 10:09:54 +0000 (13:09 +0300)]
[AMDGPU][MC][NFC][DOC] Updated description of registers

Corrected list of available register tuples to reflect changes introduced by
commits https://reviews.llvm.org/D103672 and https://reviews.llvm.org/D103800

See bug https://bugs.llvm.org/show_bug.cgi?id=51388

3 years ago[OpenCL] Supports optional 64-bit floating point types in C++ for OpenCL 2021
Justas Janickas [Tue, 31 Aug 2021 08:17:38 +0000 (09:17 +0100)]
[OpenCL] Supports optional 64-bit floating point types in C++ for OpenCL 2021

Adds support for a feature macro `__opencl_c_fp64` in C++ for OpenCL
2021 enabling a respective optional core feature from OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.

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

3 years agoRevert "[lldb/lua] Force Lua version to be 5.3"
Siger Yang [Fri, 3 Sep 2021 09:27:13 +0000 (17:27 +0800)]
Revert "[lldb/lua] Force Lua version to be 5.3"

This commit causes buildbot failures if SWIG is available but Lua is
not present.

This reverts commit 7bb42dc6b114f57200abfebaaa01160914be6bba.

3 years ago[hwasan] Support more complicated lifetimes.
Florian Mayer [Wed, 18 Aug 2021 16:19:54 +0000 (17:19 +0100)]
[hwasan] Support more complicated lifetimes.

This is important as with exceptions enabled, non-POD allocas often have
two lifetime ends: the exception handler, and the normal one.

Reviewed By: eugenis

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

3 years ago[gn build] Port 2ed91da0f1f3
LLVM GN Syncbot [Fri, 3 Sep 2021 08:53:21 +0000 (08:53 +0000)]
[gn build] Port 2ed91da0f1f3

3 years ago[JITLink] Add initial Aarch64 support
Stefan Gränitz [Fri, 3 Sep 2021 08:46:40 +0000 (10:46 +0200)]
[JITLink] Add initial Aarch64 support

Set up basic infrastructure for 64-bit ARM architecture support in JITLink. It allows for loading a minimal object file and resolving a single relocation. Advanced features like GOT and PLT handling or relaxations were intentionally left out for the moment.

This patch follows the idea to keep implementations for ARM (32-bit) and Aaarch64 (64-bit) separate, because:
* it might be easier to share code with the MachO "arm64" JITLink backend
* LLVM has individual targets for ARM and Aaarch64 as well

Reviewed By: lhames

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

3 years ago[LoopBoundSplit] Update phi node in exit block
Jingu Kang [Thu, 2 Sep 2021 14:47:24 +0000 (15:47 +0100)]
[LoopBoundSplit] Update phi node in exit block

It fixes https://bugs.llvm.org/show_bug.cgi?id=51700

Differential Revision:

3 years ago[sanitizer_common] Define wordexp_wrde_dooffs for Solaris
Rainer Orth [Fri, 3 Sep 2021 08:02:31 +0000 (10:02 +0200)]
[sanitizer_common] Define wordexp_wrde_dooffs for Solaris

The Solaris buildbots have been broken for some time:

  In file included from /opt/llvm-buildbot/home/solaris11-amd64/clang-solaris11-amd64/llvm/compiler-rt/lib/asan/asan_interceptors.cpp:174:
  /opt/llvm-buildbot/home/solaris11-amd64/clang-solaris11-amd64/llvm/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:4000:19: error: use of undeclared identifier 'wordexp_wrde_dooffs'
          ((flags & wordexp_wrde_dooffs) ? p->we_offs : 0) + p->we_wordc;
                    ^

This was caused by D108646 <https://reviews.llvm.org/D108646>; the fix is
equivalent to D108838 <https://reviews.llvm.org/D108838>.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

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

3 years ago[AArch64][SME] Support NEON vector to GPR integer moves in streaming mode
Cullen Rhodes [Wed, 11 Aug 2021 07:06:34 +0000 (07:06 +0000)]
[AArch64][SME] Support NEON vector to GPR integer moves in streaming mode

A small subset of the NEON instruction set is legal in streaming mode.
This patch adds support for the following vector to integer move
instructions:

  0x00 1110 0000 0001 0010 11xx xxxx xxxx # SMOV W|Xd,Vn.B[0]
  0x00 1110 0000 0010 0010 11xx xxxx xxxx # SMOV W|Xd,Vn.H[0]
  0100 1110 0000 0100 0010 11xx xxxx xxxx # SMOV Xd,Vn.S[0]
  0000 1110 0000 0001 0011 11xx xxxx xxxx # UMOV Wd,Vn.B[0]
  0000 1110 0000 0010 0011 11xx xxxx xxxx # UMOV Wd,Vn.H[0]
  0000 1110 0000 0100 0011 11xx xxxx xxxx # UMOV Wd,Vn.S[0]
  0100 1110 0000 1000 0011 11xx xxxx xxxx # UMOV Xd,Vn.D[0]

Only the zero index variants are legal, all others indexes are illegal.
To support this, new instructions are defined specifically for zero
index which is hardcoded, along an implicit 'VectorIndex0' operand.
Since the index operand is implicit and takes no bits in the encoding,
custom decoding is required to add the operand.

I'm not sure if this is the best approach but the predicate constraint
on a subset of an operand is unusual. Would be interested to hear some
alternatives.

The instructions are predicated on 'HasNEONorStreamingSVE', i.e. they're
enabled by either +neon or +streaming-sve. This follows on from the work
in D106272 to support the subset of SVE(2) instructions that are legal
in streaming mode.

Depends on D107902.

Reviewed By: sdesmalen

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

3 years ago[AArch64][ISel] NFC: DAG.getMachineFunction() -> MF
Cullen Rhodes [Fri, 3 Sep 2021 07:05:59 +0000 (07:05 +0000)]
[AArch64][ISel] NFC: DAG.getMachineFunction() -> MF

Reviewed By: sdesmalen

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

3 years ago[flang] COMMAND_ARGUMENT_COUNT runtime implementation
Diana Picus [Wed, 25 Aug 2021 07:51:48 +0000 (07:51 +0000)]
[flang] COMMAND_ARGUMENT_COUNT runtime implementation

Grab whatever ProgramStart has stored in executionEnvironment.argc and
subtract 1 (based on the assumption that ProgramStart is called with
a C-style argc that counts the command name as an argument).

Spoiler alert: The tests will evolve into fixtures when we implement
GET_COMMAND_ARGUMENT etc.

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

3 years ago[lldb/lua] Force Lua version to be 5.3
Siger Yang [Fri, 3 Sep 2021 03:17:37 +0000 (11:17 +0800)]
[lldb/lua] Force Lua version to be 5.3

Due to CMake cache, find_package in FindLuaAndSwig.cmake
will be ignored. This commit adds EXACT and REQUIRED flags
to it and removes find_package in Lua ScriptInterpreter.

Signed-off-by: Siger Yang <sigeryeung@gmail.com>
Reviewed By: tammela, JDevlieghere

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

3 years ago[flang] Remove *- C++ -* incantation from runtime .cpp files. NFC
Diana Picus [Thu, 2 Sep 2021 08:14:01 +0000 (08:14 +0000)]
[flang] Remove *- C++ -* incantation from runtime .cpp files. NFC

We should only need to spell the language out in .h files.

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

3 years ago[lldb] [test] Mark *fork-follow-child* tests non-Darwin
Michał Górny [Fri, 3 Sep 2021 07:07:53 +0000 (09:07 +0200)]
[lldb] [test] Mark *fork-follow-child* tests non-Darwin

3 years ago[mlir][flang] Do not prevent integer types from being parsed as MLIR keywords
Jean Perier [Fri, 3 Sep 2021 06:16:52 +0000 (08:16 +0200)]
[mlir][flang] Do not prevent integer types from being parsed as MLIR keywords

DialectAsmParser::parseKeyword is rejecting `'i' digit+` while it is
a valid identifier according to mlir/docs/LangRef.md.

Integer types actually used to be TOK_KEYWORD a while back before the
change: https://github.com/llvm/llvm-project/commit/6af866c58d21813fb243906611d02bb2a8ffa43a.

This patch Modifies `isCurrentTokenAKeyword` to return true for tokens that
match integer types too.

The motivation for this change is the parsing of `!fir.type<{` `component-name: component-type,`+ `}>`
type in FIR that represent Fortran derived types. The component-names are
parsed as keywords, and can very well be i32 or any ixxx (which are
valid Fortran derived type component names).

The Quant dialect type parser had to be modified since it relied on `iw` not
being parsed as keywords.

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

3 years ago[flang] Extend common block size to cover equivalence storage
Jean Perier [Fri, 3 Sep 2021 06:12:44 +0000 (08:12 +0200)]
[flang] Extend common block size to cover equivalence storage

The size of common block should be extended to cover any storage
sequence that are storage associated with the common block via
equivalences (8.10.2.2 point 1 (2)).

In symbol size and offset computation, the size of the common block
was not always extended to cover storage association. It was only done
if the "base symbol of an equivalence group"(*) appeared in a common block
statement. Correct this to cover all cases where a symbol appearing in a
common block statement is storage associated.

(*) the base symbol of an equivalence group is the symbol whose storage
starts first in a storage association (if several symbols starts first,
the base symbol is the last one visited by the algorithm going through
the equivalence sets).

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

3 years ago[Test] Missed opt test for D108910
Max Kazantsev [Fri, 3 Sep 2021 04:45:29 +0000 (11:45 +0700)]
[Test] Missed opt test for D108910

We can fold loop phis after we've proved that some exit has EC=0
in IndVars.

Patch by Dmitry Makogon!

3 years agoReformulate OrcJIT tutorial doc to make it more clear.
Yuichi Yoshida [Fri, 3 Sep 2021 04:58:34 +0000 (04:58 +0000)]
Reformulate OrcJIT tutorial doc to make it more clear.

Fixed a minor writing error. The text was hard to understand.

Reviewed By: lhames, mehdi_amini

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

3 years ago[AArch64][GlobalISel] Support for folding G_ROTR as shifted operands.
Amara Emerson [Thu, 2 Sep 2021 23:54:52 +0000 (16:54 -0700)]
[AArch64][GlobalISel] Support for folding G_ROTR as shifted operands.

This allows selection like: eor w0, w1, w2, ror #8

Saves 500 bytes on ClamAV -Os, which is 0.1%.

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

3 years ago[PowerPC] Enable fast-isel on AIX 64 subtarget
Qiu Chaofan [Fri, 3 Sep 2021 03:33:45 +0000 (11:33 +0800)]
[PowerPC] Enable fast-isel on AIX 64 subtarget

This patch basically enables fast-isel for AIX 64-bit subtarget
(previously enabled only for ELF 64). The initial motivation is to
introduce branch folding to AIX generated code for correct debug
behavior. I also saw some compiling time improvement in a few LLVM
test-suite benchmarks. (toast, dbms, cjpeg, burg, etc.)

Reviewed By: jsji

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

3 years agoRevert "[HardwareLoops] Change order of SCEV expression construction for InitLoopCount."
Chen Zheng [Fri, 3 Sep 2021 02:53:31 +0000 (02:53 +0000)]
Revert "[HardwareLoops] Change order of SCEV expression construction for InitLoopCount."

This causes https://bugs.llvm.org/show_bug.cgi?id=51714 and
is not a right patch according to comments in D91724

This reverts commit 42eaf4fe0adef3344adfd9fbccd49f325cb549ef.

3 years agoAMDGPU: Remove FeatureLocalMemorySize0
Matt Arsenault [Fri, 3 Sep 2021 02:33:21 +0000 (22:33 -0400)]
AMDGPU: Remove FeatureLocalMemorySize0

There's no reason to make this an explicit feature, since it's implied
by the lack of a feature with a size.

3 years ago[Coroutines] [Clang] Look up coroutine component in std namespace first
Chuanqi Xu [Fri, 3 Sep 2021 02:22:53 +0000 (10:22 +0800)]
[Coroutines] [Clang] Look up coroutine component in std namespace first

Summary: Now in libcxx and clang, all the coroutine components are
defined in std::experimental namespace.
And now the coroutine TS is merged into C++20. So in the working draft
like N4892, we could find the coroutine components is defined in std
namespace instead of std::experimental namespace.
And the coroutine support in clang seems to be relatively stable. So I
think it may be suitable to move the coroutine component into the
experiment namespace now.

But move the coroutine component into the std namespace may be an break
change. So I planned to split this change into two patch. One in clang
and other in libcxx.

This patch would make clang lookup coroutine_traits in std namespace
first. For the compatibility consideration, clang would lookup in
std::experimental namespace if it can't find definitions in std
namespace and emit a warning in this case. So the existing codes
wouldn't be break after update compiler.

Test Plan: check-clang, check-libcxx

Reviewed By: lxfind

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

3 years ago[RISCV] Add SiFive core S51
Alexander Pivovarov [Tue, 31 Aug 2021 06:23:23 +0000 (23:23 -0700)]
[RISCV] Add SiFive core S51

Add SiFive core s51 as rv64imac RocketModel

Reviewed-By: MaskRay, evandro
Differential Revision: https://reviews.llvm.org/D108886

3 years ago[OMPIRBuilder] Add ordered directive to OMPBuilder
PeixinQiao [Fri, 3 Sep 2021 01:37:58 +0000 (09:37 +0800)]
[OMPIRBuilder] Add ordered directive to OMPBuilder

Add support for ordered directive in the OpenMPIRBuilder.

This patch also modidies clang to use the ordered directive when the
option -fopenmp-enable-irbuilder is enabled.

Also fix one ICE when parsing one canonical for loop with the relational
operator LE or GE in openmp region by replacing unary increment
operation of the expression of the variable "Expr A" minus the variable
"Expr B" (++(Expr A - Expr B)) with binary addition operation of the
experssion of the variable "Expr A" minus the variable "Expr B" and the
expression with constant value "1" (Expr A - Expr B + "1").

Reviewed By: Meinersbur, kiranchandramohan

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

3 years ago[NFC] Recommit "Regenerate SVE ACLE intrinsics tests"
Usman Nadeem [Thu, 2 Sep 2021 22:45:29 +0000 (15:45 -0700)]
[NFC] Recommit "Regenerate SVE ACLE intrinsics tests"

Change-Id: Ida45fc41231cd71709048f2d37f228f14053514e

3 years agoRevert "[NFC] Regenerate SVE ACLE intrinsics tests"
Usman Nadeem [Thu, 2 Sep 2021 22:43:37 +0000 (15:43 -0700)]
Revert "[NFC] Regenerate SVE ACLE intrinsics tests"

This reverts commit 8749a556da96fb17df1a2e36b860527e557c8c7b.

3 years ago[LoopPredication] Fix MemorySSA crash in predicateLoopExits
Anna Thomas [Thu, 2 Sep 2021 21:26:45 +0000 (17:26 -0400)]
[LoopPredication] Fix MemorySSA crash in predicateLoopExits

The attached testcase crashes without the patch (Not the same accesses
in the same order).

When we move instructions before another instruction, we also need to
update the memory accesses corresponding to it.

Reviewed-By: asbirlea
Differential Revision: https://reviews.llvm.org/D109197

3 years agoFix typo in RISCVMatInt.cpp comments
Alexander Pivovarov [Fri, 3 Sep 2021 01:07:03 +0000 (18:07 -0700)]
Fix typo in RISCVMatInt.cpp comments

3 years ago[mlir][scf] Allow runtime type of iter_args to change
Matthias Springer [Fri, 3 Sep 2021 01:02:43 +0000 (10:02 +0900)]
[mlir][scf] Allow runtime type of iter_args to change

The limitation on iter_args introduced with D108806 is too restricting. Changes of the runtime type should be allowed.

Extends the dim op canonicalization with a simple analysis to determine when it is safe to canonicalize.

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

3 years ago[mlir][python] Simplify python extension loading.
Stella Laurenzo [Fri, 3 Sep 2021 00:37:00 +0000 (00:37 +0000)]
[mlir][python] Simplify python extension loading.

* Now that packaging has stabilized, removes old mechanisms for loading extensions, preferring direct importing.
* Removes _cext_loader.py, _dlloader.py as unnecessary.
* Fixes the path where the CAPI dll is written on Windows. This enables that path of least resistance loading behavior to work with no further drama (see: https://bugs.python.org/issue36085).
* With this patch, `ninja check-mlir` on Windows with Python bindings works for me, modulo some failures that are actually due to a couple of pre-existing Windows bugs. I think this is the first time the Windows Python bindings have worked upstream.
* Downstream changes needed:
  * If downstreams are using the now removed `load_extension`, `reexport_cext`, etc, then those should be replaced with normal import statements as done in this patch.

Reviewed By: jdd, aartbik

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

3 years ago[AMDGPU] Process any power of 2 in optimizeCompareInstr
Stanislav Mekhanoshin [Thu, 2 Sep 2021 19:51:14 +0000 (12:51 -0700)]
[AMDGPU] Process any power of 2 in optimizeCompareInstr

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

3 years ago[Coroutines] Only run verifyFunction in debug mode
Xun Li [Fri, 3 Sep 2021 00:35:01 +0000 (17:35 -0700)]
[Coroutines] Only run verifyFunction in debug mode

verifyFunction can be really slow on large functions. This can significantly slow down compilation in production.
Given that coroutine passes are fairly stable now, we should only run it in debug mode.

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

3 years ago[CSSPGO] Honor preinliner decision for ThinLTO importing
Wenlei He [Wed, 1 Sep 2021 20:47:19 +0000 (13:47 -0700)]
[CSSPGO] Honor preinliner decision for ThinLTO importing

When pre-inliner decision is used for CSSPGO, we should take that into account for ThinLTO importing as well, so post-link sample loader inliner can favor that decision. This is handled by a small tweak in this patch. It also includes a change to transfer preinliner decision when merging context.

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

3 years ago[AMDGPU] Fold immediates in the optimizeCompareInstr
Stanislav Mekhanoshin [Thu, 2 Sep 2021 20:06:26 +0000 (13:06 -0700)]
[AMDGPU] Fold immediates in the optimizeCompareInstr

Peephole works before the first SIFoldOperands so most of
the immediates are in registers.

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

3 years ago[WebAssembly] Rename WrapperPIC -> WrapperREL. NFC
Sam Clegg [Thu, 2 Sep 2021 18:24:53 +0000 (14:24 -0400)]
[WebAssembly] Rename WrapperPIC -> WrapperREL. NFC

This ISD node/wrapper represents am address which is relative to a base
address and therefore lowers to `i32.const` rather than `global.get`.

Use this wrapper type for TLS-relative addresses, paving the way for the
non-REL wrapper to be used to external TLS address once those are
supported.

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

3 years ago[runtimeunroll] Support epilogue unrolling with a parent loop
Philip Reames [Thu, 2 Sep 2021 23:29:20 +0000 (16:29 -0700)]
[runtimeunroll] Support epilogue unrolling with a parent loop

This patch adds support for unrolling inner loops using epilogue unrolling. The basic issue is that the original latch exit block of the inner loop could be outside the outer loop.  When we clone the inner loop and split the latch exit, the cloned blocks need to be in the outer loop.

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

3 years ago[runtimeunroll] Under EXPENSIVE_CHECKS, validate loop info
Philip Reames [Thu, 2 Sep 2021 23:27:45 +0000 (16:27 -0700)]
[runtimeunroll] Under EXPENSIVE_CHECKS, validate loop info

Requested in review comment on D108476

3 years ago[openmp] NFC add bitcode comment
Ron Lieberman [Thu, 2 Sep 2021 23:21:33 +0000 (18:21 -0500)]
[openmp] NFC add bitcode comment

3 years agoReland "Try to unbreak Win build differently after 973519826edb76""
Nico Weber [Thu, 2 Sep 2021 19:09:43 +0000 (12:09 -0700)]
Reland "Try to unbreak Win build differently after 973519826edb76""

Build should be fixed by
https://github.com/llvm/llvm-project/commit/9d22754389

This reverts commit df052e1732ab57f5d9c684ceeaed3ab39073cd9f.

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

3 years ago[Sanitizers] remove empty test case.
David Carlier [Thu, 2 Sep 2021 22:53:38 +0000 (23:53 +0100)]
[Sanitizers] remove empty test case.

3 years ago[ORC] Range check and narrow size value.
Lang Hames [Thu, 2 Sep 2021 22:43:02 +0000 (08:43 +1000)]
[ORC] Range check and narrow size value.

This should fix the build issues in
https://lab.llvm.org/buildbot#builders/171/builds/3149.

3 years ago[gn build] Port dad60f8071d5
LLVM GN Syncbot [Thu, 2 Sep 2021 22:29:41 +0000 (22:29 +0000)]
[gn build] Port dad60f8071d5

3 years ago[ORC] Add EPCGenericJITLinkMemoryManager: memory management via EPC calls.
Lang Hames [Thu, 2 Sep 2021 10:48:58 +0000 (20:48 +1000)]
[ORC] Add EPCGenericJITLinkMemoryManager: memory management via EPC calls.

All ExecutorProcessControl subclasses must provide a JITLinkMemoryManager object
that can be used to allocate memory in the executor process. The
EPCGenericJITLinkMemoryManager class provides an off-the-shelf
JITLinkMemoryManager implementation for JITs that do not need (or cannot
provide) a specialized JITLinkMemoryManager implementation. This simplifies the
process of creating new ExecutorProcessControl implementations.

3 years ago[ORC] Add specialized SPSSerializationTraits for ArrayRef<char>.
Lang Hames [Thu, 2 Sep 2021 10:45:46 +0000 (20:45 +1000)]
[ORC] Add specialized SPSSerializationTraits for ArrayRef<char>.

Deserializing from an SPSSequence<char> to an an ArrayRef<char> will point the
ArrayRef<char> at the input buffer.

3 years ago[ORC] Move callWrapper and callSPSWrapper functions to ExecutorProcessControl.
Lang Hames [Thu, 2 Sep 2021 08:34:27 +0000 (18:34 +1000)]
[ORC] Move callWrapper and callSPSWrapper functions to ExecutorProcessControl.

The ExecutionSession versions now just forward to the implementations in
ExecutorProcessControl.

This allows callWrapper / callSPSWrapper to be used while bootstrapping an
ExecutorProcessControl instance.

3 years ago[GlobalISel] Combine icmp eq/ne x, 0/1 -> x when x == 0 or 1
Jessica Paquette [Thu, 2 Sep 2021 04:55:51 +0000 (21:55 -0700)]
[GlobalISel] Combine icmp eq/ne x, 0/1 -> x when x == 0 or 1

This adds the following combines:

```
x = ... 0 or 1
c = icmp eq x, 1

->

c = x
```

and

```
x = ... 0 or 1
c = icmp ne x, 0

->

c = x
```

When the target's true value for the relevant types is 1.

This showed up in the following situation:

https://godbolt.org/z/M5jKexWTW

SDAG currently supports the `ne` case, but not the `eq` case. This can probably
be further generalized, but I don't feel like thinking that hard right now.

This gives some minor code size improvements across the board on CTMark at
-Os for AArch64. (0.1% for 7zip and pairlocalalign in particular.)

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

3 years agoFully qualify template template parameters when printing
David Blaikie [Thu, 26 Aug 2021 23:54:47 +0000 (16:54 -0700)]
Fully qualify template template parameters when printing

I discovered this quirk when working on some DWARF - AST printing prints
type template parameters fully qualified, but printed template template
parameters the way they were written syntactically, or wholely
unqualified - instead, we should print them consistently with the way we
print type template parameters: fully qualified.

The one place this got weird was for partial specializations like in
ast-print-temp-class.cpp - hence the need for checking for
TemplateNameDependenceScope::DependentInstantiation template template
parameters. (not 100% sure that's the right solution to that, though -
open to ideas)

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

3 years ago[asan] Fixed link error by setting jump symbol to R_X86_64_PLT32.
Kirill Stoimenov [Thu, 2 Sep 2021 19:26:54 +0000 (19:26 +0000)]
[asan] Fixed link error by setting jump symbol to R_X86_64_PLT32.

Fixing this link error:
ld: error: relocation R_X86_64_PC32 cannot be used against symbol __asan_report_load...; recompile with -fPIC

Reviewed By: vitalybuka

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

3 years agoRevert "[CSSPGO] Honor preinliner decision for ThinLTO importing"
Kevin Athey [Thu, 2 Sep 2021 21:09:36 +0000 (14:09 -0700)]
Revert "[CSSPGO] Honor preinliner decision for ThinLTO importing"

This reverts commit a2768b4732a0216dfd346d34e428685f03f10549.

Breaks sanitizer-x86_64-linux-fast buildbot:
https://lab.llvm.org/buildbot/#/builders/5/builds/11334

Log snippet:
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80
FAIL: LLVM :: Transforms/SampleProfile/early-inline.ll (65549 of 78729)
******************** TEST 'LLVM :: Transforms/SampleProfile/early-inline.ll' FAILED ********************
Script:
--
: 'RUN: at line 1';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/opt < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/early-inline.ll -instcombine -sample-profile -sample-profile-file=/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/Inputs/einline.prof -S | /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/early-inline.ll
--
Exit Code: 2
Command Output (stderr):
--
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1309:53: runtime error: member call on null pointer of type 'llvm::sampleprof::FunctionSamples'
    #0 0x5a730f8 in shouldInlineCandidate /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1309:53
    #1 0x5a730f8 in (anonymous namespace)::SampleProfileLoader::tryInlineCandidate((anonymous namespace)::InlineCandidate&, llvm::SmallVector<llvm::CallBase*, 8u>*) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1178:21
    #2 0x5a6cda6 in inlineHotFunctions /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1105:13
    #3 0x5a6cda6 in (anonymous namespace)::SampleProfileLoader::emitAnnotations(llvm::Function&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1633:16
    #4 0x5a5fcbe in runOnFunction /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:2008:12
    #5 0x5a5fcbe in (anonymous namespace)::SampleProfileLoader::runOnModule(llvm::Module&, llvm::AnalysisManager<llvm::Module>*, llvm::ProfileSummaryInfo*, llvm::CallGraph*) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1922:15
    #6 0x5a5de55 in llvm::SampleProfileLoaderPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:2038:21
    #7 0x6552a01 in llvm::detail::PassModel<llvm::Module, llvm::SampleProfileLoaderPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:88:17
    #8 0x57f807c in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/IR/PassManager.h:526:21
    #9 0x37c8522 in llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/opt/NewPMDriver.cpp:489:7
    #10 0x37e7c11 in main /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/opt/opt.cpp:830:12
    #11 0x7fbf4de4009a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #12 0x379e519 in _start (/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/opt+0x379e519)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1309:53 in
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/early-inline.ll
--
********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80
FAIL: LLVM :: Transforms/SampleProfile/inline-cold.ll (65643 of 78729)
******************** TEST 'LLVM :: Transforms/SampleProfile/inline-cold.ll' FAILED ********************
Script:
--
: 'RUN: at line 4';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/opt < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/inline-cold.ll -sample-profile -sample-profile-file=/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/Inputs/inline-cold.prof -S | /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck -check-prefix=NOTINLINE /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/inline-cold.ll
: 'RUN: at line 5';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/opt < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/inline-cold.ll -passes=sample-profile -sample-profile-file=/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/Inputs/inline-cold.prof -S | /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck -check-prefix=NOTINLINE /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/inline-cold.ll
: 'RUN: at line 8';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/opt < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/inline-cold.ll -sample-profile -sample-profile-file=/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/Inputs/inline-cold.prof -sample-profile-inline-size -S | /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck -check-prefix=INLINE /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/inline-cold.ll
: 'RUN: at line 11';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/opt < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/inline-cold.ll -passes=sample-profile -sample-profile-file=/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/Inputs/inline-cold.prof -sample-profile-inline-size -sample-profile-cold-inline-threshold=9999999 -S | /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck -check-prefix=INLINE /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/inline-cold.ll
: 'RUN: at line 14';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/opt < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/inline-cold.ll -passes=sample-profile -sample-profile-file=/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/Inputs/inline-cold.prof -sample-profile-inline-size -sample-profile-cold-inline-threshold=-500 -S | /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck -check-prefix=NOTINLINE /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/inline-cold.ll
--
Exit Code: 2
Command Output (stderr):
--
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1309:53: runtime error: member call on null pointer of type 'llvm::sampleprof::FunctionSamples'
    #0 0x5a730f8 in shouldInlineCandidate /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1309:53
    #1 0x5a730f8 in (anonymous namespace)::SampleProfileLoader::tryInlineCandidate((anonymous namespace)::InlineCandidate&, llvm::SmallVector<llvm::CallBase*, 8u>*) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1178:21
    #2 0x5a6cda6 in inlineHotFunctions /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1105:13
    #3 0x5a6cda6 in (anonymous namespace)::SampleProfileLoader::emitAnnotations(llvm::Function&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1633:16
    #4 0x5a5fcbe in runOnFunction /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:2008:12
    #5 0x5a5fcbe in (anonymous namespace)::SampleProfileLoader::runOnModule(llvm::Module&, llvm::AnalysisManager<llvm::Module>*, llvm::ProfileSummaryInfo*, llvm::CallGraph*) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1922:15
    #6 0x5a5de55 in llvm::SampleProfileLoaderPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:2038:21
    #7 0x6552a01 in llvm::detail::PassModel<llvm::Module, llvm::SampleProfileLoaderPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:88:17
    #8 0x57f807c in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/IR/PassManager.h:526:21
    #9 0x37c8522 in llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/opt/NewPMDriver.cpp:489:7
    #10 0x37e7c11 in main /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/opt/opt.cpp:830:12
    #11 0x7fcd534a209a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #12 0x379e519 in _start (/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/opt+0x379e519)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Transforms/IPO/SampleProfile.cpp:1309:53 in
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck -check-prefix=INLINE /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Transforms/SampleProfile/inline-cold.ll
--
********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
********************
Failed Tests (2):
  LLVM :: Transforms/SampleProfile/early-inline.ll
  LLVM :: Transforms/SampleProfile/inline-cold.ll

3 years ago[Sanitizers] intercept clock_getcpuclockid on FreeBSD, and pthread_getcpuclockid.
David Carlier [Thu, 2 Sep 2021 21:34:23 +0000 (22:34 +0100)]
[Sanitizers] intercept clock_getcpuclockid on FreeBSD, and pthread_getcpuclockid.

Reviewed By: vitalybuka

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

3 years ago[NFC] Regenerate SVE ACLE intrinsics tests
Usman Nadeem [Thu, 2 Sep 2021 21:27:11 +0000 (14:27 -0700)]
[NFC] Regenerate SVE ACLE intrinsics tests

Change-Id: Ic4ec50f9a53fcf58e86104bf19ba229c1dd132d0

3 years ago[flang] Fix scope in which undeclared symbols are created
peter klausler [Wed, 1 Sep 2021 21:03:15 +0000 (14:03 -0700)]
[flang] Fix scope in which undeclared symbols are created

Don't create new symbols in FORALL, implied DO, or other
construct scopes when an undeclared name appears; use the
innermost enclosing program unit's scope.  This clears up
a pending TODO in name resolution, and also exposes (& fixes)
an unnoticed name resolution problem in a module file test.

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

3 years ago[flang] NFC: change non-nullable pointer arguments to references
peter klausler [Wed, 1 Sep 2021 00:16:01 +0000 (17:16 -0700)]
[flang] NFC: change non-nullable pointer arguments to references

Ticking off a Parser TODO: Preprocessor::Directive()'s Prescanner
argument should be a reference, not a pointer.

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

3 years ago[OpenCL] Remove decls for scalar vloada_half and vstorea_half* fns
Stuart Brady [Thu, 12 Aug 2021 15:24:28 +0000 (16:24 +0100)]
[OpenCL] Remove decls for scalar vloada_half and vstorea_half* fns

These functions are not part of the OpenCL C specification.

See https://github.com/KhronosGroup/OpenCL-Docs/issues/648 for a
clarification regarding the vloada_half declarations.

Reviewed By: Anastasia

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

3 years ago[mlir] speed up construction of LLVM IR constants when possible
Alex Zinenko [Thu, 2 Sep 2021 13:01:19 +0000 (15:01 +0200)]
[mlir] speed up construction of LLVM IR constants when possible

The translation to LLVM IR used to construct sequential constants by recurring
down to individual elements, creating constant values for them, and wrapping
them into aggregate constants in post-order. This is highly inefficient for
large constants with known data such as DenseElementsAttr. Use LLVM's
ConstantData for the innermost dimension instead. LLVM does seem to support
data constants for nested sequential constants so the outer dimensions are
still handled recursively. Nevertheless, this speeds up the translation of
large constants with equal dimensions by up to 30x.

Users are advised to rewrite large constants to use flat types before
translating to LLVM IR if more efficiency in translation is necessary. This is
not done automatically as the translation is not aware of the expectations of
the overall compilation flow about type changes and indexing, in particular for
global constants with external linkage.

Reviewed By: silvas

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

3 years ago[NFC] Added testcase for PR40750
Dávid Bolvanský [Thu, 2 Sep 2021 20:43:41 +0000 (22:43 +0200)]
[NFC] Added testcase for PR40750

3 years ago[libc++] Define insert_iterator::iter with ranges::iterator_t.
Arthur O'Dwyer [Thu, 26 Aug 2021 14:55:18 +0000 (10:55 -0400)]
[libc++] Define insert_iterator::iter with ranges::iterator_t.

The `insert_iterator::iter` member is defined as `Container::iterator` but
the standard requires `iter` to be defined in terms of `ranges::iterator_t` as
of C++20. So, if in C++20 or later, define the `iter` member as
`ranges::iterator_t`.

Original patch by Joe Loser!

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

3 years agoFix lldb after D108614
Arthur Eubanks [Thu, 2 Sep 2021 19:58:41 +0000 (12:58 -0700)]
Fix lldb after D108614

3 years ago[MemorySSA] Properly handle liveOnEntry in the walker printer
Arthur Eubanks [Thu, 2 Sep 2021 18:21:05 +0000 (11:21 -0700)]
[MemorySSA] Properly handle liveOnEntry in the walker printer

Reviewed By: asbirlea

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

3 years ago[Verifier] Only allow invariant.group metadata on stores and loads
Arthur Eubanks [Thu, 2 Sep 2021 19:14:35 +0000 (12:14 -0700)]
[Verifier] Only allow invariant.group metadata on stores and loads

As specified by https://llvm.org/docs/LangRef.html#invariant-group-metadata.

Reviewed By: nikic

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

3 years ago[NFC] Remove some unclear attribute methods
Arthur Eubanks [Wed, 1 Sep 2021 18:32:23 +0000 (11:32 -0700)]
[NFC] Remove some unclear attribute methods

To any downstream users broken by this change, please examine your uses
of these methods and see if you can use a better method. For example,
getAttribute(AttributeList::FunctionIndex) => getFnAttr(), or
addAttribute(AttributeList::FirstArgIndex + ArgNo) =>
addParamAttribute(ArgNo). 0 corresponds to ReturnIndex, ~0 corresponds
to FunctionIndex. This may make future cleanups less painful.

I've made the mistake of assuming that these indexes are for parameters
multiple times, but actually they're based off of a weird indexing
scheme AttributeList::AttrIndex where 0 is the return value and ~0 is
the function. Hopefully renaming these methods will make this clearer.
Ideally users should use more specific methods like
AttributeList::getFnAttr().

This touches all relevant methods in AttributeList, CallBase, and Function.

This hopefully will make easier a future change to cleanup AttrIndex. A
previous worry about cleaning up AttrIndex was that too many downstream
users would have to look through all uses of AttrIndex and relevant
attribute method calls to see if anything was unintentionally hardcoded
(e.g. using 0 instead of ReturnIndex). With this change hopefully
downstream users will look at existing usages of these methods and clean
them up.

Reviewed By: rnk, MaskRay

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

3 years ago[llvm-profgen] Turn off cold context trimming by default
Wenlei He [Thu, 2 Sep 2021 16:34:10 +0000 (09:34 -0700)]
[llvm-profgen] Turn off cold context trimming by default

We merge cold context by default to save profile size. However trimming cold context after merging doesn't save size much, so default to off to reflect how it's commonly used.

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

3 years ago[test] Remove legacy PM tests in llvm/test/Other
Arthur Eubanks [Wed, 1 Sep 2021 16:51:31 +0000 (09:51 -0700)]
[test] Remove legacy PM tests in llvm/test/Other

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

3 years ago[WebAssemlby] Remove redundant SDTypeProfile. NFC
Sam Clegg [Thu, 2 Sep 2021 18:01:55 +0000 (14:01 -0400)]
[WebAssemlby] Remove redundant SDTypeProfile. NFC

I added this back in https://reviews.llvm.org/D54647 but it wasn't
actually needed.

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

3 years agoFix lld build after 5881dcff7e76a68
Nico Weber [Thu, 2 Sep 2021 19:06:43 +0000 (15:06 -0400)]
Fix lld build after 5881dcff7e76a68

3 years agoRevert "Try to unbreak Win build differently after 973519826edb76"
Geoffrey Martin-Noble [Thu, 2 Sep 2021 19:05:33 +0000 (12:05 -0700)]
Revert "Try to unbreak Win build differently after 973519826edb76"

Breaks the build and failed pre-merge checks:
https://buildkite.com/llvm-project/premerge-checks/builds/54930#07373971-3d37-49cf-9def-22c0d724ee23

> llvm-project/lld/wasm/Writer.cpp:521:16: error: non-const lvalue reference to
>  type 'llvm::StringRef' cannot bind to a temporary of type 'llvm::StringRef'
>    for (auto &feature : used.keys()) {

This reverts commit 5881dcff7e76a68323edc8bb3c6e14420ad9cf7c.

3 years agoTry to unbreak Win build differently after 973519826edb76
Nico Weber [Thu, 2 Sep 2021 16:42:48 +0000 (12:42 -0400)]
Try to unbreak Win build differently after 973519826edb76

Looks like the MS STL wants StringMapKeyIterator::operator*() to be const.
Return the result by copy instead of reference to do that.
Assigning to a hash map key iterator doesn't make sense anyways.

Also reverts 123f811fe5b0b which is now hopefully no longer needed.

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

3 years ago[test] Remove missed RUN line after D109040
Arthur Eubanks [Thu, 2 Sep 2021 18:44:45 +0000 (11:44 -0700)]
[test] Remove missed RUN line after D109040

3 years ago[test][NewPM] Remove RUN lines using -analyze
Arthur Eubanks [Wed, 1 Sep 2021 02:26:35 +0000 (19:26 -0700)]
[test][NewPM] Remove RUN lines using -analyze

Only tests in llvm/test/Analysis.

-analyze is legacy PM-specific.

This only touches files with `-passes`.

I looked through everything and made sure that everything had a new PM equivalent.

Reviewed By: MaskRay

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

3 years ago[CSSPGO] Allow inlining recursive call for preinliner
Wenlei He [Wed, 1 Sep 2021 22:30:33 +0000 (15:30 -0700)]
[CSSPGO] Allow inlining recursive call for preinliner

When preinliner is used for CSSPGO, we try to honor global preinliner decision as much as we can except for uninlinable callees. We rely on InlineCost::Never to prevent us from illegal inlining.

However, it turns out that we use InlineCost::Never for both illeagle inlining and some of the "not-so-beneficial" inlining.

The most common one is recursive inlining, while it can bloat size a lot during CGSCC bottom-up inlining, it's less of a problem when recursive inlining is guided by profile and done in top-down manner.

Ideally it'd be better to have a clear separation between inline legality check vs cost-benefit check, but that requires a bigger change.

This change enables InlineCost computation to allow inlining recursive calls, controlled by InlineParams. In SampleLoader, we now enable recursive inlining for CSSPGO when global preinliner decision is used.

With this change, we saw a few perf improvements on SPEC2017 with CSSPGO and preinliner on: 2% for povray_r, 6% for xalancbmk_s, 3% omnetpp_s, while size is about the same (no noticeable perf change for all other benchmarks)

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

3 years ago[SCEVExpander] Simplify pointer overflow check
Nikita Popov [Wed, 1 Sep 2021 21:13:01 +0000 (23:13 +0200)]
[SCEVExpander] Simplify pointer overflow check

This is a followup to D104662 to generate slightly nicer code for
pointer overflow checks. Bypass expandAddToGEP and instead
explicitly generate i8 GEPs. This saves some bitcasts and negates
the value in a more obvious way. In particular, this prevents SCEV
from looking through the umul.with.overflow, same as in the integer
case.

The wrapping-pointer-ni.ll test deserves a comment: Previously,
this generated a typed GEP which used the umulo argument rather
than the multiplication result. This results in more compact IR in
that case, but effectively does the multiplication twice, the
second one is just hidden in the GEP. Reusing the umulo result
seems pretty reasonable to me.

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

3 years ago[WebAssembly] Fix names of WebAssemblyWrapper SDNodes. NFC
Sam Clegg [Thu, 2 Sep 2021 17:27:57 +0000 (13:27 -0400)]
[WebAssembly] Fix names of WebAssemblyWrapper SDNodes. NFC

Other platforms all use CamelCase as normal for these wrapper nodes.

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

3 years ago[WebAssembly] Add Wasm SjLj support
Heejin Ahn [Mon, 2 Aug 2021 03:03:45 +0000 (20:03 -0700)]
[WebAssembly] Add Wasm SjLj support

This add support for SjLj using Wasm exception handling instructions:
https://github.com/WebAssembly/exception-handling/blob/master/proposals/exception-handling/Exceptions.md

This does not yet support the mixed use of EH and SjLj within a
function. It will be added in a follow-up CL.

This currently passes all SjLj Emscripten tests for wasm0/1/2/3/s,
except for the below:
- `test_longjmp_standalone`: Uses Node
- `test_dlfcn_longjmp`: Uses NodeRAWFS
- `test_longjmp_throw`: Mixes EH and SjLj
- `test_exceptions_longjmp1`: Mixes EH and SjLj
- `test_exceptions_longjmp2`: Mixes EH and SjLj
- `test_exceptions_longjmp3`: Mixes EH and SjLj

Reviewed By: dschuff, tlively

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

3 years ago[MipsISelLowering] avoid emitting libcalls to __multi3
Nick Desaulniers [Thu, 2 Sep 2021 17:28:41 +0000 (10:28 -0700)]
[MipsISelLowering] avoid emitting libcalls to __multi3

Similar to D108842 and D108844.

__has_builtin(builtin_mul_overflow) returns true for 32b MIPS targets,
but Clang is deferring to compiler RT when encountering long long types.
This breaks MIPS malta_defconfig builds of the Linux kernel that are
using __builtin_mul_overflow with these types for these targets.

If the semantics of __has_builtin mean "the compiler resolves these,
always" then we shouldn't conditionally emit a libcall.

This will still need to be worked around in the Linux kernel in order to
continue to support malta_defconfig builds of the Linux kernel for this
target with older releases of clang.

Link: https://bugs.llvm.org/show_bug.cgi?id=28629
Link: https://github.com/ClangBuiltLinux/linux/issues/1438
Reviewed By: rengolin

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

3 years ago[InlineCost] Introduce attributes to override InlineCost for inliner testing
Daniil Suchkov [Fri, 20 Aug 2021 22:42:29 +0000 (22:42 +0000)]
[InlineCost] Introduce attributes to override InlineCost for inliner testing

This patch introduces four new string attributes: function-inline-cost,
function-inline-threshold, call-inline-cost and call-threshold-bonus.
These attributes allow you to selectively override some aspects of
InlineCost analysis. That would allow us to test inliner separately from
the InlineCost analysis.

That could be useful when you're trying to write tests for inliner and
you need to test some very specific situation, like "the inline cost has
to be this high", or "the threshold has to be this low". Right now every
time someone does that, they have get creative to come up with a way to
make the InlineCost give them the number they need (like adding ~30
load/add pairs for a trivial test). This process can be somewhat tedious
which can discourage some people from writing enough tests for their
changes. Also, that results in tests that are fragile and can be easily
broken without anyone noticing it because the test writer can't
explicitly control what input the inliner will get from the inline cost
analysis.

These new attributes will alleviate those problems to an extent.

Reviewed By: mtrofin

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

3 years ago[Bazel] Add explicit dependency on llvm:Support to reflect layering
Geoffrey Martin-Noble [Thu, 2 Sep 2021 17:31:06 +0000 (10:31 -0700)]
[Bazel] Add explicit dependency on llvm:Support to reflect layering

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

3 years ago[AIX][PowerPC] Define __powerpc and __PPC macros
Jake Egan [Thu, 2 Sep 2021 17:29:26 +0000 (13:29 -0400)]
[AIX][PowerPC] Define __powerpc and __PPC macros

%%%
This patch defines the macros __powerpc and __PPC on AIX to be consistent with XL for AIX. See: https://www.ibm.com/docs/en/xl-c-and-cpp-aix/13.1.0?topic=macros-related-platform

Note: GCC does not currently define __powerpc and __PPC so users should prefer the __powerpc__ and __PPC__ forms.
%%%

Reviewed By: cebowleratibm

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

3 years ago[libc++] Remove an unused internal concept.
Mark de Wever [Thu, 2 Sep 2021 17:26:06 +0000 (19:26 +0200)]
[libc++] Remove an unused internal concept.

Removed as suggested by @Quuxplusone during the review of D109075.

3 years ago[X86] Remove isel predicates for xgetbv/xsetbv instructions so they can work on Windows.
Craig Topper [Thu, 2 Sep 2021 17:08:10 +0000 (10:08 -0700)]
[X86] Remove isel predicates for xgetbv/xsetbv instructions so they can work on Windows.

https://reviews.llvm.org/D56686  was supposed to allow these to
work on Windows without needing to enable the xsave feature to
match MSVC. It seems this didn't work because the backend isel
patterns would still block it.

This patch removes the predicates from the isel patterns.

Fixes PR51706.

Reviewed By: pengfei

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

3 years ago[libc++][NFC] Move concepts to a subheader.
Mark de Wever [Wed, 1 Sep 2021 17:46:22 +0000 (19:46 +0200)]
[libc++][NFC] Move concepts to a subheader.

D103357 added some new concepts. Since the header `<concepts>` has moved
all its concepts to a separate header these new concepts feel out of
place. Move them to the appropriate header.

Reviewed By: #libc, Quuxplusone, ldionne

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

3 years ago[RISCV] Improve shrink wrap test (NFC)
Evandro Menezes [Thu, 2 Sep 2021 15:28:51 +0000 (10:28 -0500)]
[RISCV] Improve shrink wrap test (NFC)

Restore test for shrink wrapping disabled.

3 years ago[libomptarget][amdgpu] Add gfx90a to build list
Jon Chesterfield [Thu, 2 Sep 2021 17:10:40 +0000 (18:10 +0100)]
[libomptarget][amdgpu] Add gfx90a to build list

3 years ago[Bazel] Update for Cpp emitter (2f0750dd2e)
Geoffrey Martin-Noble [Thu, 2 Sep 2021 17:04:48 +0000 (10:04 -0700)]
[Bazel] Update for Cpp emitter (2f0750dd2e)

Update the Bazel build for
https://github.com/llvm/llvm-project/commit/2f0750dd2e.

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

3 years ago[libc++][docs] Remove "Last Updated" entries from the docs
Louis Dionne [Wed, 1 Sep 2021 20:41:42 +0000 (16:41 -0400)]
[libc++][docs] Remove "Last Updated" entries from the docs

Those don't provide a lot of value, and they can easily be wrong anyway.

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

3 years ago[libc++][NFC] Replace uses of stdr:: by just std::ranges::
Louis Dionne [Thu, 2 Sep 2021 01:48:24 +0000 (21:48 -0400)]
[libc++][NFC] Replace uses of stdr:: by just std::ranges::

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

3 years ago[Unwind] Cast exception class pointer for strcpy
Hans Wennborg [Thu, 2 Sep 2021 16:43:26 +0000 (18:43 +0200)]
[Unwind] Cast exception class pointer for strcpy

Follow-up to f5b997e6b706, see comment on
https://reviews.llvm.org/D109047

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

3 years ago[mlir] Add missing dep on MLIRTranslation
Marius Brehler [Thu, 2 Sep 2021 16:53:53 +0000 (16:53 +0000)]
[mlir] Add missing dep on MLIRTranslation

3 years ago[AMDGPU] Use S_BITCMP0_* to replace AND in optimizeCompareInstr
Stanislav Mekhanoshin [Wed, 1 Sep 2021 20:38:31 +0000 (13:38 -0700)]
[AMDGPU] Use S_BITCMP0_* to replace AND in optimizeCompareInstr

These can be used for reversed conditions if result of the AND
is unused except in the compare:

s_cmp_eq_u32 (s_and_b32 $src, 1), 0 => s_bitcmp0_b32 $src, 0
s_cmp_eq_i32 (s_and_b32 $src, 1), 0 => s_bitcmp0_b32 $src, 0
s_cmp_eq_u64 (s_and_b64 $src, 1), 0 => s_bitcmp0_b64 $src, 0
s_cmp_lg_u32 (s_and_b32 $src, 1), 1 => s_bitcmp0_b32 $src, 0
s_cmp_lg_i32 (s_and_b32 $src, 1), 1 => s_bitcmp0_b32 $src, 0
s_cmp_lg_u64 (s_and_b64 $src, 1), 1 => s_bitcmp0_b64 $src, 0

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

3 years ago[X86][SSE] combineMulToPMADDWD - improve recognition of sign/zero extended upper...
Simon Pilgrim [Thu, 2 Sep 2021 15:46:58 +0000 (16:46 +0100)]
[X86][SSE] combineMulToPMADDWD - improve recognition of sign/zero extended upper bits

PMADDWD(v8i16 x, v8i16 y) == (v4i32) { (int)x[0]*y[0] + (int)x[1]*y[1], ..., (int)x[6]*y[6] + (int)x[7]*y[7] }

Currently combineMulToPMADDWD only folds cases where the upper 17 bits of both vXi32 inputs are known zero (i.e. the first half is positive and the second half of the pair is zero in each 2xi16 pair), this can be relaxed to only require one zero-extended input if the other input has at least 17 sign bits.

That way the sign of the result is still preserved, and the second half is still zero.

Noticed while investigating PR47437.

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

3 years agoclang/win: Add __readfsdword to intrin.h
Nico Weber [Wed, 1 Sep 2021 20:17:19 +0000 (16:17 -0400)]
clang/win: Add __readfsdword to intrin.h

When using __readfsdword(), clang used to warn that one has
to include <intrin.h> -- no matter if that was already included
or not.

Now it only warns if it's not yet included.

To verify that this was the only intrin with this problem, I ran:

    $ for f in $(grep intrin.h clang/include/clang/Basic/BuiltinsX86* |
                 egrep -o '\([^,]+,' | egrep -o '[^(,]*'); do
        if ! grep -q $f clang/lib/Headers/intrin.h; then echo $f; fi;
      done

This printed 9 more functions, but those are all in emmintrin.h,
xsaveintrin.h (which are included by intrin.h based on /arch: flags).
So this is indeed the only built-in that was missing in intrin.h.

Fixes PR51188.

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

3 years ago[llvm-profgen] Deduplicate and improve warning for truncated context
Wenlei He [Thu, 2 Sep 2021 00:31:07 +0000 (17:31 -0700)]
[llvm-profgen] Deduplicate and improve warning for truncated context

This change improves the warning for truncated context by: 1) deduplicate them as one call without probe can appear in many different context leading to duplicated warnings , 2) rephrase the message to make it easier to understand. The term "untracked frame" can be confusing.

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

3 years ago[clangd, llvm] Remove redundant calls to c_str() (NFC)
Kazu Hirata [Thu, 2 Sep 2021 16:07:13 +0000 (09:07 -0700)]
[clangd, llvm] Remove redundant calls to c_str() (NFC)

Identified with readability-redundant-string-cstr.

3 years agoTry to unbreak Win build after 973519826edb76
Nico Weber [Thu, 2 Sep 2021 16:03:25 +0000 (12:03 -0400)]
Try to unbreak Win build after 973519826edb76

Apparently some versions of the MS STL don't like constructing a
vector from a StringMapKeyIterator<>: http://45.33.8.238/win/44999/step_4.txt
It builds fine with the MS STL on my Windows box, so just sidestep the issue.

Full error for posterity:

    VC\Tools\MSVC\14.14.26428\include\xmemory(218,75):
      error: indirection requires pointer operand ('const llvm::StringMapKeyIterator<llvm::StringRef>' invalid)
          _Uses_default_construct_t<_Alloc, decltype(_Unfancy(_UDest)), decltype(*_UFirst)>())));
    VC\Tools\MSVC\14.14.26428\include\vector(1922,11):
      note: in instantiation of function template specialization 'std::_Uninitialized_copy<...>' requested here
                    return (_Uninitialized_copy(_First, _Last, _Dest, this->_Getal()));
    VC\Tools\MSVC\14.14.26428\include\vector(757,22):
      note: in instantiation of function template specialization
            'std::vector<llvm::StringRef>::_Ucopy<llvm::StringMapKeyIterator<llvm::StringRef>>' requested here
                            this->_Mylast() = _Ucopy(_First, _Last, this->_Myfirst());
    VC\Tools\MSVC\14.14.26428\include\vector(772,3):
      note: in instantiation of function template specialization
            'std::vector<llvm::StringRef>::_Range_construct_or_tidy<llvm::StringMapKeyIterator<llvm::StringRef>>' requested here
                    _Range_construct_or_tidy(_Unchecked(_First), _Unchecked(_Last), _Iter_cat_t<_Iter>{});
    ../../clang/lib/Driver/ToolChains/Arch/X86.cpp(62,30):
      note: in instantiation of function template specialization
            'std::vector<llvm::StringRef>::vector<llvm::StringMapKeyIterator<llvm::StringRef>, void>' requested here
          std::vector<StringRef> ValidArchs{ArchMap.keys().begin(),

3 years ago[RISCV] Add Zba command line to rv64i-exhaustive-w-insts.ll
Craig Topper [Thu, 2 Sep 2021 15:26:39 +0000 (08:26 -0700)]
[RISCV] Add Zba command line to rv64i-exhaustive-w-insts.ll

Zba adds a zext.w pseudoinstruction using ADDUW. This can simplify
the generated code for many of these tests.

There are at least 2 suboptimal cases in this config that I've marked
with TODOs.

3 years ago[RISCV] Remove stale TODOs from test. NFC
Craig Topper [Thu, 2 Sep 2021 15:01:40 +0000 (08:01 -0700)]
[RISCV] Remove stale TODOs from test. NFC

These were fixed by D106230.

3 years agoTry to unbreak lldb build after 973519826edb76
Nico Weber [Thu, 2 Sep 2021 15:32:08 +0000 (11:32 -0400)]
Try to unbreak lldb build after 973519826edb76

3 years ago[CSSPGO] Honor preinliner decision for ThinLTO importing
Wenlei He [Wed, 1 Sep 2021 20:47:19 +0000 (13:47 -0700)]
[CSSPGO] Honor preinliner decision for ThinLTO importing

When pre-inliner decision is used for CSSPGO, we should take that into account for ThinLTO importing as well, so post-link sample loader inliner can favor that decision. This is handled by a small tweak in this patch. It also includes a change to transfer preinliner decision when merging context.

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