summaryrefslogtreecommitdiffstats
path: root/polly/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
* [PM] Convert Polly over to directly use the legacy pass managerChandler Carruth2015-02-131-1/+1
| | | | | | | | | namespace and header rather than the top-level header and using declarations. These helpers impede modular builds and are going away. Migrating away from them will also be necessary to start mixing in any usage of the new pass manager. llvm-svn: 229091
* Add early exits for SCoPs we did not optimizeJohannes Doerfert2015-02-112-9/+57
| | | | | | | | | | | | | This allows us to skip ast and code generation if we did not optimize a SCoP and will not generate parallel or alias annotations. The initial heuristic to exit is simple but allows improvements later on. All failing test cases have been modified to disable early exit, thus to keep their coverage. Differential Revision: http://reviews.llvm.org/D7254 llvm-svn: 228851
* [Refactor] Use the LoopInfo object already presentJohannes Doerfert2015-02-081-10/+4
| | | | llvm-svn: 228540
* [Refactor] Use only one BlockGenerator for a SCoPJohannes Doerfert2015-02-062-98/+102
| | | | | | | | | | | | | | | | This change has two main purposes: 1) We do not use a static interface to hide an object we create and destroy for every basic block we copy. 2) We allow the BlockGenerator to store information between calls to the copyBB method. This will ease scalar/phi code generation later on. While a lot of method signatures were changed this should not cause any real behaviour change. Differential Revision: http://reviews.llvm.org/D7467 llvm-svn: 228443
* [FIX] Partially fix the pointer negation crashJohannes Doerfert2015-02-021-2/+39
| | | | llvm-svn: 227805
* [FIX] Handle pointer-pointer comparisonsJohannes Doerfert2015-01-291-2/+26
| | | | | | This should fix a problem introduced by r225464. llvm-svn: 227404
* [FIX] Debug build + instrinsic handlingJohannes Doerfert2015-01-261-0/+24
| | | | | | | The ignored intrinsics needed to be ignored in three other places as well. Tests and lnt pass now. llvm-svn: 227092
* Support for math/misc intrinsicsJohannes Doerfert2015-01-251-0/+24
| | | | | | | | | The support is currently limited as we only allow them in the input but do not emit them in the transformed SCoP due to the possible semantic changes. Differential Revision: http://reviews.llvm.org/D5225 llvm-svn: 227054
* CodeGen: Update IRBuilder for LLVM API changeDuncan P. N. Exon Smith2015-01-191-3/+2
| | | | | | `MDNode::getTemporary()` returns a `unique_ptr<>` as of r226504. llvm-svn: 226506
* [PM] Update Polly for LLVM r226459 which removed another pass argumentChandler Carruth2015-01-191-2/+2
| | | | | | from an API in the process of preparing for the new pass manager. llvm-svn: 226460
* Remove redundant semicolon clang-format complained aboutTobias Grosser2015-01-181-2/+2
| | | | llvm-svn: 226402
* [PM] Update Polly for LLVM r226394 and r226396 which changed some of theChandler Carruth2015-01-183-5/+15
| | | | | | | block splitting interfaces to accept specific analyses rather than a pass. llvm-svn: 226398
* [PM] Update Polly for LLVM r226385 which made LoopInfo actually deriveChandler Carruth2015-01-183-6/+6
| | | | | | | from LoopInfoBase<...>, removing the need for the awkward getBase() dance. llvm-svn: 226387
* [PM] Update Polly following LLVM r226373 which refactors LoopInfo inChandler Carruth2015-01-173-9/+9
| | | | | | preparation for the new pass manager. llvm-svn: 226374
* [PM] Track an LLVM API change by switching this code to directly createChandler Carruth2015-01-151-3/+1
| | | | | | the wrapper pass for TLI which is now separate from the core class. llvm-svn: 226159
* [PM] Update for LLVM r226078 which moved TargetLibraryInfo to theChandler Carruth2015-01-151-1/+1
| | | | | | Analysis library. llvm-svn: 226080
* Use types of matching size when generating multi-dimensional address expressionsTobias Grosser2015-01-131-3/+12
| | | | | | | | | | This change ensures that the values that represent the array size of a multi-dimensional access are correctly sign-extended when used to compute a memory address used in the run-time alias check. To make the test case more readable, we name the instructions that we generate. llvm-svn: 225818
* Check assert before the instruction that uses the assumption checked.Tobias Grosser2015-01-101-2/+3
| | | | | | I did not find a good test case, as the assert should generally hold in Polly. llvm-svn: 225582
* Add support for pointer types in expressionsTobias Grosser2015-01-082-5/+7
| | | | llvm-svn: 225464
* Use explicit StringRef TypeTobias Grosser2015-01-071-1/+1
| | | | | | | | | | We previously used a Twine here, but as pointed out by David Blaikie and Mehdi Amini storing a temporary StringRef in a Twine is not a good idea, as the StringRef will be freed before the Twine is used leaving a Twine that points to uninitialized memory. We now make it explicit that we use a StringRef here. llvm-svn: 225342
* Do not use a const Twine hereTobias Grosser2015-01-071-1/+1
| | | | | | | This has caused segfaults when using Polly in the context of Julia, that are not reproducible on my machine in 'make check-polly'. llvm-svn: 225326
* Unbreak after LLVM's metadata split in r223802Tobias Grosser2014-12-091-4/+4
| | | | llvm-svn: 223838
* Stop relying on MDNode::get() returning self-referencesDuncan P. N. Exon Smith2014-12-071-2/+3
| | | | | | | | | | | | | Update for LLVM API change, wherein self-references are not uniqued (and will never be returned by `MDNode::get()`). We already have `Id`; just return it. This should fix the failing buildbot: http://lab.llvm.org:8011/builders/polly-amd64-linux/builds/25167 http://lab.llvm.org:8011/builders/polly-amd64-linux/builds/25168 llvm-svn: 223620
* Update to the latest version of islTobias Grosser2014-12-071-0/+3
| | | | | | | | | | Isl now specifically marks modulo operations that are compared against zero. They can be implemented with the C/LLVM remainder operation. We also update a couple of test cases where the output of isl has slightly changed. llvm-svn: 223607
* Drop Cloog supportJohannes Doerfert2014-12-022-1472/+0
| | | | | | | | | This commit drops the Cloog support for Polly. The scripts and documentation are changed to only use isl as prerequisity. In the code all Cloog specific parts have been removed and all relevant tests have been ported to the isl backend when it was created. llvm-svn: 223141
* Remove -polly-codegen-scev option and related codeTobias Grosser2014-11-303-40/+8
| | | | | | | | SCEV based code generation has been the default for two weeks after having been tested for a long time. We now drop the support the non-scev-based code generation. llvm-svn: 222978
* Add PreHeader always to OuterLoopTobias Grosser2014-11-251-3/+4
| | | | | | This fixes a bug introduce in r217525. llvm-svn: 222766
* Enable SCEV based code generation by defaultTobias Grosser2014-11-161-1/+1
| | | | | | | | | | | | | | | | | | | SCEV based code generation allows Polly to detect and generate code for loops that do not have an explicit induction variable, but only virtual induction variables given by SCEV. Being able to do so has two main benefits: - We can detect more scops by default - We require less canonicalization before Polly, which means we get closer to our goal of not touching the IR before analyzing its properties. Specifically, we do not need to run -polly-indvars to introduce explicit canonical induction variables. This switch became possible as both the isl code generation and -polly-parallel are LNT error free with SCEV based code generation and the isl ast generator. llvm-svn: 222113
* Fix formattingTobias Grosser2014-11-161-1/+2
| | | | llvm-svn: 222106
* Introduce minimalistic cost model for auto parallelizationTobias Grosser2014-11-161-2/+22
| | | | | | | | | | | | | | | | | | Instead of parallelizing every parallel outermost loop, we now use a very minimalistic cost model. Specifically, we assume innermost loops are not worth parallelising and all non-innermost loops are. When parallelizing all loops in LNT we got several slowdowns/timeouts due to us parallelizing innermost loops that are executed only a couple of times (number of iterations not known statically). With this basic heuristic enabled LNT does not show any more timeouts, while several interesting loops are still parallelized. There are many ways to obtain an improved heuristic. Constructing such an improvide heuristic from a position of minimal slow-down and zero code size increase seems to be the best, as it allows us to track progress on LNT. llvm-svn: 222096
* Add OpenMP code generation to isl backendTobias Grosser2014-11-151-7/+329
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This backend supports besides the classical code generation the upcoming SCEV based code generation (which the existing CLooG backend does not support robustly). OpenMP code generation in the isl backend benefits from our run-time alias checks such that the set of loops that can possibly be parallelized is a lot larger. The code was tested on LNT. We do not regress on builds without -polly-parallel. When using -polly-parallel most tests work flawlessly, but a few issues still remain and will be addressed in follow up commits. SCEV/non-SCEV codegen: - Compile time failure in ldecod and TimberWolfMC due a problem in our run-time alias check generation triggered by pointers that escape through the OpenMP subfunction (OpenMP specific). - Several execution time failures. Due to the larger set of loops that we now parallelize (compared to the classical code generation), we currently run into some timeouts in tests with a lot loops that have a low trip count and are slowed down by parallelizing them. SCEV only: - One existing failure in lencod due to llvm.org/PR21204 (not OpenMP specific) OpenMP code generation is the last feature that was only available in the CLooG backend. With the isl backend being the only one supporting features such as run-time alias checks and delinearization, we will soon switch to use the isl ast generator by the default and subsequently remove our dependency on CLooG. http://reviews.llvm.org/D5517 llvm-svn: 222088
* Use nullptr instead of '0' for pointersTobias Grosser2014-11-142-2/+2
| | | | llvm-svn: 221982
* Safely generate new loop metadata nodeDavid Peixotto2014-11-071-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Polly was accidently modifying a debug info metadata node when attempting to generate a new unique metadata node for the loop id. The problem was that we had dwarf metadata that referred to a metadata node with a null value, like this: !6 = ... some dwarf metadata referring to !7 ... !7 = {null} When we attempt to generate a new metadata node, we reserve the first space for self-referential node by setting the first argument to null and then mutating the node later to refer to itself. However, because the nodes are uniqued based on pointer values, when we get the new metadata node it actually referred to an existing node (!7 in the example). When we went to modify the metadata to point to itself, we were accidently mutating the dwarf metatdata. We ended up in this situation: !6 = ... some dwarf metadata referring to !7 ... !7 = {!7} and this causes an assert when generating the debug info. The fix is simple, we just need to use a unique value when getting a new metadata node. The MDNode::getTemporary() provides exactly the API we need (and it is used in clang to generate the unique nodes). Differential Revision: http://reviews.llvm.org/D6174 llvm-svn: 221550
* Fix formattingTobias Grosser2014-11-061-3/+4
| | | | llvm-svn: 221483
* Explicitly annotate loops we want to run thread-parallelTobias Grosser2014-11-061-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We introduces a new flag -polly-parallel and use it to annotate the for-nodes in the isl ast that we want to execute thread parallel (e.g., using OpenMP). We previously already emmitted openmp annotations, but we did this for various kinds of parallel loops, including some which we can not run in parallel. With this patch we now have three annotations: 1) #pragma known-parallel [reduction] 2) #pragma omp for 3) #pragma simd meaning: 1) loop has no loop carried dependences 2) loop will be executed thread-parallel 3) loop can possibly be vectorized This patch introduces 1) and reduces the use of 2) to only the cases where we will actually generate thread parallel code. It is in preparation of openmp code generation in our isl backend. Legacy: - We also have a command line option -enable-polly-openmp. This option controls the OpenMP code generation in CLooG. It will become an alias of -polly-parallel after the CLooG code generation has been dropped. http://reviews.llvm.org/D6142 llvm-svn: 221479
* Extract SCEV generation into subfunctionTobias Grosser2014-11-061-8/+16
| | | | | | | This makes the code more readable and will be reused in subsequent OpenMP patches. llvm-svn: 221418
* BlockGenerator: Recompute values from SCEV before handing back the original ↵Tobias Grosser2014-11-051-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | values This patch moves the SCEV based (re)generation of values before the checking for scop-constant terms. It enables us to provide SCEV based replacements, which are necessary to correctly generate OpenMP subfunctions when using the SCEV based code generation. When recomputing a new value for a value used in the code of the original scop, we previously directly returned the same original value for all scop-constant expressions without even trying to regenerate these values using our SCEV expression. This is correct when the newly generated code remains fully in the same function, however in case we want to outline parts of the newly generated scop into subfunctions, this approach means we do not have any opportunity to update these values in the SCEV based code generation. (In the non-SCEV based code generation, we can provide such updates through the GlobalMap). To ensure we have this opportunity, we first try to regenerate scalar terms with our SCEV builder and will only return scop-constant expressions if SCEV based code generation was not possible. This change should not affect the results of the existing code generation passes. It only impacts the upcoming OpenMP based code generation. This commit also adds a test case. This test case passes before and after this commit. It was added to ensure test coverage for the changed code. llvm-svn: 221393
* BlockGenerator: inline lookupAvailableValue into getValue [NFC]Tobias Grosser2014-11-051-11/+3
| | | | | | | | | | | There was no good reason why this code was split accross two functions. In subsequent changes we will change the order in which values are looked up. Doing so would make the split into two functions even more arbitrary. We also slightly improve the documentation. llvm-svn: 221388
* Use argument type directly from fflush if available in translation unitTobias Grosser2014-11-041-1/+7
| | | | | | | | | | | | | | | When our RuntimeDebugBuilder calles fflush(NULL) to flush all output streams, it is important that the types we use in the call match the ones used in a declaration of fflush possible already available in the translation unit. As we just pass on a NULL pointer, the type of the pointer value does not really matter. However, as LLVM complains in case of mismatched types, we make sure to create a NULL pointer of identical type. No test case, as RuntimeDebugBuilder is not permanently used in Polly. Calls to it are until now only used to add informative output during debugging sessions. llvm-svn: 221251
* Delete some unnecessary codeTobias Grosser2014-10-291-12/+0
| | | | | | | | | Originally we have needed this code to map the isl_id of an array to its base pointer. However, as now the isl_id contains a reference to the array itself we obtain the base pointer from this isl_id and we do not need to add this information to the IDToValue map. llvm-svn: 220876
* Remove incorrect value description for -enable-polly-alignedTobias Grosser2014-10-221-5/+4
| | | | | | | | | The description of the parameter value passed to -enable-polly-aligned did not make any sense at all, but was just a leftover coming from when this option was copied form -enable-polly-openmp. We just drop it as the option description gives sufficient information already. llvm-svn: 220445
* Use stringFromIslObj instead of isl_..._dump to print to dbgs()Tobias Grosser2014-10-221-1/+5
| | | | | | | | | This makes sure we consistently use dbgs() when printing debug output. Previously, the code just mixed calls to isl_*_dump() with printing to dbgs() and was relying for both methods to interact in predictable ways (same output stream, no unexpected reordering of outputs). llvm-svn: 220443
* Use braces in multi-statement DEBUG() code [NFC]Tobias Grosser2014-10-221-1/+1
| | | | | | | | | | | | | | | | | | By adding braces into the DEBUG statement we can make clang-format format code such as: DEBUG(stmt1(); stmt2()) as multi-line code: DEBUG({ stmt1(); stmt2(); }); This makes control-flow in debug statements easier to read. llvm-svn: 220441
* [Refactor][NfC] Simplify and clean the handling of (new) access relationsJohannes Doerfert2014-10-131-17/+5
| | | | | | | | | | | | | | | This patch does not change the semantic on it's own. However, the dependence analysis as well as dce will now use the newest available access relation for each memory access, thus if at some point the json importer or any other pass will run before those two and set a new access relation the behaviour will be different. In general it is unclear if the dependence analysis and dce should be run on the old or new access functions anyway. If we need to access the original access function from the outside later, we can expose the getter again. Differential Revision: http://reviews.llvm.org/D5707 llvm-svn: 219612
* [Refactor][NFC] Simplify (Vector)BlockGeneratorJohannes Doerfert2014-10-081-5/+2
| | | | | | | | This removes an unnecessary cast and a unnecessary local variable. Differential Revision: http://reviews.llvm.org/D5662 llvm-svn: 219338
* Allow the VectorBlockGenerator to use the IslExprBuilder.Johannes Doerfert2014-10-082-14/+16
| | | | | | | This also enables the VectorBlockGenerator to build load store accesses according to the newAccessRelation of a MemoryAccess. llvm-svn: 219321
* [Fix] Non i1 typed select condition for weird pw aff functions.Johannes Doerfert2014-10-071-0/+2
| | | | | | | | | | | | | | | | | | | In case the pieceweise affine function used to create an isl_ast_expr had empty cases (e.g., with contradicting constraints on the parameters), it was possible that the condition of the isl_ast_expr select was not a comparison but a constant (thus of type i64). This patch does two thing: 1) Handle the case the condition of a select is not a i1 type like C. 2) Try to simplify the pieceweise affine functions for the min/max access when we generate runtime alias checks. That step can often remove empty or redundant cases as well as redundant constrains. This fixes bug: http://llvm.org/PR21167 Differential Revision: http://reviews.llvm.org/D5627 llvm-svn: 219208
* Allow multidimensional accesses in the IslExprBuilder.Johannes Doerfert2014-10-052-11/+33
| | | | | | | | | This resolved the issues with delinearized accesses that might alias, thus delinearization doesn't deactivate runtime alias checks anymore. Differential Revision: http://reviews.llvm.org/D5614 llvm-svn: 219078
* Introduce the ScopArrayInfo class.Johannes Doerfert2014-10-052-27/+16
| | | | | | | | | | | | | | | | | | | This class allows to store information about the arrays in the SCoP. For each base pointer in the SCoP one object is created storing the type and dimension sizes of the array. The objects can be obtained via the SCoP, a MemoryAccess or the isl_id associated with the output dimension of a MemoryAccess (the description of what is accessed). So far we use the information in the IslExprBuilder to create the right base type before indexing into the base array. This fixes the bug http://llvm.org/bugs/show_bug.cgi?id=21113 (both test cases are included). On top of that we can now build runtime alias checks for delinearized arrays as the dimension sizes are also part of the ScopArrayInfo objects. Differential Revision: http://reviews.llvm.org/D5613 llvm-svn: 219077
* [Fix] Accidently changed the type of a libgomp argument in r219003.Johannes Doerfert2014-10-031-3/+3
| | | | | | | Only subsequent patches introduced tests for the signature in the generated IR, thus the tests were wrong too and are adjusted now. llvm-svn: 219017
OpenPOWER on IntegriCloud