platform/upstream/llvm.git
3 years ago[flang][fir] Upstream the pre-FIR tree changes.
Eric Schweitz [Tue, 9 Mar 2021 20:28:34 +0000 (12:28 -0800)]
[flang][fir] Upstream the pre-FIR tree changes.

The PFT has been updated to support Fortran 77.
clang-tidy cleanup.

Authors: Val Donaldson, Jean Perier, Eric Schweitz, et.al.

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

3 years ago[AArch64][compiler-rt] Add Pointer Authentication support for VFORK.
Daniel Kiss [Wed, 10 Mar 2021 15:39:14 +0000 (16:39 +0100)]
[AArch64][compiler-rt] Add Pointer Authentication support for VFORK.

The LR is stored to off-stack spill area where it is vulnerable.
"paciasp" add an auth code to the LR while the "autiasp" verifies that so
LR can't be modiifed on the spill area.

Test: build with -DCMAKE_C_FLAGS="-mbranch-protection=standard",
run on Armv8.3 capable hardware with PAuth.

Reviewed By: eugenis

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

3 years ago[SystemZ][NFC] Renaming of ELF specific variables.
Yusra Syeda [Tue, 9 Mar 2021 19:34:48 +0000 (14:34 -0500)]
[SystemZ][NFC] Renaming of ELF specific variables.

Rename ELF specific variables, making it easier to add the XPLink
variables in future patches.

Reviewed By: abhina.sreeskantharajan, Kai

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

3 years agoRevert "[DebugInfo] Add DWARF emission for DBG_VALUE_LIST"
Stephen Tozer [Wed, 10 Mar 2021 14:34:47 +0000 (14:34 +0000)]
Revert "[DebugInfo] Add DWARF emission for DBG_VALUE_LIST"

This reverts commit 0da27ba56c9f5e3f534a65401962301189eac342.

This revision was causing an error on the sanitizer-x86_64-linux-autoconf build.

3 years ago[lld/mac] warn on -install_name without -dylib
Nico Weber [Tue, 9 Mar 2021 15:02:24 +0000 (10:02 -0500)]
[lld/mac] warn on -install_name without -dylib

The flag doesn't (and shouldn't) have an effect in that case.
ld64 doesn't warn on this, but it seems like a good thing to do.
If it causes problems in practice for some reason, we can revert it.

Also add a dedicated test for install_name.

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

3 years ago[lld/mac] Implement support for -mark_dead_strippable_dylib
Nico Weber [Tue, 9 Mar 2021 15:17:01 +0000 (10:17 -0500)]
[lld/mac] Implement support for -mark_dead_strippable_dylib

lld doesn't read MH_DEAD_STRIPPABLE_DYLIB to strip dead dylibs yet,
but now it can produce dylibs with it set.

While here, also switch an existing test that looks only at the main Mach-O
header from --all-headers to --private-header.

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

3 years ago[mlir][CMAKE] Fix build with BUILD_SHARED_LIBS=ON
Vladislav Vinogradov [Wed, 10 Mar 2021 13:52:09 +0000 (14:52 +0100)]
[mlir][CMAKE] Fix build with BUILD_SHARED_LIBS=ON

Link `MLIRStandardToLLVM` to `MLIRAVX512Transforms`, since
the latter uses `LLVMTypeConverter` defined in the first one.

Reviewed By: ftynse

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

3 years ago[DebugInfo] Add DWARF emission for DBG_VALUE_LIST
gbtozers [Fri, 11 Sep 2020 14:48:39 +0000 (15:48 +0100)]
[DebugInfo] Add DWARF emission for DBG_VALUE_LIST

This patch allows DBG_VALUE_LIST instructions to be emitted to DWARF with valid
DW_AT_locations. This change mainly affects DbgEntityHistoryCalculator, which
now tracks multiple registers per value, and DwarfDebug+DwarfExpression, which
can now emit multiple machine locations as part of a DWARF expression.

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

3 years ago[mlir] fix typo in OpDefinitions.md
Alex Zinenko [Wed, 10 Mar 2021 13:43:51 +0000 (14:43 +0100)]
[mlir] fix typo in OpDefinitions.md

3 years ago[clangd] Use Dirty Filesystem for cross file rename.
Nathan James [Wed, 10 Mar 2021 13:41:27 +0000 (13:41 +0000)]
[clangd] Use Dirty Filesystem for cross file rename.

Refactor cross file rename to use a Filesystem instead of a function for getting buffer contents of open files.

Depends on D94554

Reviewed By: sammccall

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

3 years ago[AArch64] Add missing intrinsics for scalar FP rounding
Jingu Kang [Tue, 9 Mar 2021 17:00:13 +0000 (17:00 +0000)]
[AArch64] Add missing intrinsics for scalar FP rounding

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

3 years agoGlobalISel: Try to combine G_[SU]DIV and G_[SU]REM
Christudasan Devadasan [Wed, 10 Mar 2021 12:33:10 +0000 (18:03 +0530)]
GlobalISel: Try to combine G_[SU]DIV and G_[SU]REM

It is good to have a combined `divrem` instruction when the
`div` and `rem` are computed from identical input operands.
Some targets can lower them through a single expansion that
computes both division and remainder. It effectively reduces
the number of instructions than individually expanding them.

Reviewed By: arsenm, paquette

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

3 years agoRevert "[clangd] Enable reflection for clangd-index-server"
Kadir Cetinkaya [Wed, 10 Mar 2021 11:14:38 +0000 (12:14 +0100)]
Revert "[clangd] Enable reflection for clangd-index-server"

This reverts commit 8080ea4c4b8c456c72c617587cc32f174b3105c1.

As discussed offline we should only do that for debug builds.

3 years ago[NFC] Unify FIME with FIXME in comments
Jinzheng Tu [Wed, 10 Mar 2021 12:59:23 +0000 (13:59 +0100)]
[NFC] Unify FIME with FIXME in comments

There are 5 occurrences FIME and 15333 FIXME. All of them should be FIXME.

Reviewed By: alexfh

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

3 years ago[Statepoint Lowering] Fix the crash with gc.relocate in a separate block
Serguei Katkov [Wed, 10 Mar 2021 07:14:03 +0000 (14:14 +0700)]
[Statepoint Lowering] Fix the crash with gc.relocate in a separate block

If it was decided to relocate derived pointer using the spill its value is
not exported in general case.
When gc.relocate is located in an another block than a statepoint we cannot
get SD for derived value but for spill case it is not required at all.
However implementation of gc.relocate lowering unconditionally request SD value
causing the assert triggering.

The CL fixes this by handling spill case earlier than SD is really required.

Reviewers: reames, dantrushin
Reviewed By: dantrushin
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D98324

3 years ago[DebugInfo] Process DBG_VALUE_LIST in LiveDebugVariables
gbtozers [Fri, 11 Sep 2020 15:07:19 +0000 (16:07 +0100)]
[DebugInfo] Process DBG_VALUE_LIST in LiveDebugVariables

This patch adds support for DBG_VALUE_LIST in the LiveDebugVariables pass. The
changes are mostly in computeIntervals, extendDef, and addDefsFromCopies; when
extending the def of a DBG_VALUE_LIST the live ranges of every used register
must be considered, and when such a def is killed by more than one of its used
registers being killed at the same time it is necessary to find valid copies of
all of those registers to create a new def with.

The DebugVariableValue class has also been changed to reference multiple
location numbers instead of just one. This has been accomplished by using a
C-style array with a unique_ptr and an array length packed into 6 bits, to
minimize the size of the class (which must be kept low to be used with
IntervalMap). This may not be the most efficient solution possible, and should
be looked at if performance issues arise.

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

3 years ago[mlir] Update comments in ArmNeon dialect. NFC
Alex Zinenko [Wed, 10 Mar 2021 12:34:43 +0000 (13:34 +0100)]
[mlir] Update comments in ArmNeon dialect. NFC

These were not updated when squashing LLVMArmNeon and ArmNeon dialects.

3 years ago[flang][driver] Add `-fdebug-dump-parsing-log`
Andrzej Warzynski [Tue, 23 Feb 2021 17:59:17 +0000 (17:59 +0000)]
[flang][driver] Add `-fdebug-dump-parsing-log`

This patch adds `-fdebug-dump-parsing-log` in the new driver. This option is
semantically identical to `-fdebug-instrumented-parse` in `f18` (the
former is added as an alias in `f18`).

As dumping the parsing log makes only sense for instrumented parses, we
set Fortran::parser::Options::instrumentedParse to `True` when
`-fdebug-dump-parsing-log` is used. This is consistent with `f18`.

To facilitate tweaking the configuration of the frontend based on the
action being requested, `setUpFrontendBasedOnAction` is introduced in
CompilerInvocation.cpp.

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

3 years ago[mlir] squash LLVM_AVX512 dialect into AVX512
Alex Zinenko [Wed, 10 Mar 2021 10:46:36 +0000 (11:46 +0100)]
[mlir] squash LLVM_AVX512 dialect into AVX512

The dialect separation was introduced to demarkate ops operating in different
type systems. This is no longer the case after the LLVM dialect has migrated to
using built-in vector types, so the original reason for separation is no longer
valid. Squash the two dialects into one.

The code size decrease isn't quite large: the ops originally in LLVM_AVX512 are
preserved because they match LLVM IR intrinsics specialized for vector element
bitwidth. However, it is still conceptually beneficial to have only one
dialect. I originally considered to use Tablegen multiclasses to define both
the type-polymorphic op and its two intrinsic-related instantiations, but
decided against it given both the complexity of the required Tablegen input and
its dissimilarity with the rest of ODS-defined ops, both potentially resulting
in very poor maintainability.

Depends On D98327

Reviewed By: nicolasvasilache, springerm

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

3 years ago[mlir] simplify type constraints in AVX512 dialect
Alex Zinenko [Wed, 10 Mar 2021 10:45:53 +0000 (11:45 +0100)]
[mlir] simplify type constraints in AVX512 dialect

VectorOfLengthAndType accepts a cartesian product of given lengths and types
rather than types produced by co-indexed values in the corresponding lists.
Update the definitions accordingly. The type validity is already enforced by
op traits.

Reviewed By: nicolasvasilache, springerm

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

3 years agoMoved getStaticLoopRanges and getStaticShape methods to LinalgInterfaces.td to add...
Inho Seo [Wed, 10 Mar 2021 11:56:14 +0000 (03:56 -0800)]
Moved getStaticLoopRanges and getStaticShape methods to LinalgInterfaces.td to add static shape verification

It is to use the methods in LinalgInterfaces.cpp for additional static shape verification to match the shaped operands and loop on linalgOps. If I used the existing methods, I would face circular dependency linking issue. Now we can use them as methods of LinalgOp.

Reviewed By: hanchung

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

3 years ago[analyzer][CTU][NFC] Fix "Add an extra regression test"
Balazs Benics [Wed, 10 Mar 2021 12:07:49 +0000 (13:07 +0100)]
[analyzer][CTU][NFC] Fix "Add an extra regression test"

As thakis reported, I will replace `rm -r` by `rm -rf`.
I hope it fixes the build bot.

3 years ago[flang][driver] Merge test/Driver and test/Flang-Driver directories
Andrzej Warzynski [Tue, 9 Mar 2021 13:57:43 +0000 (13:57 +0000)]
[flang][driver] Merge test/Driver and test/Flang-Driver directories

Until now we've been maintaining 2 test directories for Flang's drivers:
  * test/Driver for `f18` (the current driver)
  * test/Flang-Driver for `flang-new` (the new driver)
As we have started sharing tests between the drivers, this separation is
no longer required. This patch merges the two test directories. As
suggested in the review, moving forward we'll avoid having tests
specifically for the old driver.

A few notable changes:
  * Driver/version-test.f90 and Driver/no-files.f90 are deleted. The
  versions for the new driver are more robust, but tricky to share.
  * Driver/write-module.f90 is deleted in favour of
    Flang-Driver/write-module.f90 (see https://reviews.llvm.org/D97197
    for more context)

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

3 years ago[analyzer] Crash fix for alpha.cplusplus.IteratorRange
Adam Balogh [Wed, 10 Mar 2021 11:41:01 +0000 (12:41 +0100)]
[analyzer] Crash fix for alpha.cplusplus.IteratorRange

If the non-iterator side of an iterator operation
`+`, `+=`, `-` or `-=` is `UndefinedVal` an assertions happens.
This small fix prevents this.

Patch by Adam Balogh.

Reviewed By: NoQ

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

3 years ago[analyzer][CTU][NFC] Add an extra regression test
Balazs Benics [Wed, 10 Mar 2021 11:40:56 +0000 (12:40 +0100)]
[analyzer][CTU][NFC] Add an extra regression test

Before `bc713f6a004723d1325bc16e1efc32d0ac82f939` landed, the analyzer
crashed on this reduced example.
It seems important to have bot `ctu` and `-analyzer-opt-analyze-headers`
enabled in the example.

This test file ensures that no regression happens in the future in this regard.

Reviewed By: martong, NoQ

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

3 years ago[analyzer][NFC] Add more tests for ArrayBoundCheckerV2
Balazs Benics [Wed, 10 Mar 2021 11:40:52 +0000 (12:40 +0100)]
[analyzer][NFC] Add more tests for ArrayBoundCheckerV2

According to a Bugzilla ticket (https://bugs.llvm.org/show_bug.cgi?id=45148),
ArrayBoundCheckerV2 produces a false-positive report.
This patch adds a test demonstrating the current //flawed// behavior.
Also adds several similar test cases just to be on the safe side.

Reviewed By: martong

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

3 years ago[analyzer][docs][NFC] Fix typo in checkers.rst
Balazs Benics [Wed, 10 Mar 2021 11:40:46 +0000 (12:40 +0100)]
[analyzer][docs][NFC] Fix typo in checkers.rst

Move `alpha.core.BoolAssignment` out of the `alpha.clone` enumeration.

Reviewed By: Szelethus

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

3 years agoAvoid shuffle self-assignment in EXPENSIVE_CHECKS builds
Alex Richardson [Tue, 9 Mar 2021 20:14:46 +0000 (20:14 +0000)]
Avoid shuffle self-assignment in EXPENSIVE_CHECKS builds

Some versions of libstdc++ perform self-assignment in std::shuffle. This
breaks the EXPENSIVE_CHECKS builds of TableGen due to an incorrect assertion
in libstdc++.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85828.

Fixes https://llvm.org/PR37652

Reviewed By: RKSimon

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

3 years ago[SLC] Simplify strcpy and friends with non-zero address spaces
Alex Richardson [Mon, 8 Mar 2021 14:26:00 +0000 (14:26 +0000)]
[SLC] Simplify strcpy and friends with non-zero address spaces

The current logic in TargetLibraryInfoImpl::getLibFunc() was only treating
strcpy, etc. with i8* arguments in address space zero as a valid library
function. However, in the CHERI and Morello targets we expect all libc
functions to use address space 200 arguments.

This commit updates isValidProtoForLibFunc() to check that the argument
is a pointer type. This also drops the check for i8* since we should not
be checking the pointee type any more.

Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D95142

3 years ago[SLC] Baseline test for missed strcpy optimizations in non-zero AS
Alex Richardson [Mon, 8 Mar 2021 14:25:06 +0000 (14:25 +0000)]
[SLC] Baseline test for missed strcpy optimizations in non-zero AS

This will be fixed in D95142

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

3 years ago[compiler-rt] Silence a deprecation warning on FreeBSD
Alex Richardson [Mon, 8 Mar 2021 14:23:42 +0000 (14:23 +0000)]
[compiler-rt] Silence a deprecation warning on FreeBSD

On FreeBSD the sys/timeb.h header has a #warning that it's deprecated.
However, we need to include this header here, so silence this warning that
is printed multiple times otherwise.

Reviewed By: dim

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

3 years ago[asan][tests] Handle FreeBSD in large_func_test and use-after-delete
Alex Richardson [Mon, 8 Mar 2021 14:15:15 +0000 (14:15 +0000)]
[asan][tests] Handle FreeBSD in large_func_test and use-after-delete

This is the same fix as ab8a46024157b4d042ea6325710bbccd598adcfc for
Solaris and 23cd8d51ad519261137a40a5bbac6e537ee7ba25 (Windows+Darwin).

3 years ago[sanitizers] Fix typo in ca9815fc247c
Alex Richardson [Mon, 8 Mar 2021 14:14:01 +0000 (14:14 +0000)]
[sanitizers] Fix typo in ca9815fc247c

I accidentally committed the wrong version of this patch which didn't
actually enable the hooks for FreeBSD. Fixing the typo allows the tests
to actually pass.

3 years ago[mlir] Add base class for GpuKernelToBlobPass
Christian Sigg [Wed, 10 Mar 2021 09:35:20 +0000 (10:35 +0100)]
[mlir] Add base class for GpuKernelToBlobPass

Instead of configuring kernel-to-cubin/rocdl lowering through callbacks, introduce a base class that target-specific passes can derive from.

Put the base class in GPU/Transforms, according to the discussion in D98203.

The mlir-cuda-runner will go away shortly, and the mlir-rocdl-runner as well at some point. I therefore kept the existing code path working and will remove it in a separate step.

Depends On D98168

Reviewed By: herhut

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

3 years ago[DSE] Handle memcpy/memset with equal non-const sizes.
Florian Hahn [Wed, 10 Mar 2021 09:47:53 +0000 (09:47 +0000)]
[DSE] Handle memcpy/memset with equal non-const sizes.

Currently DSE misses cases where the size is a non-const IR value, even
if they match. For example, this means that llvm.memcpy/llvm.memset
calls are not eliminated, even if they write the same number of bytes.

This patch extends isOverwite to try to get IR values for the number of
bytes written from the analyzed instructions. If the values match,
alias checks are performed and the result is returned.

At the moment this only covers llvm.memcpy/llvm.memset. In the future,
we may enable MemoryLocation to also track variable sizes, but this
simple approach should allow us to cover the important cases in DSE.

Reviewed By: asbirlea

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

3 years ago[OpenCL] Set calling convention for -fdeclare-opencl-builtins
Sven van Haastregt [Wed, 10 Mar 2021 10:03:57 +0000 (10:03 +0000)]
[OpenCL] Set calling convention for -fdeclare-opencl-builtins

IR produced using TableGen builtin function declarations
(`fdeclare-opencl-builtins.cl`) did not have the target's calling
convention applied to builtin calls.

Fix this, and update the codegen test to check that IR produced using
opencl-c.h and `-fdeclare-opencl-builtins` is identical with respect
to the builtin calls.

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

3 years ago[mlir] Model MemRef memory space as Attribute
Vladislav Vinogradov [Fri, 5 Feb 2021 13:53:00 +0000 (16:53 +0300)]
[mlir] Model MemRef memory space as Attribute

Based on the following discussion:
https://llvm.discourse.group/t/rfc-memref-memory-shape-as-attribute/2229

The goal of the change is to make memory space property to have more
expressive representation, rather then "magic" integer values.

It will allow to have more clean ASM form:

```
gpu.func @test(%arg0: memref<100xf32, "workgroup">)

// instead of

gpu.func @test(%arg0: memref<100xf32, 3>)
```

Explanation for `Attribute` choice instead of plain `string`:

* `Attribute` classes allow to use more type safe API based on RTTI.
* `Attribute` classes provides faster comparison operator based on
  pointer comparison in contrast to generic string comparison.
* `Attribute` allows to store more complex things, like structs or dictionaries.
  It will allows to have more complex memory space hierarchy.

This commit preserve old integer-based API and implements it on top
of the new one.

Depends on D97476

Reviewed By: rriddle, mehdi_amini

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

3 years ago[mlir][linalg] Add support for using scalar attributes in TC ops.
Hanhan Wang [Wed, 10 Mar 2021 09:51:00 +0000 (01:51 -0800)]
[mlir][linalg] Add support for using scalar attributes in TC ops.

Reviewed By: antiagainst

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

3 years ago[DSE] Add tests with memset & memcpy combinations and non-const sizes.
Florian Hahn [Wed, 10 Mar 2021 09:43:41 +0000 (09:43 +0000)]
[DSE] Add tests with memset & memcpy combinations and non-const sizes.

3 years ago[NFC] [PowerPC] Remove unsafe-fp-math in some tests
Qiu Chaofan [Wed, 10 Mar 2021 09:27:21 +0000 (17:27 +0800)]
[NFC] [PowerPC] Remove unsafe-fp-math in some tests

As we're going to replace this ambiguous option with more precise
instruction-level fast-math description, some tests need to be updated
and the option doesn't play any role in some of them.

3 years ago[InstSimplify] Add tests for pr49495 (NFC)
Juneyoung Lee [Wed, 10 Mar 2021 08:54:31 +0000 (17:54 +0900)]
[InstSimplify] Add tests for pr49495 (NFC)

3 years ago[ADT][NFC] Use `size_t` type for index in `indexed_accessor_range`
Vladislav Vinogradov [Thu, 4 Mar 2021 08:28:24 +0000 (11:28 +0300)]
[ADT][NFC] Use `size_t` type for index in `indexed_accessor_range`

It makes it consistent with `size()` method return type and with
STL-like containers API.

Reviewed By: rriddle

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

3 years ago[NFC] Remove duplicate isNoBuiltinFunc method
serge-sans-paille [Mon, 8 Mar 2021 13:46:25 +0000 (14:46 +0100)]
[NFC] Remove duplicate isNoBuiltinFunc method

It's available both in CodeGenOptions and in LangOptions, and LangOptions
implementation is slightly better as it uses a StringRef instead of a char
pointer, so use it.

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

3 years ago[clangd] Enable reflection for clangd-index-server
Kirill Bobyrev [Wed, 10 Mar 2021 08:03:34 +0000 (09:03 +0100)]
[clangd] Enable reflection for clangd-index-server

This allows sending requests through CLI and more debugging
opportunities. Example:

```bash
$ grpc_cli ls localhost:50051
clang.clangd.remote.v1.SymbolIndex
grpc.reflection.v1alpha.ServerReflection
grpc.health.v1.Health
```

3 years ago[analyzer] Fix StdLibraryFunctionsChecker performance issue
Valeriy Savchenko [Mon, 22 Feb 2021 17:05:12 +0000 (20:05 +0300)]
[analyzer] Fix StdLibraryFunctionsChecker performance issue

`initFunctionSummaries` lazily initializes a data structure with
function summaries for standard library functions.  It is called for
every pre-, post-, and eval-call events, i.e. 3 times for each call on
the path.  If the initialization doesn't find any standard library
functions in the translation unit, it will get re-tried (with the same
effect) many times even for small translation units.

For projects not using standard libraries, the speed-up can reach 50%
after this patch.

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

3 years ago[-Wcompletion-handler] Extend list of detected conventions
Valeriy Savchenko [Tue, 9 Mar 2021 12:49:47 +0000 (15:49 +0300)]
[-Wcompletion-handler] Extend list of detected conventions

Update convention detection to accomodate changes from:
https://github.com/DougGregor/swift-evolution/blob/concurrency-objc/proposals/NNNN-concurrency-objc.md#asynchronous-completion-handler-methods

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

3 years ago[PowerPC] Reduce symmetrical swaps for lane-insensitive vector ops
Qiu Chaofan [Wed, 10 Mar 2021 07:21:32 +0000 (15:21 +0800)]
[PowerPC] Reduce symmetrical swaps for lane-insensitive vector ops

This patch simplifies pattern (xxswap (vec-op (xxswap a) (xxswap b)))
into (vec-op a b) if vec-op is lane-insensitive. The motivating case
is ScalarToVector-VecOp-ExtractElement sequence on LE, but the
peephole itself is not related to endianness, so BE may also benefit
from this.

Reviewed By: nemanjai

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

3 years ago[clangd] Treat __GCC_HAVE_DWARF2_CFI_ASM the same as isWrittenInBuiltinFile macros
Fangrui Song [Wed, 10 Mar 2021 07:11:54 +0000 (23:11 -0800)]
[clangd] Treat __GCC_HAVE_DWARF2_CFI_ASM the same as isWrittenInBuiltinFile macros

3 years ago[compiler-rt] Normalize i?86 to i386 and armv* to arm for COMPILER_RT_DEFAULT_TARGET_ARCH
Martin Storsjö [Mon, 8 Mar 2021 11:38:52 +0000 (13:38 +0200)]
[compiler-rt] Normalize i?86 to i386 and armv* to arm for COMPILER_RT_DEFAULT_TARGET_ARCH

This corresponds to getArchNameForCompilerRTLib in clang; any
32 bit x86 architecture triple (except on android, but those
exceptions are already handled in compiler-rt on a different level)
get the compiler rt library names with i386; arm targets get either
"arm" or "armhf". (Mapping to "armhf" is handled in the toplevel
CMakeLists.txt.)

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

3 years ago[WPD][ELF] Allow whole program devirtualization for version script localized symbols
Fangrui Song [Wed, 10 Mar 2021 06:33:47 +0000 (22:33 -0800)]
[WPD][ELF] Allow whole program devirtualization for version script localized symbols

A `local:` version node in a version script can change the effective symbol binding
to STB_LOCAL. The linker needs to communicate the fact to enable WPD
(otherwise LTO does not know that the `!vcall_visibility` metadata has
effectively changed from VCallVisibilityPublic to VCallVisibilityLinkageUnit).

Reviewed By: tejohnson

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

3 years ago[test] Update tests
Fangrui Song [Wed, 10 Mar 2021 06:32:28 +0000 (22:32 -0800)]
[test] Update tests

3 years agoDefine __GCC_HAVE_DWARF2_CFI_ASM if applicable
Fangrui Song [Wed, 10 Mar 2021 06:21:36 +0000 (22:21 -0800)]
Define __GCC_HAVE_DWARF2_CFI_ASM if applicable

In -fno-exceptions -fno-asynchronous-unwind-tables -g0 mode,
GCC does not emit `.cfi_*` directives.

```
% diff <(gcc -fno-asynchronous-unwind-tables -dM -E a.c) <(gcc -dM -E a.c)
130a131
> #define __GCC_HAVE_DWARF2_CFI_ASM 1
```

This macro is useful because code can decide whether inline asm should include `.cfi_*` directives.
`.cfi_*` directives without `.cfi_startproc` can cause assembler errors
(integrated assembler: `this directive must appear between .cfi_startproc and .cfi_endproc directives`).

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

3 years ago[JITLink] Add a null-terminator to eh-frame sections on ELF/x86-64.
Lang Hames [Wed, 10 Mar 2021 05:54:18 +0000 (21:54 -0800)]
[JITLink] Add a null-terminator to eh-frame sections on ELF/x86-64.

__register_ehframes on Linux requires a null terminator to identify the end of
this section.

3 years ago[lld-macho][NFC] drop opt:: when already using llvm::opt
Greg McGary [Wed, 10 Mar 2021 04:40:08 +0000 (20:40 -0800)]
[lld-macho][NFC] drop opt:: when already using llvm::opt

Top-level `using llvm::opt` has been present in `lld/MachO/Driver*.cpp` for some time, so remove lingering `opt::` prefixes.

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

3 years ago[lld-macho][NFC] when reasonable, replace auto keyword with type names
Greg McGary [Wed, 10 Mar 2021 04:15:29 +0000 (20:15 -0800)]
[lld-macho][NFC] when reasonable, replace auto keyword with type names

lld policy discourages `auto`. Replace it with a type name whenever reasonable. Retain `auto` to avoid ...
* redundancy, as for decls such as `auto *t = mumble_cast<TYPE *>` or similar that specifies the result type on the RHS
* verbosity, as for iterators
* gratuitous suffering, as for lambdas

Along the way, add `const` when appropriate.

Note: a future diff will ...
* add more `const` qualifiers
* remove `opt::` when we are already `using llvm::opt`

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

3 years ago[SampleFDO] Support enabling -funique-internal-linkage-name.
Wei Mi [Tue, 19 Jan 2021 17:20:13 +0000 (09:20 -0800)]
[SampleFDO] Support enabling -funique-internal-linkage-name.

now -funique-internal-linkage-name flag is available, and we want to flip
it on by default since it is beneficial to have separate sample profiles
for different internal symbols with the same name. As a preparation, we
want to avoid regression caused by the flip.

When we flip -funique-internal-linkage-name on, the profile is collected
from binary built without -funique-internal-linkage-name so it has no uniq
suffix, but the IR in the optimized build contains the suffix. This kind of
mismatch may introduce transient regression.

To avoid such mismatch, we introduce a NameTable section flag indicating
whether there is any name in the profile containing uniq suffix. Compiler
will decide whether to keep uniq suffix during name canonicalization
depending on the NameTable section flag. The flag is only available for
extbinary format. For other formats, by default compiler will keep uniq
suffix so they will only experience transient regression when
-funique-internal-linkage-name is just flipped.

Another type of regression is caused by places where we miss to call
getCanonicalFnName. Those places are fixed.

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

3 years ago[xray] Fix xray document spelling
Yao Zhao [Wed, 10 Mar 2021 03:23:03 +0000 (14:23 +1100)]
[xray] Fix xray document spelling

fix a couple of words spelling

Reviewed By: dberris

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

3 years ago[JITLink] Add support for STT_NOTYPE symbols to ELF/x86-64.
Lang Hames [Wed, 10 Mar 2021 04:34:50 +0000 (20:34 -0800)]
[JITLink] Add support for STT_NOTYPE symbols to ELF/x86-64.

3 years ago[JITLink] Assert that segment mapping does not exceed allocation size.
Lang Hames [Mon, 8 Mar 2021 04:55:13 +0000 (20:55 -0800)]
[JITLink] Assert that segment mapping does not exceed allocation size.

3 years ago[rs4gc] common bdv operand visitation [nfc]
Philip Reames [Wed, 10 Mar 2021 04:28:39 +0000 (20:28 -0800)]
[rs4gc] common bdv operand visitation [nfc]

3 years ago[clang][APINotes] Fix gcc Wunused-function warning (NFC)
Yang Fan [Wed, 10 Mar 2021 03:47:00 +0000 (11:47 +0800)]
[clang][APINotes] Fix gcc Wunused-function warning (NFC)

GCC warning:
```
/llvm-project/clang/lib/APINotes/APINotesYAMLCompiler.cpp:574:6: warning: ‘void {anonymous}::Module::dump()’ defined but not used [-Wunused-function]
  574 | void Module::dump() {
      |      ^~~~~~
```

3 years ago[MC][ELF] Fix "enumeral and non-enumeral type in conditional expression" warning...
Yang Fan [Wed, 10 Mar 2021 03:26:39 +0000 (11:26 +0800)]
[MC][ELF] Fix "enumeral and non-enumeral type in conditional expression" warning (NFC)

GCC warning:
```
/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp: In member function ‘void {anonymous}::ELFWriter::writeHeader(const llvm::MCAssembler&)’:
/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp:421:20: warning: enumeral and non-enumeral type in conditional expression [-Wextra]
  420 |   W.OS << char(OSABI == ELF::ELFOSABI_NONE && OWriter.seenGnuAbi()
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  421 |                    ? ELF::ELFOSABI_GNU
      |                    ^~~~~~~~~~~~~~~~~~~
  422 |                    : OSABI);
      |                    ~~~~~~~
```

3 years ago[tests] add a few more tests for D98122
Philip Reames [Wed, 10 Mar 2021 03:18:15 +0000 (19:18 -0800)]
[tests] add a few more tests for D98122

3 years ago[lld-macho] implement options -(un)exported_symbol(s_list)
Greg McGary [Wed, 3 Mar 2021 20:15:09 +0000 (12:15 -0800)]
[lld-macho] implement options -(un)exported_symbol(s_list)

Implement command-line options to alter a dylib's exported-symbols list:
* `-exported_symbol*` options override the default export list. The export list is compiled according to the command-line option(s) only.
* `-unexported_symbol*` options hide otherwise public symbols.
* `-*exported_symbol PATTERN` options specify a single literal or glob pattern.
* `-*exported_symbols_list FILE` options specify a file containing a series of lines containing symbol literals or glob patterns. Whitespace and `#`-prefix comments are stripped.

Note: This is a simple implementation of the primary use case. ld64 has much more complexity surrounding interactions with other options, many of which are obscure and undocumented. We will start simple and complexity as necessary.

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

3 years ago[Android] Default to --rtlib=compiler-rt
Ryan Prichard [Tue, 9 Mar 2021 22:20:45 +0000 (14:20 -0800)]
[Android] Default to --rtlib=compiler-rt

By default, the driver uses the compiler-rt builtins and links with
-l:libunwind.a.

Restore the previous behavior by passing --rtlib=libgcc.

Reviewed By: danalbert

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

3 years ago[coro async] Transfer the original function's attributes to the clone
Arnold Schwaighofer [Fri, 5 Mar 2021 15:17:55 +0000 (07:17 -0800)]
[coro async] Transfer the original function's attributes to the clone

rdar://75052917

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

3 years agoLog in SetPrivateState when unwind logging enabled
Jason Molenda [Wed, 10 Mar 2021 00:22:46 +0000 (16:22 -0800)]
Log in SetPrivateState when unwind logging enabled

It is easier to read the unwind logging when you can see
when the inferior resumes / stops and we're doing new unwinds.

3 years agoRemove unused variable (rolling it into an assert)
David Blaikie [Tue, 9 Mar 2021 23:50:25 +0000 (15:50 -0800)]
Remove unused variable (rolling it into an assert)

3 years ago[MemoryDependence] Fix invariant group store
William S. Moses [Tue, 9 Mar 2021 16:55:19 +0000 (11:55 -0500)]
[MemoryDependence] Fix invariant group store

Fix bug in MemoryDependence [and thus GVN] for invariant group.

Previously MemDep didn't verify that the store was storing into a
pointer rather than a store simply using a pointer.

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

3 years agoFix MLIR test post 890afad954d
Mehdi Amini [Tue, 9 Mar 2021 23:30:36 +0000 (23:30 +0000)]
Fix MLIR test post 890afad954d

3 years agoFix Flang build after MLIR API changes around `generatedTypeParser`
Mehdi Amini [Tue, 9 Mar 2021 23:13:38 +0000 (23:13 +0000)]
Fix Flang build after MLIR API changes around `generatedTypeParser`

3 years ago[llvm] Change DSOLocalEquivalent type if the underlying global value type changes
Leonard Chan [Sat, 6 Mar 2021 00:11:01 +0000 (16:11 -0800)]
[llvm] Change DSOLocalEquivalent type if the underlying global value type changes

We encountered an issue where LTO running on IR that used the DSOLocalEquivalent
constant would result in bad codegen. The underlying issue was ValueMapper wasn't
properly handling DSOLocalEquivalent, so this just adds the machinery for handling
it. This code path is triggered by a fix to DSOLocalEquivalent::handleOperandChangeImpl
where DSOLocalEquivalent could potentially not have the same type as its underlying GV.

This updates DSOLocalEquivalent::handleOperandChangeImpl to change the type if
the GV type changes and handles this constant in ValueMapper.

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

3 years ago[mlir][IR] Add an Operation::eraseOperands that supports batch erasure
River Riddle [Tue, 9 Mar 2021 23:02:03 +0000 (15:02 -0800)]
[mlir][IR] Add an Operation::eraseOperands that supports batch erasure

This method allows for removing multiple disjoint operands at once, reducing the need to erase operands individually (which results in shifting the operand list).

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

3 years ago[mlir][IR] Add a new SymbolUserMap class
River Riddle [Tue, 9 Mar 2021 23:01:54 +0000 (15:01 -0800)]
[mlir][IR] Add a new SymbolUserMap class

This class provides efficient implementations of symbol queries related to uses, such as collecting the users of a symbol, replacing all uses, etc. This provides similar benefits to use related queries, as SymbolTableCollection did for lookup queries.

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

3 years agoPR49465: Disallow constant evaluation of a call to operator delete(nullptr).
Richard Smith [Tue, 9 Mar 2021 23:04:51 +0000 (15:04 -0800)]
PR49465: Disallow constant evaluation of a call to operator delete(nullptr).

The only time we would consider allowing this is inside a call to
std::allocator<T>::deallocate, whose contract does not permit deletion
of null pointers.

3 years ago[clang][driver] Support Darwin SDK names with an optional prefix in their name
Alex Lorenz [Tue, 9 Mar 2021 22:42:07 +0000 (14:42 -0800)]
[clang][driver] Support Darwin SDK names with an optional prefix in their name

rdar://74017977

3 years agoRevert "[llvm-cov] reset executation count to 0 after wrapped segment"
Zequan Wu [Fri, 5 Mar 2021 21:38:12 +0000 (13:38 -0800)]
Revert "[llvm-cov] reset executation count to 0 after wrapped segment"

This reverts D85036

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

3 years ago[SLP] remove dead null check; NFC
Sanjay Patel [Tue, 9 Mar 2021 21:56:43 +0000 (16:56 -0500)]
[SLP] remove dead null check; NFC

We cast<> to Instruction (not dyn_cast<>), so we already
required/assumed that Cmp is not null.

3 years ago[dfsan] Tracking origins at memory transfer
Jianzhou Zhao [Sat, 6 Mar 2021 00:58:00 +0000 (00:58 +0000)]
[dfsan] Tracking origins at memory transfer

This is a part of https://reviews.llvm.org/D95835.

Reviewed By: morehouse

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

3 years agoFix LLVM Dialect LoopOptionsAttr round-tripping: the keywords were missing in the...
Mehdi Amini [Tue, 9 Mar 2021 21:59:35 +0000 (21:59 +0000)]
Fix LLVM Dialect LoopOptionsAttr round-tripping: the keywords were missing in the output

This indicated some missing test coverage, which are now added to the
roundtrip test.

3 years ago[ARM] Test for predicated scalar memops. NFC
David Green [Tue, 9 Mar 2021 21:57:18 +0000 (21:57 +0000)]
[ARM] Test for predicated scalar memops. NFC

This test shows a case where we can potentially scalarize the store in a
predicated loop, creating a lot of instructions that would be much
slower than scalar.

3 years ago[tests] add tests to show effects of D98122
Philip Reames [Tue, 9 Mar 2021 21:48:45 +0000 (13:48 -0800)]
[tests] add tests to show effects of D98122

3 years ago[cmake] Enable -Werror=return-type
Dave Lee [Mon, 8 Mar 2021 21:11:08 +0000 (13:11 -0800)]
[cmake] Enable -Werror=return-type

Turn `-Wreturn-type` into an error.

This is currently used by libcxx, libcxxabi, and libunwind, and would be a good default
for all of llvm. I'm not aware of any cases where this shouldn't be an error. This
ensures different build configs, merges, and downstream branches catch issues sooner.

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

3 years ago[clangd][NFC] Use std::string::replace in SourceCode:applyChange.
Nathan James [Tue, 9 Mar 2021 21:39:19 +0000 (21:39 +0000)]
[clangd][NFC] Use std::string::replace in SourceCode:applyChange.

Just looks nicer and easier to read.

Reviewed By: kadircet

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

3 years ago[clang][ObjC] allow the use of NSAttributedString * return type with format_arg attribute
Alex Lorenz [Tue, 9 Mar 2021 21:18:19 +0000 (13:18 -0800)]
[clang][ObjC] allow the use of NSAttributedString * return type with format_arg attribute

This is useful for APIs that want to produce an attributed NSString as a result of
some formatting API call.

3 years agoAdd default LoopOptionsAttrBuilder constructor and method to check if empty() (NFC)
Mehdi Amini [Tue, 9 Mar 2021 21:03:20 +0000 (21:03 +0000)]
Add default LoopOptionsAttrBuilder constructor and method to check if empty() (NFC)

Also move setters out-of-line to make sure the templated helper is
actually instantiated.

3 years ago[P10] [Power PC] Exploiting new load rightmost vector element instructions.
Albion Fung [Tue, 9 Mar 2021 21:07:31 +0000 (16:07 -0500)]
[P10] [Power PC] Exploiting new load rightmost vector element instructions.

This pull request implements patterns to exploit the load rightmost vector
element instructions for loading element 0 on little endian PowerPC subtargets
into v8i16 and v16i8 vector registers for i16 and i8 data types.

Differential Revision: https://reviews.llvm.org/D94816#inline-921403

3 years agoRevert "[InstCombine] Add simplification of two logical and/ors"
Juneyoung Lee [Tue, 9 Mar 2021 20:48:02 +0000 (05:48 +0900)]
Revert "[InstCombine] Add simplification of two logical and/ors"

This reverts commit 07c3b97e184d5bd828b8a680cdce46e73f3db9fc due to a reported failure in two-stage build.

3 years ago[profile] Fix InstrProfGetRangeRepValue to use UINT64_C
Fangrui Song [Tue, 9 Mar 2021 20:46:13 +0000 (12:46 -0800)]
[profile] Fix InstrProfGetRangeRepValue to use UINT64_C

This is a minor issue because the TargetValue parameter of `__llvm_profile_instrument_memop`
is usually small and cannot exceed 2**31 at all.

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

3 years ago[test] precommit tests from D98222
Philip Reames [Tue, 9 Mar 2021 20:39:47 +0000 (12:39 -0800)]
[test] precommit tests from D98222

3 years ago[SCEV] Infer known bits from known sign bits
Philip Reames [Tue, 9 Mar 2021 20:35:16 +0000 (12:35 -0800)]
[SCEV] Infer known bits from known sign bits

This was suggested by lebedev.ri over on D96534.  You'll note lack of tests.  During review, we weren't actually able to find a case which exercises it, but both I and lebedev.ri feel it's a reasonable change, straight forward, and near free.

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

3 years ago[flang] Sort symbols by creation order
Peter Steinfeld [Tue, 9 Mar 2021 01:17:14 +0000 (17:17 -0800)]
[flang] Sort symbols by creation order

We have a "<" operator defined on the type semantics::Symbol that's based on
the symbols' locations in the cooked character stream.  This is potentially
problematic when comparing symbols from .mod files when the cooked character
streams themselves might be allocated to varying memory locations.

This change fixes that by using the order in which symbols are created as the
basis for the "<" operator.  Thanks to Tim and Peter for consultation on the
necessity of doing this and the idea for what to use as the basis of the sort.

This change in the "<" operator changed the expected results for three of the
tests.  I manually inspected the new results, and they look OK to me.  The
differences in data05.f90 and typeinfo01.f90 are entirely the order, offsets,
and sizes of the derived type components.  The changes in resolve102.f90 are
due to the new, different "<" operator used for sorting.

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

3 years ago[DSE] Add test cases with memory intrinsics and varying size values.
Florian Hahn [Tue, 9 Mar 2021 13:10:47 +0000 (13:10 +0000)]
[DSE] Add test cases with memory intrinsics and varying size values.

This patch adds a few tests for memset/memcyp with non-constant size
values. Some of the tests will be optimized in further patches.

3 years agoAdd requirement for aarch64-registered-target to test change added in 42e3f97a9dd3a43...
Douglas Yung [Tue, 9 Mar 2021 20:24:32 +0000 (12:24 -0800)]
Add requirement for aarch64-registered-target to test change added in 42e3f97a9dd3a439f63a733c4ee909cba6b77e49.

3 years ago[dfsan] Update store.ll test
George Balatsouras [Tue, 9 Mar 2021 02:05:52 +0000 (18:05 -0800)]
[dfsan] Update store.ll test

This removes hard-coded shadow width references and adds more RUN
lines to increase test coverage under different options (fast16 labels
mode).

Also, shortens the test by unifying common lines under both combine- and no-combine-ptr-label options.

Reviewed By: stephan.yichao.zhao

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

3 years agoRevert D97743 "Define __GCC_HAVE_DWARF2_CFI_ASM if applicable"
Fangrui Song [Tue, 9 Mar 2021 20:14:12 +0000 (12:14 -0800)]
Revert D97743 "Define __GCC_HAVE_DWARF2_CFI_ASM if applicable"

This reverts commit c11ff4bbada3b5127a1f010e0a97a1e6e46fb61a & df67d3526962ae51446b1390e7c40e045e580ec2.

Trying to make the change to the driver to avoid round-trip issues.

3 years ago[test] Fix debug-info-macro.c
Fangrui Song [Tue, 9 Mar 2021 20:04:51 +0000 (12:04 -0800)]
[test] Fix debug-info-macro.c

3 years ago[mlir] Default for gpu-binary-annotation option.
Christian Sigg [Tue, 9 Mar 2021 19:19:32 +0000 (20:19 +0100)]
[mlir] Default for gpu-binary-annotation option.

Provide default for gpuBinaryAnnotation so that we don't need to specify it in tests.

The annotation likely only needs to be target specific if we want to lower to e.g. both CUDA and ROCDL.

Reviewed By: herhut, bondhugula

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

3 years agoMove some attribute diagnostic helper functions; NFC.
Aaron Ballman [Tue, 9 Mar 2021 19:52:59 +0000 (14:52 -0500)]
Move some attribute diagnostic helper functions; NFC.

These functions were local to SemaDeclAttr.cpp, but these functions are
useful in general (for instance, for statement or type attribute
processing). This refactoring is in advance of beginning to tablegen
diagnostic checks for statement attributes the way we already do for
declaration attributes.

There is one functional change in here as a drive-by. The
external_source_symbol attribute had one of its diagnostic checks
inside of an assert, which was corrected.

3 years ago[cgp] improve robustness of uadd/usub transforms
Philip Reames [Tue, 9 Mar 2021 19:44:43 +0000 (11:44 -0800)]
[cgp] improve robustness of uadd/usub transforms

LSR prefers to schedule iv increments just before the latch.  The recent 80511565 broadened this to moving increments in the original IR.  This pointed out a robustness problem with the CGP transform.

When we have a use of an induction increment outside of the loop (we canonicalize away from this form, but it happens e.g. unanalyzeable loops) we'd avoid performing the uadd/usub transform.  Interestingly, all of these involve moving the increment closer to it's operands, so there's no concern about dominating all uses.  We can handle that case cheaply, resulting in a more robust transform.