summaryrefslogtreecommitdiff
path: root/polly/lib/CodeGen/LoopGenerators.cpp
AgeCommit message (Collapse)Author
2025-04-28[RemoveDI][Polly] Migrate to adapt to the new DebugRecord format in more ↵Karthika Devi C
areas (#135935) Some of the changes in the patch include: 1. Using iterators instead of instruction pointers when applicable. 2. Modifying Polly functions to accept iterators instead of inst pointers. 3. Updating API usages such as use begin instead of front.
2025-04-24[RemoveDI][Polly] Use iterators instead of instruction pointers to ↵Karthika Devi C
SetInsertPoint (#135336) As part of the effort to transition to using Debug Records instead of Debug intrinsics, some API/argument changes are necessary to achieve the desired behavior from Debug Records. This particular fix involves passing iterators instead of instruction pointers to the SetInsertPoint function. While this is crucial in certain areas, it may be more than needed in others, but it does not cause any harm.
2025-01-24[NFC][DebugInfo] Use iterator-flavour getFirstNonPHI at many call-sites ↵Jeremy Morse
(#123737) As part of the "RemoveDIs" project, BasicBlock::iterator now carries a debug-info bit that's needed when getFirstNonPHI and similar feed into instruction insertion positions. Call-sites where that's necessary were updated a year ago; but to ensure some type safety however, we'd like to have all calls to getFirstNonPHI use the iterator-returning version. This patch changes a bunch of call-sites calling getFirstNonPHI to use getFirstNonPHIIt, which returns an iterator. All these call sites are where it's obviously safe to fetch the iterator then dereference it. A follow-up patch will contain less-obviously-safe changes. We'll eventually deprecate and remove the instruction-pointer getFirstNonPHI, but not before adding concise documentation of what considerations are needed (very few). --------- Co-authored-by: Stephen Tozer <Melamoto@gmail.com>
2025-01-22[Polly] Add vectorize metadata to loops identified as vectorizable by polly ↵Karthika Devi C
(#113994) This patch introduces the initial implementation for annotating loops created by Polly. Polly generates RunTimeChecks (RTCs), which result in loop versioning. Specifically, the loop created by Polly is executed when the RTCs pass, otherwise, the original loop is executed. This patch adds the "llvm.loop.vectorize.enable" metadata, setting it to true for loops created by Polly. Disabling vectorization for the original fallback loop is already merged in #119188. This behavior is controlled by the 'polly-annotate-metadata-vectorize' flag, and the annotations are applied only when this flag is enabled. This flag is set to false by default. NOTE: This commit is initial patch in effort to make polly interact with Loop Vectorizer via metadata. --------- Co-authored-by: Michael Kruse <github@meinersbur.de>
2024-03-19[NFC][RemoveDIs] Use iterators for insertion at various call-sites (#84736)Jeremy Morse
These are the last remaining "trivial" changes to passes that use Instruction pointers for insertion. All of this should be NFC, it's just changing the spelling of how we identify a position. In one or two locations, I'm also switching uses of getNextNode etc to using std::next with iterators. This too should be NFC. --------- Merged by: Stephen Tozer <stephen.tozer@sony.com>
2023-03-17[Polly] Remove some bitcasts (NFC)Nikita Popov
No longer relevant with opaque pointers.
2022-07-26[Polly] Insert !dbg metadata for emitted CallInsts.Michael Kruse
The IR Verifier requires that every call instruction to an inlineable function (among other things, its implementation must be visible in the translation unit) must also have !dbg metadata attached to it. When parallelizing, Polly emits calls to OpenMP runtime function out of thin air, or at least not directly derived from a bounded list of previous instruction. While we could search for instructions in the SCoP that has some debug info attached to it, there is no guarantee that we find any. Our solution is to generate a new DILocation that points to line 0 to represent optimized code. The OpenMP function implementation is usually not available in the user's translation unit, but can become visible in an LTO build. For the bug to appear, libomp must also be built with debug symbols. IMHO, the IR verifier rule is too strict. Runtime functions can also be inserted by other optimization passes, such as LoopIdiomRecognize. When inserting a call to e.g. memset, it uses the DebugLoc from a StoreInst from the unoptimized code. It is not required to have !dbg metadata attached either. Fixes #56692
2021-03-11[OpaquePtrs] Remove some uses of type-less CreateLoad APIs (NFC)Nikita Popov
Explicitly pass loaded type when creating loads, in preparation for the deprecation of these APIs. There are still a couple of uses left.
2020-01-28Fix polly build after StringRef change.Eli Friedman
2019-03-19[CodeGen] LLVM OpenMP Backend.Michael Kruse
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
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
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
2017-09-28Fix the build after r314375Philip Pfaffe
r314375 privatized Loop's constructor and replaced it with an Allocator. llvm-svn: 314412
2017-08-22Disable the Loop Vectorizer in case of GEMMRoman Gareev
Currently, in case of GEMM and the pattern matching based optimizations, we use only the SLP Vectorizer out of two LLVM vectorizers. Since the Loop Vectorizer can get in the way of optimal code generation, we disable the Loop Vectorizer for the innermost loop using mark nodes and emitting the corresponding metadata. Reviewed-by: Tobias Grosser <tobias@grosser.es> Differential Revision: https://reviews.llvm.org/D36928 llvm-svn: 311473
2017-06-08Fix a lot of typos. NFC.Michael Kruse
llvm-svn: 304974
2017-05-12[Polly] Remove unused headerHongbin Zheng
llvm-svn: 302868
2017-05-12[Polly] Generate more 'canonical' induction variableHongbin Zheng
Today Polly generates induction variable in this way: polly.indvar = phi 0, polly.indvar.next ... polly.indvar.next = polly.indvar + stide polly.loop_cond = predicate polly.indvar, (UB - stride) Instead of: polly.indvar = phi 0, polly.indvar.next ... polly.indvar.next = polly.indvar + stide polly.loop_cond = predicate polly.indvar.next, UB The way Polly generate induction variable cause some problem in the indvar simplify pass. This patch make polly generate the later form, by assuming the induction variable never overflow Differential Revision: https://reviews.llvm.org/D33089 llvm-svn: 302866
2017-04-11Exploit BasicBlock::getModule to shorten codeTobias Grosser
Suggested-by: Roman Gareev <gareevroman@gmail.com> llvm-svn: 299914
2017-04-11SAdjust to recent change in constructor definition of AllocaInstTobias Grosser
llvm-svn: 299913
2017-04-11Update for alloca construction changesMatt Arsenault
llvm-svn: 299905
2017-04-04Fix formatting in LoopGeneratorsPhilip Pfaffe
llvm-svn: 299424
2017-04-04[Polly][NewPM] Pull references to the legacy PM interface from utilities and ↵Philip Pfaffe
helpers Summary: A couple of the utilities used to analyze or build IR make explicit use of the legacy PM on their interface, to access analysis results. This patch removes the legacy PM from the interface, and just passes the required results directly. This shouldn't introduce any function changes, although the API technically allowed to obtain two different analysis results before, one passed by reference and one through the PM. I don't believe that was ever intended, however. Reviewers: grosser, Meinersbur Reviewed By: grosser Subscribers: nemanjai, pollydev, llvm-commits Tags: #polly Differential Revision: https://reviews.llvm.org/D31653 llvm-svn: 299423
2017-03-18[OpenMP] Do not emit lifetime markers for contextTobias Grosser
In commit r219005 lifetime markers have been introduced to mark the lifetime of the OpenMP context data structure. However, their use seems incorrect and recently caused a miscompile in ASC_Sequoia/CrystalMk after r298053 which was not at all related to r298053. r298053 only caused a change in the loop order, as this change resulted in a different isl internal representation which caused the scheduler to derive a different schedule. This change then caused the IR to change, which apparently created a pattern in which LLVM exploites the lifetime markers. It seems we are using the OpenMP context outside of the lifetime markers. Even though CrystalMk could probably be fixed by expanding the scope of the lifetime markers, it is not clear what happens in case the OpenMP function call is in a loop which will cause a sequence of starting and ending lifetimes. As it is unlikely that the lifetime markers give any performance benefit, we just drop them to remove complexity. llvm-svn: 298192
2016-12-19Fix clang-formatTobias Grosser
llvm-svn: 290103
2016-06-22clang-tidy: apply modern-use-nullptr fixesTobias Grosser
Instead of using 0 or NULL use the C++11 nullptr symbol when referencing null pointers. This cleanup was suggested by Eugene Zelenko <eugene.zelenko@gmail.com> in http://reviews.llvm.org/D21488 and was split out to increase readability. llvm-svn: 273435
2016-06-11This reverts recent expression type changesTobias Grosser
The recent expression type changes still need more discussion, which will happen on phabricator or on the mailing list. The precise list of commits reverted are: - "Refactor division generation code" - "[NFC] Generate runtime checks after the SCoP" - "[FIX] Determine insertion point during SCEV expansion" - "Look through IntToPtr & PtrToInt instructions" - "Use minimal types for generated expressions" - "Temporarily promote values to i64 again" - "[NFC] Avoid unnecessary comparison for min/max expressions" - "[Polly] Fix -Wunused-variable warnings (NFC)" - "[NFC] Simplify min/max expression generation" - "Simplify the type adjustment in the IslExprBuilder" Some of them are just reverted as we would otherwise get conflicts. I will try to re-commit them if possible. llvm-svn: 272483
2016-06-02Simplify the type adjustment in the IslExprBuilderJohannes Doerfert
We now have a simple function to adjust/unify the types of two (or three) operands before an operation that requieres the same type for all operands. Due to this change we will not promote parameters that are added to i64 anymore if that is not needed. llvm-svn: 271513
2015-12-21Adjust formatting to clang-format changes in 256149Tobias Grosser
llvm-svn: 256151
2015-11-06polly/ADT: Remove implicit ilist iterator conversions, NFCDuncan P. N. Exon Smith
Remove all the implicit ilist iterator conversions from polly, in preparation for making them illegal in ADT. There was one oddity I came across: at line 95 of lib/CodeGen/LoopGenerators.cpp, there was a post-increment `Builder.GetInsertPoint()++`. Since it was a no-op, I removed it, but I admit I wonder if it might be a bug (both before and after this change)? Perhaps it should be a pre-increment? llvm-svn: 252357
2015-10-07Move the ValueMapT declaration out of BlockGeneratorJohannes Doerfert
Value maps are created and used in many places and it is not always possible to include CodeGen/Blockgenerators.h. To this end, ValueMapT now lives in the ScopHelper.h which does not have any dependences itself. This patch also replaces uses of different other value map types with the ValueMapT. llvm-svn: 249606
2015-09-28OpenMP: Name addresses in subfunction structureTobias Grosser
While debugging, this makes it easier to understand due to which memory reference these stores have been introduced. llvm-svn: 248717
2015-09-08Do not use '.' in subfunction namesTobias Grosser
Certain backends, e.g. NVPTX, do not support '.' in function names. Hence, we ensure all '.' are replaced by '_' when generating function names for subfunctions. For the current OpenMP code generation, this is not strictly necessary, but future uses cases (e.g. GPU offloading) need this issue to be fixed. llvm-svn: 246980
2015-09-05OpenMP: Name the values passed to the subfunciton according to the original ↵Tobias Grosser
llvm::Values llvm-svn: 246924
2015-08-19Fix typoTobias Grosser
llvm-svn: 245441
2015-05-19Adapt to IRBuilder::CreateCall interface changeTobias Grosser
The IRBuilder::CreateCall interface was changed in r237624 and now requires an initializer list. llvm-svn: 237666
2015-05-11Revert "Adjust formatting to latest clang-format change"Tobias Grosser
This reverts commit 236875. Daniel fixed the clang-format bug that introduced the changed formatting. llvm-svn: 236994
2015-05-09Sort include directivesTobias Grosser
Upcoming revisions of isl require us to include header files explicitly, which have previously been already transitively included. Before we add them, we sort the existing includes. Thanks to Chandler for sort_includes.py. A simple, but very convenient script. llvm-svn: 236930
2015-05-08Adjust formatting to latest clang-format changeTobias Grosser
llvm-svn: 236875
2015-04-05[opaque pointer type] More GEP API migrationsDavid Blaikie
llvm-svn: 234131
2015-01-18[PM] Update Polly for LLVM r226394 and r226396 which changed some of theChandler Carruth
block splitting interfaces to accept specific analyses rather than a pass. llvm-svn: 226398
2015-01-18[PM] Update Polly for LLVM r226385 which made LoopInfo actually deriveChandler Carruth
from LoopInfoBase<...>, removing the need for the awkward getBase() dance. llvm-svn: 226387
2014-11-25Add PreHeader always to OuterLoopTobias Grosser
This fixes a bug introduce in r217525. llvm-svn: 222766
2014-10-03[Fix] Accidently changed the type of a libgomp argument in r219003.Johannes Doerfert
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
2014-10-03Put the parallel context alloca into the function entry block.Johannes Doerfert
We use lifetime markers to limit the actual life range (similar to clang). Differential Revision: http://reviews.llvm.org/D5582 llvm-svn: 219005
2014-10-03Add option to limit the maximal number of parallel threads.Johannes Doerfert
Differential Revision: http://reviews.llvm.org/D5581 llvm-svn: 219004
2014-10-03[Refactor] Generalize parallel code generationJohannes Doerfert
+ Generalized function names and comments + Removed OpenMP (omp) from the names and comments + Use common names (non OpenMP specific) for runtime library call creation methodes + Commented the parallel code generator and all its member functions + Refactored some values and methodes Differential Revision: http://reviews.llvm.org/D4990 llvm-svn: 219003
2014-10-02[Refactor] Rename LoopAnnotator to ScopAnnotatorJohannes Doerfert
The LoopAnnotator doesn't annotate only loops any more, thus it is called ScopAnnotator from now on. This also removes unnecessary polly:: namespace tags. llvm-svn: 218878
2014-10-01Annotate LLVM-IR for all parallel loopsJohannes Doerfert
This change allows to annotate all parallel loops with loop id metadata. Furthermore, it will annotate memory instructions with llvm.mem.parallel_loop_access metadata for all surrounding parallel loops. This is especially usefull if an external paralleliser is used. This also removes the PollyLoopInfo class and comments the LoopAnnotator. A test case for multiple parallel loops is attached. llvm-svn: 218793
2014-09-28Build domtree of new loops correctlyTobias Grosser
This fixes a bug introduced in r217525. llvm-svn: 218581
2014-09-10Allow to generate a loop without the GuardBBJohannes Doerfert
This allows us to omit the GuardBB in front of created loops if we can show the loop trip count is at least one. It also simplifies the dominance relation inside the new created region. A GuardBB (even with a constant branch condition) might trigger false dominance errors during function verification. Differential Revision: http://reviews.llvm.org/D5297 llvm-svn: 217525
2014-08-07Make used analysis passes explicitJohannes Doerfert
Use the explicit analysis if possible, only for splitBlock we will continue to use the Pass * argument. This change allows us to remove the getAnalysis calls from the code generation. llvm-svn: 215121