Commit Graph

376044 Commits

Author SHA1 Message Date
Sanjay Patel c182a00095 [Analysis] fix typo in code comment; NFC 2021-01-01 12:20:16 -05:00
Alexey Bataev bf2a78fd4a [SLP]Add a test for correct use of the reordered loads, NFC. 2021-01-01 08:27:59 -08:00
Nikita Popov 26680269e0 [InstSimplify] Add tests for gep p, -p without inbounds (NFC)
This is additional test coverage for D93820.
2021-01-01 17:00:02 +01:00
Nikita Popov 14e540febc [LVI] Handle unions of conditions
LVI previously handled "if (L && R)" conditions, but not
"if (L || R)" conditions. The latter case can still produce
useful information if L and R both constrain the same variable.

This adds support for handling the "if (L || R)" case as well.
The only difference is that we take the union instead of the
intersection of the lattice values.
2021-01-01 16:46:21 +01:00
Nikita Popov 13b1c9abaf [CVP] Add tests for union of conditions (NFC)
We currently handle intersected conditions, but not unioned
conditions.
2021-01-01 16:46:21 +01:00
Paul C. Anagnostopoulos f4c39ccd22 [TableGen] Continue cleaning up .td files
This pass includes LLVM and MLIR files.

Differential Revision: https://reviews.llvm.org/D93864
2021-01-01 10:21:02 -05:00
Florian Hahn 068a23f05f
[LoopDistribute] Add tests with uncomputable BTCs. 2021-01-01 13:57:03 +00:00
Florian Hahn 890079ef18
[LoopLoadElim] Add tests with uncomputable BTCs. 2021-01-01 13:57:02 +00:00
Florian Hahn 4a17b9a39b
[LAA] Add tests with uncomputable BTCs. 2021-01-01 13:57:02 +00:00
Florian Hahn d9f306aa52
[LV] Fix crash when generating remarks with multi-exit loops.
If DoExtraAnalysis is true (e.g. because remarks are enabled), we
continue with the analysis rather than exiting. Update code to
conditionally check if the ExitBB has phis or not a single predecessor.
Otherwise a nullptr is dereferenced with DoExtraAnalysis.
2021-01-01 13:54:41 +00:00
Juneyoung Lee da1bd953fa Precommit a test for D92015 (NFC) 2021-01-01 22:35:57 +09:00
Yang Fan d5324c052b [clang-tidy][NFC] Fix a build warning due to an extra semicolon
Differential Revision: https://reviews.llvm.org/D93961
2021-01-01 16:00:20 +08:00
Yang Fan 89b0972aa2 [Sema] Fix deleted function problem in implicitly movable test
In implicitly movable test, a two-stage overload resolution is performed.
If the first overload resolution selects a deleted function, Clang directly
performs the second overload resolution, without checking whether the
deleted function matches the additional criteria.

This patch fixes the above problem.

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D92936
2021-01-01 15:47:49 +08:00
Andrew Litteken 57a46914f5 [IRSim][IROutliner] Allowing call instructions to be outlined.
We add an extra check to make sure that we do not outline calls to
indirect functions, but outline whatever the IRSimilarityIdentifier
finds with respect to calls.

Tests:
Removing test/Transforms/IROutliner/illegal-calls.ll
Adding test/Transforms/IROutliner/outlining-calls.ll
Adding test/Transforms/IROutliner/illegal-indirect-calls.ll

Excluding DebugInfo this is the last patch for the initial
implementation of the IROutliner!

Reviewers: jroelofs, paquette

Differential Revision: https://reviews.llvm.org/D87314
2020-12-31 23:01:29 -06:00
Andrew Litteken 0d21e66014 [IRSim] Letting call instructions be legal for similarity identification.
Here we let non-intrinsic calls be considered legal and valid for
similarity only if the call is not indirect, and has a name.

For two calls to be considered similar, they must have the same name,
the same function types, and the same set of parameters, including tail
calls and calling conventions.

Tests are found in unittests/Analysis/IRSimilarityIdentifierTest.cpp.

Reviewers: jroelofs, paquette

Differential Revision: https://reviews.llvm.org/D87312
2020-12-31 20:52:45 -06:00
Roman Lebedev 831636b0e6
[SimplifyCFG] SUCCESS! Teach createUnreachableSwitchDefault() to preserve DomTree
This pretty much concludes patch series for updating SimplifyCFG
to preserve DomTree. All 318 dedicated `-simplifycfg` tests now pass
with `-simplifycfg-require-and-preserve-domtree=1`.

There are a few leftovers that apparently don't have good test coverage.
I do not yet know what gaps in test coverage will the wider-scale testing
reveal, but the default flip might be close.
2021-01-01 03:25:25 +03:00
Roman Lebedev e1440d43bc
[SimplifyCFG] Teach tryToSimplifyUncondBranchWithICmpInIt() to preserve DomTree 2021-01-01 03:25:25 +03:00
Roman Lebedev 8866583953
[SimplifyCFG] Teach FoldValueComparisonIntoPredecessors() to preserve DomTree, part 2 2021-01-01 03:25:24 +03:00
Roman Lebedev a815b6b2b2
[SimplifyCFG] Teach eliminateDeadSwitchCases() to preserve DomTree, part 1 2021-01-01 03:25:24 +03:00
Roman Lebedev 0d2f219d4d
[SimplifyCFG] Teach SimplifyEqualityComparisonWithOnlyPredecessor() to preserve DomTree, part 3 2021-01-01 03:25:23 +03:00
Roman Lebedev 9f17dab1f4
[SimplifyCFG] Teach simplifyIndirectBr() to preserve DomTree 2021-01-01 03:25:23 +03:00
Roman Lebedev b7c463d7b8
[SimplifyCFG] Teach FoldBranchToCommonDest() to preserve DomTree, part 2 2021-01-01 03:25:23 +03:00
Roman Lebedev c1b825d4b8
[SimplifyCFG] Teach FoldValueComparisonIntoPredecessors() to preserve DomTree, part 1 2021-01-01 03:25:22 +03:00
Andrew Litteken b6b1006f07 [IRSim][IROutliner] Allowing GEP instructions to be outlined.
We outline what the IRSimilarityIdentifier deems GEP Instructions to be
similar.  In this case, the types must be the same, and the operand
values after the first indexing operand must be the exact same.

Tests:
Removing test/Transforms/IROutliner/illegal-gep.ll
Adding test/Transforms/IROutliner/outlining-gep.ll

Reviewers: jroelofs, paquette

Differential Revision: https://reviews.llvm.org/D87317
2020-12-31 16:54:17 -06:00
Jacques Pienaar 8d541a1fbe [mlir][shape] Add shape.lib attribute
Enable querying shape function library ops from the module. Currently
supports singular or array of them (as long as array has all unique ops
in mappings). The preferred canonical form would have one library, but
given the invariant on the mapping, this can easily be achieved by a
simple merging pass.

Preferred the attribute approach vs naming convention as these could be
added in multiple different ways.
2020-12-31 14:46:08 -08:00
Sanjay Patel eaab71106b [Analysis] reduce code for matching min/max; NFC
This might also make it easier to adapt if we want
to match min/max intrinsics rather than cmp+sel idioms.

The 'const' part is to potentially avoid confusion
in calling code. There's some surprising and possibly
wrong behavior related to matching min/max reductions
differently than other reductions.
2020-12-31 17:19:37 -05:00
Fangrui Song d1fd72343c Refactor how -fno-semantic-interposition sets dso_local on default visibility external linkage definitions
The idea is that the CC1 default for ELF should set dso_local on default
visibility external linkage definitions in the default -mrelocation-model pic
mode (-fpic/-fPIC) to match COFF/Mach-O and make output IR similar.

The refactoring is made available by 2820a2ca3a.

Currently only x86 supports local aliases. We move the decision to the driver.
There are three CC1 states:

* -fsemantic-interposition: make some linkages interposable and make default visibility external linkage definitions dso_preemptable.
* (default): selected if the target supports .Lfoo$local: make default visibility external linkage definitions dso_local
* -fhalf-no-semantic-interposition: if neither option is set or the target does not support .Lfoo$local: like -fno-semantic-interposition but local aliases are not used. So references can be interposed if not optimized out.

Add -fhalf-no-semantic-interposition to a few tests using the half-based semantic interposition behavior.
2020-12-31 13:59:45 -08:00
Fangrui Song 219d00e0d9 [test] Make ELF tests immune to dso_local/dso_preemptable/(none) differences
ELF -cc1 -mrelocation-model pic will default to no semantic interposition plus
setting dso_local on default visibility external linkage definitions, so that
COFF, Mach-O and ELF output will be similar.

This patch makes tests immune to the differences.
2020-12-31 13:59:44 -08:00
Andrew Litteken 14dc69b092 Revert "remove pessimizing moves (reported by gcc 10)"
Causing multiple different buildbots to fail with similar errors to:
http://lab.llvm.org:8011/#/builders/84/builds/3719/
http://lab.llvm.org:8011/#/builders/21/builds/5863/

This reverts commit a2513cb865.
2020-12-31 15:14:11 -06:00
Juneyoung Lee 3c60e9bac8 Add tests for D93943 (NFC) 2021-01-01 05:59:52 +09:00
Andrew Litteken d974ac0224 [IRSim] Letting gep instructions be legal for similarity identification.
GetElementPtr instructions require the extra check that all operands
after the first must only be constants and be exactly the same to be
considered similar.

Tests are found in unittests/Analysis/IRSimilarityIdentifierTest.cpp.
2020-12-31 14:41:14 -06:00
Nuno Lopes a2513cb865 remove pessimizing moves (reported by gcc 10) 2020-12-31 20:35:56 +00:00
Juneyoung Lee 5cdf6ed744 [CodeGen] recognize select form of and/ors when splitting branch conditions
Recently a few patches are made to move towards using select i1 instead of and/or i1 to represent "a && b"/"a || b" in C/C++.
"a && b" in C/C++ does not evaluate b if a is false whereas 'and a, b' in IR evaluates b and uses its result regardless of the result of a.
This is problematic because it can cause miscompilation if b was an erroneous operation (https://llvm.org/pr48353).
In C/C++, the result is simply false because b is not evaluated, but in IR the result is poison.
The discussion at D93065 has more context about this.

This patch makes two branch-splitting optimizations (one in SelectionDAGBuilder, one in CodeGenPrepare) recognize
select form of and/or as well using m_LogicalAnd/Or.
Since it is CodeGen, I think this is semantically ok (at least as safe as what codegen already did).

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D93853
2021-01-01 04:46:10 +09:00
Juneyoung Lee 509fa8e02e [SCEV] recognize logical and/or pattern
This patch makes SCEV recognize 'select A, B, false' and 'select A, true, B'.
This is a performance improvement that will be helpful after unsound select -> and/or transformation is removed, as discussed in D93065.

SCEV's answers for the select form should be a bit more conservative than the equivalent `and A, B` / `or A, B`.
Take this example: https://alive2.llvm.org/ce/z/NsP9ue .
To check whether it is valid for SCEV's computeExitLimit to return min(n, m) as ExactNotTaken value, I put llvm.assume at tgt.
It fails because the exit limit becomes poison if n is zero and m is poison. This is problematic if e.g. the exit value of i is replaced with min(n, m).
If either n or m is constant, we can revive the analysis again. I added relevant tests and put alive2 links there.

If and is used instead, this is okay: https://alive2.llvm.org/ce/z/K9rbJk . Hence the existing analysis is sound.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D93882
2021-01-01 04:37:57 +09:00
Atmn 1a65b8c739 [Clang][Misc] Change run line in fragile test
This test has %clang in the run line when it should have %clang_cc1.
This should prevent future release test failures.

Differential Revision: https://reviews.llvm.org/D93952
2020-12-31 13:48:21 -05:00
Andrew Litteken 1a9eb19af9 [IROutliner] Adding consistent function attribute merging
When combining extracted functions, they may have different function
attributes. We want to make sure that we do not make any assumptions,
or lose any information. This attempts to make sure that we consolidate
function attributes to their most general case.

Tests:
llvm/test/Transforms/IROutliner/outlining-compatible-and-attribute-transfer.ll
llvm/test/Transforms/IROutliner/outlining-compatible-or-attribute-transfer.ll

Reviewers: jdoefert, paquette

Differential Revision: https://reviews.llvm.org/D87301
2020-12-31 12:30:23 -06:00
Fangrui Song a90b42b0fe [ThinLTO] Default -enable-import-metadata to false
The default value is dependent on `-DLLVM_ENABLE_ASSERTIONS={off,on}` (D22167), which is
error-prone. The few tests checking `!thinlto_src_module` can specify -enable-import-metadata explicitly.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D93959
2020-12-31 10:04:21 -08:00
Kazu Hirata b557c32ae9 [MemorySSA, BPF] Use isa instead of dyn_cast (NFC) 2020-12-31 09:39:13 -08:00
Kazu Hirata 7bc76fd0ec [CodeGen] Construct SmallVector with iterator ranges (NFC) 2020-12-31 09:39:11 -08:00
Kazu Hirata f904b46b1a [llvm-objcopy] Use llvm::erase_if (NFC) 2020-12-31 09:39:09 -08:00
Fangrui Song 728f99fa0b [ThinLTO][test] Specify -enable-import-metadata to make !thinlto_src_module available in -DLLVM_ENABLE_ASSERTIONS=off mode 2020-12-31 09:31:53 -08:00
Fangrui Song d7154bbf92 [ThinLTO][test] Add visibility related tests
Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D92899
2020-12-31 09:16:35 -08:00
Dávid Bolvanský ae69fa9b9f [InstCombine] Transform (A + B) - (A & B) to A | B (PR48604)
define i32 @src(i32 %x, i32 %y) {
%0:
  %a = add i32 %x, %y
  %o = and i32 %x, %y
  %r = sub i32 %a, %o
  ret i32 %r
}
=>
define i32 @tgt(i32 %x, i32 %y) {
%0:
  %b = or i32 %x, %y
  ret i32 %b
}
Transformation seems to be correct!

https://alive2.llvm.org/ce/z/2fhW6r
2020-12-31 15:04:32 +01:00
Dávid Bolvanský c1937c2af2 [NFC] Added/adjusted tests for PR48604; second pattern 2020-12-31 14:59:15 +01:00
Dávid Bolvanský 742ea77ca4 [InstCombine] Transform (A + B) - (A | B) to A & B (PR48604)
define i32 @src(i32 %x, i32 %y) {
%0:
  %a = add i32 %x, %y
  %o = or i32 %x, %y
  %r = sub i32 %a, %o
  ret i32 %r
}
=>
define i32 @tgt(i32 %x, i32 %y) {
%0:
  %b = and i32 %x, %y
  ret i32 %b
}
Transformation seems to be correct!

https://alive2.llvm.org/ce/z/aQRh2j
2020-12-31 14:03:20 +01:00
Dávid Bolvanský 9b64939463 [NFC] Added tests for PR48604 2020-12-31 14:03:20 +01:00
Bogdan Graur 8bee4d4e8f Revert "[LoopDeletion] Allows deletion of possibly infinite side-effect free loops"
Test clang/test/Misc/loop-opt-setup.c fails when executed in Release.

This reverts commit 6f1503d598.

Reviewed By: SureYeaah

Differential Revision: https://reviews.llvm.org/D93956
2020-12-31 11:47:49 +00:00
Bogdan Graur be764065be Revert "[ThinLTO][test] Add visibility related tests"
Both newly added tests fail in Release.

This reverts commit 52aa4e2107.

Reviewed By: SureYeaah

Differential Revision: https://reviews.llvm.org/D93957
2020-12-31 11:42:58 +00:00
Nuno Lopes f760d57052 LangRef: fix significand bits of fp128 2020-12-31 11:13:25 +00:00
Fangrui Song 52d7e183bf [sanitizer] Include fstab.h on glibc/FreeBSD/NetBSD/macOS 2020-12-31 00:55:58 -08:00