Commit Graph

358054 Commits

Author SHA1 Message Date
Florian Hahn 40569db7b3 [DSE,MSSA] Move reachability check to main loop.
As we traverse the CFG backwards, we could end up reaching unreachable
blocks. For unreachable blocks, we won't have computed post order
numbers and because DomAccess is reachable, unreachable blocks cannot be
on any path from it.

This fixes a crash with unreachable blocks.
2020-06-21 16:38:10 +01:00
Luboš Luňák a45f713c67 add option to instantiate templates already in the PCH
Add -fpch-instantiate-templates which makes template instantiations be
performed already in the PCH instead of it being done in every single
file that uses the PCH (but every single file will still do it as well
in order to handle its own instantiations). I can see 20-30% build
time saved with the few tests I've tried.

The change may reorder compiler output and also generated code, but
should be generally safe and produce functionally identical code.
There are some rare cases that do not compile with it,
such as test/PCH/pch-instantiate-templates-forward-decl.cpp. If
template instantiation bailed out instead of reporting the error,
these instantiations could even be postponed, which would make them
work.

Enable this by default for clang-cl. MSVC creates PCHs by compiling
them using an empty .cpp file, which means templates are instantiated
while building the PCH and so the .h needs to be self-contained,
making test/PCH/pch-instantiate-templates-forward-decl.cpp to fail
with MSVC anyway. So the option being enabled for clang-cl matches this.

Differential Revision: https://reviews.llvm.org/D69585
2020-06-21 17:05:52 +02:00
David Green 730ecb63ec [CGP] Convert phi types
If a collection of interconnected phi nodes is only ever loaded, stored
or bitcast then we can convert the whole set to the bitcast type,
potentially helping to reduce the number of register moves needed as the
phi's are passed across basic block boundaries. This has to be done in
CodegenPrepare as it naturally straddles basic blocks.

The alorithm just looks from phi nodes, looking at uses and operands for
a collection of nodes that all together are bitcast between float and
integer types. We record visited phi nodes to not have to process them
more than once. The whole subgraph is then replaced with a new type.
Loads and Stores are bitcast to the correct type, which should then be
folded into the load/store, changing it's type.

This comes up in the biquad testcase due to the way MVE needs to keep
values in integer registers. I have also seen it come up from aarch64
partner example code, where a complicated set of sroa/inlining produced
integer phis, where float would have been a better choice.

I also added undef and extract element handling which increased the
potency in some cases.

This adds it with an option that defaults to off, and disabled for 32bit
X86 due to potential issues around canonicalizing NaNs.

Differential Revision: https://reviews.llvm.org/D81827
2020-06-21 15:54:17 +01:00
David Green 0ee21cdb63 [CGP][AArch64] Convert Phi type tests. NFC 2020-06-21 15:35:52 +01:00
Nikita Popov 37d3030711 [ValueTracking, BasicAA] Don't simplify instructions
GetUnderlyingObject() (and by required symmetry
DecomposeGEPExpression()) will call SimplifyInstruction() on the
passed value if other checks fail. This simplification is very
expensive, but has little effect in practice. This patch removes
the SimplifyInstruction call(), and replaces it with a check for
single-argument phis (which can occur in canonical IR in LCSSA
form), which is the only useful simplification case I was able to
identify.

At O3 the geomean CTMark improvement is -1.7%. The largest
improvement is SPASS with ThinLTO at -6%.

In test-suite, I see only two tests with a hash difference and
no code size difference (PAQ8p, Ptrdist), which indicates that
the simplification only ends up being useful very rarely. (I would
have liked to figure out which simplification is responsible here,
but wasn't able to spot it looking at transformation logs.)

The AMDGPU test case that is update was using two selects with
undef condition, in which case GetUnderlyingObject will return
the first select operand as the underlying object. This will of
course not happen with non-undef conditions, so this was not
testing anything realistic. Additionally this illustrates potential
unsoundness: While GetUnderlyingObject will pick the first operand,
the select might be later replaced by the second operand, resulting
in inconsistent assumptions about the undef value.

Differential Revision: https://reviews.llvm.org/D82261
2020-06-21 16:31:07 +02:00
Bruno Ricci 5342dd6bf4
Revert "Add --hot-func-list to llvm-profdata show for sample profiles"
This reverts commit 7348b951fe.
It is causing Asan failures.
2020-06-21 14:33:08 +01:00
Sanjay Patel 2ad42c2653 [ValueTracking] improve analysis for fdiv with same operands
(The 'nnan' variant of this pattern is already tested to produce '1.0'.)

https://alive2.llvm.org/ce/z/D4hPBy

define i1 @src(float %x, i32 %y) {
%0:
  %d = fdiv float %x, %x
  %uge = fcmp uge float %d, 0.000000
  ret i1 %uge
}
=>
define i1 @tgt(float %x, i32 %y) {
%0:
  ret i1 1
}
Transformation seems to be correct!
2020-06-21 09:07:59 -04:00
Sanjay Patel 97c0232621 [InstSimplify] add test for fdiv signbit; NFC 2020-06-21 09:07:59 -04:00
Bruno Ricci cddc9993ea
[clang][test][NFC] Also test for serialization in AST dump tests, part 3/n.
The outputs between the direct ast-dump test and the ast-dump test after
deserialization should match modulo a few differences.

For hand-written tests, strip the "<undeserialized declarations>"s and
the "imported"s with sed.

For tests generated with "make-ast-dump-check.sh", regenerate the output.

Part 3/n.
2020-06-21 13:59:11 +01:00
Bruno Ricci ecbf2f5f3d
[clang][test][NFC] Also test for serialization in AST dump tests, part 2/n.
The outputs between the direct ast-dump test and the ast-dump test after
deserialization should match modulo a few differences.

For hand-written tests, strip the "<undeserialized declarations>"s and
the "imported"s with sed.

For tests generated with "make-ast-dump-check.sh", regenerate the
output.

Part 2/n.
2020-06-21 13:59:11 +01:00
Bruno Ricci e560280cd5
[clang][NFC] Regenerate test/AST/ast-dump-lambda.cpp with --match-full-lines. 2020-06-21 13:59:11 +01:00
Bruno Ricci 0dbeffddd1
[clang][utils] Minor tweak to make-ast-dump-check.sh
Remove the space after the "CHECK:" on each line. This space makes the use
of FileCheck --match-full-lines impossible.
2020-06-21 13:59:10 +01:00
Bruno Ricci e7ce052820
[clang][Serialization] Fix the serialization of ConstantExpr.
The serialization of ConstantExpr has currently a number of problems:

- Some fields are just not serialized (ConstantExprBits.APValueKind and
  ConstantExprBits.IsImmediateInvocation).

- ASTStmtReader::VisitConstantExpr forgets to add the trailing APValue
  to the list of objects to be destroyed when the APValue needs cleanup.

While we are at it, bring the serialization of ConstantExpr more in-line
with what is done with the other expressions by doing the following NFCs:

- Get rid of ConstantExpr::DefaultInit. It is better to not initialize
  the fields of an empty ConstantExpr since this will allow msan to
  detect if a field was not deserialized.

- Move the initialization of the fields of ConstantExpr to the constructor;
  ConstantExpr::Create allocates the memory and ConstantExpr::ConstantExpr
  is responsible for the initialization.

Review after commit since this is a straightforward mechanical fix
similar to the other serialization fixes.
2020-06-21 13:59:10 +01:00
Bruno Ricci ef3adbfc70
[clang][NFC] Fix typos/wording in the comments of ConstantExpr.
It is "trailing objects" and "tail-allocated storage".
2020-06-21 13:59:10 +01:00
Nikita Popov 93a0f0e4fe [LangRef] Fix sphinx warnings 2020-06-21 13:51:07 +02:00
Nikita Popov f26b420194 [Docs] Fix code block in MemorySSA docs (NFC) 2020-06-21 13:47:00 +02:00
Simon Pilgrim fb9f9dc318 [X86][SSE] Add SimplifyDemandedVectorEltsForTargetShuffle to handle target shuffle variable masks
Pulled out from the ongoing work on D66004, currently we don't do a good job of simplifying variable shuffle masks that have already lowered to constant pool entries.

This patch adds SimplifyDemandedVectorEltsForTargetShuffle (a custom x86 helper) to first try SimplifyDemandedVectorElts (which we already do) and then constant pool simplification to help mark undefined elements.

To prevent lowering/combines infinite loops, we only handle basic constant pool loads instead of creating new BUILD_VECTOR nodes for lowering - e.g. we don't try to convert them to broadcast/vzext_load - there might be some benefit to this but if so I'd rather we come up with some way to reuse existing code than reimplement a lot of BUILD_VECTOR code.

Differential Revision: https://reviews.llvm.org/D81791
2020-06-21 11:16:07 +01:00
clfbbn 10b0539772 [Attributor][NFC] Fix indentation
Summary: The patch D81022 seems to break the indentation of the `cleanupIR()` function. This patch fixes this problem

Reviewers: jdoerfert, sstefan1, uenoku

Reviewed By: jdoerfert

Subscribers: hiraditya, uenoku, kuter, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D82260
2020-06-21 15:43:32 +08:00
Wenlei He 7c8a6936bf [Remarks] Add callsite locations to inline remarks
Summary:
Add call site location info into inline remarks so we can differentiate inline sites.
This can be useful for inliner tuning. We can also reconstruct full hierarchical inline
tree from parsing such remarks. The messege of inline remark is also tweaked so we can
differentiate SampleProfileLoader inline from CGSCC inline.

Reviewers: wmi, davidxl, hoy

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D82213
2020-06-20 23:32:10 -07:00
Jonas Devlieghere 6e3faaeb44 [lldb/Lua] Remove redundant variable (NFC) 2020-06-20 23:28:22 -07:00
Jonas Devlieghere e13fca4fac [lldb] Remove unused <iostream> includes (NFC) 2020-06-20 22:38:45 -07:00
Amy Kwan cc95635b1b [PowerPC][Power10] Implement Vector Clear Left/Rightmost Bytes Builtins in LLVM/Clang
This patch implements builtins for the following prototypes:
```
vector signed char vec_clrl (vector signed char a, unsigned int n);
vector unsigned char vec_clrl (vector unsigned char a, unsigned int n);
vector signed char vec_clrr (vector signed char a, unsigned int n);
vector signed char vec_clrr (vector unsigned char a, unsigned int n);
```

Differential Revision: https://reviews.llvm.org/D81707
2020-06-20 18:29:16 -05:00
Eric Christopher 0861889be1 [clang/llvm] As part of using inclusive language within
the llvm project, migrate away from the use of blacklist and whitelist.
2020-06-20 16:03:58 -07:00
Craig Topper 35f7d58328 [X86] Set the cpu_vendor in __cpu_indicator_init to VENDOR_OTHER if cpuid isn't supported on the CPU.
We need to set the cpu_vendor to a non-zero value to indicate
that we already called __cpu_indicator_init once.

This should only happen on a 386 or 486 CPU.
2020-06-20 15:36:04 -07:00
Eric Christopher da6332f5f9 [clang-tidy] As part of using inclusive language within
the llvm project, migrate away from the use of blacklist and whitelist.
2020-06-20 15:20:11 -07:00
Eric Christopher ef455a55bc Update comment to be more clear. 2020-06-20 14:44:41 -07:00
Eric Christopher dc20419351 Rename function to more accurately reflect what it does. 2020-06-20 14:37:29 -07:00
Eric Christopher 10b4354136 Temporarily Revert "[lldb][NFC] Add more test for builtin formats"
as it's failing on the debian buildbots:

http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/12531

This reverts commit 90c1af106a.
2020-06-20 14:21:42 -07:00
Eric Schweitz b938eaec55 [flang] Add BoxValue.h
The bridge uses internal boxes of related ssa-values to track all the
information associated with a Fortran variable. Variables may have a
location and a value, but may also carry other properties such as rank,
shape, LEN parameters, etc. in Fortran.

Differential revision: https://reviews.llvm.org/D82228
2020-06-20 14:13:14 -07:00
Eric Christopher 8116d01905 Typos around a -> an. 2020-06-20 14:04:48 -07:00
Sanjay Patel 741e20f3d6 [VectorCombine] fix assert for type of compare operand
As shown in the post-commit comment for D81661 - we need to
loosen the type assertion to allow scalarization of a compare
for vectors of pointers.
2020-06-20 15:20:17 -04:00
Raphael Isemann 90c1af106a [lldb][NFC] Add more test for builtin formats
The previous tests apparently missed a few code branches in DumpDataExtractor
code. Also renames the 'test_instruction' which had the same name as another
test (and Python therefore ignored the test entirely).
2020-06-20 19:31:40 +02:00
weihe 7348b951fe Add --hot-func-list to llvm-profdata show for sample profiles
Summary: Add the --hot-func-list feature to llvm-profdata show for sample profiles. This feature prints a list of hot functions whose max sample count are above the 99% threshold, with their numbers of total samples, total samples percentage, max samples, entry samples, and their function names.

Reviewers: wmi, hoyFB, wenlei

Reviewed By: wmi

Subscribers: hoyFB, wenlei, llvm-commits, weihe

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81800
2020-06-20 10:13:36 -07:00
Sanjay Patel 7b201bfcac [InstCombine] remove unused parameter and add assert; NFC 2020-06-20 11:47:00 -04:00
Sanjay Patel fc3cf48e12 [InstCombine] add tests for fmul/fdiv with fabs operands; NFC 2020-06-20 11:44:27 -04:00
Simon Pilgrim 7a3f2a734a ProfileSummaryInfo.h - reduce unnecessary Function.h include to forward declaration. NFC. 2020-06-20 15:57:05 +01:00
Simon Pilgrim 3bab56cc57 RegionPass.h - remove unnecessary Function.h include. NFC.
Forward declaration is already used.
2020-06-20 15:46:31 +01:00
Sanjay Patel d84cdb81ed [InstCombine] fabs(X) / fabs(X) -> X / X
Also, consolidate related folds so we don't miss/repeat these.
2020-06-20 10:20:21 -04:00
Sanjay Patel 61b5773796 [InstCombine] add tests for fabs(x) / fabs (x); NFC 2020-06-20 10:17:09 -04:00
Simon Pilgrim 89dcbdfcfd [X86] combineSetCCMOVMSK - consistently use CmpBits variable. NFCI.
The comparison value should be the same size - I've added an assert to be absolutely certain.
2020-06-20 12:35:24 +01:00
Simon Pilgrim 56a9332328 [X86][SSE] Fold MOVMSK(PCMPEQ(X,0)) != -1 -> !PTESTZ(X,X) allof patterns 2020-06-20 12:17:32 +01:00
Nikita Popov be93ba1fd6 [CVP] Add another non null test (NFC) 2020-06-20 13:05:42 +02:00
Nikita Popov 4ae1740b87 [JumpThreading] Make test more robust (NFC)
Optimizing away this comparison is not the point of this test,
so make sure it cannot be optimized away.
2020-06-20 13:05:42 +02:00
Nikita Popov d3d4e4bcb7 [LVI] Extract addValueHandle() method (NFC)
There will be more places registering value handles.
2020-06-20 13:05:42 +02:00
Nikita Popov 64ecf85f63 [LVI] Use find_as() where possible (NFC)
This prevents us from creating temporary PoisoningVHs and
AssertingVHs while performing hashmap lookups. As such, it only
matters in assertion-enabled builds.
2020-06-20 13:05:42 +02:00
Bruno Ricci f5bbe390d2
[clang] SequenceChecker: C++17 sequencing rule for overloaded operators.
In C++17 the operand(s) of an overloaded operator are sequenced as for
the corresponding built-in operator when the overloaded operator is
called with the operator notation ([over.match.oper]p2).

Reported in PR35340.

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

Reviewed By: rsmith
2020-06-20 10:51:46 +01:00
Raphael Isemann ab888262b3 [lldb] Skip TestBuiltinFormats.py on arm for now 2020-06-20 11:22:44 +02:00
Florian Hahn 9a7d80a32c Revert "[BasicAA] Use known lower bounds for index values for size based check."
This potentially related to https://bugs.llvm.org/show_bug.cgi?id=46335
and causes a slight compile-time regression. Revert while investigating.

This reverts commit d99a1848c4.
2020-06-20 10:06:05 +01:00
Kristina Bessonova cd058033b9 [CMake] Fix runtimes build for host Windows (default target)
When building runtimes, the compiler name (e.g. clang, clang-cl) is set based on
`CMAKE_SYSTEM_NAME` passed to `llvm_ExternalProject_Add()` through `CMAKE_ARGS` argument.
This mechanism doesn't work well if the target is Windows host.
`runtime_default_target()`/`builtin_default_target()` doesn't provide a way
to specify `CMAKE_SYSTEM_NAME` and doesn't set it either.

This patch appends variables specified in `RUNTIMES_CMAKE_ARGS`/`BUILTINS_CMAKE_ARGS`
to `CMAKE_ARGS` argument of `llvm_ExternalProject_Add()` in the case of called
from `runtime_default_target()`/`builtin_default_target()` thus in particular
it allows passing CMAKE_SYSTEM_NAME whenever it is required.

Reviewed By: phosek, compnerd, plotfi

Differential Revision: https://reviews.llvm.org/D81877
2020-06-20 10:44:22 +02:00
Eric Christopher 64b04e4754 Temporarily Revert "[flang][OpenMP] Enhance parser support for flush construct to OpenMP 5.0"
as it's failing Semantics/omp-clause-validity01.f90.

This reverts commit b32401464f.
2020-06-20 01:18:53 -07:00