Commit Graph

3880 Commits

Author SHA1 Message Date
Tobias Grosser 3867bae74b [MaximalStaticExpansion] Replace isl foreach calls with for loops
llvm-svn: 337243
2018-07-17 06:33:34 +00:00
Tobias Grosser 91f851b11a [ForwardOpTree] Replace isl foreach calls with for loops
llvm-svn: 337242
2018-07-17 06:33:31 +00:00
Tobias Grosser a33871686f [Simplify] Replace isl foreach calls with for loops
llvm-svn: 337241
2018-07-17 06:33:26 +00:00
Tobias Grosser 9d8913020d [FlattenAlgo] Replace more isl foreach calls with for loops
This time we replace for loops where the return isl::stat::error has
been used to carry status information.

There are still two uses of foreach remaining as we do not have a
corresponding for implementation for pw_aff functions.

llvm-svn: 337239
2018-07-17 06:16:58 +00:00
Tobias Grosser 6106595ac1 [FlattenAlgo] Replace some isl foreach calls with for loops
Replace foreach calls which only return 'ok' with for loops.

llvm-svn: 337238
2018-07-17 06:11:53 +00:00
Tobias Grosser 046c97876a [unittest/DeLICM] Replace isl foreach calls with for loops
llvm-svn: 337237
2018-07-17 06:08:04 +00:00
Tobias Grosser 31e29a4b59 [ScopInfo] Replace isl foreach calls with for loops
After Philip added support for range-based for loops to our C++
bindings, we now convert another bunch of foreach calls to range-for loops.
This improves general readability of the code.

llvm-svn: 337201
2018-07-16 19:04:16 +00:00
Philip Pfaffe ee51d5c64e [Polly][isl] Add neutrally-named accessors to isl list elements and sizes
Summary: This could simplify the isl iterator implementation a lot.

Reviewers: grosser, Meinersbur, bollu

Reviewed By: grosser

Subscribers: pollydev, llvm-commits

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

llvm-svn: 337054
2018-07-13 22:05:01 +00:00
Michael Kruse cd4d873d15 [Docs] Fix generation of manpages.
Fix the following error when Sphinx generates the Polly manpage:

    Warning, treated as error:
    docs/Performance.rst:: WARNING: "table cell spanning" not supported

llvm-svn: 336600
2018-07-09 20:26:11 +00:00
Philip Pfaffe 492cdfc5fb Add a file that was missing in r336425
llvm-svn: 336430
2018-07-06 11:33:35 +00:00
Tobias Grosser b370615451 Update isl to isl-0.19-224-gce84a511
This is a maintenance update. Besides many minor changes it ships two
functions "isl_*_list_size" and "isl_*_list_get_at" which will allow us
to simplify the iterator implementation in Polly.

llvm-svn: 336425
2018-07-06 09:00:26 +00:00
Tobias Grosser 4aab4ec836 [ScopInfo] Move foldSizeConstantsToRight() to isl++
Summary: This patch updates the isl interface used in `foldSizeConstantsToRight()` to the new C++ interface.

Reviewers: chelini, grosser, philip.pfaffe, Meinersbur

Reviewed By: grosser

Subscribers: llvm-commits

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

llvm-svn: 336362
2018-07-05 15:23:28 +00:00
Michael Kruse 9f305371d9 [CodeGen] Fix potential null pointer dereference. NFC.
ScalarEvolution::getSCEV dereferences its argument, s.t. passing nullptr
leads to undefined behaviour.

Check for nullptr before calling it instead of checking its argument
afterwards.

llvm-svn: 336350
2018-07-05 13:44:50 +00:00
Siddharth Bhat 936c74ad0d [PPCGCodeGen] Change printf to outs() to prevent garbled output. [NFC]
Summary:
It appears that llvm uses unbuffered C++ streams. So, we should not
mix C and C++ stream operations, because that will give us mixed
up output.

Reviewers: efriedma, jdoerfert, Meinersbur, gareevroman, sebpop, zinob, huihuiz, pollydev, grosser, singam-sanjay, philip.pfaffe

Reviewed By: philip.pfaffe

Subscribers: nemanjai, kbarton

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

llvm-svn: 336288
2018-07-04 16:51:27 +00:00
Tobias Grosser a66ab832a0 ScopInfo: simplify equivalence classes before storing them [NFCI]
This change has no impact on upstream Polly directly, but reduces output
noise for some internal isl versions we are testing. In general, storing
simpler and more canonical output is a good idea. Hence, it seems useful
to upstream this change.

llvm-svn: 336281
2018-07-04 14:53:36 +00:00
Siddharth Bhat 98a7a31d1e [Polly-ACC] Add isl_space.h to gpu_tree.c
Summary:
This patch adds <isl_space.h> to gpu_tree.c. This prevents a segfault
when allocating a new isl_space in the function create_sync_domain(), as
the compiler now knows that the return type is a pointer instead of
assuming the function returns an int.

This has been updated in upstream PPCG, so we should bump up our PPCG
version.

Initially discovered by Philip Pfaffe in Polly.

Reviewers: grosser, bollu, philip.pfaffe

Reviewed By: bollu

Subscribers: nemanjai, kbarton, llvm-commits

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

Contributed-by: Alain Denzler <alaindenzler@gmail.com>
llvm-svn: 336251
2018-07-04 09:40:55 +00:00
Philip Pfaffe cb8a82929c Fix for r336080: Missing colon in REQUIRES line
llvm-svn: 336083
2018-07-02 08:36:49 +00:00
Philip Pfaffe d71493cb06 [polly-acc] change cl_get_* return types to 32/64bit
Summary:
This patch changes the return types for ocl_get_* functions during SPIR code generation. Because these functions return size_t types, the return type needs to be changed to the actual size of size_t on the device.

Based on work by Michal Babej and Pekka Jääskeläinen

Patch by: Alain Denzler

Reviewers: grosser, philip.pfaffe, bollu

Reviewed By: grosser, philip.pfaffe

Subscribers: nemanjai, kbarton, llvm-commits

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

llvm-svn: 336080
2018-07-02 07:40:47 +00:00
Tobias Grosser d43114f880 Use range for in normalizeValInst [NFCI]
llvm-svn: 335971
2018-06-29 13:06:44 +00:00
Tobias Grosser 1696e48e79 Translate a couple of foreach callbacks into range-based iterator loops
Thanks to Philip Pfaffe for providing iterator support in the previous
commit.

llvm-svn: 335970
2018-06-29 12:23:48 +00:00
Tobias Grosser da82da8a20 Add missing namespace specifier
llvm-svn: 335966
2018-06-29 11:49:34 +00:00
Philip Pfaffe 2f3eff86b1 [NFC] Fix formatting to appease builders
llvm-svn: 335952
2018-06-29 08:29:17 +00:00
Philip Pfaffe 52025af1da Implement an iterator for isl maps, basic_maps, sets, basic_sets
Summary:
Provide an iterator to simplify iteration over some isl collections.
Since these types do not natively support iteration, they have to be converted
to an list first by the caller, but can then be used in a ranged for loop:
```
isl::set S;
for (auto SubSet : S.get_basic_set_list ()) {
  // ...
}
```

Reviewers: bollu, Meinersbur, grosser, dexonsmith

Reviewed By: bollu

Subscribers: hfinkel, mgorny, Meinersbur, mehdi_amini, bollu, steven_wu, llvm-commits

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

llvm-svn: 335951
2018-06-29 08:17:03 +00:00
Philip Pfaffe ec1a3048a3 [ScopHelper] Provide support for recognising collective invariant loads
Summary: This patch aims to provide support for detecting load patterns which are collectively invariant but right now `isHoistableLoad()` is checking each load instruction individually which cannot detect the load pattern as a whole.

Patch by: Sahil Girish Yerawar

Reviewers: bollu, philip.pfaffe, Meinersbur

Reviewed By: philip.pfaffe, Meinersbur

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

llvm-svn: 335949
2018-06-29 07:29:45 +00:00
Tobias Grosser 17a098dedf test: use regex matchers to make test-case robust against register renumberings
Suggested-by: Michael Kruse
llvm-svn: 335813
2018-06-28 07:11:48 +00:00
Eli Friedman 199caa2e80 [ScopHelper] Cache ScopExpander results.
The number of SCEV expressions is usually linear in the number of IR
instructions being modeled.  However, a naive SCEV visitor is not. For
an expression like x*x, "x" will be visited twice.  If x is itself an
expression like x*x, that will be visited twice, etc, and the overall
runtime is O(2^N) in the number of SCEV expressions.

To prevent this from happening, add a cache, so we only visit each SCEV
expression once.

Not sure this is the best solution. Maybe we can instead check whether
the SCEV is scop-invariant (in which case we never need to map the
value). But we don't have a utility for that at the moment.

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

llvm-svn: 335783
2018-06-27 20:35:02 +00:00
Michael Kruse 96da1ca584 [ZoneAlgo] Use getDefToTarget in makeValInst. NFC.
Move the optimized getDefToTarget() from ForwardOpTree to ZoneAlgo such
that it can be used by makeValInst.

This reduces the compile time of GrTestUtils of the aosp buildbot from
2m46s to 21s, which should fix the timeout issue.

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

llvm-svn: 335606
2018-06-26 14:29:09 +00:00
Tim Shen 63f244c4f4 [SCEV] Re-apply r335197 (with Polly fixes).
Summary:
This initiates a discussion on changing Polly accordingly while re-applying r335197 (D48338).

I have never worked on Polly. The proposed change to param_div_div_div_2.ll is not educated, but just patterns that match the output.

All LLVM files are already reviewed in D48338.

Reviewers: jdoerfert, bollu, efriedma

Subscribers: jlebar, sanjoy, hiraditya, llvm-commits, bixia

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

llvm-svn: 335292
2018-06-21 21:29:54 +00:00
Tobias Grosser 6ec6e1d6d6 Move ScopInfo to isl++
llvm-svn: 335029
2018-06-19 08:13:53 +00:00
Tobias Grosser 67dc08bd4c Adjust for clang-format changes
llvm-svn: 334941
2018-06-18 13:01:52 +00:00
Tobias Grosser 09a5437886 [ScopInfo] Move splitAliasGroupsByDomain and getAccessDomain to isl++ [NFCI]
llvm-svn: 334940
2018-06-18 12:53:26 +00:00
Tobias Grosser 9b29af946f [ScopInfo] Move more functions to isl++ [NFCI]
This change includes:

  - getFortranArrayIds
  - adjustDomainDimensions
  - propagateInvalidStmtDomains
  - buildAliasGroupsForAccesses

llvm-svn: 334939
2018-06-18 12:49:47 +00:00
Tobias Grosser 85dfb53e32 [ScopInfo] Move addNonEmptyDomainConstraints to isl++ [NFCI]
llvm-svn: 334938
2018-06-18 12:41:58 +00:00
Tobias Grosser fd5c856fe5 Move buildConditionSet to C++
llvm-svn: 334937
2018-06-18 12:35:36 +00:00
Paul Robinson 7555c589af Update copyright year to 2018.
llvm-svn: 334936
2018-06-18 12:22:17 +00:00
Tobias Grosser a78a809afc Adjust to recent LLVM changes to fix buildbots
llvm-svn: 334893
2018-06-16 17:38:19 +00:00
Philip Pfaffe 66a05ad672 Simplify the implementation of getCUDALibDeviceFunction. NFC.
Summary:
The function is currently awfully complicated. Drop the IILE and use
StringRef over std::string.

Reviewers: Meinersbur, grosser, bollu

Reviewed By: Meinersbur

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

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

llvm-svn: 334695
2018-06-14 08:54:55 +00:00
Tobias Grosser ee5762cfab [test] Fix a typo in a test case [NFCI]
Also remove an undef value that does not add any value to the test case.

llvm-svn: 334661
2018-06-13 21:46:29 +00:00
Tobias Grosser 6538f40e31 Drop unnecessary whitespace [NFCI]
llvm-svn: 334413
2018-06-11 15:11:57 +00:00
Tobias Grosser 80677bce11 [ScopBuilder] Slightly improve code structure [NFCI]
First build the surrounding loops and then build up the polyhedral
structures. Before r326664 we had to mix these updates, clean this
up to improve readability (slightly).

llvm-svn: 334412
2018-06-11 14:59:28 +00:00
Tobias Grosser 2c543e775f Update isl to isl-0.19-185-g8e9f55ce
This is mainly a maintenance update.

llvm-svn: 334406
2018-06-11 14:25:42 +00:00
Krzysztof Parzyszek fb3ed4f409 [Polly] Fix a testcase after LLVM commit r334318
ScalarEvolution has become slightly more intelligent, so obfuscate the
exit condition in the testcase some more to keep it working.

llvm-svn: 334327
2018-06-08 21:39:55 +00:00
Philip Pfaffe 4d24093ac4 Back out of GPU Codegen if NVPTX is not available
Summary:
When enabling GPU codegen in polly, CMake will fail if NVPTX is not a target
supported by the LLVM polly is being built against. In that case, GPU codegen
should be switched off.

Reviewers: Meinersbur, grosser, bollu

Reviewed By: Meinersbur

Subscribers: mgorny, bollu, pollydev, llvm-commits

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

llvm-svn: 334233
2018-06-07 21:10:49 +00:00
Philip Pfaffe e6e1828004 Run clang-format
llvm-svn: 334172
2018-06-07 08:32:13 +00:00
Philip Pfaffe 30c5e4ad35 Fix a missing lambda return type that tripped the builders
llvm-svn: 334166
2018-06-07 07:50:55 +00:00
Michael Kruse 2dab88e652 [OpTree] Introduce shortcut for computing the def->target mapping. NFCI.
In case the schedule has not changed and the operand tree root uses a
value defined in an ancestor loop, the def-to-target mapping is trivial.
For instance, the SCoP

    for (int i < 0; i < N; i+=1) {
    DefStmt:
      D = ...;
      for (int j < 0; j < N; j+=1) {
    TargetStmt:
        use(D);
      }
    }

has DefStmt-to-TargetStmt mapping of

    { DefStmt[i] -> TargetStmt[i,j] }

This should apply on the majority of def-to-target mappings.
This patch detects this case and directly constructs the expected
mapping. It assumes that the mapping never crosses the loop header
DefStmt is in, which ForwardOpTree does not support at the moment
anyway.

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

llvm-svn: 334134
2018-06-06 21:37:35 +00:00
Tobias Grosser 6a6d9df78e getDependences to new C++ interface
Reviewers: Meinersbur, grosser, bollu, cs15btech11044, jdoerfert

Reviewed By: grosser

Subscribers: pollydev, llvm-commits

Tags: #polly

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

llvm-svn: 334092
2018-06-06 13:10:32 +00:00
Tobias Grosser a998f98ba6 Fix formatting
llvm-svn: 333988
2018-06-05 09:03:46 +00:00
David Blaikie 4490465db7 Update for a header file move in LLVM
llvm-svn: 333956
2018-06-04 21:23:32 +00:00
Tobias Grosser 78a8494eb5 partitionSetParts from C to C++ interface.
Summary: partitionSetParts from C to new C++ interface.

Reviewers: grosser, Meinersbur, jdoerfert, bollu, cs15btech11044

Reviewed By: grosser, Meinersbur

Subscribers: llvm-commits, pollydev

Tags: #polly

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

llvm-svn: 333780
2018-06-01 19:12:00 +00:00
Michael Kruse d51fbfca46 [ZoneAlgo] Make ZoneAlgorithm::isNormalized out-of-quota safe.
The aosp-O3-polly-before-vectorizer-unprofitable buildbot currently
fails in ZoneAlgorithm::isNormalized, presumably because an
out-of-quota happens in that function.

Modify ZoneAlgorithm::isNormalized to return an isl::boolean such
it can report an error.

In the failing case, it was called in an assertion in ForwardOpTree.
Allow to pass the assertion in an out-of-quota event, a condition that
is later checked before forwarding an operand tree.

llvm-svn: 333709
2018-05-31 22:44:23 +00:00
Tobias Grosser 4dcd83fcd2 Update isl C++ bindings
This update adds new list types and adds functions which convert isl
data types to lists of their contained elements:

  isl::set::get_basic_set_list
  isl::union_set::get_set_list

  isl::map::get_basic_map_list
  isl::union_map::get_map_list

llvm-svn: 333688
2018-05-31 19:48:23 +00:00
Tobias Grosser ce27773a8e Update isl to isl-0.19-173-g77fe2538
Besides other changes, this update introduces functions to translate a
maps and sets into lists of their elements. These lists are useful as
we can define iterators for lists, which allow us to replace many uses
of foreach.

llvm-svn: 333621
2018-05-31 03:59:05 +00:00
Michael Kruse d3ce899ddf [ForwardOpTree] Use less computationally expensive method to compute def-to-target map. NFCI.
When forwarding a LoadInst to another statement, a map that translates
their domain is needed. Before this patch, is was computed by appending
the def-to-use map to the def-to-target of the operand tree's target.

This patch lets the new method getDefToTarget do this. This is
computationally less expensive due to:

 * Caching of the result such that it can be used for multiple operands
   tree to the same target.

 * The map is only computed when there is a LoadInst that needs it.

 * It is only computed for the statement requiring the translator map,
   instead of having an intermediate result for every edge in the
  operand tree.

The downside is that this scheme cannot handle forwarding from a
previous loop iteration (which would require the entire path from
statement to target). Since ForwardOpTree currently does not support
forwarding across loop iterations (SCEV expressions would need to be
transformed), this was not needed anyway.

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

llvm-svn: 333426
2018-05-29 15:19:17 +00:00
Tobias Grosser 9b9c701020 [ScopInfo] Update Scop::addUserContext() to C++ interface
Summary: This patch updates `Scop::addUserContext()` function to the new C++ interface and replaces the `auto` keyword with explicit type wherever used in this function.

Reviewers: grosser, bollu, philip.pfaffe, chelini, Meinersbur

Reviewed By: grosser

Subscribers: llvm-commits

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

llvm-svn: 333366
2018-05-28 07:45:25 +00:00
Philip Pfaffe 7cc4300dac [Acc] Followup for r333105: Fix one additional testcase
llvm-svn: 333168
2018-05-24 10:18:09 +00:00
Tobias Grosser 79e3f2c6e2 Update isl to isl-0.19-152-g437e6ab0
Besides normal updates this change also contains a bug-fix to in
isl_coalesce which broke the AOSP buildbot. Thanks to Michael Kruse for
reporting this bug and Sven Verdoolage for fixing this bug.

llvm-svn: 333118
2018-05-23 20:18:50 +00:00
Tobias Grosser 10da5a0ae7 createNextIterationMap from C to C++ interface
Summary: update createNextIterationMap function to new C++ interface.

Reviewers: grosser, Meinersbur, jdoerfert, bollu, cs15btech11044

Reviewed By: cs15btech11044

Subscribers: llvm-commits, pollydev

Tags: #polly

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

llvm-svn: 333113
2018-05-23 18:41:40 +00:00
Philip Pfaffe 356d60683b [Acc] Enable legacy stmt granularity in remaining failing testcases
The default statement granularity changed in a recent change by Micheal. To
avoid forwad-porting the testcases, enable the legacy behaviour again in these tests.

llvm-svn: 333105
2018-05-23 17:46:10 +00:00
Philip Pfaffe 2e171b52ee [Acc] Update testcases for minor changes in the PPCG mapper and
statement naming

- A recent ppcg/isl update caused the grid/block size upper bounds to
deviate by one from the oracle. This is not an effect that's visible at
runtime.
- Statement naming changed in polly. Update the testcases.

llvm-svn: 333090
2018-05-23 14:56:57 +00:00
Philip Pfaffe c06a6380a0 [Acc] Re-land r326643 to finally fix PR33208.
Other than before, don't clear out LI entirely but only those relevant
loops.

llvm-svn: 333089
2018-05-23 14:52:35 +00:00
Peter Collingbourne 9a45114b3c CodeGen: Add a dwo output file argument to addPassesToEmitFile and hook it up to dwo output.
Part of PR37466.

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

llvm-svn: 332881
2018-05-21 20:16:41 +00:00
Roman Lebedev df4fed6fe7 [polly] Drop nonexistant LLVM_PLUGIN_EXPORT macro from llvmGetPassPluginInfo()
Fixes build:
/build/polly/lib/Support/RegisterPasses.cpp:709:80: error: expected ';' after top level declarator
extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK LLVM_PLUGIN_EXPORT
                                                                               ^
                                                                              ;

Was missed in rL332796 / D47082

llvm-svn: 332814
2018-05-19 19:16:35 +00:00
Eli Friedman e6ed0323cc [SCEVAffinator] BB can be null; don't use it to get the LLVMContext.
Fixes post-commit review comment on r332309.

llvm-svn: 332775
2018-05-18 21:57:44 +00:00
Michael Kruse d6c2ca8dd2 [DeLICM] Avoid assertion on out-of-quota.
An assertion was not prepared to be passed a nullptr because the
out-of-quota limit was exceeded.  Bail-out before the assertion
since the assertion does not apply on out-of-quote.

This fixes llvm.org/PR37477.

llvm-svn: 332488
2018-05-16 16:39:51 +00:00
Philip Pfaffe 9375d57202 [ScopInfo] Remove usage of isl_set_n_basic_set()
Summary: This patch aims to remove the usage of old C-styled isl functions (in this case `isl_set_n_basic_set()`) in favor of new C++ isl interface based methods in `ScopInfo.cpp`.

Patch by Sahil Yerawar

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

llvm-svn: 332471
2018-05-16 14:05:03 +00:00
Philip Pfaffe d477bb9a50 [SI] Create Scop Name lazily
Summary: Creating the Scop name is expensive, because creating the
Region name it's derived from is expensive. So create the name lazily,
because getName() is actually called rarely.

This is a reiteration of r328666, which introduced a use-after-free and
got reverted in r331363.

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

llvm-svn: 332359
2018-05-15 14:53:25 +00:00
Philip Pfaffe 8d1ea73d51 [arc] Remove unittesting from arcconfig
Summary:
Unittests aren't working, and I don't think they ever were. Just remove
them, so that we don't have  to write `arc --nounit` all the time.

Reviewers: grosser, Meinersbur, bollu

Subscribers: bollu, pollydev, llvm-commits

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

llvm-svn: 332355
2018-05-15 13:43:42 +00:00
Nicola Zaghen 349506a926 [polly] Update uses of DEBUG macro to LLVM_DEBUG.
The DEBUG() macro is very generic so it might clash with other projects.
The renaming was done as follows:
- git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g'
- git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM

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

llvm-svn: 332352
2018-05-15 13:37:17 +00:00
Eli Friedman 9ae56b9a0e [SCEVAffinator] Fix handling of pwaff complexity limit.
nullptr is not a valid affine expression, and none of the callers check
for null, so we eventually hit an isl error and crash.

Instead, invalidate the scop and return a constant zero.

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

llvm-svn: 332309
2018-05-14 23:05:43 +00:00
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