Sanjay Patel [Mon, 14 Sep 2020 14:32:11 +0000 (10:32 -0400)]
[InstSimplify] reduce code duplication for fmin/fmax folds; NFC
We use the same code structure for folding integer min/max.
Sanjay Patel [Mon, 14 Sep 2020 14:24:19 +0000 (10:24 -0400)]
[InstSimplify] add/move tests for fmin/fmax; NFC
The new tests are duplicated from the sibling patch for codegen:
D87571
Sanjay Patel [Mon, 14 Sep 2020 14:07:26 +0000 (10:07 -0400)]
[InstSimplify] fix test comments; NFC
jasonliu [Fri, 11 Sep 2020 14:26:26 +0000 (14:26 +0000)]
[XCOFF][AIX] Handle TOC entries that could not be reached by positive range in small code model
Summary:
In small code model, AIX assembler could not deal with labels that
could not be reached within the [-0x8000, 0x8000) range from TOC base.
So when generating the assembly, we would need to help the assembler
by subtracting an offset from the label to keep the actual value
within [-0x8000, 0x8000).
Reviewed By: hubert.reinterpretcast, Xiangling_L
Differential Revision: https://reviews.llvm.org/D86879
David Green [Mon, 14 Sep 2020 13:26:10 +0000 (14:26 +0100)]
[ARM] Enable tail predication for reduction tests. NFC
Sanjay Patel [Mon, 14 Sep 2020 13:06:41 +0000 (09:06 -0400)]
[InstSimplify] fix miscompiles with maximum/minimum intrinsics
As discussed in the sibling codegen functionality patch D87571,
this transform was created with D52766, but it is not correct.
The incorrect test diffs were missed during review, but the
'TODO' comment about this functionality was still in the code -
we need 'nnan' to enable this fold.
Jay Foad [Wed, 3 Jun 2020 09:01:12 +0000 (10:01 +0100)]
[AMDGPU] Don't cluster stores
Clustering loads has caching benefits, but as far as I know there is no
advantage to clustering stores on any AMDGPU subtargets.
The disadvantage is that it tends to increase register pressure and
restricts scheduling freedom.
Differential Revision: https://reviews.llvm.org/D85530
Simon Pilgrim [Mon, 14 Sep 2020 12:24:17 +0000 (13:24 +0100)]
Assert we've found both vector types. NFCI.
Fixes clang static analyzer warning about potential null dereferences.
Simon Pilgrim [Mon, 14 Sep 2020 12:04:44 +0000 (13:04 +0100)]
Don't dereference from a dyn_cast<>. NFCI.
Use cast<> instead which will assert if it fails and not just return null.
Fixes clang static analyzer warning.
Georgii Rymar [Fri, 11 Sep 2020 10:29:33 +0000 (13:29 +0300)]
[llvm-readobj/elf] - Don't use unwrapOrError when reporting errors about SHT_DYNAMIC sections.
This changes messages reported to stop using dynamic section names (use `describe()` instead).
This allows to avoid `unwrapOrError` and improves diagnostics.
Differential revision: https://reviews.llvm.org/D87503
Georgii Rymar [Fri, 11 Sep 2020 11:35:06 +0000 (14:35 +0300)]
[llvm-readobj] - Cleanup implementation LLVMStyle<ELFT>::printAddrsig().
It has following issues:
1) `getStaticSymbolName` returns `std::string`, but the code
assigns a result to `Expected<std::string>`.
2) The code uses `unwrapOrError` and never tests the error reported.
This patch fixes these issues.
Differential revision: https://reviews.llvm.org/D87507
Max Kazantsev [Mon, 14 Sep 2020 11:28:58 +0000 (18:28 +0700)]
[NFC] Add missing `const` statements in SCEV
Georgii Rymar [Thu, 10 Sep 2020 12:26:23 +0000 (15:26 +0300)]
[llvm-readelf/obj] - Refine and generalize the code that is used to dump notes.
There is some code that can be shared between GNU/LLVM styles.
Also, this fixes 2 inconsistencies related to dumping unknown note types:
1) For GNU style we printed "Unknown note type: (0x00000003)" in some cases, and
"Unknown note type (0x00000003)" (no colon) in other cases.
GNU readelf always prints `:`. This patch removes the related code
duplication and does the same.
2) For LLVM style in some cases we printed "Unknown note type (0x00000003)",
but sometimes just "Unknown (0x00000003)". The latter is the right form, which
is consistent with other unknowns that are printed in LLVM style.
Rebased on top of D87453.
Differential revision: https://reviews.llvm.org/D87454
Georgii Rymar [Thu, 10 Sep 2020 13:59:06 +0000 (16:59 +0300)]
[llvm-readobj/elf][test] - Test all core note types properly.
Currently we don't test all core note types that are defined in
`getCoreNoteTypeName` in ELFDumper.cpp.
Also we don't have a test for an unknown core note type.
This patch fixes it.
Differential revision: https://reviews.llvm.org/D87453
Dvorskiy, Mikhail [Mon, 14 Sep 2020 11:20:32 +0000 (14:20 +0300)]
[pstl] Support Threading Building Blocks 2020 (oneTBB) for "tbb" parallel backend.
After the changes the "tbb" parallel backend will work with old TBB versions(TBB_INTERFACE_VERSION <= 12000) and new ones (TBB 2020 and greater)
More about oneTBB:
https://github.com/oneapi-src/oneTBB
Phabricator Review:
https://reviews.llvm.org/D87380
Alex Zinenko [Thu, 3 Sep 2020 08:05:25 +0000 (10:05 +0200)]
[mlir] Check for type conversion success in std->llvm function conversion
Type converter may fail and return nullptr on unconvertible types. The function
conversion did not include a check and was attempting to use a nullptr type to
construct an LLVM function, leading to a crash. Add a check and return early.
The rest of the call stack propagates errors properly.
Fixes PR47403.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D87075
David Green [Mon, 14 Sep 2020 11:08:34 +0000 (12:08 +0100)]
[CGP] Limit converting phi types to simple loads and stores
Instcombine limits converting phi types to simple loads and stores. This
does the same in codegenprepare, not processing phis that are not
simple.
Note that volatile loads/store ISel will happily convert between float
and int. Atomics are more likely to always be integer. This just keeps
things simple and doesn't process either.
Differential Revision: https://reviews.llvm.org/D83770
Florian Hahn [Mon, 14 Sep 2020 10:49:27 +0000 (11:49 +0100)]
[DSE] Only eliminate candidates that always store the same loc.
AliasAnalysis/MemoryLocation does not account for loops. Two
MemoryLocation can be must-overwrite, even if the first one writes
multiple locations in a loop.
This patch prevents removing such stores, by only considering candidates
that are known to be loop invariant, or executed in the same BB.
Currently the invariant check is quite conservative and only considers
Alloca and Alloca-like instructions and arguments as invariant base pointers.
It also considers GEPs with all constant indices and invariant bases as
invariant.
This can be improved in the future, but the current implementation has
only minor impact on the total number of stores eliminated (25903 vs
26047 for the baseline). There are some 2-10% swings for some individual
benchmarks. In roughly half of the cases, the number of stores removed
increases actually, because we skip candidates that are unlikely to be
valid candidates early.
Florian Hahn [Mon, 14 Sep 2020 10:56:13 +0000 (11:56 +0100)]
[DSE] Precommit test case for invalid elimination of store in loop.
Meera Nakrani [Mon, 14 Sep 2020 10:57:41 +0000 (10:57 +0000)]
[ARM] Selects SSAT/USAT from correct LLVM IR
LLVM will canonicalize conditional selectors to a different pattern than the old code that was used.
This is updating the function to match the new expected patterns and select SSAT or USAT when successful.
Tests have also been updated to use the new patterns.
Differential Review: https://reviews.llvm.org/D87379
Eduardo Caldas [Mon, 14 Sep 2020 08:20:19 +0000 (08:20 +0000)]
[SyntaxTree][List] `assertInvariants` for `List`s
Differential Revision: https://reviews.llvm.org/D87600
Eduardo Caldas [Mon, 14 Sep 2020 07:58:30 +0000 (07:58 +0000)]
[SyntaxTree] Provide `List::classof`
Differential Revision: https://reviews.llvm.org/D87599
Eduardo Caldas [Mon, 14 Sep 2020 07:56:39 +0000 (07:56 +0000)]
[SyntaxTree][List] Fix: `ParameterDeclarationList` is the `List` inside `ParametersAndQualifiers`
Differential Revision: https://reviews.llvm.org/D87598
Sjoerd Meijer [Wed, 9 Sep 2020 13:39:51 +0000 (14:39 +0100)]
[ARM][MVE] Tail-predication: check get.active.lane.mask's TC value
This adds additional checks for the original scalar loop tripcount value, i.e.
get.active.lane.mask second argument, and perform several sanity checks to see
if it is of the form that we expect similarly like we already do for the IV
which is the first argument of get.active.lane.
Differential Revision: https://reviews.llvm.org/D86074
David Sherwood [Thu, 10 Sep 2020 07:40:17 +0000 (08:40 +0100)]
[SVE] In LoopIdiomRecognize::isLegalStore bail out for scalable vectors
The function LoopIdiomRecognize::isLegalStore looks for stores in loops
that could be transformed into memset or memcpy. However, the algorithm
currently requires that we know how big the store is at runtime, i.e.
that the store size will not overflow an unsigned integer. For scalable
vectors we cannot guarantee this so I have changed the code to bail out
for now. In addition, even if we add a way to query the maximum value of
vscale in future we will still need to update the algorithm to cope with
non-constant strides. The additional cost associated with calculating
the memset and memcpy arguments will need to be taken into account as
well.
This patch also fixes up an implicit TypeSize -> uint64_t cast,
thereby removing a warning. I've added tests here showing a fixed
width vector loop being transformed into memcpy, and a scalable
vector loop remaining unchanged:
Transforms/LoopIdiom/memcpy-vectors.ll
Differential Revision: https://reviews.llvm.org/D87439
Petar Avramovic [Mon, 14 Sep 2020 10:03:36 +0000 (12:03 +0200)]
AMDGPU/GlobalISel Check for NoNaNsFPMath in isKnownNeverSNaN
Check for NoNaNsFPMath function attribute in isKnownNeverSNaN.
Function attributes are in held in 'TargetMachine.Options'.
Among other things, this allows selection of some patterns imported
in D87351 since G_FCANONICALIZE is not generated when isKnownNeverSNaN
returns true in lowerFMinNumMaxNum.
However we notice some incorrect results since function attributes are
not correctly written in TargetMachine.Options when next function is
processed. Take a look at @v_test_no_global_nnans_med3_f32_pat0_srcmod0,
it has "no-nans-fp-math"="false" but TargetMachine.Options still has it
set to true since first function in test file had this attribute set to
true. This will be fixed in D87511.
Differential Revision: https://reviews.llvm.org/D87456
Petar Avramovic [Mon, 14 Sep 2020 09:37:14 +0000 (11:37 +0200)]
AMDGPU/GlobalISel/Emitter Recognize additional 'same operand checks'
The "name" of a non-leaf complex pattern (MY_PAT $op1, $op2) is
"MY_PAT:op1:op2" and the ones with same "name" represent same operand.
Add 'same operand check' for this case.
Differential Revision: https://reviews.llvm.org/D87351
Petar Avramovic [Mon, 14 Sep 2020 09:18:21 +0000 (11:18 +0200)]
AMDGPU/GlobalISel Add test for non-leaf complex patterns
GlobalIsel emitter does not import patterns where complex sub-operand
of a non-leaf complex pattern is referenced more then once. Multiple
references of complex patterns with same name and same sub-operands
represent the same operand. Document this with a test.
Simon Pilgrim [Mon, 14 Sep 2020 10:09:15 +0000 (11:09 +0100)]
[LegalizeDAG] Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFCI.
Sam McCall [Mon, 14 Sep 2020 09:33:12 +0000 (11:33 +0200)]
[clangd] makeStringError,make_error<StringError> -> error()
Simon Pilgrim [Mon, 14 Sep 2020 09:27:35 +0000 (10:27 +0100)]
[CodeGen][X86] Regenerate minmax reduction sequence tests to match arithmetic tests.
avx512-reduceIntrin.c wasn't bothering with the exhaustive alloca/store/load/bitcast checks and avx512-reduceMinMaxIntrin.c shouldn't need to either.
This makes it a lot easier to maintain as the update script still doesn't work properly on x86 targets
Kadir Cetinkaya [Fri, 11 Sep 2020 09:40:54 +0000 (11:40 +0200)]
[clangd] Track tweaks that fail the apply stage
Differential Revision: https://reviews.llvm.org/D87501
Jeremy Morse [Mon, 14 Sep 2020 08:55:38 +0000 (09:55 +0100)]
[DebugInstrRef][1/9] Add fields for instr-ref variable locations
Add a DBG_INSTR_REF instruction and a "debug instruction number" field to
MachineInstr. The two allow variable values to be specified by
identifying where the value is computed, rather than the register it lies
in, like so:
%0 = fooinst, debug-instr-number 1
[...]
DBG_INSTR_REF 1, 0
See the original RFC for motivation:
http://lists.llvm.org/pipermail/llvm-dev/2020-February/139440.html
This patch is NFCI; it only adds fields and other boiler plate.
Differential Revision: https://reviews.llvm.org/D85741
LLVM GN Syncbot [Mon, 14 Sep 2020 08:53:33 +0000 (08:53 +0000)]
[gn build] Port
30667c967d3
Sam McCall [Wed, 8 Jul 2020 19:49:38 +0000 (21:49 +0200)]
[clangd] Add error() function for creating formatv-style llvm::Errors. NFC
Summary:
This is considerably terser than the makeStringError and friends, and
avoids verbosity cliffs that discourage adding log information.
It follows the syntax used in log/elog/vlog/dlog that have been successful.
The main caveats are:
- it's strictly out-of-place in logger.h, though kind of fits thematically and
in implementation
- it claims the "error" identifier, which seems a bit too opinionated
to put higher up in llvm
I've updated some users of StringError mostly at random - there are lots
more mechanical changes but I'd like to get this reviewed before making
them all.
Reviewers: kbobyrev, hokein
Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83419
Petar Avramovic [Mon, 14 Sep 2020 08:39:25 +0000 (10:39 +0200)]
AMDGPU/GlobalISel/Emitter Support for predicate code that uses operands
Predicates with 'let PredicateCodeUsesOperands = 1' want to examine
matched operands. When we encounter predicate code that uses operands,
analyze its named operand arguments and create a map between argument
index and name. Later, when leaf node with name is encountered, emit
GIM_RecordNamedOperand that will store that operand at its argument
index in operand list. This operand list will be an argument to c++
code of the predicate.
Differential Revision: https://reviews.llvm.org/D87285
David Stenberg [Mon, 14 Sep 2020 07:38:54 +0000 (09:38 +0200)]
[JumpThreading] Fix an incorrect Modified status
This fixes PR47297.
When ProcessBlock() was able to constant fold the terminator's
condition, but not do any more transformations, the function would
return false, which would lead to the JumpThreading pass returning an
incorrect modified status. This patch makes so that ProcessBlock()
returns true in such cases. This will trigger an unnecessary invocation
of ProcessBlock() in such cases, but this should be rare to occur.
This was caught using the check introduced by D80916.
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D87392
Kamil Rytarowski [Mon, 14 Sep 2020 08:10:49 +0000 (10:10 +0200)]
[compiler-rt] [netbsd] Use internal_ptrace() instead of ptrace()
Jay Foad [Fri, 11 Sep 2020 21:00:36 +0000 (22:00 +0100)]
[UnifyLoopExits] Fix non-deterministic iteration order
This was causing random minor codegen differences in shaders compiled
with the AMDGPU backend.
Differential Revision: https://reviews.llvm.org/D87548
Simon Wallis [Mon, 14 Sep 2020 07:52:59 +0000 (08:52 +0100)]
[ARM] Fix so immediates and pc relative checks
Treating an SoImm offset as a multiple of 4 between -1020 and 1020
mis-handles the second of a pair of 16-bit constants where the offset is a multiple of 2 but not a multiple of 4,
leading to an LLVM ERROR: out of range pc-relative fixup value
For 32-bit and larger (64-bit) constants, continue to treat an SoImm offset as a multiple of 4 between -1020 and 1020.
For smaller (16-bit) constants, treat an SoImm offset as a multiple of 1 between -255 and 255.
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D86949
David Sherwood [Thu, 10 Sep 2020 10:54:58 +0000 (11:54 +0100)]
[CodeGen] Fix bug in IncrementPointer
In an earlier patch I meant to add the correct flags to the ADD
node when incrementing the pointer, but forgot to pass them to
SelectionDAG::getNode.
Differential Revision: https://reviews.llvm.org/D87496
Balazs Benics [Mon, 14 Sep 2020 06:43:56 +0000 (08:43 +0200)]
[analyzer][z3] Use more elaborate Z3 variable names
Previously, it was a tedious task to comprehend Z3 dumps.
We will use the same name prefix just as we use in the corresponding dump method
For all `SymbolData` values:
`$###` -> `conj_$###`
`$###` -> `derived_$###`
`$###` -> `extent_$###`
`$###` -> `meta_$###`
`$###` -> `reg_$###`
Reviewed By: xazax.hun,mikhail.ramalho
Differential Revision: https://reviews.llvm.org/D86223
Balazs Benics [Mon, 14 Sep 2020 06:43:56 +0000 (08:43 +0200)]
[analyzer][docs][NFC] Document the ento namespace in the llvm/Lexicon
Document the `ento` namespace in the Lexicon according to @nicolas17 on the
mailing list (http://lists.llvm.org/pipermail/cfe-dev/2020-August/066577.html).
The analyzer lived at different namespaces at different times.
Originally lived at the `GR` aka. (Graph Reachability) namespace [7], later it
moved under the `ento` namespace [9].
The Static Analyzer's code lived at many other places as well:
`Analysis` -[2]-> `Checker` -[5]-> `GR` -[10]> `entoSA` -[11]-> `StaticAnalyzer`
The relevant code motion, refactor commits, cfe-dev mailing in chronological
order:
1) 2008-03-15 Make a major restructuring of the clang tree: introduce a ...
7a51313d8a0a358bb92eb5dbf8fd846b7c48e7fe
2) 2010-01-25 Split libAnalysis into two libraries: libAnalysis and libChecker
d6b8708643219776b1f0f41df32c5eccf065ed5b
3) 2010-12-21 Reorganization of Checker files
http://lists.llvm.org/pipermail/cfe-dev/2010-December/012694.html
4) 2010-12-22 Refactoring: include/clang/Checker -> include/clang/GR
8d602a8aa8e6697509465d8a5473fc41cb1a382e
5) 2010-12-22 Refactoring: lib/Checker -> lib/GR
2ff5ab1516e48c2fff0138f953d887b5e695214b
6) 2010-12-22 Refactoring: Move checkers into lib/GR/Checkers and their own
a700e976b658860418bc145ec0bdacd4f1db3264
7) 2010-12-22 Refactoring: Move stuff into namespace 'GR'
ca08fba4141f1d3ae6193b3c81fb6ba8fb10d7dc
8) 2010-12-22 Refactoring: Drop the 'GR' prefix.
1696f508e2fe95793ca8bb70d78b88023b6b8625
9) 2010-12-23 Rename static analyzer namespace 'GR' to 'ento'
98857c986078c6e6a10910628dbabf75ae735b76
10) 2010-12-23 Rename headers: 'clang/GR' 'clang/EntoSA' and update Makefile
ef33f0996c6a625767690395f3cfb41afb84db5a
11) 2010-12-23 Chris Lattner has strong opinions about directory
d99bd55a5e092774214ba31fc5a871bfc31e711c
12) 2010-12-24 Remove the EntoSA directories.
9d6af5328e3a61641a125b17125952fa1a6bf11d
Reviewed By: Szelethus,martong,ASDenysPetrov,xazax.hun
Differential Revision: https://reviews.llvm.org/D86446
Balazs Benics [Mon, 14 Sep 2020 06:43:56 +0000 (08:43 +0200)]
[analyzer] Evaluate PredefinedExpressions
We did not evaluate such expressions, just returned `Unknown` for such cases.
After this patch, we will be able to access a unique value identifying a template instantiation via the value of the `PRETTY_FUNCTION` predefined expression.
Reviewed By: vsavchenko
Differential Revision: https://reviews.llvm.org/D87004
Fangrui Song [Mon, 14 Sep 2020 06:00:59 +0000 (23:00 -0700)]
[llvm-cov gcov] Refactor counting and reporting
The current organization of FileInfo and its referenced utility functions of
(GCOVFile, GCOVFunction, GCOVBlock) is messy. Some members of FileInfo are just
copied from GCOVFile. FileInfo::print (.gcov output and --intermediate output)
is interleaved with branch statistics and computation of line execution counts.
--intermediate has to do redundant .gcov output to gather branch statistics.
This patch deletes lots of code and introduces a clearer work flow:
```
fn collectFunction
for each block b
for each line lineNum
let line be LineInfo of the file on lineNum
line.exists = 1
increment function's lines & linesExec if necessary
increment line.count
line.blocks.push_back(&b)
fn collectSourceLine
compute cycle counts
count = incoming_counts + cycle_counts
if line.exists
++summary->lines
if line.count
++summary->linesExec
fn collectSource
for each line
call collectSourceLine
fn main
for each function
call collectFunction
print function summary
for each source file
call collectSource
print file summary
annotate the source file with line execution counts
if -i
print intermediate file
```
The output order of functions and files now follows the original order in
.gcno files.
Serge Pavlov [Sat, 12 Sep 2020 14:54:14 +0000 (21:54 +0700)]
[AST][FPEnv] Keep FP options in trailing storage of CastExpr
This is recommit of
6c8041aa0f, reverted in
de044f7562 because of some
fails. Original commit message is below.
This change allow a CastExpr to have optional FPOptionsOverride object,
stored in trailing storage. Of all cast nodes only ImplicitCastExpr,
CStyleCastExpr, CXXFunctionalCastExpr and CXXStaticCastExpr are allowed
to have FPOptions.
Differential Revision: https://reviews.llvm.org/D85960
Yevgeny Rouban [Mon, 14 Sep 2020 04:42:23 +0000 (11:42 +0700)]
[CodeGenPrepare] Fix zapping dead operands of assume
This patch fixes a problem of the commit
52cc97a0.
A test case is created to demonstrate the crash caused by
the instruction iterator invalidated by the recursive
removal of dead operands of assume. The solution restarts
from the blocks's first instruction in case CurInstIterator
is invalidated by RecursivelyDeleteTriviallyDeadInstructions().
Reviewed By: bkramer
Differential Revision: https://reviews.llvm.org/D87434
Dave Lee [Sun, 13 Sep 2020 23:54:47 +0000 (16:54 -0700)]
[docs] Document LLVM_EXTERNALIZE_DEBUGINFO CMake option
Add `LLVM_EXTERNALIZE_DEBUGINFO` to CMake.rst. This should help make dSYM
generation more discoverable.
Differential Revision: https://reviews.llvm.org/D87591
Craig Topper [Mon, 14 Sep 2020 02:51:20 +0000 (19:51 -0700)]
[SelectionDAG] Move ISD:PARITY formation from DAGCombine to SimplifyDemandedBits.
Previously, we formed ISD::PARITY by looking for (and (ctpop X), 1)
but the AND might be separated from the ctpop. For example if the
parity result is multiplied by 2, we'll pull the AND through the
shift.
So to handle more cases, move to SimplifyDemandedBits where we
can handle more cases that result in only the LSB of the CTPOP
being used.
Lang Hames [Sun, 13 Sep 2020 21:22:20 +0000 (14:22 -0700)]
[JITLink] Improve formatting for Edge, Block and Symbol debugging output.
Fangrui Song [Sun, 13 Sep 2020 22:17:14 +0000 (15:17 -0700)]
[llvm-cov gcov][test] Unsupport Windows
Fangrui Song [Sun, 13 Sep 2020 21:54:20 +0000 (14:54 -0700)]
[llvm-cov gcov] Add -r (--relative-only) && -s (--source-prefix)
gcov 4.7 introduced the two options.
https://sourceware.org/pipermail/gcc-patches/2011-November/328782.html
-r only dumps files with relative paths or absolute paths with the prefix
specified by -s. The two options are useful filtering out system header files.
Nikita Popov [Sun, 13 Sep 2020 20:16:24 +0000 (22:16 +0200)]
[ARM] Add some fmin/fmax tests with commuted operands (NFC)
As well as vector commuted operands.
David Blaikie [Sun, 13 Sep 2020 20:08:17 +0000 (13:08 -0700)]
PPCInstrInfo: Fix readability-inconsistent-declaration-parameter-name clang-tidy warning
Reduces the chance of confusion when calling the function with
autocomplete (will show the more accurate/informative variable name),
etc.
David Blaikie [Sun, 13 Sep 2020 20:07:58 +0000 (13:07 -0700)]
Correct end-of-namespace comment to be clang-tidy/LLVM style appropriate
David Blaikie [Sun, 13 Sep 2020 19:54:36 +0000 (12:54 -0700)]
GCOVProfiling: Avoid use-after-move
Turns out this was use-after-move of function_ref, which is trivially
copyable and movable, so the move did nothing and use after move was
safe.
But since this function_ref is being copied into a std::function, change
the function_ref to be std::function to avoid extra layers of type
erasure indirection - and then it's a real use after move, and fix that
by referring to the moved-to member variable rather than the moved-from
parameter.
Craig Topper [Sun, 13 Sep 2020 18:49:14 +0000 (11:49 -0700)]
[SelectionDAG] Remove default for 'unsigned' Alignment for getLoad/getStore/getExtLoad/getTruncStore. Add default for MaybeAlign version. NFCI
We want to remove the unsigned signatures eventually. This change
migrates any that don't explicitly pass an alignment.
Raphael Isemann [Sat, 12 Sep 2020 19:49:48 +0000 (21:49 +0200)]
[ASTImporter] Add basic support for comparing Stmts and compare function bodies
Right now the ASTImporter assumes for most Expr nodes that they are always equal
which leads to non-compatible declarations ending up being merged. This patch
adds the basic framework for comparing Stmts (and with that also Exprs) and
implements the custom checks for a few Stmt subclasses. I'll implement the
remaining subclasses in follow up patches (mostly because there are a lot of
subclasses and some of them require further changes like having GNU language in
the testing framework)
The motivation for this is that in LLDB we try to import libc++ source code and
some of the types we are importing there contain expressions (e.g. because they
use `enable_if<expr>`), so those declarations are currently merged even if they
are completely different (e.g. `enable_if<value> ...` and `enable_if<!value>
...` are currently considered equal which is clearly not true).
Reviewed By: martong, balazske
Differential Revision: https://reviews.llvm.org/D87444
Qiu Chaofan [Sun, 13 Sep 2020 16:19:06 +0000 (00:19 +0800)]
[DAGCombiner] Propagate FMF flags in FMA folding
DAG combiner folds (fma a 1.0 b) into (fadd a b) but the flag isn't
propagated into new fadd. This patch fixes that.
Some code in visitFMA is redundant and such support for vector constants
is missing. Need follow-up patch to clean.
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D87037
David Green [Sun, 13 Sep 2020 15:11:01 +0000 (16:11 +0100)]
[CGP] Prevent optimizePhiType from iterating forever
The recently added optimizePhiType algorithm had no checks to make sure
it didn't continually iterate backward and forth between float and int
types. This means that given an input like store(phi(bitcast(load))), we
could convert that back and forth to store(bitcast(phi(load))). This
particular case would usually have been simplified to a different load
type (folding the bitcast into the load) before CGP, but other cases can
occur. The one that came up was phi(bitcast(phi)), where the two phi's
of different types were bitcast between. That was not helped by a dead
bitcast being kept around which could make conversion look profitable.
This adds an extra check of the bitcast Uses or Defs, to make sure that
at least one is grounded and will not end up being converted back. It
also makes sure that dead bitcasts are removed, and there is a minor
change to include newly created Phi nodes in the Visited set so that
they do not need to be revisited.
Differential Revision: https://reviews.llvm.org/D82676
Nikita Popov [Sun, 13 Sep 2020 15:04:53 +0000 (17:04 +0200)]
[ARM] Add tests for fmin/max with largest/smallest float (NFC)
Simon Pilgrim [Sun, 13 Sep 2020 12:38:05 +0000 (13:38 +0100)]
[X86] Add test cases for PR11210
Demonstrates that redundant masked stores may be removed, as long as we're able to replace the AVX/AVX2 masked store with a generic masked store (constant mask or sign-extended bool vector mask).
Qiu Chaofan [Sun, 13 Sep 2020 11:39:49 +0000 (19:39 +0800)]
Reland "[PowerPC] Implement instruction clustering for stores"
Commit
3c0b3250 introduced store fusion for PowerPC target, but it
brought failure under UB sanitizer and was reverted. This patch fixes
them.
Fangrui Song [Sun, 13 Sep 2020 07:44:32 +0000 (00:44 -0700)]
[gcov] Fix memory leak due to BranchProbabilityInfoWrapperPass
This is weird.
Fangrui Song [Sun, 13 Sep 2020 07:07:31 +0000 (00:07 -0700)]
[gcov] Add spanning tree optimization
gcov is an "Edge Profiling with Edge Counters" application according to
Optimally Profiling and Tracing Programs (1994).
The minimum number of counters necessary is |E|-(|V|-1). The unmeasured edges
form a spanning tree. Both GCC --coverage and clang -fprofile-generate leverage
this optimization. This patch implements the optimization for clang --coverage.
The produced .gcda files are much smaller now.
Fangrui Song [Sun, 13 Sep 2020 05:42:37 +0000 (22:42 -0700)]
[gcov] Assign names to some types and loaded values used in @__llvm_internal*
This makes the generated IR much more readable.
Fangrui Song [Sun, 13 Sep 2020 05:33:41 +0000 (22:33 -0700)]
[llvm-cov gcov] Improve accuracy when some edges are not measured
Also guard against infinite recursion if GCOV_ARC_ON_TREE edges contain a cycle.
Travis Finkenauer [Sun, 13 Sep 2020 05:26:08 +0000 (05:26 +0000)]
[Docs] Fix --print-supported-cpus option rendering
Adds link/code sample to avoid rendering two dashes as non-ASCII "en dash".
Also make wording a complete sentence.
Reviewed By: nickdesaulniers, tmfink
Differential Revision: https://reviews.llvm.org/D85596
Craig Topper [Sun, 13 Sep 2020 03:54:48 +0000 (20:54 -0700)]
[LegalizeTypes] Remove a few cases from SplitVectorOperand that should never happen. NFC
CTTZ, CTLZ, CTPOP, and FCANONICALIZE all have the same input and
output types so the operand should have already been legalized when the
result type was legalized.
Craig Topper [Sun, 13 Sep 2020 01:09:27 +0000 (18:09 -0700)]
[X86] Use ISD::PARITY directly instead of emitting CTPOP and AND from combineHorizontalPredicateResult.
We have a PARITY ISD node now so might as well use it. It will
get re-expanded later.
Krzysztof Parzyszek [Sat, 12 Sep 2020 21:32:24 +0000 (16:32 -0500)]
[Hexagon] Avoid widening vectors with non-HVX element types
LLVM GN Syncbot [Sat, 12 Sep 2020 23:13:20 +0000 (23:13 +0000)]
[gn build] Port
cc2da5554b5
Sam Clegg [Fri, 27 Mar 2020 23:52:27 +0000 (16:52 -0700)]
[lld][WebAssembly] Add initial support for -Map/--print-map
Differential Revision: https://reviews.llvm.org/D77187
Nikita Popov [Sat, 12 Sep 2020 22:21:39 +0000 (00:21 +0200)]
[ARM] Add tests for fmin/max + inf folds (NFC)
Sam Clegg [Thu, 23 Jul 2020 22:06:21 +0000 (15:06 -0700)]
[lld][WebAssembly] Error on import/export of mutable global without `mutable-globals` feature
Also add the +mutable-globals features in clang when
building with `-fPIC` since the linker will generate mutable
globals imports and exports in that case.
Differential Revision: https://reviews.llvm.org/D87537
Fangrui Song [Sat, 12 Sep 2020 20:51:53 +0000 (13:51 -0700)]
[gcov] Process .gcda immediately after the accompanying .gcno instead of doing all .gcda after all .gcno
i.e. change the work flow from
* .gcno for function A
* .gcno for function B
* .gcno for function C
* .gcda for function A
* .gcda for function B
* .gcda for function C
to
* .gcno for function A
* .gcda for function A
* .gcno for function B
* .gcda for function B
* .gcno for function C
* .gcda for function C
Currently there is duplicate logic in .gcno & .gcda processing: how functions
are filtered, which edges are instrumented, etc. This refactor enables simplification.
Since we always process .gcno, in -fprofile-arcs -fno-test-coverage mode,
__llvm_internal_gcov_emit_function_args.0 will have non-zero checksums.
Nikita Popov [Sat, 12 Sep 2020 20:39:39 +0000 (22:39 +0200)]
[ARM] Add additional vecreduce float legalization test (NFC)
Paul C. Anagnostopoulos [Fri, 11 Sep 2020 14:26:26 +0000 (10:26 -0400)]
Update TableGen test files to use the new '...' range punctuation.
Paul C. Anagnostopoulos [Fri, 11 Sep 2020 13:49:27 +0000 (09:49 -0400)]
Change range operator from deprecated '-' to '...'
Fangrui Song [Sat, 12 Sep 2020 19:34:43 +0000 (12:34 -0700)]
Revert "[gcov] emitProfileArcs: iterate over GCOVFunction's instead of Function's to avoid duplicated filtering"
This reverts commit
412c9c0bf2a8ccbda2d925575891a51ef5df846e.
Fangrui Song [Sat, 12 Sep 2020 19:17:40 +0000 (12:17 -0700)]
[gcov] emitProfileArcs: iterate over GCOVFunction's instead of Function's to avoid duplicated filtering
Fangrui Song [Sat, 12 Sep 2020 19:05:25 +0000 (12:05 -0700)]
[gcov] Clean up by getting llvm.dbg.cu earlier
Nikita Popov [Sat, 12 Sep 2020 18:31:46 +0000 (20:31 +0200)]
[InstCombine] Add extra use tests for abs canonicalization (NFC)
Mateusz Mikuła [Sat, 12 Sep 2020 19:03:22 +0000 (22:03 +0300)]
[MinGW][libclang] Allow simultaneous shared and static lib
It builds fine for MinGW on Windows.
Differential Revision: https://reviews.llvm.org/D87539
Mateusz Mikuła [Sat, 12 Sep 2020 19:02:11 +0000 (22:02 +0300)]
[MinGW][clang-shlib] Build by default on MinGW
It builds without errors and makes possible to use
CLANG_LINK_CLANG_DYLIB=1.
Differential Revision: https://reviews.llvm.org/D87547
Mateusz Mikuła [Sat, 12 Sep 2020 19:00:42 +0000 (22:00 +0300)]
[MinGW] Use lib prefix for libraries
In MinGW world, UNIX like lib prefix is preferred for the libraries.
This patch adjusts CMake files to do that.
Differential Revision: https://reviews.llvm.org/D87517
Craig Topper [Sat, 12 Sep 2020 18:42:18 +0000 (11:42 -0700)]
[SelectionDAG][X86][ARM][AArch64] Add ISD opcode for __builtin_parity. Expand it to shifts and xors.
Clang emits (and (ctpop X), 1) for __builtin_parity. If ctpop
isn't natively supported by the target, this leads to poor codegen
due to the expansion of ctpop being more complex than what is needed
for parity.
This adds a DAG combine to convert the pattern to ISD::PARITY
before operation legalization. Type legalization is updated
to handled Expanding and Promoting this operation. If after type
legalization, CTPOP is supported for this type, LegalizeDAG will
turn it back into CTPOP+AND. Otherwise LegalizeDAG will emit a
series of shifts and xors followed by an AND with 1.
I've avoided vectors in this patch to avoid more legalization
complexity for this patch.
X86 previously had a custom DAG combiner for this. This is now
moved to Custom lowering for the new opcode. There is a minor
regression in vector-reduce-xor-bool.ll, but a follow up patch
can easily fix that.
Fixes PR47433
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D87209
Florian Hahn [Sat, 12 Sep 2020 18:19:49 +0000 (19:19 +0100)]
[DSE] Adjust coroutines test after
e082dee2b588.
Florian Hahn [Sat, 12 Sep 2020 17:57:26 +0000 (18:57 +0100)]
[DSE] Bail out on MemoryPhis when deleting stores at end of function.
When deleting stores at the end of a function, we have to do PHI
translation, otherwise we might miss reads in different iterations of a
loop. See multiblock-loop-carried-dependence.ll for details.
This fixes a mis-compile and surprisingly also increases the number of
eliminated stores from 26047 to 26572 for MultiSource/SPEC2000/SPEC2006
on X86 with -O3 -flto. This is most likely because we save budget by not
exploring through MemoryPhis, which are less likely to result in valid
candidates for elimination.
The issue was reported post-commit for
fb109c42d91c.
Florian Hahn [Sat, 12 Sep 2020 17:28:57 +0000 (18:28 +0100)]
[DSE] Precommit test case with loop carried dependence.
David Green [Sat, 12 Sep 2020 16:47:04 +0000 (17:47 +0100)]
[LV][ARM] Add preferInloopReduction target hook.
This allows the backend to tell the vectorizer to produce inloop
reductions through a TTI hook.
For the moment on ARM under MVE this means allowing integer add
reductions of the correct size. In the future this can include integer
min/max too, under -Os.
Differential Revision: https://reviews.llvm.org/D75512
Paul C. Anagnostopoulos [Sat, 12 Sep 2020 15:50:01 +0000 (11:50 -0400)]
TableGen: change a couple of member names to clarify their use.
Simon Pilgrim [Sat, 12 Sep 2020 14:02:30 +0000 (15:02 +0100)]
[InstCombine][X86] Covert masked load/stores with (sign extended) bool vector masks to generic intrinsics.
As detailed on PR11210, if the mask is known to come from a (sign extended) bool vector (e.g. comparisons) then we can represent with a generic masked load/store without losing anything.
We already do something similar for BLENDV -> SELECT conversion.
Florian Hahn [Sat, 12 Sep 2020 13:23:36 +0000 (14:23 +0100)]
[Clang] Add option to allow marking pass-by-value args as noalias.
After the recent discussion on cfe-dev 'Can indirect class parameters be
noalias?' [1], it seems like using using noalias is problematic for
current C++, but should be allowed for C-only code.
This patch introduces a new option to let the user indicate that it is
safe to mark indirect class parameters as noalias. Note that this also
applies to external callers, e.g. it might not be safe to use this flag
for C functions that are called by C++ functions.
In targets that allocate indirect arguments in the called function, this
enables more agressive optimizations with respect to memory operations
and brings a ~1% - 2% codesize reduction for some programs.
[1] : http://lists.llvm.org/pipermail/cfe-dev/2020-July/066353.html
Reviewed By: rjmccall
Differential Revision: https://reviews.llvm.org/D85473
Evgeny Leviant [Sat, 12 Sep 2020 13:53:12 +0000 (16:53 +0300)]
[MachineScheduler] Fix operand scheduling for pre/post-increment loads
Differential revision: https://reviews.llvm.org/D87557
Tyker [Sat, 12 Sep 2020 11:36:45 +0000 (13:36 +0200)]
Reland [AssumeBundles] Use operand bundles to encode alignment assumptions
NOTE: There is a mailing list discussion on this: http://lists.llvm.org/pipermail/llvm-dev/2019-December/137632.html
Complemantary to the assumption outliner prototype in D71692, this patch
shows how we could simplify the code emitted for an alignemnt
assumption. The generated code is smaller, less fragile, and it makes it
easier to recognize the additional use as a "assumption use".
As mentioned in D71692 and on the mailing list, we could adopt this
scheme, and similar schemes for other patterns, without adopting the
assumption outlining.
Simon Pilgrim [Sat, 12 Sep 2020 13:31:26 +0000 (14:31 +0100)]
[InstCombine][X86] Add tests for masked load/stores with comparisons.
As detailed on PR11210, if the mask is known to come from a (sign extended) bool vector (e.g. comparisons) then we can represent with a generic masked load/store without losing anything.
David Green [Sat, 12 Sep 2020 13:31:26 +0000 (14:31 +0100)]
[ARM] Fixup single source mla reductions.
This fixes a complication on top of D87276. If we are sign extending
around a mul with the two operands that are the same, instcombine will
helpfully convert one of the sext to a zext. Reverse that so that we
again generate a reduction.
Differnetial Revision: https://reviews.llvm.org/D87287
Sanjay Patel [Sat, 12 Sep 2020 13:08:07 +0000 (09:08 -0400)]
[Intrinsics] define semantics for experimental fmax/fmin vector reductions
As discussed on llvm-dev:
http://lists.llvm.org/pipermail/llvm-dev/2020-April/140729.html
This is hopefully the final remaining showstopper before we can remove
the 'experimental' from the reduction intrinsics.
No behavior was specified for the FP min/max reductions, so we have a
mess of different interpretations.
There are a few potential options for the semantics of these max/min ops.
I think this is the simplest based on current behavior/implementation:
make the reductions inherit from the existing llvm.maxnum/minnum intrinsics.
These correspond to libm fmax/fmin, and those are similar to the (now
deprecated?) IEEE-754 maxNum/minNum functions (NaNs are treated as missing
data). So the default expansion creates calls to libm functions.
Another option would be to inherit from llvm.maximum/minimum (NaNs propagate),
but most targets just crash in codegen when given those nodes because no
default expansion was ever implemented AFAICT.
We could also just assume 'nnan' semantics by default (we are already
assuming 'nsz' semantics in the maxnum/minnum intrinsics), but some targets
(AArch64, PowerPC) support the more defined behavior, so it doesn't make much
sense to not allow a tighter spec. Fast-math-flags (nnan) can be used to
loosen the semantics.
(Note that D67507 was proposed to update the LangRef to acknowledge the more
recent IEEE-754 2019 standard, but that patch seems to have stalled. If we do
update based on the new standard, the reduction instructions can seamlessly
inherit from whatever updates are made to the max/min intrinsics.)
x86 sees a regression here on 'nnan' tests because we have underlying,
longstanding bugs in FMF creation/propagation. Those need to be fixed apart
from this change (for example: https://llvm.org/PR35538). The expansion
sequence before this patch may not have been correct.
Differential Revision: https://reviews.llvm.org/D87391
Simon Pilgrim [Sat, 12 Sep 2020 12:51:25 +0000 (13:51 +0100)]
[InstCombine][X86] getNegativeIsTrueBoolVec - use ConstantExpr evaluators. NFCI.
Don't do this manually, we can just use the ConstantExpr evaluators to do it more tidily for us.