Commit Graph

377263 Commits

Author SHA1 Message Date
Sanjay Patel 48dbac5b6b [SLP] remove unnecessary use of 'OperationData'
This is another NFC-intended patch to allow matching
intrinsics (example: maxnum) as candidates for reductions.

It's possible that the loop/if logic can be reduced now,
but it's still difficult to understand how this all works.
2021-01-16 13:55:52 -05:00
Dávid Bolvanský 63bedc80da [InstSimplify] Handle commutativity for 'and' and 'outer or' for (~A & B) | ~(A | B) --> ~A
Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D94870
2021-01-16 19:42:50 +01:00
David Green 372eb2bbb6 [ARM] Add low overhead loops terminators to AnalyzeBranch
This treats low overhead loop branches the same as jump tables and
indirect branches in analyzeBranch - they cannot be analyzed but the
direct branches on the end of the block may be removed. This helps
remove the unnecessary branches earlier, which can help produce better
codegen (and change block layout in a number of cases).

Differential Revision: https://reviews.llvm.org/D94392
2021-01-16 18:30:21 +00:00
David Green c1ab698dce [ARM] Remove LLC tests from transform/hardware loop tests.
We now have a lot of llc tests for hardware loops in CodeGen, which test
a larger variety of loops and are easier to maintain. This removes the
llc from mixed llc/opt tests.
2021-01-16 18:30:21 +00:00
Dávid Bolvanský 416854d0f7 [InstSimplify] Precommit new testcases; NFC 2021-01-16 19:11:58 +01:00
Kazu Hirata 2082b10d10 [llvm] Use *::empty (NFC) 2021-01-16 09:40:55 -08:00
Kazu Hirata 19aacdb715 [llvm] Construct SmallVector with iterator ranges (NFC) 2021-01-16 09:40:53 -08:00
Kazu Hirata ba0fc7e1f8 [StringExtras] Fix comment typos (NFC) 2021-01-16 09:40:51 -08:00
Florian Hahn bca16e2fbb
[LTO] Remove options to disable inlining, vectorization & GVNLoadPRE.
This patch removes some ancient options as a clean-up before moving
code-gen to use LTOBackend in D94487.

I think it would preferable to remove those ancient options, because

  1. There are no corresponding options in LTOBackend based tools,
  2. There are no unit tests for them,
  3. They are not passed through by Clang,
  4. At least for GNVLoadPRE, users could just use GVN's `enable-load-pre`.

Alternatively we could add support for those options to lto::Config &
co, but I think it would be better to remove them, unless they are
actually used in practice.

Reviewed By: steven_wu, tejohnson

Differential Revision: https://reviews.llvm.org/D94783
2021-01-16 16:29:15 +00:00
Dávid Bolvanský bdd4dda58b [InstSimplify] Update comments, remove redundant tests 2021-01-16 16:31:23 +01:00
Hsiangkai Wang 098dbf190a [RISCV] Correct alignment settings for vector registers.
According to "9. Vector Memory Alignment Constraints" in V
specification, the alignment of vector memory access is aligned to the
size of the element. In our current implementation, we support ELEN up
to 64. We could assume the alignment of vector registers is 64 under the
assumption.

Differential Revision: https://reviews.llvm.org/D94751
2021-01-16 23:21:29 +08:00
Dávid Bolvanský a4e2a5145a [InstSimplify] Add (~A & B) | ~(A | B) --> ~A 2021-01-16 15:43:34 +01:00
Dávid Bolvanský 9fc814ed59 [Tests] Added tests for new instcombine or simplification; NFC 2021-01-16 15:43:33 +01:00
James Player 25c1578a46 Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable
Current code breaks this version of MSVC due to a mismatch between `std::is_trivially_copyable` and `llvm::is_trivially_copyable` for `std::pair` instantiations.  Hence I was attempting to use `std::is_trivially_copyable` to set `llvm::is_trivially_copyable<T>::value`.

I spent some time root causing an `llvm::Optional` build error on MSVC 16.8.3 related to the change described above:

```
62>C:\src\ocg_llvm\llvm-project\llvm\include\llvm/ADT/BreadthFirstIterator.h(96,12): error C2280: 'llvm::Optional<std::pair<std::pair<unsigned int,llvm::Graph<4>::NodeSubset> *,llvm::Optional<llvm::Graph<4>::ChildIterator>>> &llvm::Optional<std::pair<std::pair<unsigned int,llvm::Graph<4>::NodeSubset> *,llvm::Optional<llvm::Graph<4>::ChildIterator>>>::operator =(const llvm::Optional<std::pair<std::pair<unsigned int,llvm::Graph<4>::NodeSubset> *,llvm::Optional<llvm::Graph<4>::ChildIterator>>> &)': attempting to reference a deleted function (compiling source file C:\src\ocg_llvm\llvm-project\llvm\unittests\ADT\BreadthFirstIteratorTest.cpp)
...
```
The "trivial" specialization of `optional_detail::OptionalStorage` assumes that the value type is trivially copy constructible and trivially copy assignable. The specialization is invoked based on a check of `is_trivially_copyable` alone, which does not imply both `is_trivially_copy_assignable` and `is_trivially_copy_constructible` are true.

[[ https://en.cppreference.com/w/cpp/named_req/TriviallyCopyable | According to the spec ]], a deleted assignment operator does not make `is_trivially_copyable` false. So I think all these properties need to be checked explicitly in order to specialize `OptionalStorage` to the "trivial" version:
```
/// Storage for any type.
template <typename T, bool = std::is_trivially_copy_constructible<T>::value
                          && std::is_trivially_copy_assignable<T>::value>
class OptionalStorage {
```
Above fixed my build break in MSVC, but I think we need to explicitly check `is_trivially_copy_constructible` too since it might be possible the copy constructor is deleted.  Also would be ideal to move over to `std::is_trivially_copyable` instead of the `llvm` namespace verson.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D93510
2021-01-16 09:37:04 -05:00
Stephen Kelly b765eaf9a6 [ASTMatchers] Add support for CXXRewrittenBinaryOperator
Differential Revision: https://reviews.llvm.org/D94130
2021-01-16 13:44:22 +00:00
Stephen Kelly e810e95e4b [ASTMatchers] Add binaryOperation matcher
This is a simple utility which allows matching on binaryOperator and
cxxOperatorCallExpr. It can also be extended to support
cxxRewrittenBinaryOperator.

Add generic support for MapAnyOfMatchers to auto-marshalling functions.

Differential Revision: https://reviews.llvm.org/D94129
2021-01-16 13:44:09 +00:00
Bjorn Pettersson 4f15556731 [LegalizeDAG] Handle NeedInvert when expanding BR_CC
This is a follow-up fix to commit 03c8d6a0c4.
Seems like we now end up with NeedInvert being set in the result
from LegalizeSetCCCondCode more often than in the past, so we
need to handle NeedInvert when expanding BR_CC.

Not sure how to deal with the "Tmp4.getNode()" case properly,
but current assumption is that that code path isn't impacted
by the changes in 03c8d6a0c4 so we can simply move
the old assert into the if-branch and only handle NeedInvert in the
else-branch.

I think that the test case added here, for PowerPC, might have
failed also before commit 03c8d6a0c4. But we started
to hit the assert more often downstream when having merged that
commit.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D94762
2021-01-16 14:33:19 +01:00
Stephen Kelly dbe056c2e3 [ASTMatchers] Make cxxOperatorCallExpr matchers API-compatible with n-ary operators
This makes them composable with mapAnyOf().

Differential Revision: https://reviews.llvm.org/D94128
2021-01-16 12:53:11 +00:00
Stephen Kelly a7101450a4 [ASTMatchers] Add mapAnyOf matcher
Make it possible to compose a matcher for different base nodes.

This accepts one or more node matcher functors and zero or more
matchers, composing the latter into the former.

This allows composing of matchers where the same inner matcher name is
used for the same concept, but with a different node functor. Currently,
there is a limitation that the nodes must be in the same "clade", so
while

  mapAnyOf(ifStmt, forStmt).with(hasBody(stmt()))

can be used, functionDecl can not be added to the tuple.

It is possible to use this in clang-query, but it will require changes
to the QueryParser, so is deferred to a future review.

Differential Revision: https://reviews.llvm.org/D94127
2021-01-16 12:53:11 +00:00
Nikita Popov f0a0ec2d08 [InstCombine] Add more tests for select operand replacement (NFC) 2021-01-16 13:10:59 +01:00
Juneyoung Lee e0a979ccad [InstCombine] Add more tests to select-safe-transforms.ll (NFC) 2021-01-16 19:49:12 +09:00
Juneyoung Lee b664bef2ad [InstCombine] Add a test file that contains safe select transforms (NFC) 2021-01-16 19:27:43 +09:00
Jeroen Dobbelaere 668827b648 Introduce llvm.noalias.decl intrinsic
The ``llvm.experimental.noalias.scope.decl`` intrinsic identifies where a noalias
scope is declared. When the intrinsic is duplicated, a decision must
also be made about the scope: depending on the reason of the duplication,
the scope might need to be duplicated as well.

Reviewed By: nikic, jdoerfert

Differential Revision: https://reviews.llvm.org/D93039
2021-01-16 09:20:45 +01:00
Amara Emerson 8456c3a789 AArch64: fix regression introduced by fcmp immediate selection.
Forgot to check if the predicate is safe to commutate operands.
2021-01-15 22:53:25 -08:00
Mircea Trofin a61e42efbb [NPM][Inliner] Temporarily remove inline_stats test case for always
inline

The stats are printed at InlinePass destruction. When we have 2 of them,
it appears the destruction order of the Passes std::vector of the pass
manager differs in msan builds - example:
http://lab.llvm.org:8011/#/builders/74/builds/2135.

This reproes locally, too.

Temporarily removing the sub-test case, to green the build, and will
follow up with a stat dumping alternative that does not depend on vector
element dtor order.
2021-01-15 21:59:35 -08:00
Douglas Yung be68c9222b [NFC] Add -std=c11 to attr-availability.c
This test will fail with any toolchains that don't default to C11.

Adding this switch to the clang invocation in the test fixes the issue.

Patch by Justice Adams!

Reviewed By: dyung

Differential Revision: https://reviews.llvm.org/D94829
2021-01-15 21:05:49 -08:00
Kazu Hirata 8fd8ff1f67 [StringExtras] Rename SubsequentDelim to ListSeparator
This patch renames SubsequentDelim to ListSeparator to clarify the
purpose of the class.

Differential Revision: https://reviews.llvm.org/D94649
2021-01-15 21:00:56 -08:00
Kazu Hirata 4707b21298 [AMDGPU] Use llvm::is_contained (NFC) 2021-01-15 21:00:54 -08:00
Kazu Hirata a396e2e088 [utils] Use llvm::sort (NFC) 2021-01-15 21:00:52 -08:00
Mircea Trofin 029c2257c2 [Inline] Fix a missing character in inline_stats.ll 2021-01-15 20:28:15 -08:00
Mircea Trofin e8049dc3c8 [NewPM][Inliner] Move the 'always inliner' case in the same CGSCC pass as 'regular' inliner
Expanding from D94808 - we ensure the same InlineAdvisor is used by both
InlinerPass instances. The notion of mandatory inlining is moved into
the core InlineAdvisor: advisors anyway have to handle that case, so
this change also factors out that a bit better.

Differential Revision: https://reviews.llvm.org/D94825
2021-01-15 17:59:38 -08:00
Jonas Devlieghere 999f5da6b3 [debugserver] Fix inverted if block that resulted in us using the private entitlements 2021-01-15 17:41:07 -08:00
Thomas Raoux fd2083d73c [mlir] Fixing potential build break in my previous commit 2021-01-15 17:38:16 -08:00
River Riddle 2a27a9819a [mlir][AsmPrinter] Properly escape strings when printing locations
This fixes errors when location strings contains newlines, or other non-ascii characters.

Differential Revision: https://reviews.llvm.org/D94847
2021-01-15 17:14:57 -08:00
Thomas Raoux 3afbfb4145 [mlir][NFC] Move helper substWithMin into Affine utils
This allow using this helper outside of the linalg canonicalization.

Differential Revision: https://reviews.llvm.org/D94826
2021-01-15 17:13:56 -08:00
peter klausler 1bd083b5d6 [flang] Create names to allow access to inaccessible specifics
When a reference to a generic interface occurs in a specification
expression that must be emitted to a module file, we have a problem
when the generic resolves to a function whose name is inaccessible
due to being PRIVATE or due to a conflict with another use of the
same name in the scope.  In these cases, construct a new name for
the specific procedure and emit a renaming USE to the module file.
Also, relax enforcement of PRIVATE when analyzing module files.

Differential Revision: https://reviews.llvm.org/D94815
2021-01-15 16:56:38 -08:00
Mircea Trofin aa3d4d9939 [NFC] Disallow unused prefixes under MC/RISCV
Differential Revision: https://reviews.llvm.org/D94836
2021-01-15 16:21:30 -08:00
Peter Collingbourne d302398ff0 hwasan: Update register-dump-read.c test to reserve x23 instead of x20.
D90422 changed this test to write a fixed value into register x23
instead of x20, but it did not update the list of reserved registers.
This meant that x23 may have been live across the register write,
although this happens to not be the case with the current compiler.
Fix the problem by updating the reserved register list.
2021-01-15 16:14:36 -08:00
Derek Schuff 187d771d27 Revert "[WebAssembly] Add support for table linking to wasm-ld"
This reverts commit 38dfce706f.
CI discovered a bug where the table is exported twice: see
D91870
2021-01-15 15:50:41 -08:00
Derek Schuff e65b9b04cd Revert "[WebAssembly] MC layer writes table symbols to object files"
This reverts commit e9f1ed2306.

Reverting because it depends on 38dfce706f
2021-01-15 15:50:22 -08:00
Dávid Bolvanský a1500105ee [SimplifyCFG] Optimize CFG when null is passed to a function with nonnull argument
Example:

```
__attribute__((nonnull,noinline)) char * pinc(char *p)  {
  return ++p;
}

char * foo(bool b, char *a) {
       return pinc(b ? 0 : a);

}
```

optimize to

```
char * foo(bool b, char *a) {
       return pinc(a);

}
```

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D94180
2021-01-15 23:53:43 +01:00
Vladislav Vinogradov 76f5c5a7b0 [ADT][Support] Fix C4146 error from MSVC
Unary minus operator applied to unsigned type, result still unsigned.

Use `~0U` instead of `-1U` and `1 + ~VAL` instead of `-VAL`.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D94417
2021-01-15 14:34:14 -08:00
Amara Emerson aa8a2d8a3d [AArch64][GlobalISel] Select immediate fcmp if the zero is on the LHS. 2021-01-15 14:31:39 -08:00
Duncan P. N. Exon Smith ceaf0110ff Revert "Revert "ADT: Fix reference invalidation in SmallVector...""
This reverts commit 33be50daa9,
effectively reapplying:

- 260a856c2a
- 3043e5a5c3
- 49142991a6

... with a fix to skip a call to `SmallVector::isReferenceToStorage()`
when we know the parameter had been taken by value for small, POD-like
`T`. See https://reviews.llvm.org/D93779 for the discussion on the
revert.

At a high-level, these commits fix reference invalidation in
SmallVector's push_back, append, insert (one or N), and resize
operations. For more details, please see the original commit messages.

This commit fixes a bug that crept into
`SmallVectorTemplateCommon::reserveForAndGetAddress()` during the review
process after performance analysis was done. That function is now called
`reserveForParamAndGetAddress()`, clarifying that it only works for
parameter values. It uses that knowledge to bypass
`SmallVector::isReferenceToStorage()` when `TakesParamByValue`. This is
`constexpr` and avoids adding overhead for "small enough", trivially
copyable `T`.

Performance could potentially be tuned further by increasing the
threshold for `TakesParamByValue`, which is currently defined as:
```
bool TakesParamByValue = sizeof(T) <= 2 * sizeof(void *);
```
in the POD-like version of SmallVectorTemplateBase (else, `false`).

Differential Revision: https://reviews.llvm.org/D94800
2021-01-15 14:27:48 -08:00
Sanjay Patel ceb3cdccd0 [SLP] remove dead code in reduction matching; NFC
To get into this block we had: !A || B || C
and we checked C in the first 'if' clause
leaving !A || B. But the 2nd 'if' is checking:
A && !B --> !(!A || B)
2021-01-15 17:03:26 -05:00
Jason Molenda 10ac9b29a4 Skip 'g' packet tests when running on darwin; debugserver doesn't impl
Differential Revision: https://reviews.llvm.org/D94754
2021-01-15 13:57:59 -08:00
MaheshRavishankar d7bc3b7ce2 [mlir][Linalg] Add missing check to canonicalization of GenericOp that are identity ops.
The operantion is an identity if the values yielded by the operation
is the argument of the basic block of that operation. Add this missing check.

Differential Revision: https://reviews.llvm.org/D94819
2021-01-15 13:55:35 -08:00
Nick Desaulniers ed0fd567eb BreakCriticalEdges: do not split the critical edge from a CallBr indirect successor
Otherwise we'll fail the assertion in SplitBlockPredecessors() related
to splitting the edges from CallBr's.

Fixes: https://github.com/ClangBuiltLinux/linux/issues/1161
Fixes: https://github.com/ClangBuiltLinux/linux/issues/1252

Reviewed By: void, MaskRay, jyknight

Differential Revision: https://reviews.llvm.org/D88438
2021-01-15 13:51:47 -08:00
Christopher Di Bella 4a47da2cf4 [Sema] turns -Wfree-nonheap-object on by default
We'd discussed adding the warning to -Wall in D89988. This patch honours that.
2021-01-15 21:38:47 +00:00
Reid Kleckner 98c89ccfbd [MSVC] Don't add -nostdinc++ -isystem to runtimes builds
If the host compiler is MSVC or clang-cl, then the compiler used to
buidl the runtimes will be clang-cl, and it doesn't support either of
those flags.

Worse, because -isystem is a space separated flag, it causes all cmake
try_compile tests to fail, so none of the -Wno-* flags make it to the
compiler in libcxx. I noticed that we weren't passing
-Wno-user-defined-literals to clang-cl and were getting warnings in the
build, and this fixes that for me.

Differential Revision: https://reviews.llvm.org/D94817
2021-01-15 13:22:07 -08:00