Commit Graph

3689 Commits

Author SHA1 Message Date
Michael Kruse a0db63a195 [IslTools] dumpPw: Dump same structure pieces together.
Print same or similar structure elements together. Previously, the
value could take more importance that the space structure if visited
first in the space nest tree.

Before:
{
  Left[0] -> Right[i]: i >= 0;
  Left[1] -> AnotherRight[i];
  Left[2] -> Right[-1]
}

After:
{
  Left[0] -> Right[i]: i >= 0;
  Left[2] -> Right[-1];
  Left[1] -> AnotherRight[i]
}

llvm-svn: 322581
2018-01-16 18:39:42 +00:00
Michael Kruse 21de8adc36 [CMake] Use only keyword-version of target_link_library. NFC.
CMake insists that for each target, one uses only the non-keyword
version of target_link_library

    target_link_library(mytarget lib)

or the one with PUBLIC/PRIVATE/INTERFACE keyword:

    target_link_library(mytarget PUBLIC lib)

Otherwise, CMake fails with the error message:

  The keyword signature for target_link_libraries has already been used with
  the target "mytarget".  All uses of target_link_libraries with a target
  must be either all-keyword or all-plain.

Change all occurances of target_link_library to the newer keyworded
version to avoid such errors. Some already have been changed in r319840,
but might not be sufficient for all build configurations to build
the doxygen manual.

Reported-by: Tanya Lattner <tanyalattner@llvm.org>
llvm-svn: 322376
2018-01-12 16:09:18 +00:00
Hans Wennborg e525b18620 Docs, release notes: update version to 7.0.0
llvm-svn: 321731
2018-01-03 15:54:54 +00:00
Michael Kruse 271deb17b0 [CodeGen] Fix noalias annotations for memcpy/memmove.
Memory transfer instructions take two pointers. It is not defined to
which of those a noalias annotation applies. To ensure correctness,
do not add noalias annotations to memcpy/memmove instructions anymore.

The caused a miscompile with test-suite's MultiSource/Applications/obsequi.
Since r321138, the MemCpyOpt pass would remove memcpy/memmove calls if
known to copy uninitialized memory. In that case, it was initialized
by another memcpy, but the annotation for the target pointer said
it would not alias. The annotation was actually meant for the source
pointer, which was was an alloca and could not alias with the target
pointer.

llvm-svn: 321371
2017-12-22 17:44:53 +00:00
Michael Kruse 5c2441901f Fix isl out-of-quota errors affecting later quota guards.
If an out-of-quota error occurred, the last error would be
isl_error_quota unless a different error occured. We typically check
whether the max-operations occured by comparing to that error value
after leaving the quota guard. This would check whether there ever
was a quota-error, not just in the last quota guards.

The observable bug occurred if the max-operations limit was reached in
DeLICM, and if -polly-dependences-computout=0, DependenceInfo would
think that the quota for computing dependencies was the reason,
i.e., fail the operation even if the calculation itself was successful.

Fix by reseting the last error to isl_error_none when entering a
quota guard, signaling that no quota error occured unless in the
guard's scope.

llvm-svn: 321329
2017-12-22 01:10:31 +00:00
Michael Kruse 5f0e8a46cf [ScopBuilder] Split statements on encountering store instructions.
Introduce -polly-stmt-granularity=store option.

Contributed-by: Nandini Singhal <cs15mtech01004@iith.ac.in>

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

llvm-svn: 320360
2017-12-11 12:51:24 +00:00
Michael Kruse 188b437fcb [ScopBuilder] Fix typo. NFC.
Contributed-by: Nandini Singhal <cs15mtech01004@iith.ac.in>

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

llvm-svn: 320336
2017-12-10 22:56:32 +00:00
Philip Pfaffe 0969462c52 [NFC] Fix formatting
llvm-svn: 319973
2017-12-06 22:01:08 +00:00
Philip Pfaffe d98dbeeb71 Port SCEVAffinator to the isl c++ bindings
Summary: Straight forward port of SCEVAffinator

Reviewers: grosser, bollu, Meinersbur

Reviewed By: Meinersbur

Subscribers: pollydev, llvm-commits

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

llvm-svn: 319958
2017-12-06 21:02:22 +00:00
Shoaib Meenai d806af3499 [CMake] Use PRIVATE in target_link_libraries for executables
We currently use target_link_libraries without an explicit scope
specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
Dependencies added in this way apply to both the target and its
dependencies, i.e. they become part of the executable's link interface
and are transitive.

Transitive dependencies generally don't make sense for executables,
since you wouldn't normally be linking against an executable. This also
causes issues for generating install export files when using
LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
library dependencies, which are currently added as interface
dependencies. If clang is in the distribution components but the LLVM
libraries it depends on aren't (which is a perfectly legitimate use case
if the LLVM libraries are being built static and there are therefore no
run-time dependencies on them), CMake will complain about the LLVM
libraries not being in export set when attempting to generate the
install export file for clang. This is reasonable behavior on CMake's
part, and the right thing is for LLVM's build system to explicitly use
PRIVATE dependencies for executables.

Unfortunately, CMake doesn't allow you to mix and match the keyword and
non-keyword target_link_libraries signatures for a single target; i.e.,
if a single call to target_link_libraries for a particular target uses
one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
also be updated to use those keywords. This means we must do this change
in a single shot. I also fully expect to have missed some instances; I
tested by enabling all the projects in the monorepo (except dragonegg),
and configuring both with and without shared libraries, on both Darwin
and Linux, but I'm planning to rely on the buildbots for other
configurations (since it should be pretty easy to fix those).

Even after this change, we still have a lot of target_link_libraries
calls that don't specify a scope keyword, mostly for shared libraries.
I'm thinking about addressing those in a follow-up, but that's a
separate change IMO.

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

llvm-svn: 319840
2017-12-05 21:49:56 +00:00
Siddharth Bhat c0f5f4deae Update to latest clang-format. [NFC]
Differential Revision: https://reviews.llvm.org/D40791

llvm-svn: 319718
2017-12-05 00:06:09 +00:00
Philip Pfaffe f6f8b25e58 [NFC] In GPGPU testcases, replace numeric registers in CHECK directives.
Using numeric registers is flaky, since as soon as one additional
instruction is generated by us, all the tests need to be adapted.

llvm-svn: 319544
2017-12-01 14:16:39 +00:00
Philip Pfaffe 4fe21814d1 Handle Top-Level-Regions in polly::isHoistableLoad
Summary:
This can be seen as a follow-up on my previous differential [D33411](https://reviews.llvm.org/D33411).
We received a bug report where this error was triggered. I have tried my best to recreate the issue in a minimal lit testcase which is also part of this differential.

I only handle return instructions as predecessors to a virtual TLR-exit right now. From inspecting the codebase, it seems `unreachable` instructions may also be of interest here. If requested, I can extend my patches to consider them as well. I would also apply this on `ScopHelper.cpp::isErrorBlock` (see D33411), of course.

Reviewers: philip.pfaffe, bollu

Reviewed By: bollu

Subscribers: Meinersbur, pollydev, llvm-commits

Tags: #polly

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

llvm-svn: 319431
2017-11-30 13:06:10 +00:00
Michael Kruse bfb8fa5a16 Update format after clang-format change. NFC.
In r319314 clang-format changed its reflowing logic.

llvm-svn: 319426
2017-11-30 12:05:48 +00:00
Ben Hamilton 85db2bf7b6 [polly] Set up .arcconfig to point to new Diffusion PLO repository
Summary: We want to automatically copy the appropriate mailing list
for review requests to the polly repository.

For context, see the proposal and discussion here:

http://lists.llvm.org/pipermail/cfe-dev/2017-November/056032.html

Similar to D40179, I set up a new Diffusion repository with callsign
"PLO" for polly:

https://reviews.llvm.org/source/polly/

This explicitly updates polly's .arcconfig to point to the new C
repository in Diffusion, which will let us use Herald rule H270.

llvm-svn: 319056
2017-11-27 17:34:03 +00:00
Davide Italiano b0c7dee0b6 [MaximalStaticExpansion] Simplify this code a bit. NFCI.
llvm-svn: 318988
2017-11-25 23:01:31 +00:00
Michael Kruse 163cacb469 [CodeGen] Detect empty domain because of parameters context.
Isl does not allow generating isl_ast_expr from an isl_pw_aff that has an
empty domain (i.e. has no pieces). We already detected the case if the
isl_pw_aff comes with an empty domain.

isl_ast_build also considers the domain empty if it is disjoint with the
parameter context (e.g. parameters values that we exclude by runtime
versioning).

Intersect the access relation domain with the parameter context to
also detect such practically empty access domains. The effective
pointer used in the generated code is unimportand because it will never
be executed.

This fixes llvm.org/PR35362

llvm-svn: 318806
2017-11-21 22:11:10 +00:00
Michael Kruse 58166b13e0 Run polly-update-format. NFC.
polly-check-format has been failing since at least r318517,
due to more than one cause.

llvm-svn: 318795
2017-11-21 19:25:26 +00:00
Philip Pfaffe 00fd43b327 Port ScopInfo to the isl cpp bindings
Summary:
Most changes are mechanical, but in one place I changed the program semantics
by fixing a likely bug:

In `Scop::hasFeasibleRuntimeContext()`, I'm now explicitely handling the
error-case. Before, when the call to `addNonEmptyDomainConstraints()`
returned a null set, this (probably) accidentally worked because
isl_bool_error converts to true. I'm checking for nullptr now.

Reviewers: grosser, Meinersbur, bollu

Reviewed By: Meinersbur

Subscribers: nemanjai, kbarton, pollydev, llvm-commits

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

llvm-svn: 318632
2017-11-19 22:13:34 +00:00
Zhaoshi Zheng ceec175dff [NFC] Make r318597 compatible with clang-format
llvm-svn: 318561
2017-11-17 22:05:19 +00:00
Philip Pfaffe 2813ce228b [nfc] Iwyu: forward-declare/include raw_ostream in zone algo
llvm-svn: 318517
2017-11-17 11:34:29 +00:00
Philip Pfaffe 8dd0f479e8 [SI] Fix a potential use-after-free
Summary:
There is a potential use-after-free bug in Scop::buildSchedule(Region *,
LoopStackTy &, LoopInfo &).  Before, we took a reference to LoopStack.back()
which is a use after free, since back is popped off further below. This didn't
crash before by pure chance, since LoopStack is actually a vector, and the
memory isn't freed upon pop. I turned this into an iterator-based algorithm.

Reviewers: grosser, bollu, Meinersbur

Reviewed By: Meinersbur

Subscribers: llvm-commits, pollydev

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

llvm-svn: 318415
2017-11-16 16:35:19 +00:00
Mandeep Singh Grang 02e789c9bf [polly] Remove redundant return [NFC]
Reviewers: grosser, bollu

Reviewed By: grosser

Subscribers: nemanjai, kbarton, llvm-commits

Tags: #polly

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

llvm-svn: 317922
2017-11-10 20:33:08 +00:00
Michael Kruse 3a1e4bfb53 Update formatting to reflect change in clang-format. NFC.
clang-format has changed its algorithm
for sorting includes in r317794.

llvm-svn: 317808
2017-11-09 16:33:29 +00:00
Michael Kruse 4d3f3c7206 [ForwardOpTree] Limit isl operations of known content reload.
Put the analysis part of reloadKnownContent under an isl
max-operations quota scope, as has already been done for
forwardKnownLoad.

This should fix the aosp timeout of "GrTestUtils.cpp".

llvm-svn: 317495
2017-11-06 17:48:14 +00:00
Sanjay Patel 1b5114fa52 [Analysis] update to use new fast-math API - isFast()
llvm-svn: 317491
2017-11-06 16:52:31 +00:00
Florian Hahn 6720a089fd [Polly] Fix using order, as this caused a test failure (NFC)
Summary:
Without this patch, clang-format in check-polly fails for me, with current master:

```
FAILED: cd build/tools/polly && build/bin/clang-format -sort-includes -style=llvm llvm/tools/polly/include/polly/ScopPass.h | diff -u llvm/tools/polly/include/polly/ScopPass.h -
--- llvm/tools/polly/include/polly/ScopPass.h	2017-11-06 14:05:49.885345000 +0000
+++ -	2017-11-06 14:07:24.956241758 +0000
@@ -40,12 +40,12 @@
 } // namespace polly

 namespace llvm {
+using polly::SPMUpdater;
 using polly::Scop;
 using polly::ScopAnalysisManager;
 using polly::ScopAnalysisManagerFunctionProxy;
 using polly::ScopInfo;
 using polly::ScopStandardAnalysisResults;
-using polly::SPMUpdater;

 template <>
 class InnerAnalysisManagerProxy<ScopAnalysisManager, Function>::Result {
```

Reviewers: grosser, Meinersbur, bollu

Reviewed By: Meinersbur

Subscribers: llvm-commits, pollydev

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

llvm-svn: 317478
2017-11-06 14:26:04 +00:00
Michael Kruse 68821a8b91 [ZoneAlgo/ForwardOpTree] Normalize PHIs to their known incoming values.
Represent PHIs by their incoming values instead of an opaque value of
themselves. This allows ForwardOpTree to "look through" the PHIs and
forward the incoming values since forwardings PHIs is currently not
supported.

This is particularly useful to cope with PHIs inserted by GVN LoadPRE.
The incoming values all resolve to a load from a single array element
which then can be forwarded.

It should in theory also reduce spurious conflicts in value mapping
(DeLICM), but I have not yet found a profitable case yet, so it is
not included here.

To avoid transitive closure and potentially necessary overapproximations
of those, PHIs that may reference themselves are excluded from
normalization and keep their opaque self-representation.

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

llvm-svn: 317008
2017-10-31 16:11:46 +00:00
Michael Kruse ff426d974d [DeLICM] Fix wrong assumed access execution order.
ForwardOpTree may already transform a scalar access to an array
accesses. The access remains implicit (isOriginalScalarKind(), meaning
that the access is always executed at the begin/end of a statement), but
targets an array (isLatestArrayKind(), which is unrelated to whether the
execution is implicit/explicit).

Fix by properly using isOriginalXXX() to determine execution order.

This fixes the buildbots on MultiSource/Benchmarks/DOE-ProxyApps-C/miniGMG.

llvm-svn: 316995
2017-10-31 12:50:25 +00:00
Michael Kruse 06618bf71a [OpenMP] Fix reference collection of latest base ptrs.
When collecting base pointers that need to be made available in parallel
subfunctions, use the base pointer associated with the latest
ScopArrayInfo, instead of the original one.

llvm-svn: 316983
2017-10-31 10:28:22 +00:00
Philip Pfaffe 53c803871e [Acc] Do not statically dispatch into IslNodeBuilder's createFor
Summary:
When GPUNodeBuilder creates loops inside the kernel, it dispatches to
IslNodeBuilder. This however is surprisingly dangerous, since it accesses the
AST Node's user through the wrong type. This patch fixes this problem by
overriding createFor correctly.

This fixes PR35010.

Reviewers: grosser, bollu, Meinersbur

Reviewed By: Meinersbur

Subscribers: Meinersbur, nemanjai, pollydev, llvm-commits, kbarton

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

llvm-svn: 316872
2017-10-29 21:36:34 +00:00
Philip Pfaffe 9b1d1e6ae7 Fix two testcases. NFC intended.
Add missing %loadPolly directive to support out of tree builds. One of
the changes is somewhat bigger, because the directive turns on LLVM
names, and the testcase deosn't use those.

llvm-svn: 316870
2017-10-29 21:00:48 +00:00
Michael Kruse cc6ea8e74f [ForwardOpTree] Use space indention. NFC.
llvm-svn: 316769
2017-10-27 14:48:34 +00:00
Michael Kruse 822dfe271b [ForwardOpTree] Reload know values.
For scalar accesses, change the access target to an array element that
is known to contain the same value.

This may become an alternative to forwardKnownLoad which creates new
loads (and therefore closer to forwarding speculatives). Reloading does
not require the known value originating from a load, but can be a store
as well.

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

llvm-svn: 316766
2017-10-27 14:26:14 +00:00
Michael Kruse b6b65834a1 [Simplify] Mark (and sweep) based on latest access relation.
Previously we marked scalars based on the original access function. However,
when a scalar read access is redirected, the original definition
(or incoming values of a PHI) is not used anymore, and can be deleted
(unless referenced by use that has not been redirected).

llvm-svn: 316660
2017-10-26 12:34:36 +00:00
Michael Kruse 37d57dac63 [DeLICM] Add more tests for loop layouts. NFC.
llvm-svn: 316642
2017-10-26 08:03:28 +00:00
Michael Kruse 983fa9bf23 [ZoneAlgo] Translate addArrayWriteAccess to isl++. NFC.
llvm-svn: 316459
2017-10-24 16:40:34 +00:00
Michael Kruse 25bd602b7a [ISLTools] Translate computeReachingWrite to isl++. NFC.
llvm-svn: 316445
2017-10-24 15:19:46 +00:00
Michael Kruse 19cd61dc11 [DeLICM] Do not try to map to multiple array elements.
Add check and skip when the store used to determine the target accesses
multiple array elements. Only a single array location should for
mapping the scalar. Having multiple creates problems when deciding which
element to load from. While MemoryAccess::getAddressFunction() should
select just one of them, other problems arise in code that assumes
that there is just one target element per statement instance.

This fixes llvm.org/PR34989

This also reverts r313902 which fixed llvm.org/PR34485 also caused by
a non-functional target array element. This patch avoids the situation
to occur in the first place.

llvm-svn: 316432
2017-10-24 13:05:24 +00:00
Anna Thomas 0026d91437 [Polly] Add XFAIL to large-numbers-in-boundary-context.ll
After rL315683 (improve SCEV to calculate max BETakenCount when end
bound of loop is variant and loop is of form {Start,+1, Stride} LT End)
this test in polly started failing.
However, as discussed in https://reviews.llvm.org/rL315683,
this polly test is not a loops bound test and the MaxBECount calculated by
SCEV looks correct. The max BECount is the value calculated even when the end
bound of loop is invariant.

As discussed with Tobias offline, I'm marking this as an XFAIL, until he
gets a chance to update the testcase, so the build bot goes to green.

llvm-svn: 315912
2017-10-16 15:12:39 +00:00
Adam Nemet e0f1541f41 Rename OptimizationDiagnosticInfo.h to OptimizationRemarkEmitter.h
Polly version of r315249 on LLVM trunk.

llvm-svn: 315253
2017-10-09 23:49:08 +00:00
Michael Kruse cc345e6e94 [ScopBuilder] Introduce -polly-stmt-granularity=scalar-indep option.
The option splits BasicBlocks into minimal statements such that no
additional scalar dependencies are introduced.

The algorithm is based on a union-find structure, and unites sets if
putting them into separate statements would introduce a scalar
dependencies. As a consequence, instructions may be split into separate
statements such their relative order is different than the statements
they are in. This is accounted for instructions whose relative order
matters (e.g. memory accesses).

The algorithm is generic in that heuristic changes can be made
relatively easily. We might relax the order requirement for read-reads
or accesses to different base pointers. Forwardable instructions can be
made to not cause a join.

This implementation gives us a speed-up of 82% in SPEC 2006 456.hmmer
benchmark by allowing loop-distribution in a hot loop such that one of
the loops can be vectorized.

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

llvm-svn: 314983
2017-10-05 13:43:00 +00:00
Michael Kruse 482d3f41e5 [ScopBuilder] Introduce -polly-stmt-granularity option. NFC.
The option is introduced with only one possible value
-polly-stmt-granularity=bb which represents the current behaviour, which
is outlined into the new function buildSequentialBlockStmts().

More options will be added in future commits.

llvm-svn: 314900
2017-10-04 12:18:57 +00:00
Tobias Grosser c52b71db15 [GPGPU] Make sure escaping invariant load hoisted scalars are preserved
We make sure that the final reload of an invariant scalar memory access uses the
same stack slot into which the invariant memory access was stored originally.
Earlier, this was broken as we introduce a new stack slot aside of the preload
stack slot, which remained uninitialized and caused our escaping loads to
contain garbage. This happened due to us clearing the pre-populated values
in EscapeMap after kernel code generation. We address this issue by preserving
the original host values and restoring them after kernel code generation.
EscapeMap is not expected to be used during kernel code generation, hence we
clear it during kernel generation to make sure that any unintended uses are
noticed.

llvm-svn: 314894
2017-10-04 10:24:23 +00:00
Jakub Kuderski 119753ad14 UnXFAIL tests that previously failed VerifyDFSNumbers
They started passing again by the DT::eraseNode fix in r314847.

llvm-svn: 314850
2017-10-03 21:23:56 +00:00
Jakub Kuderski 3c3bf74022 XFAIL two test that fail VerifyDFSNumbers DominatorTree check
This test XFAILs two test that start to fail when verifying DT's
DFS numbers, as per Tobias' suggestion.

Related VerifyDFSNumbers patch: D38331.

llvm-svn: 314800
2017-10-03 14:31:53 +00:00
Michael Kruse 4ee19603e9 [ScopBuilder] Iterate over statement instructions. NFC.
Iterate over statement instructions instead over basic block
instructions when creating MemoryAccesses. It allows making the creation
of MemoryAccesses independent of how the basic blocks are split into
multiple ScopStmts.

llvm-svn: 314665
2017-10-02 11:41:33 +00:00
Michael Kruse f5745b4e7d [ScopBuilder] Build invariant loads separately.
Create the MemoryAccesses of invariant loads separately and before
all other MemoryAccesses.

Invariant loads are classified as synthesizable and therefore are not
contained in any statement. When iterating over all instructions of all
statements, the invariant loads are consequently not processed and
iterating over them separately becomes necessary.

This patch can change the order in which MemoryAccesses are created, but
otherwise has no functional change.

Some temporary code is introduced to ensure correctness, but will be
removed in the next commit.

llvm-svn: 314664
2017-10-02 11:41:27 +00:00
Michael Kruse 89a6f3db02 [ScopBuilder] Build escaping dependencies separately.
Instructions that compute escaping values might be synthesizable and
therefore not contained in any ScopStmt. When buildAccessFunctions is
changed to only iterate over the instruction list of statement,
"free" instructions still need to be written. We do this after the
main MemoryAccesses have been created.

This can change the order in which MemoryAccesses are created, but has
otherwise no functional change.

llvm-svn: 314663
2017-10-02 11:41:19 +00:00
Michael Kruse 0bedec0e65 [ScopBuilder] Specialize exit block handling. NFC.
Decouple handling of exit block PHIs and other MemoryAccesses. Exit PHIs
only need the PHI handling part of buildAccessFunctions but requires
code for skipping them in while creating other MemoryAcesses.

This change will make it easier to modify how statement MemoryAccesses
are created without considering the exit block special case.

llvm-svn: 314662
2017-10-02 11:41:12 +00:00