platform/upstream/llvm.git
3 years ago[flang] Make `TypeParamInquiry` monomorphic
peter klausler [Tue, 25 Aug 2020 16:40:20 +0000 (09:40 -0700)]
[flang] Make `TypeParamInquiry` monomorphic

Change the expression representation TypeParamInquiry from being
a class that's templatized on the integer KIND of its result into
a monomorphic representation that results in a SubscriptInteger
that can then be converted.

This is a minor simplification, but it's worth doing because
it is believed to also be a work-around for bugs in the MSVC
compiler with overload resolution that affect the expression
traversal framework.

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

3 years ago[ORC] Remove an unused variable.
Lang Hames [Mon, 31 Aug 2020 22:16:03 +0000 (15:16 -0700)]
[ORC] Remove an unused variable.

The unused Main variable was accidentally left in an earlier commit.

3 years ago[lldb] Add reproducer verifier
Jonas Devlieghere [Mon, 31 Aug 2020 22:13:49 +0000 (15:13 -0700)]
[lldb] Add reproducer verifier

Add a reproducer verifier that catches:

 - Missing or invalid home directory
 - Missing or invalid working directory
 - Missing or invalid module/symbol paths
 - Missing files from the VFS

The verifier is enabled by default during replay, but can be skipped by
passing --reproducer-no-verify.

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

3 years ago[SVE] Mark VectorType::getNumElements() deprecated
Christopher Tetreault [Mon, 31 Aug 2020 21:38:18 +0000 (14:38 -0700)]
[SVE] Mark VectorType::getNumElements() deprecated

getNumElements() is being removed from base VectorType in
order to eliminate the class of bugs in which a scalable vector
is accidentally treated like a fixed length vector. Clients of
this function should either call getElementCount(), and handle
the case where getElementCount().isScalable() is true, or they can
cast to FixedVectorType and call getNumElements() if they are
sure that the vector has fixed width.

Deprecated VectorType functions will be removed after the LLVM
12 branch.

See: http://lists.llvm.org/pipermail/llvm-dev/2020-March/139811.html

Reviewed By: fpetrogalli

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

3 years ago[analyzer][NFC] Add `override` keyword missing from D86027
Hubert Tong [Mon, 31 Aug 2020 21:57:22 +0000 (17:57 -0400)]
[analyzer][NFC] Add `override` keyword missing from D86027

Speculative fix for `-Werror,-Wsuggest-override` build failures on
the ppc64le-lld-multistage-test bot.

3 years ago[flang] Format label scope is independent of block scope
peter klausler [Mon, 31 Aug 2020 17:45:37 +0000 (10:45 -0700)]
[flang] Format label scope is independent of block scope

Compilation of the following program currently generates a warning message:

        i = 1
        if (i .eq. 0) then
          write(6, 200) i
200       format (I8)
        end if
        write(6, 200) i
      end

x.f90:6:9: Label '200' is not in scope
          write(6, 200) i
          ^^^^^^^^^^^^^^^

Whereas branch targets must conform to the Clause 11.1.2.1 program
requirement "Transfer of control to the interior of a block from
outside the block is prohibited, ...", this doesn't apply to format
statement references.

3 years ago[OpenMPOpt][HideMemTransfersLatency] Get values stored in offload arrays
Hamilton Tobon Mosquera [Mon, 31 Aug 2020 20:29:22 +0000 (15:29 -0500)]
[OpenMPOpt][HideMemTransfersLatency] Get values stored in offload arrays

getValuesInOffloadArrays goes through the offload arrays in __tgt_target_data_begin_mapper getting the values stored in them before the call is issued.

call void @__tgt_target_data_begin_mapper(arg0, arg1,
    i8** %offload_baseptrs, i8** %offload_ptrs, i64* %offload_sizes,
...)

Diferential Revision: https://reviews.llvm.org/D86300

3 years ago[mlir][PDL] Move the formats for PatternOp and RewriteOp to the declarative form.
River Riddle [Mon, 31 Aug 2020 19:34:04 +0000 (12:34 -0700)]
[mlir][PDL] Move the formats for PatternOp and RewriteOp to the declarative form.

This is possible now that the declarative assembly form supports regions.

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

3 years ago[mlir][OpFormatGen] Add initial support for regions in the custom op assembly format
River Riddle [Mon, 31 Aug 2020 19:33:55 +0000 (12:33 -0700)]
[mlir][OpFormatGen] Add initial support for regions in the custom op assembly format

This adds some initial support for regions and does not support formatting the specific arguments of a region. For now this can be achieved by using a custom directive that formats the arguments and then parses the region.

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

3 years ago[mlir][ODS] Add new SymbolNameAttr and add support for in assemblyFormat
River Riddle [Mon, 31 Aug 2020 19:33:46 +0000 (12:33 -0700)]
[mlir][ODS] Add new SymbolNameAttr and add support for in assemblyFormat

Symbol names are a special form of StringAttr that get treated specially in certain areas, such as formatting. This revision adds a special derived attr for them in ODS and adds support in the assemblyFormat for formatting them properly.

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

3 years ago[mlir][OpFormatGen] Add support for specifiy "custom" directives.
River Riddle [Mon, 31 Aug 2020 19:33:36 +0000 (12:33 -0700)]
[mlir][OpFormatGen] Add support for specifiy "custom" directives.

This revision adds support for custom directives to the declarative assembly format. This allows for users to use C++ for printing and parsing subsections of an otherwise declaratively specified format. The custom directive is structured as follows:

```
custom-directive ::= `custom` `<` UserDirective `>` `(` Params `)`
```

`user-directive` is used as a suffix when this directive is used during printing and parsing. When parsing, `parseUserDirective` will be invoked. When printing, `printUserDirective` will be invoked. The first parameter to these methods must be a reference to either the OpAsmParser, or OpAsmPrinter. The type of rest of the parameters is dependent on the `Params` specified in the assembly format.

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

3 years ago[docs] Fix indentation in FileCheck.rst
Arthur Eubanks [Mon, 31 Aug 2020 20:19:21 +0000 (13:19 -0700)]
[docs] Fix indentation in FileCheck.rst

Fixes
C:\src\llvm-project\llvm\docs\CommandGuide\FileCheck.rst:745:Bullet list ends without a blank line; unexpected unindent.

3 years ago[X86][CGP] Add gather test cases for D86371.
Craig Topper [Mon, 31 Aug 2020 19:39:50 +0000 (12:39 -0700)]
[X86][CGP] Add gather test cases for D86371.

3 years ago[IR][GVN] allow intrinsics in Instruction's isCommutative query (2nd try)
Sanjay Patel [Mon, 31 Aug 2020 19:53:01 +0000 (15:53 -0400)]
[IR][GVN] allow intrinsics in Instruction's isCommutative query (2nd try)

The 1st try was reverted because I missed an assert that
needed softening.

As discussed in D86798 / rG09652721 , we were potentially
returning a different result for whether an Instruction
is commutable depending on if we call the base class or
derived class method.

This requires relaxing asserts in GVN, but that pass
seems to be working otherwise.

NewGVN requires more work because it uses different
code paths for numbering binops and calls.

3 years ago[SVE] Remove calls to VectorType::getNumElements from InstCombine
Christopher Tetreault [Mon, 31 Aug 2020 19:17:51 +0000 (12:17 -0700)]
[SVE] Remove calls to VectorType::getNumElements from InstCombine

Reviewed By: efriedma

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

3 years ago[NFC][InstCombine] visitPHINode(): cleanup PHI CSE instruction replacement
Roman Lebedev [Mon, 31 Aug 2020 19:22:33 +0000 (22:22 +0300)]
[NFC][InstCombine] visitPHINode(): cleanup PHI CSE instruction replacement

As @nikic is pointing out in https://reviews.llvm.org/rGbf21ce7b908e#inline-4647
this must be sufficient otherwise `EliminateDuplicatePHINodes()`
would have hit issues with it already.

3 years ago[ORC] Remove a stray semicolon, silencing warnings. NFC.
Martin Storsjö [Mon, 31 Aug 2020 19:25:25 +0000 (22:25 +0300)]
[ORC] Remove a stray semicolon, silencing warnings. NFC.

3 years ago[ARM] Register pressure with -mthumb forces register reload before each call
Prathamesh Kulkarni [Mon, 31 Aug 2020 19:00:30 +0000 (20:00 +0100)]
[ARM] Register pressure with -mthumb forces register reload before each call

This patch implements the foldMemoryOperand hook in Thumb1InstrInfo,
allowing tBLXr and a spilled function address to be combined back into a
tBL. This can help with codesize at Oz, especailly in the tinycrypt
library.

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

3 years ago[LLD] [COFF] Error out if creating a DLL with too many exported symbols
Martin Storsjö [Thu, 27 Aug 2020 11:48:22 +0000 (14:48 +0300)]
[LLD] [COFF] Error out if creating a DLL with too many exported symbols

The PE/DLL format has a limit on 64k exported symbols per DLL; make
sure to check this.

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

3 years ago[X86][CGP] Pre-commit test cases for D86371.
Craig Topper [Mon, 31 Aug 2020 17:17:20 +0000 (10:17 -0700)]
[X86][CGP] Pre-commit test cases for D86371.

3 years ago[analyzer] Add bool operator modeling for unque_ptr
Nithin Vadukkumchery Rajendrakumar [Mon, 31 Aug 2020 17:25:33 +0000 (19:25 +0200)]
[analyzer] Add bool operator modeling for unque_ptr

Summary: Implemented boolean conversion operator for unique_ptr

Reviewers: NoQ, Szelethus, vsavchenko, xazax.hun

Reviewed By: NoQ, xazax.hun

Subscribers: martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D86027

3 years ago[NFC] [DAGCombiner] Refactor bitcast folding within fabs/fneg
Qiu Chaofan [Mon, 31 Aug 2020 16:48:12 +0000 (00:48 +0800)]
[NFC] [DAGCombiner] Refactor bitcast folding within fabs/fneg

fabs and fneg share a common transformation:

(fneg (bitconvert x)) -> (bitconvert (xor x sign))
(fabs (bitconvert x)) -> (bitconvert (and x ~sign))

This patch separate the code into a single method.

Reviewed By: spatel

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

3 years ago[NFC] [DAGCombiner] Remove unnecessary negation in visitFNEG
Qiu Chaofan [Mon, 31 Aug 2020 16:35:01 +0000 (00:35 +0800)]
[NFC] [DAGCombiner] Remove unnecessary negation in visitFNEG

In visitFNEG of DAGCombiner, the folding of (fneg (fsub c, x)) is
redundant since getNegatedExpression already handles it.

3 years ago[llvm-reduce] Create returns with undef values for non-void functions.
Florian Hahn [Mon, 31 Aug 2020 15:33:46 +0000 (16:33 +0100)]
[llvm-reduce] Create returns with undef values for non-void functions.

Currently replaceBranchTerminator/removeUninterestingBBsFromSwitch
always creates `ret void` instructions if no successor is in the chunk.

This results in invalid IR for functions with non-void return types,
which makes those reductions unfeasible. Instead, create `ret ty undef`
for functions with non-void return types.

Reviewed By: lebedev.ri

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

3 years ago[PowerPC][AIX] Add test for returning a vector type. [NFC]
Sean Fertile [Mon, 31 Aug 2020 15:14:17 +0000 (11:14 -0400)]
[PowerPC][AIX] Add test for returning a vector type. [NFC]

Shows error produced when trying to return a vector, which is not
yet supported.

3 years ago[clang-tidy] Buildbot failure fix for commit rGf5fd7486d6c0
Adam Balogh [Mon, 31 Aug 2020 14:29:01 +0000 (16:29 +0200)]
[clang-tidy] Buildbot failure fix for commit rGf5fd7486d6c0

Commit `rGf5fd7486d6c0` caused a buildbot failure because exceptions are
disabled by default on one of the buildbots. This patch forcibly enables
exceptions for the affected test.

3 years ago[CodeGen] Make sure the EH cleanup for block captures is conditional when the block...
Erik Pilkington [Mon, 31 Aug 2020 13:42:34 +0000 (09:42 -0400)]
[CodeGen] Make sure the EH cleanup for block captures is conditional when the block literal is in a conditional context

Previously, clang was crashing on the attached test because the EH cleanup for
the block capture was incorrectly emitted under the assumption that the
expression wasn't conditionally evaluated. This was because before 9a52de00260,
pushLifetimeExtendedDestroy was mainly used with C++ automatic lifetime
extension, where a conditionally evaluated expression wasn't possible. Now that
we're using this path for block captures, we need to handle this case.

rdar://66250047

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

3 years agoTeach the swift calling convention about _Atomic types
Arnold Schwaighofer [Wed, 19 Aug 2020 14:13:16 +0000 (07:13 -0700)]
Teach the swift calling convention about _Atomic types

rdar://67351073

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

3 years ago[gn build] Port f5fd7486d6c
LLVM GN Syncbot [Mon, 31 Aug 2020 14:02:39 +0000 (14:02 +0000)]
[gn build] Port f5fd7486d6c

3 years ago[gn build] Port 14dd0737822
LLVM GN Syncbot [Mon, 31 Aug 2020 14:02:39 +0000 (14:02 +0000)]
[gn build] Port 14dd0737822

3 years ago[Clang-Tidy] New check `bugprone-redundant-branch-condition`
Adam Balogh [Fri, 5 Jun 2020 11:27:09 +0000 (13:27 +0200)]
[Clang-Tidy] New check `bugprone-redundant-branch-condition`

Checking the same condition again in a nested `if` usually make no sense,
except if the value of the expression could have been changed between
the two checks. Although compilers may optimize this out, such code is
suspicious: the programmer may have meant to check something else.
Therefore it is worth to find such places in the code and notify the
user about the problem.

This patch implements a basic check for this problem. Currently it
only detects redundant conditions where the condition is a variable of
integral type. It also detects the possible bug if the variable is in an
//or// or //and// logical expression in the inner if and/or the variable
is in an //and// logical expression in the outer if statement. Negated
cases are not handled yet.

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

3 years ago[clang-tidy] New check readability-prefer-member-initializer
Adam Balogh [Thu, 12 Dec 2019 16:03:16 +0000 (17:03 +0100)]
[clang-tidy] New check readability-prefer-member-initializer

Finds member initializations in the constructor body which can
be placed to the member initializers of the constructor instead.
This does not only improves the readability of the code but also
affects positively its performance. Class-member assignments
inside a control statement or following the first control
statement are ignored.

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

3 years ago[DAGCombiner] skip reciprocal divisor optimization for x/sqrt(x), better
Sanjay Patel [Mon, 31 Aug 2020 13:31:15 +0000 (09:31 -0400)]
[DAGCombiner] skip reciprocal divisor optimization for x/sqrt(x), better

I tried to fix this in:
rG716e35a0cf53
...but that patch depends on the order that we encounter the
magic "x/sqrt(x)" expression in the combiner's worklist.

This patch should improve that by waiting until we walk the
user list to decide if there's a use to skip.

The AArch64 test reveals another (existing) ordering problem
though - we may try to create an estimate for plain sqrt(x)
before we see that it is part of a 1/sqrt(x) expression.

3 years ago[AArch64] add another test for reciprocal sqrt; NFC
Sanjay Patel [Mon, 31 Aug 2020 13:13:33 +0000 (09:13 -0400)]
[AArch64] add another test for reciprocal sqrt; NFC

3 years ago[x86] add another test for reciprocal sqrt; NFC
Sanjay Patel [Mon, 31 Aug 2020 12:42:04 +0000 (08:42 -0400)]
[x86] add another test for reciprocal sqrt; NFC

The change in rG716e35a0cf53 depends on the order that
we encounter the expression x/sqrt(x), so we need to
adjust the logic to be more flexible.

3 years ago[Flang][NFC] Remove license comments from files in docs/ folder.
sameeran joshi [Mon, 31 Aug 2020 12:59:57 +0000 (18:29 +0530)]
[Flang][NFC] Remove license comments from files in docs/ folder.

Solves issue https://reviews.llvm.org/D86131#2247275

Reviewed By: hans

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

3 years ago[analyzer] Add modeling for unique_ptr move constructor
Nithin Vadukkumchery Rajendrakumar [Mon, 31 Aug 2020 09:50:39 +0000 (11:50 +0200)]
[analyzer] Add modeling for unique_ptr move constructor

Summary:
Add support for handling move contructor of std::unique_ptr.

Reviewers: NoQ, Szelethus, vsavchenko, xazax.hun

Reviewed By: NoQ

Subscribers: martong, cfe-commits
Tags: #clang

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

3 years ago[NFCI] Silent a build warning due to an extra semi-colon
Sourabh Singh Tomar [Mon, 31 Aug 2020 12:16:46 +0000 (17:46 +0530)]
[NFCI] Silent a build warning due to an extra semi-colon

3 years ago[lldb] tab completion for class `CommandObjectTypeFormatterDelete`
Gongyu Deng [Mon, 31 Aug 2020 12:15:58 +0000 (14:15 +0200)]
[lldb] tab completion for class `CommandObjectTypeFormatterDelete`

1. Added a dedicated completion to class `CommandObjectTypeFormatterDelete`
   which can be used by these commands: `type filter/format/summary/synthetic delete`;
2. Added a related test case.

Reviewed By: teemperor

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

3 years agoFix sphinx documentation after a6a37a2fcd2a8048a75bd0d8280497ed89d73224
Alexandre Ganea [Mon, 31 Aug 2020 12:05:55 +0000 (08:05 -0400)]
Fix sphinx documentation after a6a37a2fcd2a8048a75bd0d8280497ed89d73224

3 years ago[lldb][NFC] Remove trailing whitespace in TestCompletion
Raphael Isemann [Mon, 31 Aug 2020 10:24:25 +0000 (12:24 +0200)]
[lldb][NFC] Remove trailing whitespace in TestCompletion

3 years ago[lldb] Fix TestCompletion's pid completion failing randomly
Raphael Isemann [Mon, 31 Aug 2020 09:58:26 +0000 (11:58 +0200)]
[lldb] Fix TestCompletion's pid completion failing randomly

TestCompletion is randomly failing on some bots. The error message however states
that the computed completions actually do contain the expected pid we're
looking for, so there shouldn't be any test failure.

The reason for that turns out to be that complete_from_to is actually used
for testing two different features. It can be used for testing what the
common prefix for the list of completions is and *also* for checking all the
possible completions that are returned for a command. Which one of the two
things should be checked can't be defined by a parameter to the function, but
is instead guessed by the test method instead based on the results that were
returned. If there is a common prefix in all completions, then that prefix
is searched and otherwise all completions are searched.

For TestCompletion's pid test this behaviour leads to the strange test failures.
If all the pid's that our test LLDB can see have a common prefix (e.g., it
can only see pids [123, 122, 10004, 10000] -> common prefix '1'), then
complete_from_to check that the common prefix contains our pid, which is
always fails ('1' doesn't contain '123' or any other valid pid). If there
isn't a common prefix (e.g., pids are [123, 122, 10004, 777]) then
complete_from_to will check the list of completions instead which works correctly.

This patch is fixing this by adding a simple check method that doesn't
have this behaviour and is simply searching the returned list of completions.
This should get the bots green while I'm working on a proper fix that fixes
complete_from_to.

3 years ago[llvm-readobj/elf] - Don't fail when dumping an archive with a member that can't...
Georgii Rymar [Fri, 28 Aug 2020 10:33:20 +0000 (13:33 +0300)]
[llvm-readobj/elf] - Don't fail when dumping an archive with a member that can't be recognized.

Imagine we have an archive that has 3 objects in the following order:
<valid known object>,<unknown object> and <valid known object>.

Currently llvm-readelf/obj report an error and stops dumping in the middle.
This patch changes the error reported to warning.

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

3 years agoRevert "[FileCheck] Move FileCheck implementation out of LLVMSupport into its own...
Raphael Isemann [Mon, 31 Aug 2020 09:14:09 +0000 (11:14 +0200)]
Revert "[FileCheck] Move FileCheck implementation out of LLVMSupport into its own library"

This reverts commit e9a3d1a401b07cbf7b11695637f1b549782a26cd. Seems the new
FileCheck library doesn't link on some bots. Reverting for now.

3 years ago[FileCheck] Move FileCheck implementation out of LLVMSupport into its own library
Raphael Isemann [Mon, 31 Aug 2020 09:14:09 +0000 (11:14 +0200)]
[FileCheck] Move FileCheck implementation out of LLVMSupport into its own library

The actual FileCheck logic seems to be implemented in LLVMSupport. I don't see a
good reason for having FileCheck implemented there as it has a very specific use
while LLVMSupport is a dependency of pretty much every LLVM tool there is. In
fact, the only use of FileCheck I could find (outside the FileCheck tool and the
FileCheck unit test) is a single call in GISelMITest.h.

This moves the FileCheck logic to its own LLVMFileCheck library. This way only
FileCheck and the GlobalISelTests now have a dependency on this code.

Reviewed By: jhenderson

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

3 years ago[lldb] Don't crash when LLDB can't extract the tsan report
Raphael Isemann [Mon, 31 Aug 2020 09:12:32 +0000 (11:12 +0200)]
[lldb] Don't crash when LLDB can't extract the tsan report

Right now all tsan tests are crashing on Linux. The tests were already marked as
expected failures, but since commit 20ce8affce85d added an assert that every
StopInfo needs a non-empty stop description the tests actually started crash
(which is even with an expectedFailure a failed test).

The reason for that is that we never had any stop description when hitting tsan
errors on Linux. Before the assert that just made the test fail, but now the
empty description is hitting the assert. This patch just adds a generic stop
description mentioning tsan to prevent that we hit that assert on platforms
where we don't support extracting the tsan report.

Reviewed By: friss

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

3 years ago[Test] Simplify DWARF test cases. NFC.
Xing GUO [Mon, 31 Aug 2020 06:03:02 +0000 (14:03 +0800)]
[Test] Simplify DWARF test cases. NFC.

The Length, AbbrOffset and Values fields of the debug_info section are
optional. This patch helps remove them and simplify test cases.

Reviewed By: MaskRay

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

3 years ago[Sink] Optimize/simplify sink candidate finding with nearest common dominator
Fangrui Song [Mon, 31 Aug 2020 05:51:00 +0000 (22:51 -0700)]
[Sink] Optimize/simplify sink candidate finding with nearest common dominator

For an instruction in the basic block BB, SinkingPass enumerates basic blocks
dominated by BB and BB's successors. For each enumerated basic block,
SinkingPass uses `AllUsesDominatedByBlock` to check whether the basic
block dominates all of the instruction's users. This is inefficient.

Use the nearest common dominator of all users to avoid enumerating the
candidate. The nearest common dominator may be in a parent loop which is
not beneficial. In that case, find the ancestors in the dominator tree.

In the case that the instruction has no user, with this change we will
not perform unnecessary move. This causes some amdgpu test changes.

A stage-2 x86-64 clang is a byte identical with this change.

3 years ago[Sink][test] Add nounwind test and properly test convergent
Fangrui Song [Mon, 31 Aug 2020 01:26:15 +0000 (18:26 -0700)]
[Sink][test] Add nounwind test and properly test convergent

3 years ago[InstCombine] add extra-use tests for fmul+sqrt; NFC
Venkataramanan Kumar [Sun, 30 Aug 2020 22:39:05 +0000 (18:39 -0400)]
[InstCombine] add extra-use tests for fmul+sqrt; NFC

3 years ago[GVN] add another commutable intrinsic test; NFC
Sanjay Patel [Sun, 30 Aug 2020 22:36:28 +0000 (18:36 -0400)]
[GVN] add another commutable intrinsic test; NFC

This is a reduced version of a test-suite crasher with rG25597f7

3 years agoRevert "[IR][GVN] allow intrinsics in Instruction's isCommutative query"
Sanjay Patel [Sun, 30 Aug 2020 21:02:01 +0000 (17:02 -0400)]
Revert "[IR][GVN] allow intrinsics in Instruction's isCommutative query"

This reverts commit 25597f7783e7038b8a2ee88bb49ac605b211b564.
It is causing crashing on bots such as:
http://lab.llvm.org:8011/builders/fuchsia-x86_64-linux/builds/10523/steps/ninja-build/logs/stdio

3 years ago[DSE,MemorySSA] Skip defs without analyzable write locations.
Florian Hahn [Sun, 30 Aug 2020 20:53:31 +0000 (21:53 +0100)]
[DSE,MemorySSA] Skip defs without analyzable write locations.

Similar to other checks above, if there is no write location for a def,
it cannot be considered for elimination and can be skipped.

3 years ago[IR][GVN] allow intrinsics in Instruction's isCommutative query
Sanjay Patel [Sun, 30 Aug 2020 19:32:45 +0000 (15:32 -0400)]
[IR][GVN] allow intrinsics in Instruction's isCommutative query

As discussed in D86798 / rG09652721 , we were potentially
returning a different result for whether an Instruction
is commutable depending on if we call the base class or
derived class method.

This requires relaxing an assert in GVN, but that pass
seems to be working otherwise.

NewGVN requires more work because it uses different
code paths for numbering binops and calls.

3 years ago[NewGVN] add test for commutative intrinsic; NFC
Sanjay Patel [Sun, 30 Aug 2020 15:47:17 +0000 (11:47 -0400)]
[NewGVN] add test for commutative intrinsic; NFC

3 years ago[GVN] add test for commutative intrinsic; NFC
Sanjay Patel [Sun, 30 Aug 2020 15:45:27 +0000 (11:45 -0400)]
[GVN] add test for commutative intrinsic; NFC

3 years ago[DSE,MemorySSA] Simplify code, EarlierAccess is be a MemoryDef (NFC).
Florian Hahn [Sun, 30 Aug 2020 20:27:32 +0000 (21:27 +0100)]
[DSE,MemorySSA] Simplify code, EarlierAccess is be a MemoryDef (NFC).

After recent changes, we return early if Current is a MemoryPhi, so
EarlierAccess can only be a MemoryDef.

3 years ago[X86] Pre-commit the test-shrink.ll changes from D86578.
Craig Topper [Sun, 30 Aug 2020 19:25:18 +0000 (12:25 -0700)]
[X86] Pre-commit the test-shrink.ll changes from D86578.

The conditions in these tests are guaranteed to always
go one direction. InstCombine would have folded them away.

3 years ago[llvm-reduce] Add test for BB reduction with non-void ret type.
Florian Hahn [Sun, 30 Aug 2020 18:36:46 +0000 (19:36 +0100)]
[llvm-reduce] Add test for BB reduction with non-void ret type.

Precommit test for D86849.

3 years ago[FileCheck] Add precision to format specifier
Thomas Preud'homme [Thu, 11 Jun 2020 15:14:24 +0000 (16:14 +0100)]
[FileCheck] Add precision to format specifier

Add printf-style precision specifier to pad numbers to a given number of
digits when matching them if the value is smaller than the given
precision. This works on both empty numeric expression (e.g. variable
definition from input) and when matching a numeric expression. The
syntax is as follows:

[[#%.<precision><format specifier>, ...]

where <format specifier> is optional and ... can be a variable
definition or not with an empty expression or not. In the absence of a
precision specifier, a variable definition will accept leading zeros.

Reviewed By: jhenderson, grimar

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

3 years agoFix gcc warning by explicitly initializing the base class copy ctor (NFC)
Mehdi Amini [Sun, 30 Aug 2020 17:45:41 +0000 (17:45 +0000)]
Fix gcc warning by explicitly initializing the base class copy ctor (NFC)

Full diagnostic was:

warning: base class ‘class mlir::OptReductionBase<mlir::OptReductionPass>’ should be explicitly initialized in the copy constructor [-Wextra]

3 years ago[LV] Update CFG before adding runtime checks.
Florian Hahn [Sun, 30 Aug 2020 17:14:44 +0000 (18:14 +0100)]
[LV] Update CFG before adding runtime checks.

addRuntimeChecks uses SCEVExpander, which relies on the DT/LoopInfo to
be up-to-date. Changing the CFG afterwards may invalidate some inserted
instructions, especially LCSSA phis.

Reorder the code to first update the CFG and then create the runtime
checks. This should not have any impact on the generated code, as we
adjust the CFG and generate runtime checks together.

Fixes PR47343.

3 years ago[libcxx/variant] Implement workaround for GCC bug.
Michael Park [Sun, 30 Aug 2020 16:42:35 +0000 (12:42 -0400)]
[libcxx/variant] Implement workaround for GCC bug.

A parameter pack is deemed to be uncaptured, which is bogus... but it seems to
be because it's within an expression that involves `decltype` of an uncaptured
pack or something: https://godbolt.org/z/b8z3sh

Drive-by fix for uglified name.

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

3 years ago[FastISel] update to use intrinsic's isCommutative(); NFC
Sanjay Patel [Sun, 30 Aug 2020 15:36:41 +0000 (11:36 -0400)]
[FastISel] update to use intrinsic's isCommutative(); NFC

This requires adding a missing 'const' to the definition because
the callers are using const args, but there should be no change
in behavior.

The intrinsic method was added with D86798 / rG096527214033

3 years ago[DAGCombiner] skip reciprocal divisor optimization for x/sqrt(x)
Sanjay Patel [Sun, 30 Aug 2020 14:51:28 +0000 (10:51 -0400)]
[DAGCombiner] skip reciprocal divisor optimization for x/sqrt(x)

In general, we probably want to try the multi-use reciprocal
transform before sqrt transforms, but x/sqrt(x) is a special-case
because that will always reduce to plain sqrt(x) or an estimate.

The AArch64 tests show that the transform is limited by TLI
hook to patterns where there are 3 or more uses of the divisor.
So this change can result in an extra division compared to
what we had, but that's the intended behvior based on the
current setting of that hook.

3 years ago[AArch64] add tests for multi-use fast sqrt/recip; NFC
Sanjay Patel [Sun, 30 Aug 2020 12:51:17 +0000 (08:51 -0400)]
[AArch64] add tests for multi-use fast sqrt/recip; NFC

3 years ago[x86] add tests for multi-use fast sqrt/recip; NFC
Sanjay Patel [Sun, 30 Aug 2020 12:40:27 +0000 (08:40 -0400)]
[x86] add tests for multi-use fast sqrt/recip; NFC

3 years ago[SLP] make commutative check apply only to binops; NFC
Sanjay Patel [Sun, 30 Aug 2020 12:32:13 +0000 (08:32 -0400)]
[SLP] make commutative check apply only to binops; NFC

As discussed in D86798, it's not clear if the caller code
works with a more liberal definition of "commutative" that
includes intrinsics like min/max. This makes the binop
restriction (current functionality is unchanged) explicit
until the code is audited/tested.

3 years ago[CVP] Regenerate test checks (NFC)
Nikita Popov [Sun, 30 Aug 2020 14:23:59 +0000 (16:23 +0200)]
[CVP] Regenerate test checks (NFC)

3 years ago[NFC][compiler-rt] Factor out __div[sdt]i3 and __mod[dt]i3 implementations
Anatoly Trosinenko [Sun, 30 Aug 2020 13:12:44 +0000 (16:12 +0300)]
[NFC][compiler-rt] Factor out __div[sdt]i3 and __mod[dt]i3 implementations

Reviewed By: MaskRay

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

3 years ago[Hexagon] Fix perfect shuffle generation for single vectors
Krzysztof Parzyszek [Sat, 29 Aug 2020 22:07:48 +0000 (17:07 -0500)]
[Hexagon] Fix perfect shuffle generation for single vectors

Perfect shuffle instruction (vdealvdd/vshuffvdd) work on vector
pairs. When given a single input vector, half of it first needs
to be transposed into the other vector before the generated
shuffles can take effect. Also the first transpose needs to be
undone at the end (this last step was missing).

3 years ago[LV] Add some const to RecurrenceDescriptor. NFC
David Green [Sun, 30 Aug 2020 11:27:51 +0000 (12:27 +0100)]
[LV] Add some const to RecurrenceDescriptor. NFC

3 years ago[llvm-reduce] Function body reduction: don't forget to unset comdat
Tyker [Sun, 30 Aug 2020 10:17:21 +0000 (12:17 +0200)]
[llvm-reduce] Function body reduction: don't forget to unset comdat

althought the interstingness test should usually fail when the module is invalid
this changes reduces the frequency at which llvm-reduce generate invalid IR.

Reviewed By: lebedev.ri

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

3 years agoReland [OpenMPOpt] ICV tracking for calls
sstefan1 [Sun, 30 Aug 2020 09:27:48 +0000 (11:27 +0200)]
Reland [OpenMPOpt] ICV tracking for calls

The problem with module slice has been addressed in D86319

Introduce two new AAs. AAICVTrackerFunctionReturned which checks if a
function can have a unique ICV value after it is finished, and
AAICVCallSiteReturned which checks AAICVTrackerFunctionReturned for a
call site. This enables us to check the value of a call and if it
changes the ICV. This also changes the approach in
`getReplacementValues()` to a worklist-based approach so we can explore
all relevant BBs.

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

3 years ago[Attributor] Introduce module slice.
sstefan1 [Sun, 30 Aug 2020 08:29:07 +0000 (10:29 +0200)]
[Attributor] Introduce module slice.

Summary:
The module slice describes which functions we can analyze and transform
while working on an SCC as part of the Attributor-CGSCC pass. So far we
simply restricted it to the SCC.

Reviewers: jdoerfert

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

3 years agoImprove doc comments for several methods returning bools
Kamlesh Kumar [Sun, 30 Aug 2020 07:59:53 +0000 (13:29 +0530)]
Improve doc comments for several methods returning bools

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

3 years ago[OpenMPOpt][NFC] add reproducer for problem found in D85544
sstefan1 [Sun, 30 Aug 2020 07:59:25 +0000 (09:59 +0200)]
[OpenMPOpt][NFC] add reproducer for problem found in D85544

3 years ago[LangRef] Apply a missing comment from D86189
Juneyoung Lee [Sun, 30 Aug 2020 05:56:10 +0000 (14:56 +0900)]
[LangRef] Apply a missing comment from D86189

3 years ago[LangRef] State that storing an aggregate fills padding with undef
Juneyoung Lee [Wed, 19 Aug 2020 02:21:05 +0000 (11:21 +0900)]
[LangRef] State that storing an aggregate fills padding with undef

This patch makes LangRef be explicit about the value of padding when storing an aggregate.
It states that when an aggregate is stored into memory, padding is filled with undef.

Here is a clue that supports this change (edited to reflect the discussion from llvm-dev):

- IPSCCP ignores padding and directly stores a constant aggregate if possible. It loses the data stored in the padding. https://godbolt.org/z/xzenYs Memcpyopt ignores (the preexisting value of) padding when copying an aggregate or storing a constant: https://godbolt.org/z/hY6ndd / https://godbolt.org/z/3WMP5a

The two items below are not relevant with this patch because Clang lowers load/store of individual field of struct into load/stores of the corresponding pointer with a primitive type. Also, when copy is needed, it uses memcpy instead of load/store of an aggregate, as discussed in the llvm-dev. However, this patch is still valid (as discussed) because it is needed to explain the two optimizations above.

- According to C17, the value of padding bytes when storing values in structures or unions is unspecified.

- I updated Alive2 and it did not find any problematic transformation from LLVM unit tests and while running translation validation of a few C programs.

Reviewed By: nikic

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

3 years ago[Attributor] Fix callsite check in AAUndefinedBehavior
Shinji Okumura [Sun, 30 Aug 2020 04:17:02 +0000 (13:17 +0900)]
[Attributor] Fix callsite check in AAUndefinedBehavior

This is the next patch of D86842
When we check `noundef` attribute violation at callsites, we do not have to require `nonnull` in the following two cases.
1. An argument is known to be simplified to undef
2. An argument is known to be dead

Reviewed By: jdoerfert

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

3 years ago[Attributor][NFC] Fix dependency type in AAUndefinedBehaviorImpl::updateImpl
Shinji Okumura [Sun, 30 Aug 2020 03:34:50 +0000 (12:34 +0900)]
[Attributor][NFC] Fix dependency type in AAUndefinedBehaviorImpl::updateImpl

This patch fixes wrong dependency type in AAUB.

Reviewed By: jdoerfert

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

3 years agoSet alignment of .llvmbc and .llvmcmd to 1
Fangrui Song [Sun, 30 Aug 2020 01:27:34 +0000 (18:27 -0700)]
Set alignment of .llvmbc and .llvmcmd to 1

Otherwise their alignment is dependent on the size of the section.  If the size
is large than 16, the alignment will be 16.

16 is a bad choice for both .llvmbc and .llvmcmd because the padding between two
contributions from input sections is of a variable size.

A bitstream is actually guaranteed to be 4-byte aligned, but consumers don't
need this property.

3 years agoRemove OpenBSD/sparc support
Brad Smith [Sun, 30 Aug 2020 00:47:18 +0000 (20:47 -0400)]
Remove OpenBSD/sparc support

3 years ago[ORC] Add getDFSLinkOrder / getReverseDFSLinkOrder methods to JITDylib.
Lang Hames [Sat, 29 Aug 2020 21:05:04 +0000 (14:05 -0700)]
[ORC] Add getDFSLinkOrder / getReverseDFSLinkOrder methods to JITDylib.

DFS and Reverse-DFS linkage orders are used to order execution of
deinitializers and initializers respectively.

This patch replaces uses of special purpose DFS order functions in
MachOPlatform and LLJIT with uses of the new methods.

3 years ago[libc++] Temporarily force-set the LIBCXX_TEST_CONFIG cache value
Louis Dionne [Sat, 29 Aug 2020 22:07:26 +0000 (18:07 -0400)]
[libc++] Temporarily force-set the LIBCXX_TEST_CONFIG cache value

This ensures that existing CMake build trees will start using the new
default without having to nuke their build directories.

3 years ago[libc++] Move the default site config template alongside other config files
Louis Dionne [Sat, 29 Aug 2020 21:13:02 +0000 (17:13 -0400)]
[libc++] Move the default site config template alongside other config files

3 years ago[libc++] Add from-scratch configuration files for the test suite
Louis Dionne [Fri, 28 Aug 2020 21:56:24 +0000 (17:56 -0400)]
[libc++] Add from-scratch configuration files for the test suite

This commit adds the first from-scratch configuration files for running
the libc++ test suite without using the old configuration:

- libcxx-trunk-shared.cfg.py:
   Runs the test suite against a trunk libc++ shared library.
- libcxx-trunk-static.cfg.py:
   Runs the test suite against a trunk libc++ static library.

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

3 years ago[Attributor] Fix AANoUndef identification
Shinji Okumura [Sat, 29 Aug 2020 20:34:24 +0000 (05:34 +0900)]
[Attributor] Fix AANoUndef identification

Even though `noundef` IR attribute might be attached to non-void type values, AANoUndef is mistakenly identified for pointer type values only.
This patch fixes that.

Reviewed By: jdoerfert

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

3 years ago[InstSimplify] Reduce code duplication in simplifySelectWithICmpCond (NFC)
Nikita Popov [Sat, 29 Aug 2020 20:31:06 +0000 (22:31 +0200)]
[InstSimplify] Reduce code duplication in simplifySelectWithICmpCond (NFC)

Canonicalize icmp ne to icmp eq and implement all the folds only once.

3 years ago[InstSimplify] Protect against more poison in SimplifyWithOpReplaced (PR47322)
Nikita Popov [Sat, 29 Aug 2020 08:55:55 +0000 (10:55 +0200)]
[InstSimplify] Protect against more poison in SimplifyWithOpReplaced (PR47322)

Replace the check for poison-producing instructions in
SimplifyWithOpReplaced() with the generic helper canCreatePoison()
that properly handles poisonous shifts and thus avoids the problem
from PR47322.

This additionally fixes a bug in IIQ.UseInstrInfo=false mode, which
previously could have caused this code to ignore poison flags.
Setting UseInstrInfo=false should reduce the possible optimizations,
not increase them.

This is not a full solution to the problem, as poison could be
introduced more indirectly. This is just a minimal, easy to backport
fix.

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

3 years ago[LV] Check opt-for-size before expanding runtime checks.
Florian Hahn [Sat, 29 Aug 2020 19:21:19 +0000 (20:21 +0100)]
[LV] Check opt-for-size before expanding runtime checks.

Move bail out when optimizing for size before runtime check generation.
In that case, we do not use the result of the expansion, the expanded
instruction will be dead and cleaned up later.

By doing the check before expanding the runtime-checks, we can save a
bit of unnecessary work.

3 years ago[LVI] Remove unnecessary lambda capture (NFC)
Nikita Popov [Sat, 29 Aug 2020 19:33:19 +0000 (21:33 +0200)]
[LVI] Remove unnecessary lambda capture (NFC)

3 years agoReapply [LVI] Normalize pointer behavior
Nikita Popov [Wed, 4 Dec 2019 19:51:31 +0000 (20:51 +0100)]
Reapply [LVI] Normalize pointer behavior

This got reverted because a dependency was reverted. It has since
been reapplied, so reapply this as well.

-----

Related to D69686. As noted there, LVI currently behaves differently
for integer and pointer values: For integers, the block value is always
valid inside the basic block, while for pointers it is only valid at
the end of the basic block. I believe the integer behavior is the
correct one, and CVP relies on it via its getConstantRange() uses.

The reason for the special pointer behavior is that LVI checks whether
a pointer is dereferenced in a given basic block and marks it as
non-null in that case. Of course, this information is valid only after
the dereferencing instruction, or in conservative approximation,
at the end of the block.

This patch changes the treatment of dereferencability: Instead of
including it inside the block value, we instead treat it as something
similar to an assume (it essentially is a non-nullness assume) and
incorporate this information in intersectAssumeOrGuardBlockValueConstantRange()
if the context instruction is the terminator of the basic block.
This happens either when determining an edge-value internally in LVI,
or when a terminator was explicitly passed to getValueAt(). The latter
case makes this more powerful than the previous implementation as
a side-effect, and this does actually seem benefitial in practice.

Of course, we do not want to recompute dereferencability on each
intersectAssume call, so we need a new cache for this. The
dereferencability analysis requires walking the entire basic block
and computing underlying objects of all memory operands. This was
previously done separately for each queried pointer value. In the
new implementation (both because this makes the caching simpler,
and because it is faster), I instead only walk the full BB once and
cache all the dereferenced pointers. So the traversal is now performed
only once per BB, instead of once per queried pointer value.

I think the overall model now makes more sense than before, and there
will be no more pitfalls due to differing integer/pointer behavior.

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

3 years ago[NFC][Local] EliminateDuplicatePHINodes(): add STATISTIC()
Roman Lebedev [Sat, 29 Aug 2020 19:02:35 +0000 (22:02 +0300)]
[NFC][Local] EliminateDuplicatePHINodes(): add STATISTIC()

3 years ago[NFCI][Local] Rewrite EliminateDuplicatePHINodes to optionally check hashing invariants
Roman Lebedev [Sat, 29 Aug 2020 17:18:25 +0000 (20:18 +0300)]
[NFCI][Local] Rewrite EliminateDuplicatePHINodes to optionally check hashing invariants

EarlyCSE has a mode to verify the invariant that hash equality equals
key equality, but EliminateDuplicatePHINodes() doesn't.

I've verified that this would have caught the stage2-stage3 mismatches
5ec2b757cc7d37ff0d03b36ee863b0962fe78108 revert has fixed,
that were introduced last time in 3e69871ab5a66fb55913a2a2f5e7f5b42899a4c9.

3 years ago[Attributor][NFC] Do not manifest noundef for positions to be changed to undef
Shinji Okumura [Sat, 29 Aug 2020 18:23:41 +0000 (03:23 +0900)]
[Attributor][NFC] Do not manifest noundef for positions to be changed to undef

This patch fixes AANoUndef manifestation.
We should not manifest noundef for positions that will be changed to undef.

Reviewed By: jdoerfert

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

3 years ago[Attributor][NFC] rerun update_test_checks without --scrub-attributes
sstefan1 [Sat, 29 Aug 2020 17:31:13 +0000 (19:31 +0200)]
[Attributor][NFC] rerun update_test_checks without --scrub-attributes

3 years ago[DSE,MemorySSA] Return early when hitting a MemoryPhi.
Florian Hahn [Mon, 24 Aug 2020 11:12:15 +0000 (12:12 +0100)]
[DSE,MemorySSA] Return early when hitting a MemoryPhi.

A MemoryPhi can never be eliminated. If we hit one, return the Phi, so
the caller can continue traversing the incoming accesses.

This saves some unnecessary read clobber checks and improves
compile-time
http://llvm-compile-time-tracker.com/compare.php?from=1ffc58b6d098ce8fa71f3a80fe75b990f633f921&to=d0fa8d1982380b57d7b6067528104bc373dbe07a&stat=instructions

3 years ago[IR] Inline AttrBuilder::addAttribute. It just sets 1 bit. NFC.
Benjamin Kramer [Sat, 29 Aug 2020 17:08:17 +0000 (19:08 +0200)]
[IR] Inline AttrBuilder::addAttribute. It just sets 1 bit. NFC.

3 years ago[Sema] Simplify ShouldDiagnoseUnusedDecl, NFC
Aaron Puchert [Sat, 29 Aug 2020 16:10:16 +0000 (18:10 +0200)]
[Sema] Simplify ShouldDiagnoseUnusedDecl, NFC

Instead of writing to a flag and then returning based on that flag we
can also return directly. The flag name also doesn't provide additional
information, it just reflects the name of the function (isReferenced).