platform/upstream/llvm.git
4 years ago[HIP] Add gfx1031 and gfx1030
Yaxun (Sam) Liu [Tue, 8 Sep 2020 20:01:30 +0000 (16:01 -0400)]
[HIP] Add gfx1031 and gfx1030

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

4 years agoSema: extract a check for `isCFError` (NFC)
Saleem Abdulrasool [Tue, 8 Sep 2020 20:06:07 +0000 (20:06 +0000)]
Sema: extract a check for `isCFError` (NFC)

Extract a simple check to check if a `RecordDecl` is a `CFError` Decl.
This is a simple refactoring to prepare for an upcoming change.  NFC.

Patch is extracted from
https://github.com/llvm/llvm-project-staging/commit/8afaf3aad2af43cfedca7a24cd817848c4e95c0c.

4 years agofix typos; improve a couple of descriptions;
Paul C. Anagnostopoulos [Sun, 30 Aug 2020 18:00:25 +0000 (14:00 -0400)]
fix typos; improve a couple of descriptions;
add release note

4 years ago[ValueTracking] Compute known bits of min/max intrinsics
Nikita Popov [Tue, 8 Sep 2020 19:06:59 +0000 (21:06 +0200)]
[ValueTracking] Compute known bits of min/max intrinsics

Implement known bits for the min/max intrinsics based on the
recently added KnownBits primitives.

4 years ago[InstCombine] Add tests for known bits for min/max intrinsics (NFC)
Nikita Popov [Tue, 8 Sep 2020 18:57:40 +0000 (20:57 +0200)]
[InstCombine] Add tests for known bits for min/max intrinsics (NFC)

We already have test coverage for the underlying calculation,
this just checked that the folding is wired up...

4 years agoRetry of D84974
Walter Erquinigo [Wed, 2 Sep 2020 01:52:14 +0000 (18:52 -0700)]
Retry of D84974

The test is being disabled on Linux, as lldb-vscode has a bug with
--wait-for on LInux.
I'm also fixing some compilation warnings.

4 years ago[UnifyFunctionExitNodes] Remove unused getters, NFC
David Stenberg [Tue, 8 Sep 2020 16:54:30 +0000 (18:54 +0200)]
[UnifyFunctionExitNodes] Remove unused getters, NFC

The get{Return,Unwind,Unreachable}Block functions in
UnifyFunctionExitNodes have not been used for many years,
so just remove them.

Reviewed By: bjope

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

4 years ago[LLD][ELF] Fix performance of MarkLive::scanEhFrameSection
Andrew Ng [Mon, 7 Sep 2020 16:36:14 +0000 (17:36 +0100)]
[LLD][ELF] Fix performance of MarkLive::scanEhFrameSection

MarkLive::scanEhFrameSection is used to retain personality/LSDA
functions when --gc-sections is enabled.

Improve its performance by only iterating over the .eh_frame relocations
that need to be resolved for an EhSectionPiece. This optimization makes
the same assumption as elsewhere in LLD that the .eh_frame relocations
are sorted by r_offset.

This appears to be a performance regression introduced in commit
e6c24299d237 (https://reviews.llvm.org/D59800).

This change has been seen to reduce link time by up to ~50%.

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

4 years ago[llvm-install-name-tool] Add a test with multiple input files
Alexander Shaposhnikov [Tue, 8 Sep 2020 17:24:58 +0000 (10:24 -0700)]
[llvm-install-name-tool] Add a test with multiple input files

This diff adds a test which checks the error-message when multiple input files
are passed to llvm-install-name-tool.

Test plan: make check-all

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

4 years agoUpdate clang/test/Driver/darwin-infer-simulator-sdkroot.c
Azharuddin Mohammed [Tue, 8 Sep 2020 17:57:06 +0000 (10:57 -0700)]
Update clang/test/Driver/darwin-infer-simulator-sdkroot.c

 - Fix it to work on Apple Silicon
 - Add testcases for simulators running on Apple Silicon

4 years ago[InstCombine] Fold comparison of abs with int min
Nikita Popov [Tue, 8 Sep 2020 18:23:03 +0000 (20:23 +0200)]
[InstCombine] Fold comparison of abs with int min

If the abs is poisoning, this is already folded to true/false.
For non-poisoning abs, we can convert this to a comparison with
the operand.

4 years ago[InstCombine] Test comparison of abs with int min (NFC)
Nikita Popov [Tue, 8 Sep 2020 18:20:32 +0000 (20:20 +0200)]
[InstCombine] Test comparison of abs with int min (NFC)

4 years ago[InstCombine] Fold abs of known negative operand
Nikita Popov [Sat, 5 Sep 2020 15:23:48 +0000 (17:23 +0200)]
[InstCombine] Fold abs of known negative operand

If we know that the abs operand is known negative, we can replace
it with a neg.

To avoid computing known bits twice, I've removed the fold for the
non-negative case from InstSimplify. Both the non-negative and the
negative case are handled by InstCombine now, with one known bits call.

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

4 years ago[Coroutine] Make dealing with alloca spills more robust
Xun Li [Tue, 8 Sep 2020 17:58:35 +0000 (10:58 -0700)]
[Coroutine] Make dealing with alloca spills more robust

D66230 attempted to fix a problem where when there are allocas used before CoroBegin.
It keeps allocas and their uses stay in put if there are no escapse/changes to the data before CoroBegin.
Unfortunately that's incorrect.
Consider this code:

%var = alloca i32
%1 = getelementptr .. %var; stays put
%f = call i8* @llvm.coro.begin
store ... %1
After this fix, %1 will now stay put, however if a store happens after coro.begin and hence modifies the content, this change will not be reflected in the coroutine frame (and will eventually be DCEed).
To generalize the problem, if any alias ptr is created before coro.begin for an Alloca and that alias ptr is latter written into after coro.begin, it will lead to incorrect behavior.

There are also a few other minor issues, such as incorrect dominate condition check in the ptr visitor, unhandled memory intrinsics and etc.
Ths patch attempts to fix some of these issue, and make it more robust to deal with aliases.

While visiting through the alloca pointer, we also keep track of all aliases created that will be used after CoroBegin. We track the offset of each alias, and then reacreate these aliases after CoroBegin using these offset.
It's worth noting that this is not perfect and there will still be cases we cannot handle. I think it's impractical to handle all cases given the current design.
This patch makes it more robust and should be a pure win.
In the meantime, we need to think about what how to completely elimiante these issues, likely through the route as @rjmccall mentioned in D66230.

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

4 years ago[X86] SSE4_A should only imply SSE3 not SSSE3 in the frontend.
Craig Topper [Tue, 8 Sep 2020 17:49:32 +0000 (10:49 -0700)]
[X86] SSE4_A should only imply SSE3 not SSSE3 in the frontend.

SSE4_1 and SSE4_2 due imply SSSE3. So I guess I got confused when
switching the code to being table based in D83273.

Fixes PR47464

4 years agoAdd detailed reference for the SearchableTables backend.
Paul C. Anagnostopoulos [Wed, 2 Sep 2020 15:50:30 +0000 (11:50 -0400)]
Add detailed reference for the SearchableTables backend.

4 years agoRevert "[ARM] Follow AACPS standard for volatile bit-fields access width"
Ties Stuij [Tue, 8 Sep 2020 17:43:59 +0000 (18:43 +0100)]
Revert "[ARM] Follow AACPS standard for volatile bit-fields access width"

This reverts commit 514df1b2bb1ecd1a33327001ea38a347fd2d0380.

Some of the buildbots got llvm-lit errors on CodeGen/volatile.c

4 years agoCFGUpdate.h - remove unused APInt include. NFCI.
Simon Pilgrim [Tue, 8 Sep 2020 17:24:52 +0000 (18:24 +0100)]
CFGUpdate.h - remove unused APInt include. NFCI.

4 years agoRISCVMatInt.h - remove unnecessary includes. NFCI.
Simon Pilgrim [Tue, 8 Sep 2020 17:04:41 +0000 (18:04 +0100)]
RISCVMatInt.h - remove unnecessary includes. NFCI.

Add APInt forward declaration and move include to RISCVMatInt.cpp

4 years ago[sanitizers] Remove unneeded MaybeCall*DefaultOptions() and nullptr checks
Fangrui Song [Sat, 5 Sep 2020 02:19:20 +0000 (19:19 -0700)]
[sanitizers] Remove unneeded MaybeCall*DefaultOptions() and nullptr checks

D28596 added SANITIZER_INTERFACE_WEAK_DEF which can guarantee `*_default_options` are always defined.
The weak attributes on the `__{asan,lsan,msan,ubsan}_default_options` declarations can thus be removed.

`MaybeCall*DefaultOptions` no longer need nullptr checks, so their call sites can just be replaced by `__*_default_options`.

Reviewed By: #sanitizers, vitalybuka

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

4 years agoAdd more explicit error message when creating a type or attribute for an unregistered...
Mehdi Amini [Tue, 8 Sep 2020 16:53:24 +0000 (16:53 +0000)]
Add more explicit error message when creating a type or attribute for an unregistered dialect (NFC)

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

4 years ago[GVN] Add testcase that uses masked loads and stores, NFC
Krzysztof Parzyszek [Tue, 8 Sep 2020 16:26:10 +0000 (11:26 -0500)]
[GVN] Add testcase that uses masked loads and stores, NFC

4 years ago[ARM] Follow AACPS standard for volatile bit-fields access width
Ties Stuij [Fri, 28 Aug 2020 14:08:02 +0000 (15:08 +0100)]
[ARM] Follow AACPS standard for volatile bit-fields access width

This patch resumes the work of D16586.
According to the AAPCS, volatile bit-fields should
be accessed using containers of the widht of their
declarative type. In such case:
```
struct S1 {
  short a : 1;
}
```
should be accessed using load and stores of the width
(sizeof(short)), where now the compiler does only load
the minimum required width (char in this case).
However, as discussed in D16586,
that could overwrite non-volatile bit-fields, which
conflicted with C and C++ object models by creating
data race conditions that are not part of the bit-field,
e.g.
```
struct S2 {
  short a;
  int  b : 16;
}
```
Accessing `S2.b` would also access `S2.a`.

The AAPCS Release 2020Q2
(https://documentation-service.arm.com/static/5efb7fbedbdee951c1ccf186?token=)
section 8.1 Data Types, page 36, "Volatile bit-fields -
preserving number and width of container accesses" has been
updated to avoid conflict with the C++ Memory Model.
Now it reads in the note:
```
This ABI does not place any restrictions on the access widths of bit-fields where the container
overlaps with a non-bit-field member or where the container overlaps with any zero length bit-field
placed between two other bit-fields. This is because the C/C++ memory model defines these as being
separate memory locations, which can be accessed by two threads simultaneously. For this reason,
compilers must be permitted to use a narrower memory access width (including splitting the access into
multiple instructions) to avoid writing to a different memory location. For example, in
struct S { int a:24; char b; }; a write to a must not also write to the location occupied by b, this requires at least two
memory accesses in all current Arm architectures. In the same way, in struct S { int a:24; int:0; int b:8; };,
writes to a or b must not overwrite each other.
```

Patch D16586 was updated to follow such behavior by verifying that we
only change volatile bit-field access when:
 - it won't overlap with any other non-bit-field member
 - we only access memory inside the bounds of the record
 - avoid overlapping zero-length bit-fields.

Regarding the number of memory accesses, that should be preserved, that will
be implemented by D67399.

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

The following people contributed to this patch:
- Diogo Sampaio
- Ties Stuij

4 years agoGlobalISel: Combine `op undef, x` to 0
Volkan Keles [Tue, 8 Sep 2020 16:46:38 +0000 (09:46 -0700)]
GlobalISel: Combine `op undef, x` to 0

https://reviews.llvm.org/D86611

4 years ago[WebAssembly] Fix fixEndsAtEndOfFunction for try-catch
Heejin Ahn [Sun, 6 Sep 2020 17:36:07 +0000 (10:36 -0700)]
[WebAssembly] Fix fixEndsAtEndOfFunction for try-catch

When the function return type is non-void and `end` instructions are at
the very end of a function, CFGStackify's `fixEndsAtEndOfFunction`
function fixes the corresponding block/loop/try's type to match the
function's return type. This is applied to consecutive `end` markers at
the end of a function. For example, when the function return type is
`i32`,
```
block i32    ;; return type is fixed to i32
  ...
  loop i32   ;; return type is fixed to i32
    ...
  end_loop
end_block
end_function
```

But try-catch is a little different, because it consists of two parts:
a try part and a catch part, and both parts' return type should satisfy
the function's return type. Which means,
```
try i32      ;; return type is fixed to i32
  ...
  block i32  ;; this should be changed i32 too!
    ...
  end_block
catch
  ...
end_try
end_function
```
As you can see in this example, it is not sufficient to only `end`
instructions at the end of a function; in case of `try`, we should
check instructions before `catch`es, in case their corresponding `try`'s
type has been fixed.

This changes `fixEndsAtEndOfFunction`'s algorithm to use a worklist
that contains a reverse iterator, each of which is a starting point for
a new backward `end` instruction search.

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

Reviewed By: dschuff, tlively

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

4 years agoLiveRegUnits.h - reduce MachineRegisterInfo.h include. NFC.
Simon Pilgrim [Tue, 8 Sep 2020 16:21:28 +0000 (17:21 +0100)]
LiveRegUnits.h - reduce MachineRegisterInfo.h include. NFC.

We only need to include MachineInstrBundle.h, but exposes an implicit dependency in MachineOutliner.h.

Also, remove duplicate includes from LiveRegUnits.cpp + MachineOutliner.cpp.

4 years agoAdd an option for unrolling loops up to a factor.
Lubomir Litchev [Thu, 3 Sep 2020 20:15:39 +0000 (13:15 -0700)]
Add an option for unrolling loops up to a factor.

Currently, there is no option to allow for unrolling a loop up to a specific factor (specified by the user).
The code for doing that is there and there are benefits when unrolling is done  to smaller loops (smaller than the factor specified).

Reviewed By: bondhugula

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

4 years ago[clang-tidy] Fix linking for FrontendOpenMP
Heejin Ahn [Tue, 8 Sep 2020 16:20:06 +0000 (09:20 -0700)]
[clang-tidy] Fix linking for FrontendOpenMP

Without this, builds with `-DBUILD_SHARED_LIBS=ON` fail.

4 years ago[AMDGPU] Support disassembly for AMDGPU kernel descriptors
Ronak Chauhan [Mon, 7 Sep 2020 09:10:00 +0000 (14:40 +0530)]
[AMDGPU] Support disassembly for AMDGPU kernel descriptors

Decode AMDGPU Kernel descriptors as assembler directives.

Reviewed By: scott.linder, jhenderson, kzhuravl

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

4 years ago[clang-format] Handle shifts within conditions
mydeveloperday [Tue, 8 Sep 2020 15:39:11 +0000 (16:39 +0100)]
[clang-format] Handle shifts within conditions

In some situation shifts can be treated as a template, and is thus formatted as one. So, by doing a couple extra checks to assure that the condition doesn't contain a template, and is in fact a bit shift should solve this problem.

This is a fix for [[ https://bugs.llvm.org/show_bug.cgi?id=46969 | bug 46969 ]]

Reviewed By: MyDeveloperDay

Patch By: Saldivarcher

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

4 years ago[libc++] Allow overriding the cached value of LIBCXX_TEST_CONFIG
Louis Dionne [Tue, 8 Sep 2020 15:29:32 +0000 (11:29 -0400)]
[libc++] Allow overriding the cached value of LIBCXX_TEST_CONFIG

4 years ago[libc++] Make sure we always print all available features
Louis Dionne [Tue, 8 Sep 2020 15:17:10 +0000 (11:17 -0400)]
[libc++] Make sure we always print all available features

Previously, we'd only print the features added through the new config,
however printing all the features is important for debugging purposes.

4 years ago[DAGTypeLegalizer] Handle ZERO_EXTEND of promoted type in WidenVecRes_Convert.
Jonas Paulsson [Wed, 19 Aug 2020 10:01:03 +0000 (12:01 +0200)]
[DAGTypeLegalizer] Handle ZERO_EXTEND of promoted type in WidenVecRes_Convert.

On SystemZ, a ZERO_EXTEND of an i1 vector handled by WidenVecRes_Convert()
always ended up being scalarized, because the type action of the input is
promotion which was previously an unhandled case in this method.

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

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

Patch by Eli Friedman.
Review: Ulrich Weigand

4 years ago[clang-tidy] Fix dynamic build failures after 156b127945a8c923d141e608b7380427da024376
Haojian Wu [Tue, 8 Sep 2020 14:26:48 +0000 (16:26 +0200)]
[clang-tidy] Fix dynamic build failures after 156b127945a8c923d141e608b7380427da024376

4 years agoRevert 3e782bf809 "[Sema][MSVC] warn at dynamic_cast when /GR- is given"
Hans Wennborg [Tue, 8 Sep 2020 14:09:33 +0000 (16:09 +0200)]
Revert 3e782bf809 "[Sema][MSVC] warn at dynamic_cast when /GR- is given"

This caused more warnings than expected, see https://crbug.com/1126019

Also reverts the follow-up 7907e5516.

> Differential Revision: https://reviews.llvm.org/D86369

4 years agoStructPackAlignCheck: Fix a -Winconsistent-missing-override warning
Nico Weber [Tue, 8 Sep 2020 14:02:00 +0000 (10:02 -0400)]
StructPackAlignCheck: Fix a -Winconsistent-missing-override warning

4 years ago[gn build] (manually) port 156b127945a8
Nico Weber [Tue, 8 Sep 2020 14:00:24 +0000 (10:00 -0400)]
[gn build] (manually) port 156b127945a8

4 years ago[DSE,MemorySSA] Increase walker limit a bit.
Florian Hahn [Fri, 4 Sep 2020 15:44:58 +0000 (16:44 +0100)]
[DSE,MemorySSA] Increase walker limit a bit.

This slightly bumps the walker limit so that it covers more cases while
not increasing compile-time too much:
http://llvm-compile-time-tracker.com/compare.php?from=0fc1c2b51ba0cfb9145139af35be638333865251&to=91144a50ea4fa82c0c877e77784f60371640b263&stat=instructions

4 years ago[NFC][ARM] Precommit test
Sam Parker [Tue, 8 Sep 2020 13:41:42 +0000 (14:41 +0100)]
[NFC][ARM] Precommit test

4 years ago[mlir][VectorOps] Fix more GCC5 weirdness
Benjamin Kramer [Tue, 8 Sep 2020 13:40:14 +0000 (15:40 +0200)]
[mlir][VectorOps] Fix more GCC5 weirdness

VectorToSCF.cpp:515:47: error: specialization of 'template<class TransferOpTy> mlir::LogicalResult mlir::VectorTransferRewriter<TransferOpTy>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const' in different namespace [-fpermissive]

4 years ago[clang] Limit the maximum level of fold-expr expansion.
Haojian Wu [Tue, 8 Sep 2020 13:34:52 +0000 (15:34 +0200)]
[clang] Limit the maximum level of fold-expr expansion.

Introduce a new diagnostic, and respect the bracket-depth (256) by default.

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

4 years agoAdd a new altera check for structure packing and alignment.
Frank Derry Wanye [Tue, 8 Sep 2020 13:35:14 +0000 (09:35 -0400)]
Add a new altera check for structure packing and alignment.

The altera struct pack align lint check finds structs that are inefficiently
packed or aligned and recommends packing/aligning of the structs using the
packed and aligned attributes as needed in a warning.

4 years ago[InstCombine] add bitwise logic fold tests for D86395; NFC
Sanjay Patel [Tue, 8 Sep 2020 13:17:01 +0000 (09:17 -0400)]
[InstCombine] add bitwise logic fold tests for D86395; NFC

4 years ago[analyzer] [NFC] Introduce refactoring of PthreadLockChecker
Denys Petrov [Fri, 4 Sep 2020 12:03:09 +0000 (15:03 +0300)]
[analyzer] [NFC] Introduce refactoring of PthreadLockChecker

Change capitalization of some names due to LLVM naming rules.
Change names of some variables to make them more speaking.
Rework similar bug reports into one common function.

Prepare code for the next patches to reduce unrelated changes.

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

4 years ago[CMake] Remove dead FindPythonInterp code
Raul Tambre [Sat, 5 Sep 2020 14:52:23 +0000 (17:52 +0300)]
[CMake] Remove dead FindPythonInterp code

LLVM has bumped the minimum required CMake version to 3.13.4, so this has become dead code.

Reviewed By: #libc, ldionne

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

4 years ago[mlir] Fix bug in copy removal
Ehsan Toosi [Mon, 24 Aug 2020 11:19:50 +0000 (13:19 +0200)]
[mlir] Fix bug in copy removal

A crash could happen due to copy removal. The bug is fixed and two more
test cases are added.

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

4 years ago[mlir][VectorOps]
Benjamin Kramer [Tue, 8 Sep 2020 12:02:46 +0000 (14:02 +0200)]
[mlir][VectorOps]

Put back anonymous namespace to work around GCC5 bug.

VectorToSCF.cpp:241:61: error: specialization of 'template<class ConcreteOp> mlir::LogicalResult {anonymous}::NDTransferOpHelper<ConcreteOp>::doReplace()' in different namespace [-fpermissive]

4 years ago[Codegen][X86] Begin moving X86 specific codegen tests into X86 subfolder.
Simon Pilgrim [Tue, 8 Sep 2020 12:01:09 +0000 (13:01 +0100)]
[Codegen][X86] Begin moving X86 specific codegen tests into X86 subfolder.

Discussed with @craig.topper and @spatel - this is to try and tidyup the codegen folder and move the x86 specific tests (as opposed to general tests that just happen to use x86 triples) into subfolders. Its up to other targets if they follow suit.

It also helps speed up test iterations as using wildcards on lit commands often misses some filenames.

4 years agoX86CallLowering.cpp - improve auto const/pointer/reference qualifiers. NFCI.
Simon Pilgrim [Tue, 8 Sep 2020 11:46:00 +0000 (12:46 +0100)]
X86CallLowering.cpp - improve auto const/pointer/reference qualifiers. NFCI.

Fix clang-tidy warnings by ensuring auto variables are more cleanly qualified, or just avoid auto entirely.

4 years agoX86DomainReassignment.cpp - improve auto const/pointer/reference qualifiers. NFCI.
Simon Pilgrim [Tue, 8 Sep 2020 11:45:08 +0000 (12:45 +0100)]
X86DomainReassignment.cpp - improve auto const/pointer/reference qualifiers. NFCI.

Fix clang-tidy warnings by ensuring auto variables are more cleanly qualified, or just avoid auto entirely.

4 years ago[DWARFYAML] Make the debug_ranges section optional.
Xing GUO [Tue, 8 Sep 2020 11:55:14 +0000 (19:55 +0800)]
[DWARFYAML] Make the debug_ranges section optional.

This patch makes the debug_ranges section optional. When we specify an
empty debug_ranges section, yaml2obj only emits the section header.

Reviewed By: jhenderson

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

4 years ago[mlir] remove BufferAssignmentPlacer from BufferAssignmentOpConversionPattern
Ehsan Toosi [Thu, 20 Aug 2020 10:56:19 +0000 (12:56 +0200)]
[mlir] remove BufferAssignmentPlacer from BufferAssignmentOpConversionPattern

BufferPlacement has been removed, as allocations are no longer placed during the conversion.

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

4 years ago[OpenMP] Fix typo in CodeGenFunction::EmitOMPWorksharingLoop (PR46412)
Simon Pilgrim [Tue, 8 Sep 2020 10:59:38 +0000 (11:59 +0100)]
[OpenMP] Fix typo in CodeGenFunction::EmitOMPWorksharingLoop (PR46412)

Fixes issue noticed by static analysis where we have a copy+paste typo, testing ScheduleKind.M1 twice instead of ScheduleKind.M2.

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

4 years ago[mlir][VectorOps] Clean up outdated comments. NFCI.
Benjamin Kramer [Tue, 8 Sep 2020 09:57:50 +0000 (11:57 +0200)]
[mlir][VectorOps] Clean up outdated comments. NFCI.

While there
- De-templatify code that can use function_ref
- Make BoundCaptures usable when they're const
- Address post-submit review comment (static function into global namespace)

4 years ago[SyntaxTree] Fix crash on functions with default arguments.
Eduardo Caldas [Mon, 7 Sep 2020 17:47:09 +0000 (17:47 +0000)]
[SyntaxTree] Fix crash on functions with default arguments.

* Do not visit `CXXDefaultArgExpr`
* To build `CallArguments` nodes, just go through non-default arguments

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

4 years ago[SyntaxTree] Ignore implicit `CXXFunctionalCastExpr` wrapping constructor
Eduardo Caldas [Mon, 7 Sep 2020 08:40:49 +0000 (08:40 +0000)]
[SyntaxTree] Ignore implicit `CXXFunctionalCastExpr` wrapping constructor

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

4 years ago[SyntaxTree] Ignore implicit leaf `CXXConstructExpr`
Eduardo Caldas [Thu, 27 Aug 2020 09:44:09 +0000 (09:44 +0000)]
[SyntaxTree] Ignore implicit leaf `CXXConstructExpr`

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

4 years ago[SyntaxTree] Ignore implicit non-leaf `CXXConstructExpr`
Eduardo Caldas [Thu, 27 Aug 2020 09:43:14 +0000 (09:43 +0000)]
[SyntaxTree] Ignore implicit non-leaf `CXXConstructExpr`

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

4 years ago[mlir] Fix of broken build on windows caused by using uint
Jakub Lichman [Tue, 8 Sep 2020 09:42:25 +0000 (09:42 +0000)]
[mlir] Fix of broken build on windows caused by using uint

4 years ago[ARM][LowOverheadLoops] Remove modifications to the correct element
Sam Tebbs [Mon, 7 Sep 2020 09:39:14 +0000 (10:39 +0100)]
[ARM][LowOverheadLoops] Remove modifications to the correct element
count register

After my patch at D86087, code that now uses the mov operand rather than
the vctp operand will no longer remove modifications to the vctp operand
as they should. This patch fixes that by explicitly removing
modifications to the vctp operand rather than the register used as the
element count.

4 years agoRevert "[PowerPC] Implement instruction clustering for stores"
Qiu Chaofan [Tue, 8 Sep 2020 09:20:00 +0000 (17:20 +0800)]
Revert "[PowerPC] Implement instruction clustering for stores"

This reverts commit 3c0b3250230b3847a2a47dfeacfdb794c2285f02, (along
with ea795304 and bb39eb9e) since it breaks test with UB sanitizer.

4 years ago[mlir][VectorOps] Redo the scalar loop emission in VectoToSCF to pad instead of clipping
Benjamin Kramer [Mon, 7 Sep 2020 15:39:16 +0000 (17:39 +0200)]
[mlir][VectorOps] Redo the scalar loop emission in VectoToSCF to pad instead of clipping

This replaces the select chain for edge-padding with an scf.if that
performs the memory operation when the index is in bounds and uses the
pad value when it's not. For transfer_write the same mechanism is used,
skipping the store when the index is out of bounds.

The integration test has a bunch of cases of how I believe this should
work.

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

4 years ago[mlir] Conv ops vectorization pass
Jakub Lichman [Tue, 8 Sep 2020 08:31:52 +0000 (08:31 +0000)]
[mlir] Conv ops vectorization pass

In this commit a new way of convolution ops lowering is introduced.
The conv op vectorization pass lowers linalg convolution ops
into vector contractions. This lowering is possible when conv op
is first tiled by 1 along specific dimensions which transforms
it into dot product between input and kernel subview memory buffers.
This pass converts such conv op into vector contraction and does
all necessary vector transfers that make it work.

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

4 years agoProvide anchor for compiler extensions
Serge Guelton [Thu, 25 Jun 2020 09:57:01 +0000 (05:57 -0400)]
Provide anchor for compiler extensions

This patch is cherry-picked from 04b0a4e22e3b4549f9d241f8a9f37eebecb62a31, and
amended to prevent an undefined reference to `llvm::EnableABIBreakingChecks'

4 years agogetClangStripDependencyFileAdjuster(): Do not remove -M args when using MSVC cl driver
Shivanshu Goyal [Tue, 8 Sep 2020 08:17:05 +0000 (10:17 +0200)]
getClangStripDependencyFileAdjuster(): Do not remove -M args when using MSVC cl driver

MSVC's cl.exe has a few command line arguments which start with -M such
as "-MD", "-MDd", "-MT", "-MTd", "-MP".
These arguments are not dependency file generation related, and these
arguments were being removed by getClangStripDependencyFileAdjuster()
which was wrong.

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

4 years ago[mlir][Vector] Make VectorToSCF deterministic
Nicolas Vasilache [Tue, 8 Sep 2020 07:39:23 +0000 (03:39 -0400)]
[mlir][Vector] Make VectorToSCF deterministic

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

4 years ago[obj2yaml] Stop parsing the debug_str section when it encounters a string without...
Xing GUO [Tue, 8 Sep 2020 08:08:42 +0000 (16:08 +0800)]
[obj2yaml] Stop parsing the debug_str section when it encounters a string without the null terminator.

When obj2yaml encounters a string without the null terminator, it should
stop parsing the debug_str section. This patch addresses comments in
[D86867](https://reviews.llvm.org/D86867#inline-803291).

Reviewed By: jhenderson

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

4 years ago[flang] Convert release notes to markdown
Richard Barton [Thu, 3 Sep 2020 10:44:03 +0000 (11:44 +0100)]
[flang] Convert release notes to markdown

Switch ReleaseNotes from .rst to .md to match the other docs.

At the same time, fix the version number for master.

4 years ago[Test] More tests where IndVars fails to eliminate a range check
Max Kazantsev [Tue, 8 Sep 2020 07:33:47 +0000 (14:33 +0700)]
[Test] More tests where IndVars fails to eliminate a range check

4 years ago[PowerPC] Fix getMemOperandWithOffsetWidth
Qiu Chaofan [Tue, 8 Sep 2020 07:30:16 +0000 (15:30 +0800)]
[PowerPC] Fix getMemOperandWithOffsetWidth

Commit 3c0b3250 introduced memory cluster under pwr10 target, but a
check for operands was unexpectedly removed. This adds it back to avoid
regression.

4 years ago[AARCH64][RegisterCoalescer] clang miscompiles zero-extension to long long
Simon Wallis [Tue, 8 Sep 2020 07:04:52 +0000 (08:04 +0100)]
[AARCH64][RegisterCoalescer] clang miscompiles zero-extension to long long

Implement AArch64 variant of shouldCoalesce() to detect a known failing case
and prevent the coalescing of a 32-bit copy into a 64-bit sign-extending load.

Do not coalesce in the following case:
COPY where source is bottom 32 bits of a 64-register,
and destination is a 32-bit subregister of a 64-bit register,
ie it causes the rest of the register to be implicitly set to zero.

A mir test has been added.

In the test case, the 32-bit copy implements a 32 to 64 bit zero extension
and relies on the upper 32 bits being zeroed.

Coalescing to the result of the 64-bit load meant overwriting
the upper 32 bits incorrectly when the loaded byte was negative.

Reviewed By: john.brawn

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

4 years ago[PowerPC] Add parentheses to silence gcc warning
Mikael Holmen [Tue, 8 Sep 2020 06:05:47 +0000 (08:05 +0200)]
[PowerPC] Add parentheses to silence gcc warning

Without gcc 7.4 warns with

../lib/Target/PowerPC/PPCInstrInfo.cpp:2284:25: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
          BaseOp1.isFI() &&
          ~~~~~~~~~~~~~~~^~
              "Only base registers and frame indices are supported.");
              ~

4 years ago[clang] Remove a stray semicolon, fixing pedantic GCC warnings. NFC.
Martin Storsjö [Tue, 8 Sep 2020 06:26:39 +0000 (09:26 +0300)]
[clang] Remove a stray semicolon, fixing pedantic GCC warnings. NFC.

4 years ago[LSR] Canonicalize a formula before insert it into the list
Andrew Wei [Tue, 8 Sep 2020 05:14:53 +0000 (13:14 +0800)]
[LSR] Canonicalize a formula before insert it into the list

In GenerateConstantOffsetsImpl, we may generate non canonical Formula
if BaseRegs of that Formula is updated and includes a recurrent expr reg
related with current loop while its ScaledReg is not.

Patched by: mdchen
Reviewed By: qcolombet

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

4 years ago[ELF] --symbol-ordering-file: optimize a loop
Fangrui Song [Tue, 8 Sep 2020 04:44:26 +0000 (21:44 -0700)]
[ELF] --symbol-ordering-file: optimize a loop

4 years ago[Attributor][FIX] Don't crash on internalizing linkonce_odr hidden functions
Johannes Doerfert [Tue, 18 Aug 2020 20:32:21 +0000 (15:32 -0500)]
[Attributor][FIX] Don't crash on internalizing linkonce_odr hidden functions

The CloneFunctionInto has implicit requirements with regards to the
linkage and visibility of the function. We now update these after we did
the CloneFunctionInto on the copy with the same linkage and visibility
as the original.

4 years ago[Attributor][NFC] Cleanup internalize test case
Johannes Doerfert [Fri, 4 Sep 2020 04:42:33 +0000 (23:42 -0500)]
[Attributor][NFC] Cleanup internalize test case

One run line was different and probably introduced for the manually
added function attribute & name checks. We can do this with the script
and a check prefix used for the other run lines as well.

4 years ago[Attributor][NFC] Change variable spelling
Johannes Doerfert [Thu, 3 Sep 2020 21:13:28 +0000 (16:13 -0500)]
[Attributor][NFC] Change variable spelling

4 years ago[Attributor][NFC] Clang tidy: no else after continue
Johannes Doerfert [Sat, 5 Sep 2020 18:26:20 +0000 (13:26 -0500)]
[Attributor][NFC] Clang tidy: no else after continue

4 years ago[Attributor][NFC] Expand `auto` types (clang-fix-it)
Johannes Doerfert [Thu, 3 Sep 2020 16:08:39 +0000 (11:08 -0500)]
[Attributor][NFC] Expand `auto` types (clang-fix-it)

4 years ago[Attributor][FIX] Properly return changed if the IR was modified
Johannes Doerfert [Fri, 28 Aug 2020 01:34:07 +0000 (20:34 -0500)]
[Attributor][FIX] Properly return changed if the IR was modified

Deleting or replacing anything is certainly a modification. This caused
a later assertion in IPSCCP when compiling 400.perlbench with the new PM.
I'm not sure how to test this.

4 years ago[Test] Auto-generated checks for some IndVarSimplify tests
Max Kazantsev [Tue, 8 Sep 2020 04:14:36 +0000 (11:14 +0700)]
[Test] Auto-generated checks for some IndVarSimplify tests

4 years ago[Sema] fix /gr warning test case
Zequan Wu [Tue, 8 Sep 2020 03:55:05 +0000 (20:55 -0700)]
[Sema] fix /gr warning test case

4 years ago[PowerPC] Implement instruction clustering for stores
Qiu Chaofan [Tue, 8 Sep 2020 03:03:09 +0000 (11:03 +0800)]
[PowerPC] Implement instruction clustering for stores

On Power10, it's profitable to schedule some stores with adjacent target
address together. This patch implements this feature.

Reviewed By: steven.zhang

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

4 years ago[llvm-objcopy] Consolidate and unify version tests
Alexander Shaposhnikov [Tue, 8 Sep 2020 01:29:48 +0000 (18:29 -0700)]
[llvm-objcopy] Consolidate and unify version tests

In this diff the tests which verify version printing functionality are refactored.
Since they are not specific to a particular format we move them into tool-version.test
and slightly unify (similarly to tool-name.test and tool-help-message.test).

Test plan: make check-all

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

4 years ago[flang][OpenMP] Enhance parser support for atomic construct to OpenMP 5.0
Kiran Kumar T P [Tue, 8 Sep 2020 01:22:07 +0000 (06:52 +0530)]
[flang][OpenMP] Enhance parser support for atomic construct to OpenMP 5.0

Summary:
This patch enhances parser support for atomic construct to OpenMP 5.0.
2.17.7 atomic -> ATOMIC [clause [,]] atomic-clause [[,] clause] |
                 ATOMIC [clause]
       clause -> memory-order-clause | HINT(hint-expression)
       memory-order-clause -> SEQ_CST | ACQ_REL | RELEASE | ACQUIRE | RELAXED
       atomic-clause -> READ | WRITE | UPDATE | CAPTURE

The patch includes code changes and testcase modifications.

Reviewed By: DavidTruby, kiranchandramohan, sameeranjoshi

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

4 years ago[builtins] Inline __paritysi2 into __paritydi2 and inline __paritydi2 into __parityti2.
Craig Topper [Tue, 8 Sep 2020 00:57:39 +0000 (17:57 -0700)]
[builtins] Inline __paritysi2 into __paritydi2 and inline __paritydi2 into __parityti2.

No point in making __parityti2 go through 2 calls to get to
__paritysi2.

Reviewed By: MaskRay, efriedma

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

4 years agoUpdate SVG images to be properly cropped (NFC)
Mehdi Amini [Tue, 8 Sep 2020 00:56:10 +0000 (00:56 +0000)]
Update SVG images to be properly cropped (NFC)

4 years agoAdd a doc/tutorial on traversing the IR
Mehdi Amini [Tue, 8 Sep 2020 00:06:37 +0000 (00:06 +0000)]
Add a doc/tutorial on traversing the IR

Reviewed By: stephenneuendorffer

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

4 years agoAdd documentation for getDependentDialects() in the PassManagement infra docs
Mehdi Amini [Mon, 7 Sep 2020 23:58:54 +0000 (23:58 +0000)]
Add documentation for getDependentDialects() in the PassManagement infra docs

Reviewed By: rriddle

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

4 years ago[Sema][MSVC] warn at dynamic_cast when /GR- is given
Zequan Wu [Fri, 21 Aug 2020 20:42:20 +0000 (13:42 -0700)]
[Sema][MSVC] warn at dynamic_cast when /GR- is given

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

4 years ago[DSE,MemorySSA] Add an early check for read clobbers to traversal.
Florian Hahn [Mon, 7 Sep 2020 21:52:10 +0000 (22:52 +0100)]
[DSE,MemorySSA] Add an early check for read clobbers to traversal.

Depending on the benchmark, this early exit can save a substantial
amount of compile-time:

http://llvm-compile-time-tracker.com/compare.php?from=505f2d817aa8e07ba98e5fd4a8f6ff0666f89df1&to=eb4e441147f9b4b7a5fcbbc57428cadbe9e01f10&stat=instructions

4 years ago[asan][test] Use --image-base for Linux/asan_prelink_test.cpp if ld is LLD
Fangrui Song [Mon, 7 Sep 2020 21:44:53 +0000 (14:44 -0700)]
[asan][test] Use --image-base for Linux/asan_prelink_test.cpp if ld is LLD

LLD supports -Ttext but with the option there is still a PT_LOAD at address zero
and thus the Linux kernel will map it to a different address and the test will fail.

Use --image-base instead.

4 years agoReland [SimplifyCFG][LoopRotate] SimplifyCFG: disable common instruction hoisting...
Roman Lebedev [Mon, 7 Sep 2020 20:54:06 +0000 (23:54 +0300)]
Reland [SimplifyCFG][LoopRotate] SimplifyCFG: disable common instruction hoisting by default, enable late in pipeline

This was reverted in 503deec2183d466dad64b763bab4e15fd8804239
because it caused gigantic increase (3x) in branch mispredictions
in certain benchmarks on certain CPU's,
see https://reviews.llvm.org/D84108#2227365.

It has since been investigated and here are the results:
https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20200907/827578.html
> It's an amazingly severe regression, but it's also all due to branch
> mispredicts (about 3x without this). The code layout looks ok so there's
> probably something else to deal with. I'm not sure there's anything we can
> reasonably do so we'll just have to take the hit for now and wait for
> another code reorganization to make the branch predictor a bit more happy :)
>
> Thanks for giving us some time to investigate and feel free to recommit
> whenever you'd like.
>
> -eric

So let's just reland this.
Original commit message:

I've been looking at missed vectorizations in one codebase.
One particular thing that stands out is that some of the loops
reach vectorizer in a rather mangled form, with weird PHI's,
and some of the loops aren't even in a rotated form.

After taking a more detailed look, that happened because
the loop's headers were too big by then. It is evident that
SimplifyCFG's common code hoisting transform is at fault there,
because the pattern it handles is precisely the unrotated
loop basic block structure.

Surprizingly, `SimplifyCFGOpt::HoistThenElseCodeToIf()` is enabled
by default, and is always run, unlike it's friend, common code sinking
transform, `SinkCommonCodeFromPredecessors()`, which is not enabled
by default and is only run once very late in the pipeline.

I'm proposing to harmonize this, and disable common code hoisting
until //late// in pipeline. Definition of //late// may vary,
here currently i've picked the same one as for code sinking,
but i suppose we could enable it as soon as right after
loop rotation happens.

Experimentation shows that this does indeed unsurprizingly help,
more loops got rotated, although other issues remain elsewhere.

Now, this undoubtedly seriously shakes phase ordering.
This will undoubtedly be a mixed bag in terms of both compile- and
run- time performance, codesize. Since we no longer aggressively
hoist+deduplicate common code, we don't pay the price of said hoisting
(which wasn't big). That may allow more loops to be rotated,
so we pay that price. That, in turn, that may enable all the transforms
that require canonical (rotated) loop form, including but not limited to
vectorization, so we pay that too. And in general, no deduplication means
more [duplicate] instructions going through the optimizations. But there's still
late hoisting, some of them will be caught late.

As per benchmarks i've run {F12360204}, this is mostly within the noise,
there are some small improvements, some small regressions.
One big regression i saw i fixed in rG8d487668d09fb0e4e54f36207f07c1480ffabbfd, but i'm sure
this will expose many more pre-existing missed optimizations, as usual :S

llvm-compile-time-tracker.com thoughts on this:
http://llvm-compile-time-tracker.com/compare.php?from=e40315d2b4ed1e38962a8f33ff151693ed4ada63&to=c8289c0ecbf235da9fb0e3bc052e3c0d6bff5cf9&stat=instructions
* this does regress compile-time by +0.5% geomean (unsurprizingly)
* size impact varies; for ThinLTO it's actually an improvement

The largest fallout appears to be in GVN's load partial redundancy
elimination, it spends *much* more time in
`MemoryDependenceResults::getNonLocalPointerDependency()`.
Non-local `MemoryDependenceResults` is widely-known to be, uh, costly.
There does not appear to be a proper solution to this issue,
other than silencing the compile-time performance regression
by tuning cut-off thresholds in `MemoryDependenceResults`,
at the cost of potentially regressing run-time performance.
D84609 attempts to move in that direction, but the path is unclear
and is going to take some time.

If we look at stats before/after diffs, some excerpts:
* RawSpeed (the target) {F12360200}
  * -14 (-73.68%) loops not rotated due to the header size (yay)
  * -272 (-0.67%) `"Number of live out of a loop variables"` - good for vectorizer
  * -3937 (-64.19%) common instructions hoisted
  * +561 (+0.06%) x86 asm instructions
  * -2 basic blocks
  * +2418 (+0.11%) IR instructions
* vanilla test-suite + RawSpeed + darktable  {F12360201}
  * -36396 (-65.29%) common instructions hoisted
  * +1676 (+0.02%) x86 asm instructions
  * +662 (+0.06%) basic blocks
  * +4395 (+0.04%) IR instructions

It is likely to be sub-optimal for when optimizing for code size,
so one might want to change tune pipeline by enabling sinking/hoisting
when optimizing for size.

Reviewed By: mkazantsev

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

This reverts commit 503deec2183d466dad64b763bab4e15fd8804239.

4 years ago[KnownBits] Avoid some copies (NFC)
Nikita Popov [Mon, 7 Sep 2020 19:07:02 +0000 (21:07 +0200)]
[KnownBits] Avoid some copies (NFC)

These lambdas don't need copies, use const reference.

4 years ago[SCCP] Compute ranges for supported intrinsics
Nikita Popov [Sat, 5 Sep 2020 08:27:23 +0000 (10:27 +0200)]
[SCCP] Compute ranges for supported intrinsics

For intrinsics supported by ConstantRange, compute the result range
based on the argument ranges. We do this independently of whether
some or all of the input ranges are full, as we can often still
constrain the result in some way.

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

4 years ago[SelectionDAG][X86][ARM] Teach ExpandIntRes_ABS to use sra+add+xor expansion when...
Craig Topper [Mon, 7 Sep 2020 19:23:15 +0000 (12:23 -0700)]
[SelectionDAG][X86][ARM] Teach ExpandIntRes_ABS to use sra+add+xor expansion when ADDCARRY is supported.

Rather than using SELECT instructions, use SRA, UADDO/ADDCARRY and
XORs to expand ABS. This is the multi-part version of the sequence
we use in LegalizeDAG.

It's also the same as the Custom sequence uses for i64 on 32-bit
and i128 on 64-bit. So we can remove the X86 customization.

Reviewed By: RKSimon

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

4 years ago[InstCombine] improve fold of pointer differences
Sanjay Patel [Mon, 7 Sep 2020 19:47:57 +0000 (15:47 -0400)]
[InstCombine] improve fold of pointer differences

This was supposed to be an NFC cleanup, but there's
a real logic difference (did not drop 'nsw') visible
in some tests in addition to an efficiency improvement.

This is because in the case where we have 2 GEPs,
the code was *always* swapping the operands and
negating the result. But if we have 2 GEPs, we
should *never* need swapping/negation AFAICT.

This is part of improving flags propagation noticed
with PR47430.

4 years ago[InstCombine] add ptr difference tests; NFC
Sanjay Patel [Mon, 7 Sep 2020 19:26:43 +0000 (15:26 -0400)]
[InstCombine] add ptr difference tests; NFC

4 years ago[X86] Use the same sequence for i128 ISD::ABS on 64-bit targets as we use for i64...
Craig Topper [Mon, 7 Sep 2020 17:59:57 +0000 (10:59 -0700)]
[X86] Use the same sequence for i128 ISD::ABS on 64-bit targets as we use for i64 on 32-bit targets.

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