summaryrefslogtreecommitdiffstats
path: root/polly/include
Commit message (Collapse)AuthorAgeFilesLines
* Polly: Fix a tag type mismatch (struct/class)David Blaikie2020-01-021-1/+1
|
* Generalize the pass registration mechanism used by Polly to any third-party toolserge_sans_paille2020-01-021-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | There's quite a lot of references to Polly in the LLVM CMake codebase. However the registration pattern used by Polly could be useful to other external projects: thanks to that mechanism it would be possible to develop LLVM extension without touching the LLVM code base. This patch has two effects: 1. Remove all code specific to Polly in the llvm/clang codebase, replaicing it with a generic mechanism 2. Provide a generic mechanism to register compiler extensions. A compiler extension is similar to a pass plugin, with the notable difference that the compiler extension can be configured to be built dynamically (like plugins) or statically (like regular passes). As a result, people willing to add extra passes to clang/opt can do it using a separate code repo, but still have their pass be linked in clang/opt as built-in passes. Differential Revision: https://reviews.llvm.org/D61446
* [NFC][ScopBuilder] Move buildDomains and its callees to ScopBuilder.Dominik Adamski2019-08-062-114/+188
| | | | | | | | | | | | | | | | | | | | Scope of changes: 1) Moved buildDomains function to ScopBuilder class. 2) Moved buildDomainsWithBranchConstraints function to ScopBuilder class. 3) Moved propagateDomainConstraints to ScopBuilder class. 4) Moved propagateDomainConstraintsToRegionExit to ScopBuilder class. 5) Moved propagateInvalidStmtDomains to ScopBuilder class. 6) Moved getPredecessorDomainConstraints function to ScopBuilder class. 7) Moved addLoopBoundsToHeaderDomain function to ScopBuilder class. 8) Moved getPwAff function to ScopBuilder class. 9) Moved buildConditionSets functions to ScopBuilder class. 10) Added updateMaxLoopDepth, notifyErrorBlock, getOrInitEmptyDomain, isDomainDefined, setDomain functions to Scop class. They are used by ScopBuilder. 11) Moved helper functions: getRegionNodeBasicBlock, getRegionNodeSuccessor, containsErrorBlock, createNextIterationMap, collectBoundedParts, partitionSetParts, buildConditionSet to ScopBuilder.cpp file. Differential Revision: https://reviews.llvm.org/D65729 llvm-svn: 368100
* [NFC][ScopBuilder] Move addUserAssumptions to ScopBuilderDominik Adamski2019-08-062-17/+58
| | | | | | | | | | | Scope of changes: 1) Moved addUserAssumptions function to ScopBuilder class. 2) Moved buildConditionSets functions to polly namespace. 3) Moved getRepresentingInvariantLoadSCEV to public section of the Scop class Differential Revision: https://reviews.llvm.org/D65241 llvm-svn: 368089
* [Polly] Clang complains about missing virtual destructorGuillaume Chatelet2019-07-221-0/+2
| | | | | | | | | | | | | | | | Summary: Feel free to reassign if needed. Reviewers: mhalk, bollu, jdoerfert Reviewed By: jdoerfert Subscribers: jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64786 llvm-svn: 366697
* [NFC][ScopBuilder] Move buildSchedule and its callees to ScopBuilder or ↵Dominik Adamski2019-07-173-60/+78
| | | | | | | | | | | | | | | | | | ScopHelper Scope of changes: 1. Moved buildSchedule functions to ScopBuilder. 2. Moved combineInSequence function to ScopBuilder. 3. Moved mapToDimension function to ScopBuilder. 4. Moved LoopStackTy to ScopBuilder. 5. Moved getLoopSurroundingScop to ScopHelper. 6. Moved getNumBlocksInLoop to ScopHelper. 7. Moved getNumBlocksInRegionNode to ScopHelper. 8. Moved getRegionNodeLoop to ScopHelper. Differential Revision: https://reviews.llvm.org/D64223 llvm-svn: 366377
* [NFC][ScopBuilder]Move finalizeAccesses and its callees to ScopBuilderDominik Adamski2019-07-172-63/+69
| | | | | | | | | | | | | | | Scope of changes: 1) Moved finalizeAccesses to ScopBuilder 2) Moved updateAccessDimensionality to ScopBuilder 3) Moved foldSizeConstantsToRight to ScopBuilder 4) Moved foldSizeConstantsToRight to ScopBuilder 5) Moved assumeNoOutOfBounds to ScopBuilder 6) Moved markFortranArrays to ScopBuilder 7) Added iterator range for AccessFunctions vector. Differential Revision: https://reviews.llvm.org/D63794 llvm-svn: 366374
* [NFC][ScopBuilder] Move addUserContext to ScopBuilderDominik Adamski2019-07-162-3/+3
| | | | | | | | | | Scope of changes: 1) Moved addUserContext to ScopBuilder. 2) Moved command line option UserContextStr to ScopBuilder. Differential Revision: https://reviews.llvm.org/D63740 llvm-svn: 366266
* [NFC][ScopBuilder] Move buildAliasChecks and its implementing methods to ↵Dominik Adamski2019-07-162-50/+66
| | | | | | | | | | | | | | | | | | | | | | | | ScopBuilder Scope of changes: 1) Moved buildAliasChecks to ScopBuilder. 2) Moved buildAliasGroup to ScopBuilder. 3) Moved buildAliasGroups to ScopBuilder. 4) Moved buildAliasGroupsForAccesses to ScopBuilder. 5) Moved splitAliasGroupsByDomain to ScopBuilder. 6) Moved addNonEmptyDomainConstraints to ScopBuilder. 7) Moved buildMinMaxAccess to ScopBuilder. 8) Moved calculateMinMaxAccess to ScopBuilder. 9) Moved getAccessDomain to ScopBuilder. 10) Moved command line options used only by buildAliasChecks functions to ScopBuilder. 11) Refactored buildAliasGroup function. Added addAliasGroup function to Scop class for pushing back calculated min/max accesses. 12) Added function incrementNumberOfAliasingAssumptions which increments number of statistic variable AssumptionsAliasing. AssumptionsAliasing variable is defined by STATISTIC macro inside ScopInfo.cpp and it is also used by function trackAssumption from Scop class. 13) Added reference to OptimizationRemarkEmitter to ScopBuilder class. 14) Moved calculateMinMaxAccess function to ScopBuilder class. Differential Revision: https://reviews.llvm.org/D63693 llvm-svn: 366262
* [NFC][ScopBuilder] Move addRecordedAssumption to ScopBuilderDominik Adamski2019-07-162-22/+32
| | | | | | | | | | | | | Scope of changes: 1) Moved addRecordedAssumptions to ScopBuilder. 2) Moved Assumption struct outside Scop class. 3) Refactored addRecordedAssumptions function. Replaced while loop by for range loop. 4) Added function to clear processed Assumptions. Differential Revision: https://reviews.llvm.org/D63572 llvm-svn: 366260
* [ScopInfo][NFC] Add dot at the end of comment statement.Dominik Adamski2019-07-151-1/+1
| | | | llvm-svn: 366134
* [ScopBuilder] Move addInvariantLoads to ScopBuilder. NFC.Michael Kruse2019-06-122-8/+14
| | | | | | | | | | | | | | | | | | | Moved addInvariantLoads and functions listed below to ScopBuilder: isAParameter canAlwaysBeHoisted These functions were referenced only by getNonHoistableCtx. Moved CLI parameter PollyAllowDereferenceOfAllFunctionParams to ScopBuilder. Added iterator range through InvariantEquivClasses. Patch by Dominik Adamski <adamski.dominik@gmail.com> Differential Revision: https://reviews.llvm.org/D63172 llvm-svn: 363216
* [ScopBuilder] Move getNonHoistableCtx to ScopBuilder. NFC.Michael Kruse2019-06-122-17/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | This review is based on review: https://reviews.llvm.org/D62925 . It is part of moving hoistInvariantLoads function and all functions referenced only by hoistInvariantLoads to ScopBuilder. Moved getNonHoistableCtx and functions listed below to ScopBuilder: isRequiredInvariantLoad hasNonHoistableBasePtrInScop isAccessRangeTooComplex These functions were referenced only by getNonHoistableCtx. MaxDimensionsInAccessRange and MaxDisjunctsInDomain constant is marked as extern and it is added to polly namespace. It is used by Scop and ScopBuilder classes. MaxDimensionsInAccessRange constant moved to ScopBuilder. It is not used outside ScopBuilder. Patch by Dominik Adamski <adamski.dominik@gmail.com> Differential Revision: https://reviews.llvm.org/D63066 llvm-svn: 363214
* [ScopBuilder] Move hoistInvariantLoads to ScopBuilder. NFC.Michael Kruse2019-06-122-31/+31
| | | | | | | | | | | | | | | | | Refactor Scop and ScopBuilder class: 1. Move hoistInvariantLoads function from Scop to ScopBuilder class. 2. Private functions (addInvariantLoads, getNonHoistableCtx) are moved to public section of Scop class. hoistInvariantLoads function references these functions. These functions will be moved to ScopBuilder as well in the next steps. Patch by Dominik Adamski <adamski.dominik@gmail.com> Differential Revision: https://reviews.llvm.org/D62925 llvm-svn: 363121
* [ScopBuilder] Move canonicalizeDynamicsBasePtrs from ScopInfo. NFC.Michael Kruse2019-06-042-28/+28
| | | | | | | | | | | Refactor Scop and ScopBuilder class. Move canonicalizeDynamicsBasePtrs and corresponding static functions from ScopInfo.cpp to ScopBuilder.cpp Patch by Dominik Adamski <adamski.dominik@gmail.com> Differential Revision: https://reviews.llvm.org/D62781 llvm-svn: 362554
* [ScopBuilder] Move verifyInvariantLoads function from ScopInfo. NFC.Michael Kruse2019-05-312-15/+15
| | | | | | | | | | | Refactor Scop and ScopBuilder class. Move verifyInvariantLoads from Scop class to ScopBuilder class. Patch by: Dominik Adamski <adamski.dominik@gmail.com> Differential Revision: https://reviews.llvm.org/D62628 llvm-svn: 362258
* [ScheduleOptimizer] Hoist extension nodes after schedule optimization.Michael Kruse2019-05-312-5/+26
| | | | | | | | | | | | | | | | | | | | | | Extension nodes make schedule trees are less flexible: Many operations, such as rescheduling, do not work on such schedule trees with extension. As such, some functionality such as determining parallel loops in isl's AST are disabled. Currently, only the pattern-matching generalized matrix-matrix multiplication optimization adds extension nodes (to add copy-in statements). This patch removes all extension nodes as the last step of the schedule optimization by hoisting the extension node's added domain up to the root domain node. All following passes can assume that schedule trees work without restrictions, including the parallelism test. Mark the outermost loop of the optimized matrix-matrix multiplication as parallel such that -polly-parallel is able to parallelize that loop. Differential Revision: https://reviews.llvm.org/D58202 llvm-svn: 362257
* [ScopBuilder] Move buildInvariantEquivalenceClasses function from ScopInfo. NFC.Michael Kruse2019-05-282-14/+26
| | | | | | | | | | | | Refactor Scop and ScopBuilder class. Move buildInvariantEquivalenceClasses function from Scop class to ScopBuilder class. Patch by: Dominik Adamski <adamski.dominik@gmail.com> Differential Revision: https://reviews.llvm.org/D62351 llvm-svn: 361902
* [polly] Fix non-determinism in IslNodeBuilder.Eli Friedman2019-05-141-1/+1
| | | | | | | | | The iteration order of OutsideLoopIterations matters for IslNodeBuilder::getReferencesInSubtree, which inserts the values from the map into a SetVector, which is eventually used to construct the type of the context for parallel loops. llvm-svn: 360723
* [ZoneAlgo] Fix PHI inconsistency in invalid contexts.Michael Kruse2019-05-101-0/+15
| | | | | | | | | | PHI nodes (reads) could point to multiple instances of predecessor blocks (PHI writes) when in an invalid context. Fix by removing PHI instances that are in an invalid or ouside assumed context. This fixes llvm.org/PR41656. llvm-svn: 360454
* [polly][SCEV] Expand SCEV matcher cases for new smin/umin opsKeno Fischer2019-05-081-0/+2
| | | | | | | These were added in rL360159, but I neglected to update polly at the same time. llvm-svn: 360238
* Apply include-what-you-use #include removal suggestions. NFC.Michael Kruse2019-03-2826-277/+17
| | | | | | | | | | | | This removes unused includes (and forward declarations) as suggested by include-what-you-use. If a transitive include of a removed include is required to compile a file, I added the required header (or forward declaration if suggested by include-what-you-use). This should reduce compilation time and reduce the number of iterative recompilations when a header was changed. llvm-svn: 357209
* [CodeGen] LLVM OpenMP Backend.Michael Kruse2019-03-193-36/+276
| | | | | | | | | | | | | | | | | | | | | The ParallelLoopGenerator class is changed such that GNU OpenMP specific code was removed, allowing to use it as super class in a template-pattern. Therefore, the code has been reorganized and one may not use the ParallelLoopGenerator directly anymore, instead specific implementations have to be provided. These implementations contain the library-specific code. As such, the "GOMP" (code completely taken from the existing backend) and "KMP" variant were created. For "check-polly" all tests that involved "GOMP": equivalents were added that test the new functionalities, like static scheduling and different chunk sizes. "docs/UsingPollyWithClang.rst" shows how the alternative backend may be used. Patch by Michael Halkenhäuser <michaelhalk@web.de> Differential Revision: https://reviews.llvm.org/D59100 llvm-svn: 356434
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1944-176/+132
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [TI removal] Make `getTerminator()` return a generic `Instruction`.Chandler Carruth2018-10-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This removes the primary remaining API producing `TerminatorInst` which will reduce the rate at which code is introduced trying to use it and generally make it much easier to remove the remaining APIs across the codebase. Also clean up some of the stragglers that the previous mechanical update of variables missed. Users of LLVM and out-of-tree code generally will need to update any explicit variable types to handle this. Replacing `TerminatorInst` with `Instruction` (or `auto`) almost always works. Most of these edits were made in prior commits using the perl one-liner: ``` perl -i -ple 's/TerminatorInst(\b.* = .*getTerminator\(\))/Instruction\1/g' ``` This also my break some rare use cases where people overload for both `Instruction` and `TerminatorInst`, but these should be easily fixed by removing the `TerminatorInst` overload. llvm-svn: 344504
* [IslAst] Fix InParallelFor nesting.Michael Kruse2018-09-271-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IslAst could mark two nested outer loops as "OutermostParallel". It caused that the code generator tried to OpenMP-parallelize both loops, which it is not prepared loop. It was because the recursive AST build algorithm managed a flag "InParallelFor" to ensure that no nested loop is also marked as "OutermostParallel". Unfortunatetly the same flag was used by nodes marked as SIMD, and reset to false after the SIMD node. Since loops can be marked as SIMD inside "OutermostParallel" loops, the recursive algorithm again tried to mark loops as "OutermostParellel" although still nested inside another "OutermostParallel" loop. The fix exposed another bug: The function "astScheduleDimIsParallel" was only called when a loop was potentially "OutermostParallel" or "InnermostParallel", but as a side-effect also determines the minimum dependence distance. Hence, changing when we need to know whether a loop is "OutermostParallel" also changed which loop was annotated with "#pragma minimal dependence distance". Moreover, some complex condition linked with "InParallelFor" determined whether a loop should be an "InnermostParallel" loop. It missed some situations where it would not use mark as such although being inside an SIMD mark node, and therefore not be annotated using "#pragma simd". The changes in particular: 1. Split the "InParallelFor" flag into an "InParallelFor" and an "InSIMD" flag. 2. Unconditionally call "astScheduleDimIsParallel" for its side-effects and store the result in "InParallel" for later use. 3. Simplify the condition when a loop is "InnermostParallel". Fixes llvm.org/PR33153 and llvm.org/PR38073. llvm-svn: 343212
* [PerfMonitor] Fix rdtscp callsitesTobias Grosser2018-09-111-6/+1
| | | | | | | | | | | | | Summary: Update all rdtscp callsites in PerfMonitor so that they conform with the signature changes introduced in r341698. Reviewers: grosser, bollu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D51928 llvm-svn: 341946
* [DepInfo] Use isl++ in Dependences::isValidSchedule. NFC.Michael Kruse2018-08-101-2/+3
| | | | | | | Also change StatementToIslMapTy to hold isl::map, because it is used as a parameter. llvm-svn: 339484
* [ScopBuilder] Set domain to empty instead of NULL.Michael Kruse2018-08-011-1/+1
| | | | | | | | | | | | | | The domain generation used nullptr to mark the domain of an error block as never-executed. Later, nullptr domains are recreated with a zero-tuple domain that then mismatches with the expected domain the error block within the loop. Instead of using nullptr, assign an empty domain which preserves the expected space. Remove empty domains during SCoP simplification. Fixes llvm.org/PR38218. llvm-svn: 338646
* [CodeGen] Convert IslNodeBuilder::getNumberOfIterations to isl++. NFC.Michael Kruse2018-07-311-1/+1
| | | | llvm-svn: 338451
* [CodeGen] Convert IslNodeBuilder::createForSequential to isl++. NFC.Michael Kruse2018-07-311-1/+1
| | | | llvm-svn: 338450
* [CodeGen] Convert IslNodeBuilder::getUpperBound to isl++. NFC.Michael Kruse2018-07-311-2/+1
| | | | llvm-svn: 338449
* [isl] Simplify iterator implementation by building on top of list accessorsPhilip Pfaffe2018-07-231-64/+26
| | | | | | | | | | | | | | | | | | Summary: With the new accessors, it's straightforward to use the templated iterator instead of subclassing it for all the list types. Depends on D49019 Reviewers: grosser, Meinersbur, bollu Reviewed By: grosser Subscribers: mehdi_amini, steven_wu, dexonsmith, pollydev, llvm-commits Differential Revision: https://reviews.llvm.org/D49021 llvm-svn: 337702
* [IslNodeBuilder] Use isl++ to replace foreach_set with for loopTobias Grosser2018-07-171-2/+2
| | | | llvm-svn: 337247
* [NFC] Fix formatting to appease buildersPhilip Pfaffe2018-06-291-1/+2
| | | | llvm-svn: 335952
* Implement an iterator for isl maps, basic_maps, sets, basic_setsPhilip Pfaffe2018-06-291-0/+90
| | | | | | | | | | | | | | | | | | | | | | | 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
* [ScopHelper] Provide support for recognising collective invariant loadsPhilip Pfaffe2018-06-291-1/+3
| | | | | | | | | | | | | | 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
* [ZoneAlgo] Use getDefToTarget in makeValInst. NFC.Michael Kruse2018-06-261-0/+34
| | | | | | | | | | | | 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
* [OpTree] Introduce shortcut for computing the def->target mapping. NFCI.Michael Kruse2018-06-061-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* getDependences to new C++ interfaceTobias Grosser2018-06-061-1/+1
| | | | | | | | | | | | | | 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
* [ZoneAlgo] Make ZoneAlgorithm::isNormalized out-of-quota safe.Michael Kruse2018-05-311-2/+2
| | | | | | | | | | | | | | | 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
* [SI] Create Scop Name lazilyPhilip Pfaffe2018-05-151-2/+7
| | | | | | | | | | | | | 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
* [SCEVAffinator] Fix handling of pwaff complexity limit.Eli Friedman2018-05-141-0/+1
| | | | | | | | | | | 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
* Revert "[polly] [ScopInfo] Don't pre-compute the name of the Scop's region."Philip Pfaffe2018-05-021-1/+4
| | | | | | | | | 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
* Remove the last uses of isl::give and isl::takeTobias Grosser2018-04-291-5/+0
| | | | llvm-svn: 331126
* [CodeGen] Fix comment. NFC.Michael Kruse2018-04-251-2/+2
| | | | llvm-svn: 330865
* [CodeGen] Print executed statement instances at runtime.Michael Kruse2018-04-252-1/+42
| | | | | | | | | | | | | 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
* [ScopDetect] Reject loop with multiple exit blocks.Michael Kruse2018-04-251-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Allow arbitrary function calls for debugging purposes.Michael Kruse2018-04-201-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [RuntimeDebugBuilder] Print vectors passed without withspacesTobias Grosser2018-04-181-8/+2
| | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud