Commit Graph

3760 Commits

Author SHA1 Message Date
Tobias Grosser 6bbca36414 Adjust to debug info metadata format change.
Rename variable to retainedNodes. This unbreaks the Polly builds.

llvm-svn: 331960
2018-05-10 07:09:10 +00:00
Michael Kruse e330071b43 [ScopInfo] Remove bail out condition in buildMinMaxAccess().
The condition was introduced in r267142 to mitigate a long compile-time
case. In r306087, a max-computation limit was introduced that should
handle the same case while leaving the max disjuncts heuristic it
should have replaced intact.

Today, the max disjuncts bail-out causes problems in that it prematurely
stops SCoPs from being detected, e.g. in SPEC's lbm. This would hit less
like if isl_set_coalesce would be called after isl_set_remove_divs
(which makes more basic_set likely to be coalescable) instead of before.

This patch tries to remove the premature max-disjuncts bail-out
condition by using simple_hull() to reduce the computational overhead,
instead of directly invalidating that SCoP.

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

Contributed-by: Sahil Girish Yerawar <cs15btech11044@iith.ac.in>
llvm-svn: 331891
2018-05-09 16:23:56 +00:00
Tobias Grosser 1c88d41020 [test] Replace undef with true/false to make test case less fragile
This test case does not require undef to be present in branch
conditions. Replace these undef values with true/false values to clarify
the control-flow required to reach the loop under testing.

llvm-svn: 331744
2018-05-08 07:24:05 +00:00
Philip Pfaffe f1fadea5ce Pass compiler arguments in the create_ll.sh script
Summary:
Occasionally you need an include or similar things to be configured
when making a new testcase. Allow passing these to the script and down to the
compiler calls.

Reviewers: grosser, Meinersbur, bollu

Reviewed By: Meinersbur

Subscribers: bollu, llvm-commits, pollydev

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

llvm-svn: 331364
2018-05-02 15:27:32 +00:00
Philip Pfaffe e9ca17e9b6 Revert "[polly] [ScopInfo] Don't pre-compute the name of the Scop's region."
This reverts commit 0f9dc03765dc301fff7a52e2a0e1dd3e5f3130c5, r328666.

The change introduced a use-after-free, caused by the temporary name string
being destroyed after converting it to a StringRef.

llvm-svn: 331363
2018-05-02 14:55:39 +00:00
Tobias Grosser e1cadf1722 Remove keep/take/give from isl C++ bindings
These functions have been legacy leftovers which we used before the
official C++ bindings existed. As all uses of these legacy functions
have been removed, this polly-specific extension can also be dropped.

llvm-svn: 331130
2018-04-29 00:57:43 +00:00
Tobias Grosser 8dae41a1cb Remove another set or release() calls
llvm-svn: 331129
2018-04-29 00:57:38 +00:00
Tobias Grosser d3d3d6b75d Remove the last uses of isl::give and isl::take
llvm-svn: 331126
2018-04-29 00:28:26 +00:00
Tobias Grosser 72018edae7 Fix one unit test
llvm-svn: 331125
2018-04-29 00:28:14 +00:00
Tobias Grosser da3e8c4ba7 [DeLICM] Remove uses of isl::give
llvm-svn: 331122
2018-04-28 22:11:55 +00:00
Tobias Grosser daf68ea309 [ZoneAlgo] Remove uses of isl::give - II
llvm-svn: 331121
2018-04-28 22:11:48 +00:00
Tobias Grosser 2f549fd6a9 [ZoneAlgo] Remove uses of isl::give
This moves more of Polly to islpp.

llvm-svn: 331120
2018-04-28 21:22:17 +00:00
Tobias Grosser 0ba8c4a868 [islpp] Remove use of isl::give from unittests
We do this mostly by just moving directly to pure C++ code.

llvm-svn: 331119
2018-04-28 21:06:14 +00:00
Tobias Grosser 77e871aaf5 [MaximalStaticExpansion] Replace copied function with version from ISLTools
llvm-svn: 331118
2018-04-28 20:42:35 +00:00
Tobias Grosser b58928096e Update to latest version of the isl c++ bindings
The delta to the previous version is rather small, but a change in brace
placement makes this a rather noisy commit.

llvm-svn: 331113
2018-04-28 16:02:30 +00:00
Michael Kruse 8aedbd9d2e [CodeGen] Fix comment. NFC.
llvm-svn: 330865
2018-04-25 19:54:16 +00:00
Michael Kruse e819fffee3 [CodeGen] Print executed statement instances at runtime.
Add the options -polly-codegen-trace-stmts and
-polly-codegen-trace-scalars. When enabled, adds a call to the
beginning of every generated statement that prints the executed
statement instance. With -polly-codegen-trace-scalars, it also prints
the value of all scalars that are used in the statement, and PHIs
defined in the beginning of the statement.

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

llvm-svn: 330864
2018-04-25 19:43:49 +00:00
Michael Kruse beffdb9daa [ScopDetect] Reject loop with multiple exit blocks.
The current statement domain derivation algorithm does not (always)
consider that different exit blocks of a loop can have different
conditions to be reached.

From the code

      for (int i = n; ; i-=2) {
        if (i <= 0) goto even;
        if (i <= 1) goto odd;
        A[i] = i;
      }
    even:
      A[0] = 42;
      return;
    odd:
      A[1] = 21;
      return;

Polly currently derives the following domains:

        Stmt_even_critedge
            Domain :=
                [n] -> { Stmt_even_critedge[] };
        Stmt_odd
            Domain :=
                [n] -> { Stmt_odd[] : (1 + n) mod 2 = 0 and n > 0 };

while the domain for the odd case is correct, Stmt_even is assumed to be
executed unconditionally, which is obviously wrong. While projecting out
the loop dimension in `adjustDomainDimensions`, it does not consider
that there are other exit condition that have matched before.

I don't know a how to fix this without changing a lot of code. Therefore
This patch rejects loops with multiple exist blocks to fix the
miscompile of test-suite's uuencode.

The odd condition is transformed by LLVM to

    %cmp1 = icmp eq i64 %indvars.iv, 1

such that the project_out in adjustDomainDimensions() indeed only
matches for odd n (using this condition only, we'd have an infinite loop
otherwise).

The even condition manifests as

    %cmp = icmp slt i64 %indvars.iv, 3

Because buildDomainsWithBranchConstraints() does not consider other exit
conditions, it has to assume that the induction variable will eventually
be lower than 3 and taking this exit.

IMHO we need to reuse the algorithm that determines the number of
iterations (addLoopBoundsToHeaderDomain) to determine which exit
condition applies first. It has to happen in
buildDomainsWithBranchConstraints() because the result will need to
propagate to successor BBs. Currently addLoopBoundsToHeaderDomain() just
look for union of all backedge conditions (which means leaving not the
loop here). The patch in llvm.org/PR35465 changes it to look for exit
conditions instead. This is required because there might be other exit
conditions that do not alternatively go back to the loop header.

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

llvm-svn: 330858
2018-04-25 18:53:33 +00:00
Tobias Grosser 5fa86378aa Update isl to isl-0.19-114-g385262af
llvm-svn: 330800
2018-04-25 06:10:35 +00:00
David Blaikie 60dc462b04 Fixup Polly for an LLVM header file change.
llvm-svn: 330679
2018-04-24 02:23:41 +00:00
Tobias Grosser 6135b0fe83 Update isl to isl-0.19-107-gc4fe33d8
This is a regular maintenance update.

llvm-svn: 330496
2018-04-21 08:34:22 +00:00
Michael Kruse 76238aac8b [isl++] abort() on assertion violation.
Before this patch, ISL_ASSERT only printed an error message to stderr.
This can be easily missed if the program continues or just fails later.
To fail-early and help error diagnostics (e.g. using bugpoint), call
abort() when an assertion does not hold.

I seem to just have forgotten to add this abort() when I originally
proposed the ISL_ASSERT macro.

Suggested-By: Eli Friedman <efriedma@codeaurora.org>

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

llvm-svn: 330467
2018-04-20 18:59:13 +00:00
Michael Kruse 5369ea5dd5 Allow arbitrary function calls for debugging purposes.
Add the switch -polly-debug-func to define the name of a debug
function. This function is ignored for any validity check.

Its purpose is to allow to observe a value after transformation by a
SCoP, and to follow which statements are executed in which order. For
instance, consider the following code:

    static void dbg_printf(int sum, int i) {
      fprintf(stderr, "The value of sum is %d, i=%d\n", sum, i);
      fflush(stderr);
    }

    void func(int n) {
      int sum = 0;
      for (int i = 0; i < 16; i+=1) {
        sum += i;
        dbg_printf(sum, i);
      }
    }

Executing this after Polly's codegen with -polly-debug-func=dbg_printf
reveals the new execution order and the assumed values at that point of
execution.

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

llvm-svn: 330466
2018-04-20 18:55:44 +00:00
Tobias Grosser c49f115b27 [RuntimeDebugBuilder] Do not break for 64 bit integers
In r330292 this assert was turned incorrectly into an unreachable, but
the correct behavior (thanks Michael) is to assert for anything that is
not 64 bit, but falltrough for 64 bit. I document this in the source
code.

llvm-svn: 330309
2018-04-19 05:38:12 +00:00
Tobias Grosser f4a3ff008d [RuntimeDebugBuilder] Print vectors passed without withspaces
Originally the RuntimeDebugBuilder printed vectors with withspaces
between the elements. This historic use is meanwhile gone, but the
functionality is still available.

We now change the behavior to print elements just one after the other
without adding white spaces in between. This is useful for D45743, an
upcoming commmit, which also adds test coverage for this feature.

In general, printing elements of a vector directly is more generic as
it allows uses where no white-spaces are desired. Specifically, it
allows the user to build vectors of items to be printed where their
length is only known at run-time.

llvm-svn: 330292
2018-04-18 20:28:26 +00:00
Tobias Grosser b20ae44ed0 [RuntimeDebugBuilder] Turn assert into an unreachable
llvm-svn: 330289
2018-04-18 20:18:43 +00:00
Tobias Grosser fcc3ad5d3c [ScopDetect / ScopInfo] Get statistics for scops without any loop correctly
Make sure we also counts scops not containing any loops.

llvm-svn: 330285
2018-04-18 20:03:36 +00:00
Philip Pfaffe 8da7d1d7ee [NewPM] Update pass registration for the LLVM plugin interface
Summary:
As of rL329273, LLVM has a mechanism to load new-pm plugins in opt. Use
this API in Polly.

Reviewers: grosser, Meinersbur, bollu

Reviewed By: grosser, Meinersbur

Subscribers: lksbhm, bollu, pollydev, llvm-commits

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

llvm-svn: 330181
2018-04-17 07:59:46 +00:00
Tobias Grosser be483ae665 Add isl operator overloads for isl::pw_aff (Try II)
Piecewise affine expressions have directly corresponding mathematical
operators. Introduce these operators as overloads as this makes writing
code with isl::pw_aff expressions more directly readable.

We can now write:

  A = B + C    instead of    A = B.add(C)

Reviewers: Meinersbur, bollu, sebpop

Reviewed By: Meinersbur

Subscribers: philip.pfaffe, pollydev, llvm-commits

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

llvm-svn: 329880
2018-04-12 06:15:17 +00:00
Tobias Grosser 7bbacbf4ca Revert r327216 'Add isl operator overloads for isl::pw_aff'
This commit requires further discussions.

llvm-svn: 329825
2018-04-11 16:58:08 +00:00
Michael Kruse 4485ae0890 [CodeGen] Allow undefined loads in statement instances outside context.
A check in assert-builds was meant to verify that a load provides a
value in all statement instances (i.e. its domain).  The domain is
commonly gist'ed within the parameter context to contain fewer
constraints.  However, statement instances outside the context are
no valid executions, hence the value provided can be undefined.

Refine the check for valid loads to only needed to be defined within
the SCoP context.

In addition, the JSONImporter had to be changed to allow importing
access relations that are broader than the current access relation,
but still defined over all statement instances.

This should fix the compiler crash in test-suite's oggenc of the
-polly-process-unprofitable buildbot.

llvm-svn: 329655
2018-04-10 01:20:51 +00:00
Michael Kruse 388730c9e0 [CodeGen] Convert BlockGenerator::generateScalarLoads to isl++. NFC.
llvm-svn: 329654
2018-04-10 01:20:47 +00:00
Michael Kruse db6f71e48d [ScopInfo] Avoid iterator invalidation.
Commit r329640 introduced the removal of all MemoryAccesses of a Scop.
It accidentally continued iterating over a vector whose iterators
have been invalidated by a MemoryAccess removal.

Make a copy of the MemoryAccesses to remove to iterate over while
removing them.

llvm-svn: 329653
2018-04-10 01:20:41 +00:00
Michael Kruse 192e7f72ca [ScopInfo] Completely remove MemoryAccesses when their parent statement is removed.
Removing a statement left its MemoryAccesses in some lists and maps of
the SCoP.  Which lists depends on at which phase of the SCoP
construction the statement is deleted.  Follow-up passes could still see
the already deleted MemoryAccesses by iterating through these
lists/maps, resulting in an access violation.

When removing a ScopStmt, also remove all its MemoryAccesses by using
the same mechnism that removes a MemoryAccess.

llvm-svn: 329640
2018-04-09 23:13:05 +00:00
Michael Kruse 7de61668ae [ScopInfo] Actually remove from list.
std::remove, despite its name, does not remove elements from a list, but
only moves them to the end of a list.  Call erase() to shorten the
vector to the remaining elements.

Test case included in next commit.

llvm-svn: 329639
2018-04-09 23:13:01 +00:00
Michael Kruse df8e140349 Remove immediate dominator heuristic for error block detection.
This patch removes the heuristic in
- Polly :: lib/Support/ScopHelper.cpp

The heuristic forces blocks that directly follow a loop header to not to be considered error blocks.
It was introduced in r249611 with the following commit message:

>   This replaces the support for user defined error functions by a
>   heuristic that tries to determine if a call to a non-pure function
>   should be considered "an error". If so the block is assumed not to be
>   executed at runtime. While treating all non-pure function calls as
>   errors will allow a lot more regions to be analyzed, it will also
>   cause us to dismiss a lot again due to an infeasible runtime context.
>   This patch tries to limit that effect. A non-pure function call is
>   considered an error if it is executed only in conditionally with
>   regards to a cheap but simple heuristic.

In the code below `CCK_Abort2()` would be considered as an error block, but not `CCK_Abort1()` due to this heuristic.
```
for (int i = 0; i < n; i+=1) {
  if (ErrorCondition1)
    CCK_Abort1(); // No __attribute__((noreturn))
  if (ErrorCondition2)
    CCK_Abort2(); // No __attribute__((noreturn))
}
```

This does not seem useful. Checking error conditions in the beginning of some work is quite common. It causes a switch default-case to be not considered an error block in SPEC's cactuBSSN. The comment justifying the heuristic mentions a "load", which does not seem to be applicable here. It has been proposed to remove the heuristic.

In addition, the patch fixes the following test cases:
- Polly :: ScopDetect/mod_ref_read_pointer.ll
- Polly :: ScopInfo/max-loop-depth.ll
- Polly :: ScopInfo/mod_ref_access_pointee_arguments.ll
- Polly :: ScopInfo/mod_ref_read_pointee_arguments.ll
- Polly :: ScopInfo/mod_ref_read_pointer.ll
- Polly :: ScopInfo/mod_ref_read_pointers.ll

The test cases failed after removing the heuristic.

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

Contributed-by: Lorenzo Chelini <l.chelini@icloud.com>
llvm-svn: 329548
2018-04-09 06:07:44 +00:00
Michael Kruse 9b67e569c6 [doc] Overhaul doc on preparing IR for processing by Polly.
The previously documented method did not work (anymore).

Suggested-by: Philip Pfaffe <philip.pfaffe@gmail.com>
llvm-svn: 329446
2018-04-06 19:24:18 +00:00
Michael Kruse ae180b95b0 Silence msvc warning on isl. NFC.
The warning is:

    isl_union_map.c(2041): warning C4221: nonstandard extension used: 'filter_user': cannot be initialized using address of automatic variable 'data'

for the following code (and others)

	struct isl_un_op_drop_user_data data = { &isl_set_is_wrapping };
	struct isl_un_op_control control = {
		.filter = &un_op_filter_drop_user,
		.filter_user = &data,
		.fn_map = &isl_set_wrapped_domain_map,
	};

llvm-svn: 329328
2018-04-05 18:30:44 +00:00
Michael Kruse 2ce9274da6 Remove namespace comment at end of class. NFC.
The
}; // namespace polly
comment was put at the closing brace of the FunctionToScopPassAdaptor class.
Since no namespace ends here, the comment is misplaced.

Reported-by: Lukas Böhm <lukas.boehm93@gmail.com>
llvm-svn: 329302
2018-04-05 15:32:06 +00:00
Huihui Zhang 71e54ccd06 [Polly][IslAst] Fix minimal dependence distance.
Summary:
When checking the parallelism of a scheduling dimension, we first check if excluding reduction dependences the loop is parallel or not.
If the loop is not parallel, then we need to return the minimal dependence distance of all data dependences, including the previously subtracted reduction dependences.


Reviewers: grosser, Meinersbur, efriedma, eli.friedman, jdoerfert, bollu

Reviewed By: Meinersbur

Subscribers: llvm-commits, pollydev

Tags: #polly

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

llvm-svn: 329214
2018-04-04 18:08:13 +00:00
Reid Kleckner 757c8cf615 Fix polly build after r328717
llvm-svn: 328728
2018-03-28 19:56:26 +00:00
Eli Friedman ac4ad45177 [polly] [ScopInfo] Don't pre-compute the name of the Scop's region.
This gets very expensive for basic blocks which don't have a name: it
calls printAsOperand, which numbers the entire module. We don't
normally need the name anyway, though; it's only used for debug dumps,
so don't compute it by default.

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

llvm-svn: 328666
2018-03-27 20:51:49 +00:00
David Blaikie fd94eee3b9 Update for LLVM header movement
llvm-svn: 328169
2018-03-21 23:21:10 +00:00
Tobias Grosser 3a99893618 Adjust to clang-format changes
llvm-svn: 328005
2018-03-20 17:16:32 +00:00
Tobias Grosser e5340a8ce9 Move code generation test case to test/CodeGen/
llvm-svn: 327857
2018-03-19 15:05:30 +00:00
Mandeep Singh Grang daec0aa71f [polly] Change std::sort to llvm::sort in response to r327219
Summary:
r327219 added wrappers to std::sort which randomly shuffle the container before sorting.
This will help in uncovering non-determinism caused due to undefined sorting
order of objects having the same key.

To make use of that infrastructure we need to invoke llvm::sort instead of std::sort.

Reviewers: grosser, efriedma, jdoerfert, bollu, sebpop

Reviewed By: sebpop

Subscribers: sebpop, mehdi_amini, llvm-commits, pollydev

Tags: #polly

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

llvm-svn: 327361
2018-03-13 05:25:23 +00:00
Tobias Grosser 5fdbdeb542 Revert untested changes in SCEVAffinator
llvm-svn: 327221
2018-03-10 19:15:23 +00:00
Tobias Grosser a1da86b224 Add isl operator overloads for isl::pw_aff
Piecewise affine expressions have directly corresponding mathematical
operators. Introduce these operators as overloads as this makes writing
code with isl::pw_aff expressions more directly readable.

We can now write:

  A = B + C    instead of    A = B.add(C)

llvm-svn: 327216
2018-03-10 18:07:03 +00:00
Philip Pfaffe 15186d4938 [Polly][CMake] Fix lit setup for building the in the mono repo
Summary:
When building polly as part of the monorepo (actually, as part of any setup
using LLVM_ENABLE_PROJECTS), the LLVMPolly library used in the lit tests ends
up in a different directory in the build tree than in an in-tree build

Reviewers: Meinersbur, grosser, bollu

Reviewed By: Meinersbur

Subscribers: mgorny, bollu, pollydev, llvm-commits

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

llvm-svn: 326702
2018-03-05 14:43:04 +00:00
Tobias Grosser b94863001a [ScopInfo] Do not use the set dimension ids to carry loop information
isl does not guarantee that set dimension ids will be preserved, so using them
to carry information is not a good idea. Furthermore, the loop information can
be derived without problem from the statement itself. As this even requires
less code than propagating loop information on set dimension ids, starting from
this commit we just derive the loop information in collectSurroundingLoops
directly from the IR.

Interestingly this also results in a couple of isl sets to take a simpler
representation.

llvm-svn: 326664
2018-03-03 19:27:54 +00:00