platform/upstream/llvm.git
3 years ago[lldb] Also Catch invalid calls to TestPExpectTest's expect()
Raphael Isemann [Thu, 5 Nov 2020 12:41:26 +0000 (13:41 +0100)]
[lldb] Also Catch invalid calls to TestPExpectTest's expect()

This is a follow up to D88792 which found an issue in a call to PExpectTest's
expect function that allows passing a string to the `substrs` parameter. However
this issue was found by just grepping and TestPExpect's expect function is still
accepting a single string as a value to `substrs`.

This patch adds the same sanity check that D88792 added to the PExpectTest's
implementation of `expect` and also adds a small test for it.

Reviewed By: kastiglione, JDevlieghere

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

3 years ago[Flang][f18] Remove unimplemented options from `flang -help` (NFC)
Andrzej Warzynski [Thu, 5 Nov 2020 12:34:42 +0000 (12:34 +0000)]
[Flang][f18] Remove unimplemented options from `flang -help` (NFC)

3 years ago[GVN] Fix MemorySSA update when replacing assume(false) with stores.
Florian Hahn [Thu, 5 Nov 2020 11:51:06 +0000 (11:51 +0000)]
[GVN] Fix MemorySSA update when replacing assume(false) with stores.

When replacing an assume(false) with a store, we have to be more careful
with the order we insert the new access. This patch updates the code to
look at the accesses in the block to find a suitable insertion point.

Alterantively we could check the defining access of the assume, but IIRC
there has been some discussion about making assume() readnone, so
looking at the access list might be more future proof.

Fixes PR48072.

Reviewed By: asbirlea

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

3 years ago[OpenCL] Support vec_step in C++ for OpenCL mode
Sven van Haastregt [Thu, 5 Nov 2020 12:02:59 +0000 (12:02 +0000)]
[OpenCL] Support vec_step in C++ for OpenCL mode

Enable the vec_step builtin in C++ for OpenCL mode for compatibility
with OpenCL C.

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

3 years ago[GlobalISel] ComputeKnownBits - use common KnownBits shift handling (PR44526)
Simon Pilgrim [Thu, 5 Nov 2020 11:52:07 +0000 (11:52 +0000)]
[GlobalISel] ComputeKnownBits - use common KnownBits shift handling (PR44526)

Convert GISelKnownBits.computeKnownBitsImpl shift handling to use the common KnownBits implementations, which makes use of the known leading/trailing bits for shifted values in cases where we don't know the shift amount value, as detailed in https://blog.regehr.org/archives/1709

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

3 years ago[lsan] Disable some LSAN tests for arm-linux-gnueabi{hf}
Adhemerval Zanella [Mon, 2 Nov 2020 17:42:24 +0000 (14:42 -0300)]
[lsan] Disable some LSAN tests for arm-linux-gnueabi{hf}

The tests do not report the expected leak when issued with use_stack
or use_tls option equal to 0 on arm-linux-gnueabihf (ubuntu 18.04,
glibc 2.27).

This issue is being tracked by https://bugs.llvm.org/show_bug.cgi?id=48052

3 years ago[sanitizer] Assume getrandom might not be supported by the kernel
Adhemerval Zanella [Mon, 2 Nov 2020 17:38:12 +0000 (14:38 -0300)]
[sanitizer] Assume getrandom might not be supported by the kernel

It was added on kernel 3.17.

3 years ago[OpenMP] avoid warning: equality comparison with extraneous parentheses
Joachim Protze [Thu, 5 Nov 2020 09:50:17 +0000 (10:50 +0100)]
[OpenMP] avoid warning: equality comparison with extraneous parentheses

The macros are used in several places with an if(macro) pattern. This results
in several warnings about extraneous parenteses in equality comparison.

Having the constant at the lhs of the comparison, avoids this warning.

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

3 years ago[SVE] Return StackOffset for TargetFrameLowering::getFrameIndexReference.
Sander de Smalen [Wed, 4 Nov 2020 08:56:54 +0000 (08:56 +0000)]
[SVE] Return StackOffset for TargetFrameLowering::getFrameIndexReference.

To accommodate frame layouts that have both fixed and scalable objects
on the stack, describing a stack location or offset using a pointer + uint64_t
is not sufficient. For this reason, we've introduced the StackOffset class,
which models both the fixed- and scalable sized offsets.

The TargetFrameLowering::getFrameIndexReference is made to return a StackOffset,
so that this can be used in other interfaces, such as to eliminate frame indices
in PEI or to emit Debug locations for variables on the stack.

This patch is purely mechanical and doesn't change the behaviour of how
the result of this function is used for fixed-sized offsets. The patch adds
various checks to assert that the offset has no scalable component, as frame
offsets with a scalable component are not yet supported in various places.

Reviewed By: arsenm

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

3 years agoRevert rGbbeb08497ce58 "Revert "[GlobalISel] GISelKnownBits::computeKnownBitsImpl...
Simon Pilgrim [Thu, 5 Nov 2020 10:39:53 +0000 (10:39 +0000)]
Revert rGbbeb08497ce58 "Revert "[GlobalISel] GISelKnownBits::computeKnownBitsImpl - Replace TargetOpcode::G_MUL handling with the common KnownBits::computeForMul implementation""

Updated the GISel KnownBits tests as KnownBits::computeForMul allows more accurate computation.

3 years ago[UnitTests] Add exhaustive tests for KnownBits shl/lshr/ashr
Simon Pilgrim [Wed, 4 Nov 2020 18:19:26 +0000 (18:19 +0000)]
[UnitTests] Add exhaustive tests for KnownBits shl/lshr/ashr

Thanks to @foad for the suggestion.

3 years ago[InstCombine] Remove orphan InstCombinerImpl method declarations. NFCI.
Simon Pilgrim [Wed, 4 Nov 2020 17:34:08 +0000 (17:34 +0000)]
[InstCombine] Remove orphan InstCombinerImpl method declarations. NFCI.

3 years ago[SyntaxTree] Add reverse links to syntax Nodes.
Eduardo Caldas [Tue, 27 Oct 2020 15:14:03 +0000 (15:14 +0000)]
[SyntaxTree] Add reverse links to syntax Nodes.

Rationale:
Children of a syntax tree had forward links only, because there was no
need for reverse links.

This need appeared when we started mutating the syntax tree.
On a forward list, to remove a target node in O(1) we need a pointer to the node before the target. If we don't have this "before" pointer, we have to find it, and that requires O(n).
So in order to remove a syntax node from a tree, we would similarly need to find the node before to then remove. This is both not ergonomic nor does it have a good complexity.

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

3 years ago[mlir] Restructure C API tests for IR
Alex Zinenko [Wed, 4 Nov 2020 09:30:00 +0000 (10:30 +0100)]
[mlir] Restructure C API tests for IR

The test file is a long list of functions, followed by equally long FileCheck
comments inside "main". Distribute FileCheck comments closer to the functions
that produce the output we are checking.

Reviewed By: mehdi_amini, stellaraccident

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

3 years ago[mlir][Linalg] Side effects interface for Linalg ops
Nicolas Vasilache [Thu, 5 Nov 2020 08:17:15 +0000 (08:17 +0000)]
[mlir][Linalg] Side effects interface for Linalg ops

The LinalgDependenceGraph and alias analysis provide the necessary analysis for the Linalg fusion on buffers case.

However this is not enough for linalg on tensors which require proper memory effects to play nicely with DCE and other transformations.
This revision adds side effects to Linalg ops that were previously missing and has 2 consequences:
1. one example in the copy removal pass now fails since the linalg.generic op has side effects and the pass does not perform alias analysis / distinguish between reads and writes.
2. a few examples in fusion-tensor.mlir need to return the resulting tensor otherwise DCE automatically kicks in as part of greedy pattern application.

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

3 years ago[flang] update ODS syntax to use OpBuidlerDAG instead of OpBuilder
Alex Zinenko [Tue, 27 Oct 2020 11:59:22 +0000 (12:59 +0100)]
[flang] update ODS syntax to use OpBuidlerDAG instead of OpBuilder

Upstream MLIR has deprecated OpBuilder in ODS.

Reviewed By: schweitz

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

3 years ago[ARM] Make tests less dependent on scheduling. NFC
David Green [Thu, 5 Nov 2020 08:26:55 +0000 (08:26 +0000)]
[ARM] Make tests less dependent on scheduling. NFC

3 years ago[mlir][spirv] Add VectorExtractDynamicOp and vector.extractelement lowering
Artur Bialas [Thu, 5 Nov 2020 07:26:54 +0000 (08:26 +0100)]
[mlir][spirv] Add VectorExtractDynamicOp and vector.extractelement lowering

VectorExtractDynamicOp in SPIRV dialect
conversion from vector.extractelement to spirv VectorExtractDynamicOp

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

3 years ago[mlir][spirv] Allow usage of vector size 8 and 16 with Vector16 capability
Artur Bialas [Thu, 5 Nov 2020 07:26:15 +0000 (08:26 +0100)]
[mlir][spirv] Allow usage of vector size 8 and 16 with Vector16 capability

Per spec, vector sizes 8 and 16 are allowed when Vector16 capability is present.
This change expands the limitation of vector sizes to accept these sizes.

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

3 years ago[test] Add 'REQUIRES: bpf-registered-target' to bpf-O0.c
Arthur Eubanks [Thu, 5 Nov 2020 07:18:48 +0000 (23:18 -0800)]
[test] Add 'REQUIRES: bpf-registered-target' to bpf-O0.c

3 years ago[NFC] Fix cpplint warnings
Vitaly Buka [Thu, 5 Nov 2020 06:56:08 +0000 (22:56 -0800)]
[NFC] Fix cpplint warnings

3 years ago[LSAN] Fix compilation error on MSVC
Vitaly Buka [Thu, 5 Nov 2020 06:32:49 +0000 (22:32 -0800)]
[LSAN] Fix compilation error on MSVC

3 years agoRevert "[LSAN] Fix preprocessor condition for MSVC"
Vitaly Buka [Thu, 5 Nov 2020 06:31:36 +0000 (22:31 -0800)]
Revert "[LSAN] Fix preprocessor condition for MSVC"

Missread the error message. It was not the reason.

This reverts commit 2d041554d1f94abed3ddd396d8af944acf63fe4e.

3 years ago[LSAN] Fix preprocessor condition for MSVC
Vitaly Buka [Thu, 5 Nov 2020 06:27:35 +0000 (22:27 -0800)]
[LSAN] Fix preprocessor condition for MSVC

3 years ago[NewPM] Provide method to run all pipeline callbacks, used for -O0
Arthur Eubanks [Fri, 30 Oct 2020 16:35:32 +0000 (09:35 -0700)]
[NewPM] Provide method to run all pipeline callbacks, used for -O0

    Some targets may add required passes via
    TargetMachine::registerPassBuilderCallbacks(). We need to run those even
    under -O0. As an example, BPFTargetMachine adds
    BPFAbstractMemberAccessPass, a required pass.

    This also allows us to clean up BackendUtil.cpp (and out-of-tree Rust
    usage of the NPM) by allowing us to share added passes like coroutines
    and sanitizers between -O0 and other optimization levels.

    Tests are a continuation of those added in
    https://reviews.llvm.org/D89083.

    In order to prevent TargetMachines from adding unnecessary optimization
    passes at -O0, TargetMachine::registerPassBuilderCallbacks() will be
    changed to take an OptimizationLevel, but that will be done separately.

Reviewed By: asbirlea

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

3 years ago[LSAN] Enabled only with __ANDROID_API__ >= 28
Vitaly Buka [Thu, 5 Nov 2020 05:42:51 +0000 (21:42 -0800)]
[LSAN] Enabled only with __ANDROID_API__ >= 28

Code does not work as-is with emulated tls even if
lsan is disabled with runtime flag.

3 years agoCapture the name for mlir::OpPassManager in std::string instead of StringRef (NFC)
Mehdi Amini [Thu, 5 Nov 2020 03:09:20 +0000 (03:09 +0000)]
Capture the name for mlir::OpPassManager in std::string instead of StringRef (NFC)

The previous behavior was fragile when building an OpPassManager using a
string, as it was forcing the client to ensure the string to outlive the
entire PassManager.
This isn't a performance sensitive area either that would justify
optimizing further.

3 years ago[sanitizers] Add missing definition
Vy Nguyen [Thu, 5 Nov 2020 05:19:38 +0000 (00:19 -0500)]
[sanitizers] Add missing definition

Fix breakages from https://reviews.llvm.org/D90811

http://lab.llvm.org:8011/#/builders/37/builds/471/steps/8/logs/stdio

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

3 years ago[Driver] Add callback to Command execution
Serge Pavlov [Fri, 24 Apr 2020 05:48:39 +0000 (12:48 +0700)]
[Driver] Add callback to Command execution

Summary:
Object of type `Compilation` now can keep a callback that is called
after each execution of `Command`. This must simplify adaptation of
clang in custom distributions and allow facilities like collection of
execution statistics.

Reviewers: rsmith, rjmccall, Eugene.Zelenko

Subscribers: cfe-commits

Tags: #clang

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

3 years agoRevert "[SCEV] Handle non-positive case in isImpliedViaOperations"
Max Kazantsev [Thu, 5 Nov 2020 04:27:23 +0000 (11:27 +0700)]
Revert "[SCEV] Handle non-positive case in isImpliedViaOperations"

This reverts commit 8dc98897c4af20aeb52f1f19f538c08e55793283.

Commited by mistake.

3 years ago[MachineSink] add more profitable pattern.
Chen Zheng [Tue, 22 Sep 2020 00:33:05 +0000 (20:33 -0400)]
[MachineSink] add more profitable pattern.

Add more profitable sinking patterns if the target bb register pressure
is not too high.

Reviewed By: qcolombet

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

3 years ago[SCEV] Handle non-positive case in isImpliedViaOperations
Max Kazantsev [Thu, 5 Nov 2020 03:30:42 +0000 (10:30 +0700)]
[SCEV] Handle non-positive case in isImpliedViaOperations

We already handle non-negative case there. Add support for non-positive.

3 years agoRecommit "[RISCV] Move some test cases from rv64i-single-softfloat.ll to a new rv64i...
Craig Topper [Thu, 5 Nov 2020 03:55:52 +0000 (19:55 -0800)]
Recommit "[RISCV] Move some test cases from rv64i-single-softfloat.ll to a new rv64i-double-softfloat.ll. NFC""

With new test file this time.

Original message

This new test covers both with and without the F extension enabled.

This shows that the fptosi/fptoui for double->i32 use a different
libcall depending on whether the F extension is enabled. If it's
not enabled we use the 'si' library call. If it is enabled we use 'di'.

3 years agoRevert "[RISCV] Move some test cases from rv64i-single-softfloat.ll to a new rv64i...
Craig Topper [Thu, 5 Nov 2020 03:55:13 +0000 (19:55 -0800)]
Revert "[RISCV] Move some test cases from rv64i-single-softfloat.ll to a new rv64i-double-softfloat.ll. NFC"

I failed to git add the new test file.

This reverts commit 36072cc0a487fb5ad315d264064daa73d916469c.

3 years ago[RISCV] Move some test cases from rv64i-single-softfloat.ll to a new rv64i-double...
Craig Topper [Thu, 5 Nov 2020 03:51:43 +0000 (19:51 -0800)]
[RISCV] Move some test cases from rv64i-single-softfloat.ll to a new rv64i-double-softfloat.ll. NFC

This new test covers both with and without the F extension enabled.

This shows that the fptosi/fptoui for double->i32 use a different
libcall depending on whether the F extension is enabled. If it's
not enabled we use the 'si' library call. If it is enabled we use 'di'.

3 years ago[LangRef] Adds llvm.loop.mustprogress loop metadata
Atmn Patel [Thu, 5 Nov 2020 03:30:58 +0000 (22:30 -0500)]
[LangRef] Adds llvm.loop.mustprogress loop metadata

This patch adds the llvm.loop.mustprogress loop metadata. This is to be
added to loops where the frontend language requires that the loop makes
observable interactions with the environment. This is the loop-level
equivalent to the function attribute `mustprogress` defined in D86233.

Reviewed By: jdoerfert

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

3 years ago[sanitizer] Fix -fno-emulated-tls setup
Vitaly Buka [Thu, 5 Nov 2020 03:22:28 +0000 (19:22 -0800)]
[sanitizer] Fix -fno-emulated-tls setup

COMPILER_RT_TEST_COMPILER_CFLAGS is a string

3 years ago[NFC] Extract InitializePlatformCommonFlags
Vitaly Buka [Thu, 5 Nov 2020 02:52:15 +0000 (18:52 -0800)]
[NFC] Extract InitializePlatformCommonFlags

And move some Android specifi declarations from headers

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

3 years ago[lsan] Remove unnecessary elf-tls condition
Vy Nguyen [Thu, 5 Nov 2020 02:09:36 +0000 (21:09 -0500)]
[lsan] Remove unnecessary elf-tls condition

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

3 years ago[clang] Add mustprogress and llvm.loop.mustprogress attribute deduction
Atmn Patel [Mon, 2 Nov 2020 21:03:21 +0000 (16:03 -0500)]
[clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

Since C++11, the C++ standard has a forward progress guarantee
[intro.progress], so all such functions must have the `mustprogress`
requirement. In addition, from C11 and onwards, loops without a non-zero
constant conditional or no conditional are also required to make
progress (C11 6.8.5p6). This patch implements these attribute deductions
so they can be used by the optimization passes.

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

3 years ago[sanitizer] Quick fix for non-Linux build
Vitaly Buka [Thu, 5 Nov 2020 02:34:19 +0000 (18:34 -0800)]
[sanitizer] Quick fix for non-Linux build

3 years ago[LSAN] Fix CAN_SANITIZE_LEAKS on Android
Vitaly Buka [Thu, 5 Nov 2020 02:28:51 +0000 (18:28 -0800)]
[LSAN] Fix CAN_SANITIZE_LEAKS on Android

3 years ago[mlir] Change deprecated -Werror-implicit-function-declaration to -Werror=implicit...
Fangrui Song [Thu, 5 Nov 2020 02:33:51 +0000 (18:33 -0800)]
[mlir] Change deprecated -Werror-implicit-function-declaration to -Werror=implicit-function-declaration

This -Werror- form has been deprecated since 2007 (GCC r122017).

And only enable it for CMAKE_C_FLAGS. C++ does not need it.

3 years ago[flang][openacc] Lower wait directive
Valentin Clement [Thu, 5 Nov 2020 02:15:35 +0000 (21:15 -0500)]
[flang][openacc] Lower wait directive

This patch upstream the lowering of Wait directive that was initially done in
https://github.com/flang-compiler/f18-llvm-project/pull/532

Reviewed By: schweitz

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

3 years agoReland [lsan] Enable LSAN for Android
Vy Nguyen [Wed, 4 Nov 2020 22:09:08 +0000 (14:09 -0800)]
Reland [lsan] Enable LSAN for Android

Reland: a2291a58bf1c860d026581fee6fe96019dc25440.

New fixes for the breakages reported in D85927 include:
 - declare a weak decl for `dl_iterate_phdr`, because it does not exist on older  APIs
 - Do not enable leak-sanitizer if api_level is less than 29, because of  `ld.lld: error: undefined symbol: __aeabi_read_tp` for armv7, API level 16.
 - Put back the interceptor for `memalign` but still opt out intercepting `__libc_memalign` and `cfree` because both of these don't exist in Bionic.

Reviewed By: srhines, vitalybuka

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

3 years ago[X86] Enable shrink-wrapping for no-frame-pointer non-nounwind functions on platforms...
Fangrui Song [Thu, 5 Nov 2020 00:51:48 +0000 (16:51 -0800)]
[X86] Enable shrink-wrapping for no-frame-pointer non-nounwind functions on platforms not using compact unwind

The current compact unwind scheme does not work when the prologue is not at the
start (the instructions before the prologue cannot be described).  (Technically
this is fixable, but it requires multiple compact unwind descriptors for one
function.)

rL255175 chose to not perform shrink-wrapping for no-frame-pointer functions not
marked as nounwind to work around PR25614. This is overly limited, as platforms
not supporting compact unwind (all non-Darwin) does not need the workaround.
This patch restricts the limitation to compact unwind platforms.

Reviewed By: qcolombet

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

3 years ago[sanitizer] Allow preinit array on Android
Vy Nguyen [Wed, 4 Nov 2020 22:09:08 +0000 (14:09 -0800)]
[sanitizer] Allow preinit array on Android

Extracted from D89251

3 years ago[flang][openacc] Lower init and shutdown directive
Valentin Clement [Thu, 5 Nov 2020 00:30:39 +0000 (19:30 -0500)]
[flang][openacc] Lower init and shutdown directive

This patch upstream the lowering of Init and Shutdown directives that was initially done in
https://github.com/flang-compiler/f18-llvm-project/pull/529

Reviewed By: schweitz

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

3 years ago[MLIR][NFC] Update syntax of global_memref in ODS description.
Rahul Joshi [Wed, 4 Nov 2020 21:43:57 +0000 (13:43 -0800)]
[MLIR][NFC] Update syntax of global_memref in ODS description.

- The ODS description was using an old syntax that was updated during the review.
  This fixes the ODS description to match the current syntax.

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

3 years ago[NFC][sanitizer] Reformat some code
Vitaly Buka [Wed, 4 Nov 2020 23:37:48 +0000 (15:37 -0800)]
[NFC][sanitizer] Reformat some code

Extracted from D89251

3 years ago[PowerPC] Add Sema checks for MMA types
Baptiste Saleil [Wed, 4 Nov 2020 23:00:48 +0000 (17:00 -0600)]
[PowerPC] Add Sema checks for MMA types

The use of the new types introduced for PowerPC MMA instructions needs to be restricted.
We add a PowerPC function checking that the given type is valid in a context in which we don't allow MMA types.
This function is called from various places in Sema where we want to prevent the use of these types.

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

3 years agoFix UB in one libcxx test, when deleting D through a pointer to B.
Arthur O'Dwyer [Wed, 4 Nov 2020 22:34:05 +0000 (17:34 -0500)]
Fix UB in one libcxx test, when deleting D through a pointer to B.

This undefined behavior was found by applying LĂ©nárd Szolnoki's proposal
to disable implicit conversion of default_delete<D> to default_delete<B>.

The offending part of the test is circa line 243.

The wording that makes it undefined behavior is http://eel.is/c++draft/expr.delete#3 .

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

3 years ago[sanitizer] Get Android API from --target
Vitaly Buka [Wed, 4 Nov 2020 21:10:17 +0000 (13:10 -0800)]
[sanitizer] Get Android API from --target

Depends on D90792.

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

3 years ago[NFC][LSAN] Remove unused variable
Vitaly Buka [Wed, 4 Nov 2020 21:09:09 +0000 (13:09 -0800)]
[NFC][LSAN] Remove unused variable

Depends on D90791.

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

3 years ago[NFC] Fix comment in test
Vitaly Buka [Wed, 4 Nov 2020 21:06:59 +0000 (13:06 -0800)]
[NFC] Fix comment in test

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

3 years agoBasic: Change Module::Umbrella to a PointerUnion, NFC
Duncan P. N. Exon Smith [Thu, 29 Oct 2020 19:14:30 +0000 (15:14 -0400)]
Basic: Change Module::Umbrella to a PointerUnion, NFC

Change `Module::Umbrella` from a `const void *` to a `PointerUnion` of
`FileEntry` and `DirectoryEntry`. We can drop the `HasUmbrellaDir` bit
(since `PointerUnion` includes that).

This change makes it safer to update to `FileEntryRef` and
`DirectoryEntryRef` in a future patch.

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

3 years agoReland [NewPM] Add OptimizationLevel param to registerPipelineStartEPCallback
Arthur Eubanks [Wed, 4 Nov 2020 18:14:37 +0000 (10:14 -0800)]
Reland [NewPM] Add OptimizationLevel param to registerPipelineStartEPCallback

This allows targets to skip optional optimization passes at -O0.

Reviewed By: ychen

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

3 years agoRevert "[NewPM] Add OptimizationLevel param to registerPipelineStartEPCallback"
Arthur Eubanks [Wed, 4 Nov 2020 20:57:32 +0000 (12:57 -0800)]
Revert "[NewPM] Add OptimizationLevel param to registerPipelineStartEPCallback"

This reverts commit 7a83aa0520d24ee5285a9c60b97b57a1db1d65e8.

Causing buildbot failures.

3 years ago[NewPM] Add OptimizationLevel param to registerPipelineStartEPCallback
Arthur Eubanks [Wed, 4 Nov 2020 18:14:37 +0000 (10:14 -0800)]
[NewPM] Add OptimizationLevel param to registerPipelineStartEPCallback

This allows targets to skip optional optimization passes at -O0.

Reviewed By: ychen

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

3 years ago[crashlog] Pass the debugger around instead of relying on lldb.debugger
Jonas Devlieghere [Wed, 4 Nov 2020 20:50:38 +0000 (12:50 -0800)]
[crashlog] Pass the debugger around instead of relying on lldb.debugger

The lldb.debugger et al convenience variables are only available from
the interactive script interpreter. In all other scenarios, they are
None (since fc1fd6bf9fcfac412b10b4193805ec5de0e8df57) before that they
were default initialized.

The crashlog script was hacking around that by setting the lldb.debugger
to a newly created debugger instance when running outside of the script
interpreter, which works fine until lldb creates a script interpreter
instance under the hood and clears the variables. This was resulting in
an AttributeError when invoking the script directly (from outside of
lldb):

  AttributeError: 'NoneType' object has no attribute 'GetSourceManager'

This patch fixes that by passing around the debugger instance.

rdar://64775776

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

3 years ago[flang][openacc] Lower update directive
Valentin Clement [Wed, 4 Nov 2020 20:47:40 +0000 (15:47 -0500)]
[flang][openacc] Lower update directive

This patch upstream the lowering of Update directive that was initially done in
https://github.com/flang-compiler/f18-llvm-project/pull/528

Reviewed By: schweitz

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

3 years agoFix -Wsign-compare issue in MasmParser.cpp
Eric Astor [Wed, 4 Nov 2020 20:43:18 +0000 (15:43 -0500)]
Fix -Wsign-compare issue in MasmParser.cpp

3 years ago[ms] [llvm-ml] Lex MASM strings, including escaping
Eric Astor [Wed, 4 Nov 2020 20:28:22 +0000 (15:28 -0500)]
[ms] [llvm-ml] Lex MASM strings, including escaping

Allow single-quoted strings and double-quoted character values, as well as doubled-quote escaping.

Reviewed By: thakis

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

3 years ago[SelectionDAG] Add legalizations for VECREDUCE_SEQ_FMUL
Cameron McInally [Wed, 4 Nov 2020 20:16:49 +0000 (14:16 -0600)]
[SelectionDAG] Add legalizations for VECREDUCE_SEQ_FMUL

Hook up legalizations for VECREDUCE_SEQ_FMUL. This is following up on the VECREDUCE_SEQ_FADD work from D90247.

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

3 years ago[NFC] Use Register/MCRegister
Mircea Trofin [Tue, 3 Nov 2020 23:20:40 +0000 (15:20 -0800)]
[NFC] Use Register/MCRegister

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

3 years ago[flang][openacc] Lower enter data directive
Valentin Clement [Wed, 4 Nov 2020 20:17:15 +0000 (15:17 -0500)]
[flang][openacc] Lower enter data directive

This patch upstream the lowering of Enter Data directive that was initially done in
https://github.com/flang-compiler/f18-llvm-project/pull/526

Reviewed By: schweitz

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

3 years ago[lld][ELF][test] test LTO-removed symbols are not in symtab
Edd Dawson [Tue, 3 Nov 2020 14:11:21 +0000 (14:11 +0000)]
[lld][ELF][test] test LTO-removed symbols are not in symtab

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

3 years ago[libc++] Remove stray setting of use_system_cxx_lib left behind
Louis Dionne [Wed, 4 Nov 2020 20:01:59 +0000 (15:01 -0500)]
[libc++] Remove stray setting of use_system_cxx_lib left behind

3 years ago[libc++] Move availability-related Lit configuration to the DSL
Louis Dionne [Wed, 4 Nov 2020 19:46:25 +0000 (14:46 -0500)]
[libc++] Move availability-related Lit configuration to the DSL

The implementation is not really satisfactory, but it's better than
being in the legacy config, which causes other issues.

3 years ago[RISCV] Remove assertsexti32 from fslw/fsrw isel patterns.
Craig Topper [Wed, 4 Nov 2020 19:37:58 +0000 (11:37 -0800)]
[RISCV] Remove assertsexti32 from fslw/fsrw isel patterns.

The operations in these patterns shouldn't be effected by sign
bits. And the pattern is starting from a sign_extend_inreg so
we aren't expecting sign bits to be passed through either.

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

3 years ago[flang][openacc] Lower exit data directive
Valentin Clement [Wed, 4 Nov 2020 19:34:23 +0000 (14:34 -0500)]
[flang][openacc] Lower exit data directive

This patch upstream the lowering of Exit Data construct that was initially done in
https://github.com/flang-compiler/f18-llvm-project/pull/527

Reviewed By: schweitz

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

3 years ago[MemorySSA] Use provided memory location even if instruction is call
Nikita Popov [Sat, 3 Oct 2020 15:28:12 +0000 (17:28 +0200)]
[MemorySSA] Use provided memory location even if instruction is call

If getClobberingMemoryAccess() is called with an explicit
MemoryLocation, but the starting access happens to be a call, the
provided location is currently ignored, and alias analysis queries
will be performed against the call instruction instead. Something
similar happens if the starting access is a load with a MemoryDef.

Change the implementation to not set Q.Inst in the first place if
we want to perform a MemoryLocation-based query, to make sure it
can't be turned into an Instruction-based query along the way...

Additionally, remove the special handling that lifetime.start
intrinsics currently get. They simply report NoAlias for clobbers
between lifetime.start and other calls, but that's obviously not
right if the other call is something like a memset or memcpy. The
default behavior we get from getModRefInfo() will already do the
right thing here.

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

3 years agoAdd info about the cherry-picked commit and contributor
Steven Wan [Wed, 4 Nov 2020 18:40:02 +0000 (13:40 -0500)]
Add info about the cherry-picked commit and contributor

3 years ago[PowerPC] Rename mftbl to mftb
Steven Wan [Thu, 15 Oct 2020 22:16:09 +0000 (18:16 -0400)]
[PowerPC] Rename mftbl to mftb

`mftb` and `mftbl` are equivalent, there is no need to have two names for doing the same thing, rename `mftbl` to only have `mftb`.

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

3 years ago[mlir][std] Add SignedCeilDivIOp and SignedFloorDivIOp with std to std lowering trigg...
Alexandre Eichenberger [Wed, 4 Nov 2020 18:51:10 +0000 (13:51 -0500)]
[mlir][std] Add SignedCeilDivIOp and SignedFloorDivIOp with std to std lowering triggered by -std-expand-divs option. The new operations support positive/negative nominator/denominator numbers.

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

Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com>
3 years ago[RISCV] Correct the operand order for fshl/fshr to fsl/fsr instructions.
Craig Topper [Wed, 4 Nov 2020 19:01:52 +0000 (11:01 -0800)]
[RISCV] Correct the operand order for fshl/fshr to fsl/fsr instructions.

fsl/fsr take their shift amount in $rs2 or an immediate. The
sources are $rs1 and $rs3.

fshl/fshr ISD opcodes both concatenate operand 0 in the high bits and
operand 1 in the lower bits. fshl returns the high bits after
shifting and fshr returns the low bits. So a shift amount of 0
returns operand 0 for fshl and operand 1 for fshr.

fsl/fsr concatenate their operands in different orders such that
$rs1 will be returned for a shift amount of 0. So $rs1 needs to
come from operand 0 of fshl and operand 1 of fshr.

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

3 years agoBasic: Split out DirectoryEntry.h, NFC
Duncan P. N. Exon Smith [Thu, 29 Oct 2020 19:11:40 +0000 (15:11 -0400)]
Basic: Split out DirectoryEntry.h, NFC

Move `DirectoryEntry` and `DirectoryEntryRef` into their own header,
similar to the creation of FileEntry.h. No functionality change here,
just preparing to include it in more places to allow wider adoption of
`DirectoryEntryRef` without requiring all of `FileManager.h`.

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

3 years ago[DAGCombine] Fix bug in load scalarization
Fraser Cormack [Tue, 21 Apr 2020 15:23:11 +0000 (16:23 +0100)]
[DAGCombine] Fix bug in load scalarization

Summary:
For vector element types which are not byte-sized, we would generate
incorrect scalar offsets and produce incorrect codegen.

This optimization could potentially be supported in the future, e.g. by
loading in bytes, then shifting and masking out the remaining bits of
the vector element. However, without an upstream target to test against
it's best to avoid the bad codegen in the simplest possible way.

Related to this bug:

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

Reviewed by: foad

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

3 years ago[libc++] NFC: Remove trailing whitespace
Louis Dionne [Wed, 4 Nov 2020 19:07:59 +0000 (14:07 -0500)]
[libc++] NFC: Remove trailing whitespace

3 years agoRefactor PyPrintAccumulatorm, PyFileAccumulator, and PySinglePartStringAccumulator...
Mehdi Amini [Wed, 4 Nov 2020 06:26:46 +0000 (06:26 +0000)]
Refactor PyPrintAccumulatorm, PyFileAccumulator, and PySinglePartStringAccumulator from IRModules.cpp to PybindUtils.h

These are reusable utilities across bindings.

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

3 years agoMove MlirStringCallback declaration from mlir-c/IR.h to mlir-c/Support.h (NFC)
Mehdi Amini [Wed, 4 Nov 2020 06:25:05 +0000 (06:25 +0000)]
Move MlirStringCallback declaration from mlir-c/IR.h to mlir-c/Support.h (NFC)

This is a generic utility that can be reused beyond the IR bindings.

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

3 years ago[OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts
cchen [Wed, 4 Nov 2020 18:36:38 +0000 (12:36 -0600)]
[OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

Clang now asserts for the below case:
```
void clang::CodeGen::CGOpenMPRuntime::createOffloadEntriesAndInfoMetadata(): Assertion `std::get<0>(E) && "All ordered entries must exist!"' failed.
```

The reason why Clang hit the assert is because in
`emitTargetDataCalls`, both `BeginThenGen` and `BeginElseGen` call
`registerTargetRegionEntryInfo` and try to register the Entry in
OffloadEntriesTargetRegion with same key. If changing the expression in
if clause to any constant expression, then the assert disappear. (https://godbolt.org/z/TW7haj)

The assert itself is to avoid
user from accessing elements out of bound inside `OrderedEntries` in
`createOffloadEntriesAndInfoMetadata`.

In this patch, I add a check in `registerTargetRegionEntryInfo` to avoid
register the target region more than once.

A test case that triggers assert: https://godbolt.org/z/4cnGW8

Reviewed By: ABataev

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

3 years ago[RISCV] Remove assertsexti32 from inputs to riscv_sllw/srlw nodes in B extension...
Craig Topper [Wed, 4 Nov 2020 18:35:05 +0000 (10:35 -0800)]
[RISCV] Remove assertsexti32 from inputs to riscv_sllw/srlw nodes in B extension isel patterns.

riscv_sllw/srlw only reads the lower 32 bits of the first operand.
And the lower 5 bits of the second operands. Whether the upper
32 bits of the input are sign bits or not doesn't matter.

Also use ineg and not to shorten the patterns.

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

3 years ago[MLIR] Refactor memref type -> LLVM Type conversion
Rahul Joshi [Wed, 4 Nov 2020 16:14:05 +0000 (08:14 -0800)]
[MLIR] Refactor memref type -> LLVM Type conversion

- Eliminate duplicated information about mapping from memref -> its descriptor fields
  by consolidating that mapping in two functions:  getMemRefDescriptorFields and
  getUnrankedMemRefDescriptorFields.
- Change convertMemRefType() and convertUnrankedMemRefType() to use these
  functions.
- Remove convertMemrefSignature and convertUnrankedMemrefSignature.

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

3 years ago[MLIR] Remove NoSideEffect from std.global_memref op.
Rahul Joshi [Wed, 4 Nov 2020 16:20:46 +0000 (08:20 -0800)]
[MLIR] Remove NoSideEffect from std.global_memref op.

- Also spell "isUninitialized" correctly.

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

3 years agoStart of an llvm.coro.async implementation
Arnold Schwaighofer [Wed, 21 Oct 2020 21:41:47 +0000 (14:41 -0700)]
Start of an llvm.coro.async implementation

This patch adds the `async` lowering of coroutines.

This will be used by the Swift frontend to lower async functions. In
contrast to the `retcon` lowering the frontend needs to be in control
over control-flow at suspend points as execution might be suspended at
these points.

This is very much work in progress and the implementation will change as
it evolves with the frontend. As such the documentation is lacking
detail as some of it might change.

rdar://70097093

Reapply with fix for memory sanitizer failure and sphinx failure.

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

3 years ago[mlir] Make linalg-bufferize a composable bufferization pass
Sean Silva [Tue, 3 Nov 2020 01:18:46 +0000 (17:18 -0800)]
[mlir] Make linalg-bufferize a composable bufferization pass

Previously, linalg-bufferize was a "finalizing" bufferization pass (it
did a "full" conversion). This wasn't great because it couldn't be used
composably with other bufferization passes like std-bufferize and
scf-bufferize.

This patch makes linalg-bufferize a composable bufferization pass.
Notice that the integration tests are switched over to using a pipeline
of std-bufferize, linalg-bufferize, and (to finalize the conversion)
func-bufferize. It all "just works" together.

While doing this transition, I ran into a nasty bug in the 1-use special
case logic for forwarding init tensors. That logic, while
well-intentioned, was fundamentally flawed, because it assumed that if
the original tensor value had one use, then the converted memref could
be mutated in place. That assumption is wrong in many cases. For
example:

```
  %0 = some_tensor : tensor<4xf32>
  br ^bb0(%0, %0: tensor<4xf32>, tensor<4xf32>)
^bb0(%bbarg0: tensor<4xf32>, %bbarg1: tensor<4xf32>)
  // %bbarg0 is an alias of %bbarg1. We cannot safely write
  // to it without analyzing uses of %bbarg1.
  linalg.generic ... init(%bbarg0) {...}
```

A similar example can happen in many scenarios with function arguments.
Even more sinister, if the converted memref is produced by a
`std.get_global_memref` of a constant global memref, then we might
attempt to write into read-only statically allocated storage! Not all
memrefs are writable!

Clearly, this 1-use check is not a local transformation that we can do
on the fly in this pattern, so I removed it.

The test is now drastically shorter and I basically rewrote the CHECK
lines from scratch because:
- the new composable linalg-bufferize just doesn't do as much, so there
is less to test
- a lot of the tests were related to the 1-use check, which is now gone,
so there is less to test
- the `-buffer-hoisting -buffer-deallocation` is no longer mixed in, so
the checks related to that had to be rewritten

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

3 years ago[mlir] Fix materializations for unranked tensors.
Sean Silva [Mon, 2 Nov 2020 23:12:55 +0000 (15:12 -0800)]
[mlir] Fix materializations for unranked tensors.

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

3 years ago[RISCV] Check all 64-bits of the mask in SelectRORIW.
Craig Topper [Wed, 4 Nov 2020 18:15:30 +0000 (10:15 -0800)]
[RISCV] Check all 64-bits of the mask in SelectRORIW.

We need to ensure the upper 32 bits of the mask are zero.
So that the srl shifts zeroes into the lower 32 bits.

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

3 years agoSwitch from C-style comments `/* ... */` to C++ style `//` (NFC)
Mehdi Amini [Wed, 4 Nov 2020 18:08:34 +0000 (18:08 +0000)]
Switch from C-style comments `/* ... */` to C++ style `//` (NFC)

This is mostly a scripted update, it may not be perfect.

function replace() {
  FROM=$1
  TO=$2
  git grep "$FROM" $REPO_PATH |cut -f 1 -d : | sort -u | \
    while read file; do
      sed -i "s#$FROM#$TO#" $file ;
    done
}

replace '|\*===----------------------------------------------------------------------===\*|$' '//===----------------------------------------------------------------------===//'
replace '^/\* =' '//=='
replace '^/\*=' '//='
replace '^\\\*=' '//='
replace '^|\*' '//'
replace ' \*|$' ''
replace '=\*\\$' '=//'
replace '== \*/$' '===//'
replace '==\*/$' '==//'
replace '^/\*\*\(.*\)\*/$' '///\1'
replace '^/\*\(.*\)\*/$' '//\1'
replace '//============================================================================//' '//===----------------------------------------------------------------------===//'

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

3 years ago[UBSan] Cannot negate smallest negative signed integer
Christopher Tetreault [Wed, 4 Nov 2020 17:16:09 +0000 (09:16 -0800)]
[UBSan] Cannot negate smallest negative signed integer

Silence warning Undefined Behavior Sanitzer warning:
runtime error: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long'); cast to an unsigned type to negate this value to itself

Reviewed By: paulwalker-arm

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

3 years ago[RISCV] Remove custom isel for (srl (shl val, 32), imm). Use pattern instead. NFCI
Craig Topper [Wed, 4 Nov 2020 17:59:14 +0000 (09:59 -0800)]
[RISCV] Remove custom isel for (srl (shl val, 32), imm). Use pattern instead. NFCI

We don't need custom matching, we just a need a predicate to check
the immediate is greater than 32. We can use the existing ImmSub32
to adjust the immediate.

I've also used the new predicate in the other location that used
ImmSub32. I tried to create a test case where we would break without
the greater than 32 check on that pattern, but DAG combine defeated me.
Still seemed safer to have it.

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

3 years ago[AMDGPU] Resolve pseudo registers at encoding uses
Joe Nash [Tue, 3 Nov 2020 22:26:29 +0000 (17:26 -0500)]
[AMDGPU] Resolve pseudo registers at encoding uses

Pseudo-registers allow different register encodings
between gpu generations. Make sure we resolve the
pseudo regs to real regs whenever we get their
hardware encoding.
Using the correct encodings revealed a register
bank conflict and an unnecessary write dependency.
Tests have been updated to match.

Reviewed By: rampitec

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

Change-Id: I73c154cd24aecc820993b50bebaf4df97a5710ca

3 years agoRevert "[GlobalISel] GISelKnownBits::computeKnownBitsImpl - Replace TargetOpcode...
Fangrui Song [Wed, 4 Nov 2020 17:54:04 +0000 (09:54 -0800)]
Revert "[GlobalISel] GISelKnownBits::computeKnownBitsImpl - Replace TargetOpcode::G_MUL handling with the common KnownBits::computeForMul implementation"

This reverts commit 0b8711e1af97d6c82dc9d25c12c5a06af060cc56 which broke GlobalISelTests AArch64GISelMITest.TestKnownBits

3 years ago[NewPM] Don't run before pass instrumentation on required passes
Arthur Eubanks [Sun, 1 Nov 2020 06:08:15 +0000 (23:08 -0700)]
[NewPM] Don't run before pass instrumentation on required passes

This allows those instrumentation to log when they decide to skip a
pass. This provides extra helpful info for optnone functions and also
will help with opt-bisect.

Have OptNoneInstrumentation print when it skips due to seeing optnone.

Reviewed By: asbirlea

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

3 years ago[AMDGPU] Fix iterating in SIFixSGPRCopies
Sebastian Neubauer [Thu, 29 Oct 2020 16:52:22 +0000 (17:52 +0100)]
[AMDGPU] Fix iterating in SIFixSGPRCopies

The insertion of waterfall loops splits the current basic block into
three blocks. So the basic block that we iterate over must be updated.

This failed assert(!NodePtr->isKnownSentinel()) in ilist_iterator for
divergent calls in branches before.

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

3 years ago[llvm-objcopy] Make --set-section-flags work with --add-section
Fangrui Song [Wed, 4 Nov 2020 17:39:14 +0000 (09:39 -0800)]
[llvm-objcopy] Make --set-section-flags work with --add-section

This matches behavior GNU objcopy and can simplify clang-offload-bundler
(which currently works around the issue by invoking llvm-objcopy twice).

Reviewed By: jhenderson

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

3 years ago[llvm-objcopy][MachO] Make isValidMachOCannonicalName static
Alexander Shaposhnikov [Wed, 4 Nov 2020 08:30:43 +0000 (00:30 -0800)]
[llvm-objcopy][MachO] Make isValidMachOCannonicalName static

This diff makes the function isValidMachOCannonicalName static.
NFC.

Test plan: make check-all

3 years agoAdd facilities to print/parse a pass pipeline through the C API
Mehdi Amini [Wed, 4 Nov 2020 00:08:35 +0000 (00:08 +0000)]
Add facilities to print/parse a pass pipeline through the C API

This also includes and exercise a register function for individual
passes.

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

3 years ago[KnownBits] KnownBits::computeForMul - avoid unnecessary APInt copies. NFCI.
Simon Pilgrim [Wed, 4 Nov 2020 17:15:54 +0000 (17:15 +0000)]
[KnownBits] KnownBits::computeForMul - avoid unnecessary APInt copies. NFCI.

Use const references instead.