platform/upstream/llvm.git
3 years ago[MLIR] Fix affine_map compose with multi-symbols
Chengji Yao [Sat, 2 Jan 2021 01:25:40 +0000 (06:55 +0530)]
[MLIR] Fix affine_map compose with multi-symbols

Fix bug: https://bugs.llvm.org/show_bug.cgi?id=46845

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

3 years ago[NFC][RISCV] Move vmsge{u}.vx processing to RISCVAsmParser.
Hsiangkai Wang [Fri, 1 Jan 2021 16:29:40 +0000 (00:29 +0800)]
[NFC][RISCV] Move vmsge{u}.vx processing to RISCVAsmParser.

We could expand vmsge{u}.vx pseudo instructions in RISCVAsmParser.
It is more appropriate to expand it before encoding.

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

3 years ago[sanitizer] Enable mallopt and mallinfo interceptors on Android after D93848
Fangrui Song [Fri, 1 Jan 2021 22:43:08 +0000 (14:43 -0800)]
[sanitizer] Enable mallopt and mallinfo interceptors on Android after D93848

Reviewed By: aeubanks

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

3 years ago[compiler-rt][test] Suppress stderr of ldd output
Fangrui Song [Fri, 1 Jan 2021 22:09:13 +0000 (14:09 -0800)]
[compiler-rt][test] Suppress stderr of ldd output

3 years ago[AMDGPU][SimplifyCFG] Teach AMDGPUUnifyDivergentExitNodes to preserve {,Post}DomTree
Roman Lebedev [Fri, 1 Jan 2021 20:18:35 +0000 (23:18 +0300)]
[AMDGPU][SimplifyCFG] Teach AMDGPUUnifyDivergentExitNodes to preserve {,Post}DomTree

This is a (last big?) part of the patch series to make SimplifyCFG
preserve DomTree. Currently, it still does not actually preserve it,
even thought it is pretty much fully updated to preserve it.

Once the default is flipped, a valid DomTree must be passed into
simplifyCFG, which means that whatever pass calls simplifyCFG,
should also be smart about DomTree's.

As far as i can see from `check-llvm` with default flipped,
this is the last LLVM test batch (other than bugpoint tests)
that needed fixes to not break with default flipped.

The changes here are boringly identical to the ones i did
over 42+ times/commits recently already,
so while AMDGPU is outside of my normal ecosystem,
i'm going to go for post-commit review here,
like in all the other 42+ changes.

Note that while the pass is taught to preserve {,Post}DomTree,
it still doesn't do that by default, because simplifycfg
still doesn't do that by default, and flipping default
in this pass will implicitly flip the default for simplifycfg.
That will happen, but not right now.

3 years ago[SimplifyCFG] Teach removeUndefIntroducingPredecessor to preserve DomTree
Roman Lebedev [Fri, 1 Jan 2021 18:58:12 +0000 (21:58 +0300)]
[SimplifyCFG] Teach removeUndefIntroducingPredecessor to preserve DomTree

3 years ago[CodeGen][SimplifyCFG] Teach DwarfEHPrepare to preserve DomTree
Roman Lebedev [Fri, 1 Jan 2021 17:27:09 +0000 (20:27 +0300)]
[CodeGen][SimplifyCFG] Teach DwarfEHPrepare to preserve DomTree

Once the default for SimplifyCFG flips, we can no longer pass nullptr
instead of DomTree to SimplifyCFG, so we need to propagate it here.

We don't strictly need to actually preserve DomTree in DwarfEHPrepare,
but we might as well do it, since it's trivial.

3 years ago[NFC][CodeGen][Tests] Mark all tests that fail to preserve DomTree for SimplifyCFG...
Roman Lebedev [Fri, 1 Jan 2021 18:15:07 +0000 (21:15 +0300)]
[NFC][CodeGen][Tests] Mark all tests that fail to preserve DomTree for SimplifyCFG as such

These tests start to fail when the SimplifyCFG's default regarding DomTree
updating is switched on, so mark them as needing changes.

3 years ago[NFC][CodeGen] Split DwarfEHPrepare pass into an actual transform and an legacy-PM...
Roman Lebedev [Fri, 1 Jan 2021 16:06:44 +0000 (19:06 +0300)]
[NFC][CodeGen] Split DwarfEHPrepare pass into an actual transform and an legacy-PM wrapper

This is consistent with the layout of other passes,
and simplifies further refinements regarding DomTree handling.

This is indended to be a NFC commit.

3 years ago[NFC] clang-format the entire DwarfEHPrepare.cpp
Roman Lebedev [Fri, 1 Jan 2021 14:57:14 +0000 (17:57 +0300)]
[NFC] clang-format the entire DwarfEHPrepare.cpp

3 years ago[Utils] LocalTest: fix SimplifyCFGWithNullAC test to work with `-simplifycfg-require...
Roman Lebedev [Fri, 1 Jan 2021 21:20:50 +0000 (00:20 +0300)]
[Utils] LocalTest: fix SimplifyCFGWithNullAC test to work with `-simplifycfg-require-and-preserve-domtree=1`

3 years ago[IR] PassManagerTest: Register DominatorTreeAnalysis before running SimplifyCFGPass
Roman Lebedev [Fri, 1 Jan 2021 14:06:56 +0000 (17:06 +0300)]
[IR] PassManagerTest: Register DominatorTreeAnalysis before running SimplifyCFGPass

Otherwise these particular tests fail when SimplifyCFG requires DomTree

3 years ago[SimplifyCFG] Teach eliminateDeadSwitchCases() to preserve DomTree, part 2
Roman Lebedev [Fri, 1 Jan 2021 13:37:55 +0000 (16:37 +0300)]
[SimplifyCFG] Teach eliminateDeadSwitchCases() to preserve DomTree, part 2

3 years ago[SimplifyCFG] Teach tryWidenCondBranchToCondBranch() to preserve DomTree
Roman Lebedev [Fri, 1 Jan 2021 13:33:19 +0000 (16:33 +0300)]
[SimplifyCFG] Teach tryWidenCondBranchToCondBranch() to preserve DomTree

3 years ago[SimplifyCFGPass] Ensure that DominatorTreeWrapperPass is init'd before SimplifyCFG
Roman Lebedev [Fri, 1 Jan 2021 13:31:11 +0000 (16:31 +0300)]
[SimplifyCFGPass] Ensure that DominatorTreeWrapperPass is init'd before SimplifyCFG

It's probably better than hoping that it will happen to be
already initialized.

3 years ago[llvm] Use isa instead of dyn_cast (NFC)
Kazu Hirata [Fri, 1 Jan 2021 20:44:56 +0000 (12:44 -0800)]
[llvm] Use isa instead of dyn_cast (NFC)

3 years ago[llvm] Use *Map::lookup (NFC)
Kazu Hirata [Fri, 1 Jan 2021 20:44:54 +0000 (12:44 -0800)]
[llvm] Use *Map::lookup (NFC)

3 years ago[SSAUpdater] Remove unused code InstrIsPHI (NFC)
Kazu Hirata [Fri, 1 Jan 2021 20:44:52 +0000 (12:44 -0800)]
[SSAUpdater] Remove unused code InstrIsPHI (NFC)

The last use of this function was removed on Jan 4, 2018 in commit
commit 90ecac01e9dcbcaf92781a6dcffa07a27191b661.

3 years agotest/OpenMP/parallel_codegen.cpp: Allow multiple result attributes
Fangrui Song [Fri, 1 Jan 2021 18:46:34 +0000 (10:46 -0800)]
test/OpenMP/parallel_codegen.cpp: Allow multiple result attributes

On many targets the matched line is `define dso_local i32 @main` while
on ppc64 it is `define dso_local signext i32 @main`.

3 years ago[Analysis] flatten enums for recurrence types
Sanjay Patel [Fri, 1 Jan 2021 17:09:02 +0000 (12:09 -0500)]
[Analysis] flatten enums for recurrence types

This is almost all mechanical search-and-replace and
no-functional-change-intended (NFC). Having a single
enum makes it easier to match/reason about the
reduction cases.

The goal is to remove `Opcode` from reduction matching
code in the vectorizers because that makes it harder to
adapt the code to handle intrinsics.

The code in RecurrenceDescriptor::AddReductionVar() is
the only place that required closer inspection. It uses
a RecurrenceDescriptor and a second InstDesc to sometimes
overwrite part of the struct. It seem like we should be
able to simplify that logic, but it's not clear exactly
which cmp+sel patterns that we are trying to handle/avoid.

3 years ago[Analysis] fix typo in code comment; NFC
Sanjay Patel [Fri, 1 Jan 2021 14:52:44 +0000 (09:52 -0500)]
[Analysis] fix typo in code comment; NFC

3 years ago[SLP]Add a test for correct use of the reordered loads, NFC.
Alexey Bataev [Fri, 1 Jan 2021 16:27:23 +0000 (08:27 -0800)]
[SLP]Add a test for correct use of the reordered loads, NFC.

3 years ago[InstSimplify] Add tests for gep p, -p without inbounds (NFC)
Nikita Popov [Fri, 1 Jan 2021 16:00:02 +0000 (17:00 +0100)]
[InstSimplify] Add tests for gep p, -p without inbounds (NFC)

This is additional test coverage for D93820.

3 years ago[LVI] Handle unions of conditions
Nikita Popov [Fri, 1 Jan 2021 15:32:19 +0000 (16:32 +0100)]
[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.

3 years ago[CVP] Add tests for union of conditions (NFC)
Nikita Popov [Fri, 1 Jan 2021 15:12:44 +0000 (16:12 +0100)]
[CVP] Add tests for union of conditions (NFC)

We currently handle intersected conditions, but not unioned
conditions.

3 years ago[TableGen] Continue cleaning up .td files
Paul C. Anagnostopoulos [Fri, 25 Dec 2020 00:02:52 +0000 (19:02 -0500)]
[TableGen] Continue cleaning up .td files

This pass includes LLVM and MLIR files.

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

3 years ago[LoopDistribute] Add tests with uncomputable BTCs.
Florian Hahn [Fri, 1 Jan 2021 13:31:59 +0000 (13:31 +0000)]
[LoopDistribute] Add tests with uncomputable BTCs.

3 years ago[LoopLoadElim] Add tests with uncomputable BTCs.
Florian Hahn [Fri, 1 Jan 2021 13:31:23 +0000 (13:31 +0000)]
[LoopLoadElim] Add tests with uncomputable BTCs.

3 years ago[LAA] Add tests with uncomputable BTCs.
Florian Hahn [Thu, 31 Dec 2020 12:40:48 +0000 (12:40 +0000)]
[LAA] Add tests with uncomputable BTCs.

3 years ago[LV] Fix crash when generating remarks with multi-exit loops.
Florian Hahn [Wed, 30 Dec 2020 16:14:40 +0000 (16:14 +0000)]
[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.

3 years agoPrecommit a test for D92015 (NFC)
Juneyoung Lee [Fri, 1 Jan 2021 13:35:57 +0000 (22:35 +0900)]
Precommit a test for D92015 (NFC)

3 years ago[clang-tidy][NFC] Fix a build warning due to an extra semicolon
Yang Fan [Fri, 1 Jan 2021 06:16:12 +0000 (14:16 +0800)]
[clang-tidy][NFC] Fix a build warning due to an extra semicolon

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

3 years ago[Sema] Fix deleted function problem in implicitly movable test
Yang Fan [Fri, 1 Jan 2021 05:30:36 +0000 (13:30 +0800)]
[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

3 years ago[IRSim][IROutliner] Allowing call instructions to be outlined.
Andrew Litteken [Tue, 8 Sep 2020 18:42:56 +0000 (13:42 -0500)]
[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

3 years ago[IRSim] Letting call instructions be legal for similarity identification.
Andrew Litteken [Wed, 16 Sep 2020 03:25:05 +0000 (22:25 -0500)]
[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

3 years ago[SimplifyCFG] SUCCESS! Teach createUnreachableSwitchDefault() to preserve DomTree
Roman Lebedev [Fri, 1 Jan 2021 00:19:17 +0000 (03:19 +0300)]
[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.

3 years ago[SimplifyCFG] Teach tryToSimplifyUncondBranchWithICmpInIt() to preserve DomTree
Roman Lebedev [Thu, 31 Dec 2020 23:44:17 +0000 (02:44 +0300)]
[SimplifyCFG] Teach tryToSimplifyUncondBranchWithICmpInIt() to preserve DomTree

3 years ago[SimplifyCFG] Teach FoldValueComparisonIntoPredecessors() to preserve DomTree, part 2
Roman Lebedev [Thu, 31 Dec 2020 23:21:53 +0000 (02:21 +0300)]
[SimplifyCFG] Teach FoldValueComparisonIntoPredecessors() to preserve DomTree, part 2

3 years ago[SimplifyCFG] Teach eliminateDeadSwitchCases() to preserve DomTree, part 1
Roman Lebedev [Thu, 31 Dec 2020 22:02:06 +0000 (01:02 +0300)]
[SimplifyCFG] Teach eliminateDeadSwitchCases() to preserve DomTree, part 1

3 years ago[SimplifyCFG] Teach SimplifyEqualityComparisonWithOnlyPredecessor() to preserve DomTr...
Roman Lebedev [Thu, 31 Dec 2020 21:13:48 +0000 (00:13 +0300)]
[SimplifyCFG] Teach SimplifyEqualityComparisonWithOnlyPredecessor() to preserve DomTree, part 3

3 years ago[SimplifyCFG] Teach simplifyIndirectBr() to preserve DomTree
Roman Lebedev [Thu, 31 Dec 2020 19:46:42 +0000 (22:46 +0300)]
[SimplifyCFG] Teach simplifyIndirectBr() to preserve DomTree

3 years ago[SimplifyCFG] Teach FoldBranchToCommonDest() to preserve DomTree, part 2
Roman Lebedev [Thu, 31 Dec 2020 19:23:23 +0000 (22:23 +0300)]
[SimplifyCFG] Teach FoldBranchToCommonDest() to preserve DomTree, part 2

3 years ago[SimplifyCFG] Teach FoldValueComparisonIntoPredecessors() to preserve DomTree, part 1
Roman Lebedev [Thu, 31 Dec 2020 17:13:30 +0000 (20:13 +0300)]
[SimplifyCFG] Teach FoldValueComparisonIntoPredecessors() to preserve DomTree, part 1

3 years ago[IRSim][IROutliner] Allowing GEP instructions to be outlined.
Andrew Litteken [Tue, 8 Sep 2020 01:19:54 +0000 (20:19 -0500)]
[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

3 years ago[mlir][shape] Add shape.lib attribute
Jacques Pienaar [Thu, 31 Dec 2020 22:46:08 +0000 (14:46 -0800)]
[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.

3 years ago[Analysis] reduce code for matching min/max; NFC
Sanjay Patel [Thu, 31 Dec 2020 21:45:33 +0000 (16:45 -0500)]
[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.

3 years agoRefactor how -fno-semantic-interposition sets dso_local on default visibility externa...
Fangrui Song [Thu, 31 Dec 2020 21:59:45 +0000 (13:59 -0800)]
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 2820a2ca3a0e69c3f301845420e0067ffff2251b.

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.

3 years ago[test] Make ELF tests immune to dso_local/dso_preemptable/(none) differences
Fangrui Song [Thu, 31 Dec 2020 21:37:35 +0000 (13:37 -0800)]
[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.

3 years agoRevert "remove pessimizing moves (reported by gcc 10)"
Andrew Litteken [Thu, 31 Dec 2020 21:13:46 +0000 (15:13 -0600)]
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 a2513cb8655e0aea4baffb4391e946ad3e56d883.

3 years agoAdd tests for D93943 (NFC)
Juneyoung Lee [Thu, 31 Dec 2020 20:59:26 +0000 (05:59 +0900)]
Add tests for D93943 (NFC)

3 years ago[IRSim] Letting gep instructions be legal for similarity identification.
Andrew Litteken [Tue, 8 Sep 2020 01:12:52 +0000 (20:12 -0500)]
[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.

3 years agoremove pessimizing moves (reported by gcc 10)
Nuno Lopes [Thu, 31 Dec 2020 20:35:56 +0000 (20:35 +0000)]
remove pessimizing moves (reported by gcc 10)

3 years ago[CodeGen] recognize select form of and/ors when splitting branch conditions
Juneyoung Lee [Thu, 31 Dec 2020 19:46:10 +0000 (04:46 +0900)]
[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

3 years ago[SCEV] recognize logical and/or pattern
Juneyoung Lee [Thu, 31 Dec 2020 19:33:18 +0000 (04:33 +0900)]
[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

3 years ago[Clang][Misc] Change run line in fragile test
Atmn [Thu, 31 Dec 2020 17:50:17 +0000 (12:50 -0500)]
[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

3 years ago[IROutliner] Adding consistent function attribute merging
Andrew Litteken [Mon, 24 Aug 2020 08:24:59 +0000 (03:24 -0500)]
[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

3 years ago[ThinLTO] Default -enable-import-metadata to false
Fangrui Song [Thu, 31 Dec 2020 18:04:21 +0000 (10:04 -0800)]
[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

3 years ago[MemorySSA, BPF] Use isa instead of dyn_cast (NFC)
Kazu Hirata [Thu, 31 Dec 2020 17:39:12 +0000 (09:39 -0800)]
[MemorySSA, BPF] Use isa instead of dyn_cast (NFC)

3 years ago[CodeGen] Construct SmallVector with iterator ranges (NFC)
Kazu Hirata [Thu, 31 Dec 2020 17:39:11 +0000 (09:39 -0800)]
[CodeGen] Construct SmallVector with iterator ranges (NFC)

3 years ago[llvm-objcopy] Use llvm::erase_if (NFC)
Kazu Hirata [Thu, 31 Dec 2020 17:39:09 +0000 (09:39 -0800)]
[llvm-objcopy] Use llvm::erase_if (NFC)

3 years ago[ThinLTO][test] Specify -enable-import-metadata to make !thinlto_src_module available...
Fangrui Song [Thu, 31 Dec 2020 17:31:53 +0000 (09:31 -0800)]
[ThinLTO][test] Specify -enable-import-metadata to make !thinlto_src_module available in -DLLVM_ENABLE_ASSERTIONS=off mode

3 years ago[ThinLTO][test] Add visibility related tests
Fangrui Song [Thu, 31 Dec 2020 17:16:35 +0000 (09:16 -0800)]
[ThinLTO][test] Add visibility related tests

Reviewed By: tejohnson

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

3 years ago[InstCombine] Transform (A + B) - (A & B) to A | B (PR48604)
Dávid Bolvanský [Thu, 31 Dec 2020 14:04:32 +0000 (15:04 +0100)]
[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

3 years ago[NFC] Added/adjusted tests for PR48604; second pattern
Dávid Bolvanský [Thu, 31 Dec 2020 13:59:15 +0000 (14:59 +0100)]
[NFC] Added/adjusted tests for PR48604; second pattern

3 years ago[InstCombine] Transform (A + B) - (A | B) to A & B (PR48604)
Dávid Bolvanský [Thu, 31 Dec 2020 13:02:44 +0000 (14:02 +0100)]
[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

3 years ago[NFC] Added tests for PR48604
Dávid Bolvanský [Thu, 31 Dec 2020 12:57:20 +0000 (13:57 +0100)]
[NFC] Added tests for PR48604

3 years agoRevert "[LoopDeletion] Allows deletion of possibly infinite side-effect free loops"
Bogdan Graur [Thu, 31 Dec 2020 11:47:30 +0000 (11:47 +0000)]
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 6f1503d59854b331f1f970d39839619b0a26bbc7.

Reviewed By: SureYeaah

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

3 years agoRevert "[ThinLTO][test] Add visibility related tests"
Bogdan Graur [Thu, 31 Dec 2020 11:41:03 +0000 (11:41 +0000)]
Revert "[ThinLTO][test] Add visibility related tests"

Both newly added tests fail in Release.

This reverts commit 52aa4e210744361a5ed6dc50fef78ed91706e508.

Reviewed By: SureYeaah

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

3 years agoLangRef: fix significand bits of fp128
Nuno Lopes [Thu, 31 Dec 2020 11:13:25 +0000 (11:13 +0000)]
LangRef: fix significand bits of fp128

3 years ago[sanitizer] Include fstab.h on glibc/FreeBSD/NetBSD/macOS
Fangrui Song [Thu, 31 Dec 2020 08:55:57 +0000 (00:55 -0800)]
[sanitizer] Include fstab.h on glibc/FreeBSD/NetBSD/macOS

3 years ago[sanitizer] Define SANITIZER_GLIBC to refine SANITIZER_LINUX feature detection and...
Fangrui Song [Thu, 31 Dec 2020 08:44:25 +0000 (00:44 -0800)]
[sanitizer] Define SANITIZER_GLIBC to refine SANITIZER_LINUX feature detection and support musl

Several `#if SANITIZER_LINUX && !SANITIZER_ANDROID` guards are replaced
with the more appropriate `#if SANITIZER_GLIBC` (the headers are glibc
extensions, not specific to Linux (i.e. if we ever support GNU/kFreeBSD
or Hurd, the guards may automatically work)).

Several `#if SANITIZER_LINUX && !SANITIZER_ANDROID` guards are refined
with `#if SANITIZER_GLIBC` (the definitions are available on Linux glibc,
but may not be available on other libc (e.g. musl) implementations).

This patch makes `ninja asan cfi msan stats tsan ubsan xray` build on a musl based Linux distribution (apk install musl-libintl)
Notes about disabled interceptors for musl:

* `SANITIZER_INTERCEPT_GLOB`: musl does not implement `GLOB_ALTDIRFUNC` (GNU extension)
* Some ioctl structs and functions operating on them.
* `SANITIZER_INTERCEPT___PRINTF_CHK`: `_FORTIFY_SOURCE` functions are GNU extension
* `SANITIZER_INTERCEPT___STRNDUP`: `dlsym(RTLD_NEXT, "__strndup")` errors so a diagnostic is formed. The diagnostic uses `write` which hasn't been intercepted => SIGSEGV
* `SANITIZER_INTERCEPT_*64`: the `_LARGEFILE64_SOURCE` functions are glibc specific. musl does something like `#define pread64 pread`
* Disabled `msg_iovlen msg_controllen cmsg_len` checks: musl is conforming while many implementations (Linux/FreeBSD/NetBSD/Solaris) are non-conforming. Since we pick the glibc definition, exclude the checks for musl (incompatible sizes but compatible offsets)

Pass through LIBCXX_HAS_MUSL_LIBC to make check-msan/check-tsan able to build libc++ (https://bugs.llvm.org/show_bug.cgi?id=48618).

Many sanitizer features are available now.

```
% ninja check-asan
(known issues:
* ASAN_OPTIONS=fast_unwind_on_malloc=0 odr-violations hangs
)
...
Testing Time: 53.69s
  Unsupported      : 185
  Passed           : 512
  Expectedly Failed:   1
  Failed           :  12

% ninja check-ubsan check-ubsan-minimal check-memprof # all passed

% ninja check-cfi
( all cross-dso/)
...
Testing Time: 8.68s
  Unsupported      : 264
  Passed           :  80
  Expectedly Failed:   8
  Failed           :  32

% ninja check-msan
(Many are due to functions not marked unsupported.)
Testing Time: 23.09s
  Unsupported      :   6
  Passed           : 764
  Expectedly Failed:   2
  Failed           :  58

% ninja check-tsan
Testing Time: 23.21s
  Unsupported      :  86
  Passed           : 295
  Expectedly Failed:   1
  Failed           :  25
```

Used `ASAN_OPTIONS=verbosity=2` to verify no unneeded interceptors.

Partly based on Jari Ronkainen's https://reviews.llvm.org/D63785#1921014

Reviewed By: vitalybuka

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

3 years ago[test] Add {{.*}} to make ELF tests immune to dso_local/dso_preemptable/(none) differ...
Fangrui Song [Thu, 31 Dec 2020 08:27:11 +0000 (00:27 -0800)]
[test] Add {{.*}} to make ELF tests immune to dso_local/dso_preemptable/(none) differences

For a default visibility external linkage definition, dso_local is set for ELF
-fno-pic/-fpie and COFF and Mach-O. Since default clang -cc1 for ELF is similar
to -fpic ("PIC Level" is not set), this nuance causes unneeded binary format differences.

To make emitted IR similar, ELF -cc1 -fpic will default to -fno-semantic-interposition,
which sets dso_local for default visibility external linkage definitions.

To make this flip smooth and enable future (dso_local as definition default),
this patch replaces (function) `define ` with `define{{.*}} `,
(variable/constant/alias) `= ` with `={{.*}} `, or inserts appropriate `{{.*}} `.

3 years ago[test] Fix -triple and delete UNSUPPORTED: system-windows
Fangrui Song [Thu, 31 Dec 2020 08:13:34 +0000 (00:13 -0800)]
[test] Fix -triple and delete UNSUPPORTED: system-windows

3 years agoUpdate inselt tests at llvm/test/Analysis to have poison as shufflevector's placehold...
Juneyoung Lee [Thu, 31 Dec 2020 08:11:31 +0000 (17:11 +0900)]
Update inselt tests at llvm/test/Analysis to have poison as shufflevector's placeholder (NFC)

File listed by:

grep -R -E "^[^;]*shufflevector <.*> .*, <.*> undef" . | grep inseltpoison

Updated with:

sed -i -E 's/shufflevector <(.*)> (.*), <(.*)> undef/shufflevector <\1> \2, <\3> poison/g' $1

3 years ago[mlir][python] Fix python extension building on windows.
Stella Laurenzo [Thu, 31 Dec 2020 08:11:39 +0000 (00:11 -0800)]
[mlir][python] Fix python extension building on windows.

3 years ago[mlir][python] Tweaks to make python extensions packagable/distributable.
Stella Laurenzo [Wed, 30 Dec 2020 07:34:58 +0000 (23:34 -0800)]
[mlir][python] Tweaks to make python extensions packagable/distributable.

* Works in tandem with prototype packaging scripts here: https://github.com/stellaraccident/mlir-py-release
* The `mlir` top-level now differentiates between in-tree builds where all packages are co-located and distribution mode where all native components are under a top-level `_mlir_libs` package.
* Also fixes the generated dialect python installation again. Hopefully the last tweak.
* With this, I am able to install and generate archives with the above setup script on Linux. Archive size=31M with just host codegen and headers/shared-libraries. Will need more linker tweaks when wiring up the next dependent project.

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

3 years ago[lld/mac] fix typo
Thorsten Schütt [Thu, 31 Dec 2020 07:23:29 +0000 (08:23 +0100)]
[lld/mac] fix typo

3 years agoSupport tilezero intrinsic and c interface for AMX.
Luo, Yuanke [Tue, 8 Dec 2020 12:47:48 +0000 (20:47 +0800)]
Support tilezero intrinsic and c interface for AMX.

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

3 years ago[CodeGenModule] Set dso_local for Mach-O GlobalValue
Fangrui Song [Thu, 31 Dec 2020 04:52:01 +0000 (20:52 -0800)]
[CodeGenModule] Set dso_local for Mach-O GlobalValue

* static relocation model: always
* other relocation models: if isStrongDefinitionForLinker

This will make LLVM IR emitted for COFF/Mach-O and executable ELF similar.

3 years ago[test] Add {{.*}} to make tests immune to dso_local/dso_preemptable/(none) differences
Fangrui Song [Thu, 31 Dec 2020 04:45:56 +0000 (20:45 -0800)]
[test] Add {{.*}} to make tests immune to dso_local/dso_preemptable/(none) differences

For a definition (of most linkage types), dso_local is set for ELF -fno-pic/-fpie
and COFF, but not for Mach-O.  This nuance causes unneeded binary format differences.

This patch replaces (function) `define ` with `define{{.*}} `,
(variable/constant/alias) `= ` with `={{.*}} `, or inserts appropriate `{{.*}} `
if there is an explicit linkage.

* Clang will set dso_local for Mach-O, which is currently implied by TargetMachine.cpp. This will make COFF/Mach-O and executable ELF similar.
* Eventually I hope we can make dso_local the textual LLVM IR default (write explicit "dso_preemptable" when applicable) and -fpic ELF will be similar to everything else. This patch helps move toward that goal.

3 years ago[RISCV] Define vector single-width type-convert intrinsic.
Monk Chiang [Thu, 31 Dec 2020 03:37:13 +0000 (11:37 +0800)]
[RISCV] Define vector single-width type-convert intrinsic.

Define intrinsics:
  1. vfcvt.xu.f.v/vfcvt.x.f.v
  2. vfcvt.rtz.xu.f.v/vfcvt.rtz.x.f.v
  3. vfcvt.f.xu.v/vfcvt.f.x.v

We work with @rogfer01 from BSC to come out this patch.

Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Monk Chiang <monk.chiang@sifive.com>
Differential Revision: https://reviews.llvm.org/D93933

3 years ago[RISCV] Define vector narrowing type-convert intrinsic.
Monk Chiang [Thu, 31 Dec 2020 03:35:37 +0000 (11:35 +0800)]
[RISCV] Define vector narrowing type-convert intrinsic.

Define intrinsics:
  1. vfncvt.xu.f.w/vfncvt.x.f.w
  2. vfncvt.rtz.xu.f.w/vfncvt.rtz.x.f.w
  3. vfncvt.f.xu.w/vfncvt.f.x.w
  4. vfncvt.f.f.w/vfncvt.rod.f.f.w

We work with @rogfer01 from BSC to come out this patch.

Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Monk Chiang <monk.chiang@sifive.com>
Differential Revision: https://reviews.llvm.org/D93932

3 years ago[RISCV] Define vector widening type-convert intrinsic.
Monk Chiang [Thu, 31 Dec 2020 03:31:46 +0000 (11:31 +0800)]
[RISCV] Define vector widening type-convert intrinsic.

Define intrinsics:
  1. vfwcvt.xu.f.v/vfwcvt.x.f.v
  2. vfwcvt.rtz.xu.f.v/vfwcvt.rtz.x.f.v
  3. vfwcvt.f.xu.v/vfwcvt.f.x.v
  4. vfwcvt.f.f.v

We work with @rogfer01 from BSC to come out this patch.

Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Monk Chiang <monk.chiang@sifive.com>
Differential Revision: https://reviews.llvm.org/D93855

3 years agoAdd intrinsic testcase for some missing widening reduction.
Monk Chiang [Thu, 31 Dec 2020 03:12:40 +0000 (11:12 +0800)]
Add intrinsic testcase for some missing widening reduction.

Add vfredosum/vfredsum/vwredsum/vwredsumu testcase.

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

3 years ago[lsan] Ignore inderect leaks referenced by suppressed blocks
Vitaly Buka [Tue, 29 Dec 2020 03:19:38 +0000 (19:19 -0800)]
[lsan] Ignore inderect leaks referenced by suppressed blocks

This makes suppression list to work similar to __lsan_ignore_object.

Existing behavior was inconsistent and very inconvenient for complex
data structures.

Example:

struct B;
struct A { B* ptr; };
A* t = makeA();
t->ptr = makeB();

Before the patch: if makeA suppressed by suppression file, lsan will
still report the makeB() leak, so we need two suppressions.

After the patch: a single makeA suppression is enough (the same as a
single __lsan_ignore_object(t)).

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

3 years ago[X86] Don't fold negative offset into 32-bit absolute address (e.g. movl $foo-1,...
Fangrui Song [Thu, 31 Dec 2020 02:47:26 +0000 (18:47 -0800)]
[X86] Don't fold negative offset into 32-bit absolute address (e.g. movl $foo-1, %eax)

When building abseil-cpp `bin/absl_hash_test` with Clang in -fno-pic
mode, an instruction like `movl $foo-2147483648, $eax` may be produced
(subtracting a number from the address of a static variable). If foo's
address is smaller than 2147483648, GNU ld/gold/LLD will error because
R_X86_64_32 cannot represent a negative value.

```
using absl::Hash;
struct NoOp {
  template < typename HashCode >
  friend HashCode AbslHashValue(HashCode , NoOp );
};
template <typename> class HashIntTest : public testing::Test {};
TYPED_TEST_SUITE_P(HashIntTest);
TYPED_TEST_P(HashIntTest, BasicUsage) {
  if (std::numeric_limits< TypeParam >::min )
    EXPECT_NE(Hash< NoOp >()({}),
              Hash< TypeParam >()(std::numeric_limits< TypeParam >::min()));
}
REGISTER_TYPED_TEST_CASE_P(HashIntTest, BasicUsage);
using IntTypes = testing::Types< int32_t>;
INSTANTIATE_TYPED_TEST_CASE_P(My, HashIntTest, IntTypes);

ld: error: hash_test.cc:(function (anonymous namespace)::gtest_suite_HashIntTest_::BasicUsage<int>::TestBody(): .text+0x4E472): relocation R_X86_64_32 out of range: 18446744071564237392 is not in [0, 4294967295]; references absl::hash_internal::HashState::kSeed
```

Actually any negative offset is not allowed because the symbol address
can be zero (e.g. set by `-Wl,--defsym=foo=0`). So disallow such folding.

Reviewed By: pengfei

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

3 years ago[LoopDeletion] Allows deletion of possibly infinite side-effect free loops
Atmn Patel [Wed, 23 Dec 2020 02:54:21 +0000 (21:54 -0500)]
[LoopDeletion] Allows deletion of possibly infinite side-effect free loops

From C11 and C++11 onwards, a forward-progress requirement has been
introduced for both languages. In the case of C, loops with non-constant
conditionals that do not have any observable side-effects (as defined by
6.8.5p6) can be assumed by the implementation to terminate, and in the
case of C++, this assumption extends to all functions. The clang
frontend will emit the `mustprogress` function attribute for C++
functions (D86233, D85393, D86841) and emit the loop metadata
`llvm.loop.mustprogress` for every loop in C11 or later that has a
non-constant conditional.

This patch modifies LoopDeletion so that only loops with
the `llvm.loop.mustprogress` metadata or loops contained in functions
that are required to make progress (`mustprogress` or `willreturn`) are
checked for observable side-effects. If these loops do not have an
observable side-effect, then we delete them.

Loops without observable side-effects that do not satisfy the above
conditions will not be deleted.

Reviewed By: jdoerfert

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

3 years ago[lld/mac] Add -adhoc_codesign / -no_adhoc_codesign flags
Nico Weber [Thu, 31 Dec 2020 01:56:19 +0000 (20:56 -0500)]
[lld/mac] Add -adhoc_codesign / -no_adhoc_codesign flags

These are new in Xcode 12's ld64. lld never codesigns at the moment, so
-no_adhoc_codesign doesn't even have to warn that it's not implemented.

3 years ago[Analysis] Remove unused code recursivelySimplifyInstruction (NFC)
Kazu Hirata [Thu, 31 Dec 2020 01:45:39 +0000 (17:45 -0800)]
[Analysis] Remove unused code recursivelySimplifyInstruction (NFC)

The last use of the function, located in RemovePredecessorAndSimplify,
was removed on Dec 25, 2020 in commit
46bea9b29714ba77010612b04ba13aff56d62e7b.

The last use of RemovePredecessorAndSimplify was removed on Sep 29,
2010 in commit 99c985c37dd45dd0fbd03863037d8e93153783e6.

3 years ago[PGO] Use isa instead of dyn_cast (NFC)
Kazu Hirata [Thu, 31 Dec 2020 01:45:37 +0000 (17:45 -0800)]
[PGO] Use isa instead of dyn_cast (NFC)

3 years ago[ARM] Declare Op within an if statement (NFC)
Kazu Hirata [Thu, 31 Dec 2020 01:45:36 +0000 (17:45 -0800)]
[ARM] Declare Op within an if statement (NFC)

3 years ago[ThinLTO][test] Add visibility related tests
Fangrui Song [Thu, 31 Dec 2020 00:58:20 +0000 (16:58 -0800)]
[ThinLTO][test] Add visibility related tests

Reviewed By: tejohnson

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

3 years ago[TargetMachine] Drop implied dso_local for definitions in ELF static relocation model/PIE
Fangrui Song [Thu, 31 Dec 2020 00:57:50 +0000 (16:57 -0800)]
[TargetMachine] Drop implied dso_local for definitions in ELF static relocation model/PIE

TargetMachine::shouldAssumeDSOLocal currently implies dso_local for such definitions.

Since clang -fno-pic add the dso_local specifier, we don't need to special case.

3 years ago[test] Add explicit dso_local to definitions in ELF static relocation model tests
Fangrui Song [Thu, 31 Dec 2020 00:52:23 +0000 (16:52 -0800)]
[test] Add explicit dso_local to definitions in ELF static relocation model tests

3 years ago[LowerEmuTls] Copy dso_local from <var> to __emutls_v.<var>
Fangrui Song [Thu, 31 Dec 2020 00:11:31 +0000 (16:11 -0800)]
[LowerEmuTls] Copy dso_local from <var> to __emutls_v.<var>

This effect is not testable until we drop the implied dso_local for ELF
static/PIE defined symbols from TargetMachine::shouldAssumeDSOLocal.

3 years ago[test] Add explicit dso_local to definitions in ELF static relocation model tests
Fangrui Song [Wed, 30 Dec 2020 23:47:16 +0000 (15:47 -0800)]
[test] Add explicit dso_local to definitions in ELF static relocation model tests

3 years ago[ORC] Remove some stale debugging output.
Lang Hames [Wed, 30 Dec 2020 04:34:44 +0000 (15:34 +1100)]
[ORC] Remove some stale debugging output.

3 years ago[RISCV][test] Add explicit dso_local to definitions in ELF static relocation model...
Fangrui Song [Wed, 30 Dec 2020 23:28:10 +0000 (15:28 -0800)]
[RISCV][test] Add explicit dso_local to definitions in ELF static relocation model tests

3 years ago[SystemZ][test] Add explicit dso_local to definitions in ELF static relocation model...
Fangrui Song [Wed, 30 Dec 2020 23:26:09 +0000 (15:26 -0800)]
[SystemZ][test] Add explicit dso_local to definitions in ELF static relocation model tests

3 years ago[ARM][test] Add explicit dso_local to definitions in ELF static relocation model...
Fangrui Song [Wed, 30 Dec 2020 23:23:20 +0000 (15:23 -0800)]
[ARM][test] Add explicit dso_local to definitions in ELF static relocation model tests

TargetMachine::shouldAssumeDSOLocal currently implies dso_local for such definitions.

Adding explicit dso_local makes these tests align with the clang -fno-pic behavior
and allow the removal of the TargetMachine::shouldAssumeDSOLocal special case.