platform/upstream/llvm.git
3 years ago[Reassociate] Guard `add`-like `or` conversion into an `add` with profitability check
Roman Lebedev [Wed, 4 Nov 2020 11:33:11 +0000 (14:33 +0300)]
[Reassociate] Guard `add`-like `or` conversion into an `add` with profitability check

This is slightly better compile-time wise,
since we avoid potentially-costly knownbits analysis that will
ultimately not allow us to actually do anything with said `add`.

3 years ago[mlir][std] Add DimOp folding for dim(tensor_load(m)) -> dim(m).
Nicolas Vasilache [Wed, 4 Nov 2020 11:19:51 +0000 (11:19 +0000)]
[mlir][std] Add DimOp folding for dim(tensor_load(m)) -> dim(m).

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

3 years ago[MLIR] Support walks over regions and blocks
Frederik Gossen [Wed, 4 Nov 2020 11:02:08 +0000 (11:02 +0000)]
[MLIR] Support walks over regions and blocks

Relands
- [MLIR] Support walks over regions and blocks
         (dbae3d50f114a8ec0a7c3211e3b1b9fb6ef22dbd)
- [MLIR] Use llvm::is_one_of in walk templates
         (56299b1e58bf3720dff2fe60163739ee1554a371)

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

3 years ago[llvm-exegesis] Fix rGaf658d920e2b
Clement Courbet [Wed, 4 Nov 2020 12:22:01 +0000 (13:22 +0100)]
[llvm-exegesis] Fix rGaf658d920e2b

Add missing header.

```
../../llvm/tools/llvm-exegesis/lib/X86/Target.cpp(606,14): error: use of undeclared identifier '__readeflags'
    Eflags = __readeflags();
```

3 years ago[gn build] Port 73b6cb67dcd
LLVM GN Syncbot [Wed, 4 Nov 2020 12:00:24 +0000 (12:00 +0000)]
[gn build] Port 73b6cb67dcd

3 years ago[gn build] Port 1124bf4ab77
LLVM GN Syncbot [Wed, 4 Nov 2020 12:00:24 +0000 (12:00 +0000)]
[gn build] Port 1124bf4ab77

3 years ago[gn build] try to port 707d69ff32309b
Nico Weber [Wed, 4 Nov 2020 12:00:05 +0000 (07:00 -0500)]
[gn build] try to port 707d69ff32309b

3 years ago[VE] Add +vpu attribute
Simon Moll [Wed, 4 Nov 2020 11:41:11 +0000 (12:41 +0100)]
[VE] Add +vpu attribute

`+vpu` controls whether VEISelLowering adds any vregs.  This defaults to
`-vpu` to have scalar code generation out of the box.  We bring up
vector isel under the `+vpu` flag. Once vector isel is stable we switch
to `+vpu` and advertise vregs and vops in TTI.

Reviewed By: kaz7

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

3 years ago[SVE][CodeGen] Lower scalable integer vector reductions
Kerry McLaughlin [Wed, 4 Nov 2020 11:08:10 +0000 (11:08 +0000)]
[SVE][CodeGen] Lower scalable integer vector reductions

This patch uses the existing LowerFixedLengthReductionToSVE function to also lower
scalable vector reductions. A separate function has been added to lower VECREDUCE_AND
& VECREDUCE_OR operations with predicate types using ptest.

Lowering scalable floating-point reductions will be addressed in a follow up patch,
for now these will hit the assertion added to expandVecReduce() in TargetLowering.

Reviewed By: paulwalker-arm

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

3 years ago[mlir][SCF] Add canonicalization pattern for scf::For to eliminate yields that just...
Nicolas Vasilache [Wed, 4 Nov 2020 10:01:26 +0000 (10:01 +0000)]
[mlir][SCF] Add canonicalization pattern for scf::For to eliminate yields that just forward.

For instance:
```
func @for_yields_3(%lb : index, %ub : index, %step : index) -> (i32, i32, i32) {
  %a = call @make_i32() : () -> (i32)
  %b = call @make_i32() : () -> (i32)
  %r:3 = scf.for %i = %lb to %ub step %step iter_args(%0 = %a, %1 = %a, %2 = %b) -> (i32, i32, i32) {
    %c = call @make_i32() : () -> (i32)
    scf.yield %0, %c, %2 : i32, i32, i32
  }
  return %r#0, %r#1, %r#2 : i32, i32, i32
}
```

Canonicalizes as:
```
  func @for_yields_3(%arg0: index, %arg1: index, %arg2: index) -> (i32, i32, i32) {
    %0 = call @make_i32() : () -> i32
    %1 = call @make_i32() : () -> i32
    %2 = scf.for %arg3 = %arg0 to %arg1 step %arg2 iter_args(%arg4 = %0) -> (i32) {
      %3 = call @make_i32() : () -> i32
      scf.yield %3 : i32
    }
    return %0, %2, %1 : i32, i32, i32
  }
```

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

3 years ago[DAG] computeKnownBits - Replace ISD::MUL handling with the common KnownBits::compute...
Simon Pilgrim [Wed, 4 Nov 2020 10:59:56 +0000 (10:59 +0000)]
[DAG] computeKnownBits - Replace ISD::MUL handling with the common KnownBits::computeForMul implementation

3 years ago[libomptarget][nfc] Build amdgcn deviceRTL with nogpulib
Jon Chesterfield [Wed, 4 Nov 2020 11:28:35 +0000 (11:28 +0000)]
[libomptarget][nfc] Build amdgcn deviceRTL with nogpulib

3 years ago[AMDGPU] Set rsrc1 flags for graphics shaders
Sebastian Neubauer [Wed, 14 Oct 2020 15:14:25 +0000 (17:14 +0200)]
[AMDGPU] Set rsrc1 flags for graphics shaders

Before they were only set for compute kernels and compute shaders but
not for other shaders.

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

3 years ago[AMDGPU] Fix ieee mode default value
Sebastian Neubauer [Wed, 14 Oct 2020 12:11:47 +0000 (14:11 +0200)]
[AMDGPU] Fix ieee mode default value

Previously, the default value for ieee mode was
- on for compute kernels and compute shaders,
- off for all shaders except compute shaders.

This commit changes the default to be
- on for compute kernels,
- off for shaders.

This aligns the default value with the settings that are actually in
use.  To my knowledge, all users of shader calling conventions (mesa and
llpc) disable the ieee mode by default.

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

3 years ago[NFC][UBSAN] Replace "count 0" with FileCheck
Vitaly Buka [Wed, 4 Nov 2020 10:31:16 +0000 (02:31 -0800)]
[NFC][UBSAN] Replace "count 0" with FileCheck

Unrelated system warnings may confuse "check 0"

3 years ago[mlir] Fix failing shared libraries build
Andrzej Warzynski [Wed, 4 Nov 2020 10:30:19 +0000 (10:30 +0000)]
[mlir] Fix failing shared libraries build

Failing buildbot: http://lab.llvm.org:8011/#/builders/33/builds/478

Patch that introduced the breaking change: https://reviews.llvm.org/D90667

3 years ago[JITLink][ELF] Omit temporary labels in tests
Stefan Gränitz [Wed, 4 Nov 2020 10:02:59 +0000 (10:02 +0000)]
[JITLink][ELF] Omit temporary labels in tests

Oneshot temporary labels for declaring function size can be omitted. Follow-up from D90331.

Reviewed By: MaskRay

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

3 years ago[Clang] Add more fp128 math library function builtins
Qiu Chaofan [Wed, 4 Nov 2020 09:57:14 +0000 (17:57 +0800)]
[Clang] Add more fp128 math library function builtins

Since glibc has supported math library functions conforming IEEE 128-bit
floating point types on some platform (like ppc64le), we can fix clang's
math builtins missing this type.

Reviewed By: bkramer

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

3 years ago[llvm-exegesis][X86] Save and restore eflags.
Clement Courbet [Mon, 2 Nov 2020 13:25:14 +0000 (14:25 +0100)]
[llvm-exegesis][X86] Save and restore eflags.

This is needed to benchmark instruction that touch EFLAGS (e.g. STD: set direction flag).

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

3 years ago[clangd] Pass parameters to config apply functions
Kadir Cetinkaya [Fri, 30 Oct 2020 11:06:16 +0000 (12:06 +0100)]
[clangd] Pass parameters to config apply functions

This will enable some fragments to apply their features selectively.

Depends on D90270.

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

3 years ago[lldb] Delete Value::Vector class
Pavel Labath [Tue, 3 Nov 2020 16:22:35 +0000 (17:22 +0100)]
[lldb] Delete Value::Vector class

This class and it's surroundings contain a lot of shady code, but as far
as I can tell all of that code is unreachable (there is no code actually
setting the value to eValueTypeVector).

According to history this class was introduced in 2012 in
r167033/0665a0f09. At that time, the code seemed to serve some purpose,
and it had two entry points (in Value::SetContext and
ClangExpressionDeclMap::LookupDecl). The first entry point was deleted
in D17897 and the second one in r179842/44342735.

The stated purpose of the patch introducing this class was to fix
TestRegisters.py, and "expr $xmm0" in particular. Both of these things
function perfectly well these days without this class.

3 years ago[sanitizer] Remove ANDROID_NDK_VERSION
Vitaly Buka [Wed, 4 Nov 2020 09:14:13 +0000 (01:14 -0800)]
[sanitizer] Remove ANDROID_NDK_VERSION

3 years ago[llvm-exegesis] Fix unused variable warning.
Clement Courbet [Wed, 4 Nov 2020 09:09:07 +0000 (10:09 +0100)]
[llvm-exegesis] Fix unused variable warning.

3 years ago[ARM] Remove unused variable. NFC
David Green [Wed, 4 Nov 2020 09:00:03 +0000 (09:00 +0000)]
[ARM] Remove unused variable. NFC

3 years ago[sanitizer] Remove -Wno-non-virtual-dtor
Vitaly Buka [Tue, 3 Nov 2020 04:45:57 +0000 (20:45 -0800)]
[sanitizer] Remove -Wno-non-virtual-dtor

Warning should be fixed with d48f2d7c02743571075bb7812bb4c9e634e51ed1

3 years agoUse LLD for Android compiler-rt
Vy Nguyen [Wed, 4 Nov 2020 00:10:35 +0000 (16:10 -0800)]
Use LLD for Android compiler-rt

Reviewed By: vitalybuka

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

3 years ago[NFCI] Replace AArch64StackOffset by StackOffset.
Sander de Smalen [Tue, 3 Nov 2020 16:44:20 +0000 (16:44 +0000)]
[NFCI] Replace AArch64StackOffset by StackOffset.

This patch replaces the AArch64StackOffset class by the generic one
defined in TypeSize.h.

Reviewed By: david-arm

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

3 years agoRe-land "[llvm-exegesis] Save target state before running the benchmark."
Clement Courbet [Wed, 4 Nov 2020 07:56:27 +0000 (08:56 +0100)]
Re-land "[llvm-exegesis] Save target state before running the benchmark."

The X86 exegesis target is never executed run on non-X86 hosts, disable
X86 instrinsic code on non-X86 targets.

This reverts commit 8cfc872129a99782ab07a19171bf8eace85589ae.

3 years ago[mlir] Add a simpler lowering pattern for WhileOp representing a do-while loop
Alex Zinenko [Wed, 4 Nov 2020 08:42:32 +0000 (09:42 +0100)]
[mlir] Add a simpler lowering pattern for WhileOp representing a do-while loop

When the "after" region of a WhileOp is merely forwarding its arguments back to
the "before" region, i.e. WhileOp is a canonical do-while loop, a simpler CFG
subgraph that omits the "after" region with its extra branch operation can be
produced. Loop rotation from general "while" to "if { do-while }" is left for a
future canonicalization pattern when it becomes necessary.

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

3 years ago[mlir] Add lowering to CFG for WhileOp
Alex Zinenko [Wed, 4 Nov 2020 08:42:04 +0000 (09:42 +0100)]
[mlir] Add lowering to CFG for WhileOp

The lowering is a straightforward inlining of the "before" and "after" regions
connected by (conditional) branches. This plugs the WhileOp into the
progressive lowering scheme. Future commits may choose to target WhileOp
instead of CFG when lowering ForOp.

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

3 years ago[mlir] Add a generic while/do-while loop to the SCF dialect
Alex Zinenko [Wed, 4 Nov 2020 08:41:55 +0000 (09:41 +0100)]
[mlir] Add a generic while/do-while loop to the SCF dialect

The new construct represents a generic loop with two regions: one executed
before the loop condition is verifier and another after that. This construct
can be used to express both a "while" loop and a "do-while" loop, depending on
where the main payload is located. It is intended as an intermediate
abstraction for lowering, which will be added later. This form is relatively
easy to target from higher-level abstractions and supports transformations such
as loop rotation and LICM.

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

3 years ago[clangd] Store the containing symbol for refs
Nathan Ridge [Mon, 19 Oct 2020 05:22:21 +0000 (01:22 -0400)]
[clangd] Store the containing symbol for refs

This is needed to implement call hierarchy.

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

3 years ago[Flang][OpenMP] Add semantic checks for OpenMP copyin clause.
Praveen G [Wed, 4 Nov 2020 07:52:04 +0000 (02:52 -0500)]
[Flang][OpenMP] Add semantic checks for OpenMP copyin clause.

Add the semantic checks for the OpenMP 4.5 - 2.15.4.1 copyin clause.

Resolve OpenMPThreadprivate directive since the list of items specified
in copyin clause should be threadprivate.

Test cases : omp-copyin01.f90, omp-copyin02.f90, omp-copyin03.f90,
             omp-copyin04.f90, omp-copyin05.f90

Reviewed By: kiranchandramohan

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

3 years ago[DebugInfo] Delete unused DwarfUnit::addConstantFPValue & addConstantValue overloads...
Fangrui Song [Wed, 4 Nov 2020 08:05:57 +0000 (00:05 -0800)]
[DebugInfo] Delete unused DwarfUnit::addConstantFPValue & addConstantValue overloads. NFC

This functions appear to be unused for many years.

3 years agoRevert "Re-land "[llvm-exegesis] Save target state before running the benchmark."
Clement Courbet [Wed, 4 Nov 2020 07:48:44 +0000 (08:48 +0100)]
Revert "Re-land "[llvm-exegesis] Save target state before running the benchmark."

Still issues on some architectures.

This reverts commit fd13d7ce09af2bcad6976b8f5207874992bdd908.

3 years agoRe-land "[llvm-exegesis] Save target state before running the benchmark.
Clement Courbet [Mon, 2 Nov 2020 14:31:58 +0000 (15:31 +0100)]
Re-land "[llvm-exegesis] Save target state before running the benchmark.

Use `__builtin_ia32_fxsave64` under __GNUC__, (_fxsave64) does not exist in old versions of
gcc (pre-9.1).

This reverts commit e128f9cafca4e72b089fcd1381af5a1ec656d987.

3 years ago[mlir][Python] Return and accept OpView for all functions.
Stella Laurenzo [Mon, 2 Nov 2020 07:05:36 +0000 (23:05 -0800)]
[mlir][Python] Return and accept OpView for all functions.

* All functions that return an Operation now return an OpView.
* All functions that accept an Operation now accept an _OperationBase, which both Operation and OpView extend and can resolve to the backing Operation.
* Moves user-facing instance methods from Operation -> _OperationBase so that both can have the same API.
* Concretely, this means that if there are custom op classes defined (i.e. in Python), any iteration or creation will return the appropriate instance (i.e. if you get/create an std.addf, you will get an instance of the mlir.dialects.std.AddFOp class, getting full access to any custom API it exposes).
* Refactors all __eq__ methods after realizing the proper way to do this for _OperationBase.

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

3 years agoFix linkage error on mlirLogicalResultIsFailure.
Stella Laurenzo [Wed, 4 Nov 2020 06:45:56 +0000 (22:45 -0800)]
Fix linkage error on mlirLogicalResultIsFailure.

* For C, this needs to be inline static like the others.

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

3 years agoRevert "[AggressiveInstCombine] Generalize foldGuardedRotateToFunnelShift to generic...
Martin Storsjö [Wed, 4 Nov 2020 06:27:22 +0000 (08:27 +0200)]
Revert "[AggressiveInstCombine] Generalize foldGuardedRotateToFunnelShift to generic funnel shifts"

This reverts commit 59b22e495c15d2830f41381a327f5d6bf49ff416.

That commit broke building for ARM and AArch64, reproducible like this:

$ cat apedec-reduced.c
a;
b(e) {
  int c;
  unsigned d = f();
  c = d >> 32 - e;
  return c;
}
g() {
  int h = i();
  if (a)
    h = h << a | b(a);
  return h;
}
$ clang -target aarch64-linux-gnu -w -c -O3 apedec-reduced.c
clang: ../lib/Transforms/InstCombine/InstructionCombining.cpp:3656: bool llvm::InstCombinerImpl::run(): Assertion `DT.dominates(BB, UserParent) && "Dominance relation broken?"' failed.

Same thing for e.g. an armv7-linux-gnueabihf target.

3 years agoEnable -Werror-implicit-function-declaration by default (NFC)
Mehdi Amini [Wed, 4 Nov 2020 00:06:28 +0000 (00:06 +0000)]
Enable -Werror-implicit-function-declaration by default (NFC)

This is useful in C source files where it is easy for a typo to be
silently assumed by the compiler to be an implicit declaration.

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

3 years agoSwitch the CallbackOstream wrapper in the MLIR C API to an Unbuffered stream
Mehdi Amini [Tue, 3 Nov 2020 23:46:42 +0000 (23:46 +0000)]
Switch the CallbackOstream wrapper in the MLIR C API to an Unbuffered stream

This delegate the control of the buffering to the user of the API. This
seems like a safer option as messages are immediately propagated to the
user, which may lead to less surprising behavior during debugging for
instance.
In terms of performance, a user can add a buffered stream on the other
side of the callback.

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

3 years agoAdd a basic C API for the MLIR PassManager as well as a basic TableGen backend for...
Mehdi Amini [Tue, 3 Nov 2020 21:38:34 +0000 (21:38 +0000)]
Add a basic C API for the MLIR PassManager as well as a basic TableGen backend for creating passes

This is exposing the basic functionalities (create, nest, addPass, run) of
the PassManager through the C API in the new header: `include/mlir-c/Pass.h`.

In order to exercise it in the unit-test, a basic TableGen backend is
also provided to generate a simple C wrapper around the pass
constructor. It is used to expose the libTransforms passes to the C API.

Reviewed By: stellaraccident, ftynse

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

3 years agoPort print-must-be-executed-contexts and print-mustexecute to NPM
Arthur Eubanks [Tue, 27 Oct 2020 02:57:39 +0000 (19:57 -0700)]
Port print-must-be-executed-contexts and print-mustexecute to NPM

Reviewed By: asbirlea

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

3 years ago[RISCV] Add fshl with immediate tests for Zbt extension. NFC
Craig Topper [Wed, 4 Nov 2020 04:57:53 +0000 (20:57 -0800)]
[RISCV] Add fshl with immediate tests for Zbt extension. NFC

We should be able to map this to fsri with adjustment of the
immediate.

3 years ago[StackColoring] Conservatively merge catch point of V for catch(V)
Xiang1 Zhang [Tue, 3 Nov 2020 01:12:35 +0000 (09:12 +0800)]
[StackColoring] Conservatively merge catch point of V for catch(V)

Reviewed By: thanm, clin1

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

3 years ago[MachineInstr] Add support for instructions with multiple memory operands.
Michael Liao [Mon, 12 Oct 2020 14:01:40 +0000 (10:01 -0400)]
[MachineInstr] Add support for instructions with multiple memory operands.

- Basically iterate each pair of memory operands from both instructions
  and return true if any of them may alias.
- The exception are memory instructions without any memory operand. They
  may touch everything and could alias to any memory instruction.

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

3 years ago[clangd][NFC] Make Located::operator->() use pointer sematics
Nathan James [Wed, 4 Nov 2020 01:36:13 +0000 (01:36 +0000)]
[clangd][NFC] Make Located::operator->() use pointer sematics

This enables using the arrow operator to access members of the contained item.
```lang=c++
Located<std::string> X;
const char* CStr = X->c_str();
```
This is inline with how classes like `Optional` handle the arrow operator.

Reviewed By: kadircet

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

3 years ago[NFC] Use [MC]Register in register allocation
Gaurav Jain [Tue, 3 Nov 2020 04:07:58 +0000 (20:07 -0800)]
[NFC] Use [MC]Register in register allocation

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

3 years ago[AArch64][GlobalISel] Add combine for G_EXTRACT_VECTOR_ELT to allow selection of...
Amara Emerson [Tue, 3 Nov 2020 19:17:31 +0000 (11:17 -0800)]
[AArch64][GlobalISel] Add combine for G_EXTRACT_VECTOR_ELT to allow selection of pairwise FADD.

For the <2 x float> case, instead of adding another combine or legalization to
get it into a <4 x float> form, I'm just adding a GISel specific selection
pattern to cover it.

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

3 years ago[MLIR] Check for duplicate entries in attribute dictionary during custom parsing
Rahul Joshi [Tue, 3 Nov 2020 22:31:23 +0000 (14:31 -0800)]
[MLIR] Check for duplicate entries in attribute dictionary during custom parsing

- Verify that attributes parsed using a custom parser do not have duplicates.
- If there are duplicated in the attribute dictionary in the input, they get caught during the
  dictionary parsing.
- This check verifies that there is no duplication between the parsed dictionary and any
  attributes that might be added by the custom parser (or when the custom parsing code
  adds duplicate attributes).
- Fixes https://bugs.llvm.org/show_bug.cgi?id=48025

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

3 years ago[flang] Dodge gcc 8.2.0 build problem (NFC)
peter klausler [Tue, 3 Nov 2020 18:45:01 +0000 (10:45 -0800)]
[flang] Dodge gcc 8.2.0 build problem (NFC)

Add explicit member initializers to the declarations of
some constexpr values added in a recent patch to avoid an
apparent problem with gcc 8.2.0 with default initializers.

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

3 years ago[MLIR] Move eraseArguments and eraseResults to FunctionLike
mikeurbach [Thu, 22 Oct 2020 17:39:39 +0000 (11:39 -0600)]
[MLIR] Move eraseArguments and eraseResults to FunctionLike

Previously, they were only defined for `FuncOp`.

To support this, `FunctionLike` needs a way to get an updated type
from the concrete operation. This adds a new hook for that purpose,
called `getTypeWithoutArgsAndResults`.

For now, `FunctionLike` continues to assume the type is
`FunctionType`, and concrete operations that use another type can hide
the `getType`, `setType`, and `getTypeWithoutArgsAndResults` methods.

Reviewed By: rriddle

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

3 years ago[libc][NFC][Obvious] Use the new macro to declare special constants in tests.
Siva Chandra Reddy [Sun, 1 Nov 2020 05:28:44 +0000 (22:28 -0700)]
[libc][NFC][Obvious] Use the new macro to declare special constants in tests.

3 years ago[WebAssembly] Don't fold frame offset for global addresses
Julien Jorge [Mon, 2 Nov 2020 01:29:26 +0000 (17:29 -0800)]
[WebAssembly] Don't fold frame offset for global addresses

When machine instructions are in the form of
```
%0 = CONST_I32 @str
%1 = ADD_I32 %stack.0, %0
%2 = LOAD 0, 0, %1
```

In the `ADD_I32` instruction, it is possible to fold it if `%0` is a
`CONST_I32` from an immediate number. But in this case it is a global
address, so we shouldn't do that. But we haven't checked if the operand
of `ADD` is an immediate so far. This fixes the problem. (The case
applies the same for `ADD_I64` and `CONST_I64` instructions.)

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

Patch by Julien Jorge (jjorge@quarkslab.com)

Reviewed By: dschuff

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

3 years ago[mlir][vector] Make linalg FillOp vectorization use Transfer op
Thomas Raoux [Tue, 3 Nov 2020 22:35:26 +0000 (14:35 -0800)]
[mlir][vector] Make linalg FillOp vectorization use Transfer op

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

3 years ago[ARM] remove cost-kind predicate for most math op costs
Sanjay Patel [Tue, 3 Nov 2020 22:06:21 +0000 (17:06 -0500)]
[ARM] remove cost-kind predicate for most math op costs

This is based on the same idea that I am using for the basic model implementation
and what I have partly already done for x86: throughput cost is number of
instructions/uops, so size/blended costs are identical except in special cases
(for example, fdiv or other known-expensive machine instructions or things like
MVE that may require cracking into >1 uop)).

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

3 years agoRemove extra comma after macro, fix GCC warning (NFC)
Mehdi Amini [Tue, 3 Nov 2020 22:21:39 +0000 (22:21 +0000)]
Remove extra comma after macro, fix GCC warning (NFC)

3 years ago[MLIR] NFC : Move OpenMP dialect include to translation
Kiran Chandramohan [Tue, 3 Nov 2020 17:42:05 +0000 (17:42 +0000)]
[MLIR] NFC : Move OpenMP dialect include to translation

The OpenMP dialect include is only needed for translation
and is not required in LLVM dialect.

Reviewed By: ftynse

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

3 years agoWhen re-checking an already-substituted template argument, don't lose
Richard Smith [Tue, 3 Nov 2020 22:02:56 +0000 (14:02 -0800)]
When re-checking an already-substituted template argument, don't lose
the reference-ness of the parameter's type.

3 years agoUndo Revert "Ignore template instantiations if not in AsIs mode"
Matt Morehouse [Tue, 3 Nov 2020 21:59:01 +0000 (13:59 -0800)]
Undo Revert "Ignore template instantiations if not in AsIs mode"

MaskRay already fixed the ASan bug.

3 years agoRevert "Ignore template instantiations if not in AsIs mode"
Matt Morehouse [Tue, 3 Nov 2020 19:48:07 +0000 (11:48 -0800)]
Revert "Ignore template instantiations if not in AsIs mode"

This reverts commit 53df3beb624989ed32d87697d0c17601d7871465 due to
check-asan failure on the buildbot.

3 years ago[docs] Fix docs-llvm-html after recent TableGen changes D90617
Fangrui Song [Tue, 3 Nov 2020 21:43:24 +0000 (13:43 -0800)]
[docs] Fix docs-llvm-html after recent TableGen changes D90617

3 years ago[libc++][NFC] Mark LWG issue 2899 as not complete.
zoecarver [Tue, 3 Nov 2020 21:35:12 +0000 (13:35 -0800)]
[libc++][NFC] Mark LWG issue 2899 as not complete.

Commit 59e26308e60a08a5a4534ba827744564c71d7aff accidentally
marked this LWG issue as complete but it has not yet been
implemented. D66262 fixes this issue.

3 years ago[LIBC][NFC] Rename errno and assert files to match other files with functions
Michael Jones [Mon, 2 Nov 2020 23:16:00 +0000 (23:16 +0000)]
[LIBC][NFC] Rename errno and assert files to match other files with functions

Rename the files containing the `__errno_location` function
to `__errno_location.h/cpp` to match the other files and move
the `llvmlibc_errno` macro to its own file.

Split assert.h into `__assert_fail.h` (contains the function prototype)
and assert.h (contains the assert macro).

Reviewed By: sivachandra

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

3 years ago[NFC] Fix call to lldb RegisterValue constructor
Jordan Rupprecht [Tue, 3 Nov 2020 21:24:06 +0000 (13:24 -0800)]
[NFC] Fix call to lldb RegisterValue constructor

3 years ago[mlir][Parser] Small optimization to parsing
River Riddle [Tue, 3 Nov 2020 20:31:24 +0000 (12:31 -0800)]
[mlir][Parser] Small optimization to parsing

* Use function_ref instead of std::function in several methods
* Use ::get instead of ::getChecked for IntegerType.
  - It is already fully verified and constructing a mlir::Location can be extremely costly during parsing.

3 years ago[PowerPC] Add MMA builtin decoding and definitions
Baptiste Saleil [Tue, 3 Nov 2020 21:08:00 +0000 (15:08 -0600)]
[PowerPC] Add MMA builtin decoding and definitions

Add MMA builtin decoding. These builtins use the new PowerPC-specific types __vector_pair and __vector_quad.
So to avoid pervasive changes, we use custom type descriptors and custom decoding for these builtins.
We also use custom code generation to expand builtin calls with pointers to simpler intrinsic calls with non-pointer types.

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

3 years ago[NFC] Inline wasm assertion-only variable
Jordan Rupprecht [Tue, 3 Nov 2020 21:06:52 +0000 (13:06 -0800)]
[NFC] Inline wasm assertion-only variable

3 years ago[libc++] Harden tests against executors not running tests in a shell
Louis Dionne [Tue, 3 Nov 2020 19:44:47 +0000 (14:44 -0500)]
[libc++] Harden tests against executors not running tests in a shell

Some executors do not run the tests in a shell, and so assuming that
they can understand shell builtins is wrong. Instead, call Bash
directly to do what we need to do.

This still requires the executor to be able to run Bash, but at least
it does not require it to interpret command lines in the Bash language.

3 years ago[lldb] [test] Update XFAILs/skips for FreeBSD
Michał Górny [Tue, 3 Nov 2020 18:25:48 +0000 (19:25 +0100)]
[lldb] [test] Update XFAILs/skips for FreeBSD

Update expected failures and test skips based on common results
for the old and new FreeBSD plugins.

3 years ago[lldb] [test/Shell] Pass -pthread to host toolchain on FreeBSD too
Michał Górny [Tue, 3 Nov 2020 18:25:16 +0000 (19:25 +0100)]
[lldb] [test/Shell] Pass -pthread to host toolchain on FreeBSD too

3 years ago[lldb] [test] Remove xfail from tests that pass on FreeBSD
Michał Górny [Tue, 3 Nov 2020 17:46:10 +0000 (18:46 +0100)]
[lldb] [test] Remove xfail from tests that pass on FreeBSD

3 years ago[OpenMP] Fixed an issue in the test case parallel_offloading_map
Shilei Tian [Tue, 3 Nov 2020 20:59:05 +0000 (15:59 -0500)]
[OpenMP] Fixed an issue in the test case parallel_offloading_map

There is a non-conforming use of variable-sized array in the test case `parallel_offloading_map.c`. This patch fixed it.

Reviewed By: protze.joachim

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

3 years ago[clangd] Fix missing override warnings in remote-index client
Kadir Cetinkaya [Tue, 3 Nov 2020 20:46:44 +0000 (21:46 +0100)]
[clangd] Fix missing override warnings in remote-index client

3 years ago[clangd] Handle absolute/relative path specifications in Config
Kadir Cetinkaya [Tue, 27 Oct 2020 22:03:41 +0000 (23:03 +0100)]
[clangd] Handle absolute/relative path specifications in Config

This introduces a mechanism for providers to interpret paths specified
in a fragment either as absolute or relative to fragment location.
This information should be used during compile stage to handle blocks correctly.

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

3 years ago[libc++] Remove support for .run.fail.cpp tests
Louis Dionne [Tue, 3 Nov 2020 20:24:00 +0000 (15:24 -0500)]
[libc++] Remove support for .run.fail.cpp tests

Unfortunately, executing these tests correctly on platforms that do not
support a shell is very challenging. Since the executor can't just negate
the result of the command, we'd have to ship a portable program capable
of running the actual test executable, and negating its result.

Doing this portably is challenging. Since we do not currently have strong
use cases for tests that fail at runtime (we effectively have no tests
using that capability right now), it is difficult to justify making them
work portably. Instead, it makes more sense to remove this feature until
we can implement it properly (i.e. without requiring shell support).

3 years ago[unittest][TrasnformerTest] Fix asan stack-use-after-return
Fangrui Song [Tue, 3 Nov 2020 20:34:45 +0000 (12:34 -0800)]
[unittest][TrasnformerTest] Fix asan stack-use-after-return

3 years ago[libc++] NFC: Simplify how we run config tests
Louis Dionne [Tue, 3 Nov 2020 19:37:42 +0000 (14:37 -0500)]
[libc++] NFC: Simplify how we run config tests

We can use the convenience substitutions provided by the format instead
of bootstrapping our own.

3 years ago[crashlog] Print the actual exception in the CommandReturnObject
Jonas Devlieghere [Tue, 3 Nov 2020 19:49:59 +0000 (11:49 -0800)]
[crashlog] Print the actual exception in the CommandReturnObject

Before:

  error: python exception <class 'AttributeError'>

After:

  error: python exception: 'DarwinImage' object has no attribute 'debugger'

3 years ago[musttail] Unify musttail call preceding return checking
Xun Li [Tue, 3 Nov 2020 19:39:27 +0000 (11:39 -0800)]
[musttail] Unify musttail call preceding return checking

There is already an API in BasicBlock that checks and returns the musttail call if it precedes the return instruction.
Use it instead of manually checking in each place.

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

3 years ago[compiler-rt] Use empty SuspendedThreadsList for Fuchsia
Petr Hosek [Tue, 3 Nov 2020 18:41:17 +0000 (10:41 -0800)]
[compiler-rt] Use empty SuspendedThreadsList for Fuchsia

d48f2d7 made destructor of SuspendedThreadsList protected, so we need
an empty subclass to pass to the callback now.

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

3 years ago[memprof] Don't protect destructor in final
Vitaly Buka [Tue, 3 Nov 2020 19:27:04 +0000 (11:27 -0800)]
[memprof] Don't protect destructor in final

3 years ago[Reassociate] Convert `add`-like `or`'s into an `add`'s to allow reassociation
Roman Lebedev [Tue, 3 Nov 2020 19:01:22 +0000 (22:01 +0300)]
[Reassociate] Convert `add`-like `or`'s into an `add`'s to allow reassociation

InstCombine is quite aggressive in doing the opposite transform,
folding `add` of operands with no common bits set into an `or`,
and that not many things support that new pattern..

In this case, teaching Reassociate about it is easy,
there's preexisting art for `sub`/`shl`:
just convert such an `or` into an `add`:
https://rise4fun.com/Alive/Xlyv

3 years ago[NFC][Reassociate] Add tests with `add`-like `or` (w/ no common bits set)
Roman Lebedev [Tue, 3 Nov 2020 18:24:13 +0000 (21:24 +0300)]
[NFC][Reassociate] Add tests with `add`-like `or` (w/ no common bits set)

3 years ago[mlir][vector] Add canonicalization patterns for ExtractStride/ShapeCast + Splat...
Thomas Raoux [Tue, 3 Nov 2020 18:56:22 +0000 (10:56 -0800)]
[mlir][vector] Add canonicalization patterns for ExtractStride/ShapeCast + Splat constant

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

3 years agoRevert "Precommit LTO pipeline test"
Sanne Wouda [Tue, 3 Nov 2020 19:29:14 +0000 (19:29 +0000)]
Revert "Precommit LTO pipeline test"

This reverts commit 5a72a1623e4afd9365a13473079db1ec66af1f0e.

3 years agoRevert "Add loop distribution to the LTO pipeline"
Sanne Wouda [Tue, 3 Nov 2020 19:29:00 +0000 (19:29 +0000)]
Revert "Add loop distribution to the LTO pipeline"

This reverts commit 6e80318eecde2639faa1e72be045c78b8b8aedad.

3 years ago[AMDGPU] Add some missing tests for GFX10.3 subtargets
Jay Foad [Tue, 3 Nov 2020 19:17:27 +0000 (19:17 +0000)]
[AMDGPU] Add some missing tests for GFX10.3 subtargets

3 years agoFix - [Clang] Add the ability to map DLL storage class to visibility
Ben Dunbobbin [Tue, 3 Nov 2020 18:54:57 +0000 (18:54 +0000)]
Fix - [Clang] Add the ability to map DLL storage class to visibility

415f7ee883 had a silly typo introduced when I inlined some
code into a loop from its own function.

Original commit message:

For PlayStation we offer source code compatibility with
Microsoft's dllimport/export annotations; however, our file
format is based on ELF.

To support this we translate from DLL storage class to ELF
visibility at the end of codegen in Clang.

Other toolchains have used similar strategies (e.g. see the
documentation for this ARM toolchain:

https://developer.arm.com/documentation/dui0530/i/migrating-from-rvct-v3-1-to-rvct-v4-0/changes-to-symbol-visibility-between-rvct-v3-1-and-rvct-v4-0)

This patch adds the ability to perform this translation. Options
are provided to support customizing the mapping behaviour.

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

3 years agoAdd loop distribution to the LTO pipeline
Sanne Wouda [Wed, 21 Oct 2020 11:01:59 +0000 (11:01 +0000)]
Add loop distribution to the LTO pipeline

The LoopDistribute pass is missing from the LTO pipeline, so
-enable-loop-distribute has no effect during post-link. The pre-link
loop distribution doesn't seem to survive the LTO pipeline either.

With this patch (and -flto -mllvm -enable-loop-distribute) we see a 43%
uplift on SPEC 2006 hmmer for AArch64. The rest of SPECINT 2006 is
unaffected.

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

3 years agoPrecommit LTO pipeline test
Sanne Wouda [Wed, 21 Oct 2020 19:27:47 +0000 (19:27 +0000)]
Precommit LTO pipeline test

3 years agoReturn actual type from SBType::GetArrayElementType
Andy Yankovsky [Tue, 3 Nov 2020 18:32:42 +0000 (10:32 -0800)]
Return actual type from SBType::GetArrayElementType

SBType::GetArrayElementType should return the actual type, not the
canonical type (e.g. int32_t, not the underlying int).

Added a test case to validate the new behavior. I also ran all other
tests on Linux (ninja check-lldb), they all pass.

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

3 years ago[WebAssembly] Implement ref.null
Andy Wingo [Tue, 3 Nov 2020 18:46:23 +0000 (10:46 -0800)]
[WebAssembly] Implement ref.null

This patch adds a new "heap type" operand kind to the WebAssembly MC
layer, used by ref.null. Currently the possible values are "extern" and
"func"; when typed function references come, though, this operand may be
a type index.

Note that the "heap type" production is still known as "refedtype" in
the draft proposal; changing its name in the spec is
ongoing (https://github.com/WebAssembly/reference-types/issues/123).

The register form of ref.null is still untested.

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

3 years ago[HIP] Math Headers to use type promotion
Aaron En Ye Shi [Wed, 28 Oct 2020 17:51:55 +0000 (17:51 +0000)]
[HIP] Math Headers to use type promotion

Similar to libcxx implementation of cmath function
overloads, use type promotion templates to determine
return types of multi-argument math functions.

Fixes: SWDEV-256825

Reviewed By: tra, yaxunl

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

3 years ago[HIP] Use argv[0] as the default choice for the Executable name.
Artem Belevich [Thu, 29 Oct 2020 22:19:06 +0000 (15:19 -0700)]
[HIP] Use argv[0] as the default choice for the Executable name.

The path produced by getMainExecutable() may not be the right one when the files are installed in
a symlinked tree and when the real location of llvm-objdump is in a different directory.

Given that clang-offload-bundler is invoked by clang, the driver already does the job figuring out
the right path (e.g. it pays attention to -no-canonical-prefixes).
Offload bundler should use it, instead of trying to figure out the path on its
own.

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

3 years ago[CUDA] Allow local static variables with target attributes.
Artem Belevich [Fri, 25 Sep 2020 23:25:27 +0000 (16:25 -0700)]
[CUDA] Allow local static variables with target attributes.

While CUDA documentation claims that such variables are not allowed[1], NVCC has
been accepting them since CUDA-10.0[2] and some headers in CUDA-11 rely on this
working.

1. https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#static-variables-function
2. https://godbolt.org/z/zsodzc

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

3 years ago[GVN] small improvements to comments
Jameson Nash [Tue, 3 Nov 2020 18:17:52 +0000 (13:17 -0500)]
[GVN] small improvements to comments

3 years ago[crashlog] Modularize parser
Jonas Devlieghere [Tue, 3 Nov 2020 18:21:00 +0000 (10:21 -0800)]
[crashlog] Modularize parser

Instead of parsing the crashlog in one big loop, use methods that
correspond to the different parsing modes.

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

3 years agoCleanup namespace comment to fix clang-tidy warning. NFCI.
Simon Pilgrim [Tue, 3 Nov 2020 18:13:21 +0000 (18:13 +0000)]
Cleanup namespace comment to fix clang-tidy warning. NFCI.

3 years ago[DAG] computeKnownBits - Move ISD::SRA handling into KnownBits::ashr
Simon Pilgrim [Tue, 3 Nov 2020 18:09:15 +0000 (18:09 +0000)]
[DAG] computeKnownBits - Move ISD::SRA handling into KnownBits::ashr

As discussed on D90527, we should be trying to move shift handling functionality into KnownBits to avoid code duplication in SelectionDAG/GlobalISel/ValueTracking.