summaryrefslogtreecommitdiff
path: root/polly/lib/CodeGen/BlockGenerators.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-03-30[polly] Use DenseMap::insert_range (NFC) (#133657)Kazu Hirata
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-24[NFC][DebugInfo] Use iterator moveBefore at many call-sites (#123583)Jeremy Morse
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 moveBefore use iterators. This patch adds a (guaranteed dereferenceable) iterator-taking moveBefore, and changes a bunch of call-sites where it's obviously safe to change to use it by just calling getIterator() on an instruction pointer. A follow-up patch will contain less-obviously-safe changes. We'll eventually deprecate and remove the instruction-pointer insertBefore, but not before adding concise documentation of what considerations are needed (very few).
2025-01-08[Polly] Switch DT/LI in RegionGenerator for parallel subfn (#120413)Karthika Devi C
The patch #102460 already implements separate DT/LI/SE for parallel sub function. Crashes have been reported while region generator tries using oringinal function's DT while creating new parallel sub function due to checks in #101198. This patch aims at fixing those cases by switching the DT/LI while generating parallel function using Region Generator. Fixes #117877
2024-10-16[polly] Avoid llvm::Type::getPointerTo() (NFC) (#112368)Youngsuk Kim
`llvm::Type::getPointerTo()` is to be deprecated & removed soon. Also, avoid pointercasts that are essentially no-ops.
2024-09-17[polly] Tidy uses of raw_string_ostream (NFC)Youngsuk Kim
As specified in the docs, 1) raw_string_ostream is always unbuffered and 2) the underlying buffer may be used directly ( 65b13610a5226b84889b923bae884ba395ad084d for further reference ) * Don't call raw_string_ostream::flush(), which is essentially a no-op. * Avoid unneeded calls to raw_string_ostream::str(), to avoid excess indirection.
2024-08-10[Polly] Use separate DT/LI/SE for outlined subfn. NFC. (#102460)Michael Kruse
DominatorTree, LoopInfo, and ScalarEvolution are function-level analyses that expect to be called only on instructions and basic blocks of the function they were original created for. When Polly outlined a parallel loop body into a separate function, it reused the same analyses seemed to work until new checks to be added in #101198. This patch creates new analyses for the subfunctions. GenDT, GenLI, and GenSE now refer to the analyses of the current region of code. Outside of an outlined function, they refer to the same analysis as used for the SCoP, but are substituted within an outlined function. Additionally to the cross-function queries of DT/LI/SE, we must not create SCEVs that refer to a mix of expressions for old and generated values. Currently, SCEVs themselves do not "remember" which ScalarEvolution analysis they were created for, but mixing them is just as unexpected as using DT/LI across function boundaries. Hence `SCEVLoopAddRecRewriter` was combined into `ScopExpander`. `SCEVLoopAddRecRewriter` only replaced induction variables but left SCEVUnknowns to reference the old function. `SCEVParameterRewriter` would have done so but its job was effectively superseded by `ScopExpander`, and now also `SCEVLoopAddRecRewriter`. Some issues persist put marked with a FIXME in the code. Changing them would possibly cause this patch to be not NFC anymore.
2024-06-29[IRBuilder] Don't include Module.h (NFC) (#97159)Nikita Popov
This used to be necessary to fetch the DataLayout, but isn't anymore.
2024-06-24Revert "[IR][NFC] Update IRBuilder to use InsertPosition (#96497)"Stephen Tozer
Reverts the above commit, as it updates a common header function and did not update all callsites: https://lab.llvm.org/buildbot/#/builders/29/builds/382 This reverts commit 6481dc57612671ebe77fe9c34214fba94e1b3b27.
2024-06-24[IR][NFC] Update IRBuilder to use InsertPosition (#96497)Stephen Tozer
Uses the new InsertPosition class (added in #94226) to simplify some of the IRBuilder interface, and removes the need to pass a BasicBlock alongside a BasicBlock::iterator, using the fact that we can now get the parent basic block from the iterator even if it points to the sentinel. This patch removes the BasicBlock argument from each constructor or call to setInsertPoint. This has no functional effect, but later on as we look to remove the `Instruction *InsertBefore` argument from instruction-creation (discussed [here](https://discourse.llvm.org/t/psa-instruction-constructors-changing-to-iterator-only-insertion/77845)), this will simplify the process by allowing us to deprecate the InsertPosition constructor directly and catch all the cases where we use instructions rather than iterators.
2024-03-05[NFC][RemoveDIs] Always use iterators for inserting PHIsJeremy Morse
It's becoming potentially unsafe to insert a PHI instruction using a plain Instruction pointer. Switch all the remaining sites that create and insert PHIs to use iterators instead. For example, the code in ComplexDeinterleavingPass.cpp is definitely at-risk of mixing PHIs and debug-info.
2023-07-18[polly] Remove use of getWithSamePointeeType() (NFC)Nikita Popov
2023-05-23[BBUtils][NFC] Delete SplitBlockAndInsertIfThen with DT.Joshua Cao
The method is marked for deprecation. Delete the method and move all of its consumers to use the DomTreeUpdater version. Reviewed By: foad Differential Revision: https://reviews.llvm.org/D149428
2023-03-08[Polly] Remove Polly-ACC.Michael Kruse
Polly-ACC is unmaintained and since it has never been ported to the NPM pipeline, since D136621 it is not even accessible anymore without manually specifying the passes on the `opt` command line. Since there is no plan to put it to a maintainable state, remove it from Polly. Reviewed By: grosser Differential Revision: https://reviews.llvm.org/D142580
2023-03-08[Polly] Remove -polly-vectorizer=polly.Michael Kruse
Polly's internal vectorizer is not well maintained and is known to not work in some cases such as region ScopStmts. Unlike LLVM's LoopVectorize pass it also does not have a target-dependent cost heuristics, and we recommend using LoopVectorize instead of -polly-vectorizer=polly. In the future we hope that Polly can collaborate better with LoopVectorize, like Polly marking a loop is safe to vectorize with a specific simd width, instead of replicating its functionality. Reviewed By: grosser Differential Revision: https://reviews.llvm.org/D142640
2022-06-07[NFC] Use predecessors to replace make_range.jacquesguan
Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D127085
2022-06-05Remove unneeded cl::ZeroOrMore for cl::opt/cl::list optionsFangrui Song
2022-06-04Remove unneeded cl::ZeroOrMore for cl::opt optionsFangrui Song
Similar to 557efc9a8b68628c2c944678c6471dac30ed9e8e. This commit handles options where cl::ZeroOrMore is more than one line below cl::opt.
2022-02-16[polly] Match function definitions and header declarations. NFC.Michael Kruse
Ensure that function definitions match their declrations in header files, even if they have no effect on linking. This includes 1. Both have the same __isl_* annotations 2. Both use the same type alias 3. Remove unused declarations that have no definition 4. Use explicit polly namespace qualifier for definitions; generally, the .cpp file should use at most an anon namespace region since only symbols declared in the header file can be accessed from other translation units anyway. For defintions that have been declared in the header file, the explicit namespace qualifier ensures that both match.
2021-11-05[Polly][Isl] Use the function unsignedFromIslSize to manage a isl::size ↵Riccardo Mori
object. NFCI This is part of an effort to reduce the differences between the custom C++ bindings used right now by polly in lib/External/isl/include/isl/isl-noxceptions.h and the official isl C++ interface. In the official interface the type `isl::size` cannot be casted to an unsigned without previously having checked if it contains a valid value with the function `isl::size::is_error()`. For this reason two helping functions have been added: - `IslAssert`: assert that no errors are present in debug builds and just disables the mandatory error check in non-debug builds - `unisgnedFromIslSIze`: cast the `isl::size` object to `unsigned` Changes made: - Add the functions `IslAssert` and `unsignedFromIslSize` - Add the utility function `rangeIslSize()` - Retype `MaxDisjunctsInDomain` from `int` to `unsigned` - Retype `RunTimeChecksMaxAccessDisjuncts` from `int` to `unsigned` - Retype `MaxDimensionsInAccessRange` from `int` to `unsigned` - Replaced some usages of `isl_size` to `unsigned` since we aim not to use `isl_size` anymore - `isl-noexceptions.h` has been generated by https://github.com/patacca/isl/commit/e704f73c88f0b4d88e62e447bdb732cf5914094b No functional change intended. Reviewed By: Meinersbur Differential Revision: https://reviews.llvm.org/D113101
2021-08-16[Polly][Isl] Move to the new-polly-generator branch version of ↵Riccardo Mori
isl-noexceptions.h. NFCI This is part of an effort to reduce the differences between the custom C++ bindings used right now by polly in `lib/External/isl/include/isl/isl-noxceptions.h` and the official isl C++ interface. With this commit we are moving from the `polly-generator` branch to the `new-polly-generator` branch that is more mantainable and is based on the official C++ interface `cpp-checked.h`. Changes made: - There are now many sublcasses for `isl::ast_node` representing different isl types. Use `isl::ast_node_for`, `isl::ast_node_user`, `isl::ast_node_block` and `isl::ast_node_mark` where needed. - There are now many sublcasses for `isl::schedule_node` representing different isl types. Use `isl::schedule_node_mark`, `isl::schedule_node_extension`, `isl::schedule_node_band` and `isl::schedule_node_filter` where needed. - Replace the `isl::*::dump` with `dumpIslObj` since the isl dump method is not exposed in the C++ interface. - `isl::schedule_node::get_child` has been renamed to `isl::schedule_node::child` - `isl::pw_multi_aff::get_pw_aff` has been renamed to `isl::pw_multi_aff::at` - The constructor `isl::union_map(isl::union_pw_multi_aff)` has been replaced with the static method `isl::union_map::from()` - Replace usages of `isl::val::add_ui` with `isl::val::add` - `isl::union_set_list::alloc` is now a constructor - All the `isl_size` values are now wrapped inside the class `isl::size` use `isl::size::release` to get the internal `isl_size` value where needed. - `isl-noexceptions.h` has been generated by https://github.com/patacca/isl/commit/73f5ed1f4d1f72582f731590ef9e43d9ab1956ad No functional change intended. Reviewed By: Meinersbur Differential Revision: https://reviews.llvm.org/D107225
2021-07-18[polly] Fix regression tests with POLLY_ENABLE_GPGPU_CODEGENEli Friedman
Apparently there was a latent bug here.
2021-07-18[polly] Get rid of a couple uses of PointerType::getElementType().Eli Friedman
2021-03-11[Polly] Remove uses of type-less CreateLoad() APIs (NFC)Nikita Popov
These are incompatible with opaque pointers and are going away. Explicitly specify the loaded type instead.
2020-10-20Get the address space within getVectorPtrTyChristopher Tetreault
getVectorPtrTy is private to VectorBlockGenerator, and all uses query the address space from the passed-in pointer prior to calling it. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D89745
2020-10-14Polly - specify address space when creating a pointer to a vector typeMark Schimmel
Polly incorrectly dropped the address space specified for a load instruction when it vectorized the code. Reviewed By: Meinersbur Differential Revision: https://reviews.llvm.org/D88907
2020-05-29[SVE] Eliminate calls to default-false VectorType::get() from pollyChristopher Tetreault
Reviewers: bollu, efriedma, david-arm, fpetrogalli, gchatelet Reviewed By: fpetrogalli Subscribers: tschuett, rkruppe, psnobl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D80341
2020-05-16AllocaInst should store Align instead of MaybeAlign.Eli Friedman
Along the lines of D77454 and D79968. Unlike loads and stores, the default alignment is getPrefTypeAlign, to match the existing handling in various places, including SelectionDAG and InstCombine. Differential Revision: https://reviews.llvm.org/D80044
2020-01-28Fix polly build after StringRef change.Eli Friedman
2020-01-27[Alignment][NFC] Use Align with CreateAlignedLoadGuillaume Chatelet
Summary: This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet, bollu Subscribers: hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D73449
2020-01-23[Alignment][NFC] Use Align with CreateAlignedStoreGuillaume Chatelet
Summary: This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet, bollu Subscribers: arsenm, jvesely, nhaehnle, hiraditya, kerbowa, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D73274
2019-11-12[CodeGen] Fix getArrayAccessFor crashes as in bug 32534 with ↵Michael Kruse
-polly-vectorizer=polly. Root cause is VectorBlockGenerator::copyStmt iterates all instructions in basic block, however some load instructions may be not unnecessary thus removed by simplification. As a result, these load instructions don't have a corresponding array. Looking at BlockGenerator::copyBB, it only iterates instructions list of ScopStmt. Given it must be a block type scop in case of vectorization, I think we should do the same in VectorBlockGenerator::copyStmt. Patch by bin.narwal <bin.narwal@gmail.com> Differential Revision: https://reviews.llvm.org/D70076
2019-10-03[Alignment][NFC] Remove StoreInst::setAlignment(unsigned)Guillaume Chatelet
Summary: This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet, bollu, jdoerfert Subscribers: hiraditya, asbirlea, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D68268 llvm-svn: 373595
2019-09-30[Alignment] Fix polly buildGuillaume Chatelet
llvm-svn: 373199
2019-05-20[CodeGen] Fix order of PHINode and MA Write generation.Michael Kruse
At the end of a region statement, the PHINode must be generated while the current IRBuilder's block is the region's exit node. For obvious reasons: The PHINode references the region's exiting block. A partial write would insert new control flow, i.e. insert new basic blocks between the exiting blocks and the current block. We fix this by generating the PHI nodes (region exit values) before generating any MemoryAccess's stores. This should fix the AOSP buildbot. Reported-by: Eli Friedman <efriedma@quicinc.com> llvm-svn: 361204
2019-03-28Apply include-what-you-use #include removal suggestions. NFC.Michael Kruse
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
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
2018-10-15[TI removal] Make `getTerminator()` return a generic `Instruction`.Chandler Carruth
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
2018-06-05Fix formattingTobias Grosser
llvm-svn: 333988
2018-06-04Update for a header file move in LLVMDavid Blaikie
llvm-svn: 333956
2018-04-25[CodeGen] Print executed statement instances at runtime.Michael Kruse
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-10[CodeGen] Allow undefined loads in statement instances outside context.Michael Kruse
A check in assert-builds was meant to verify that a load provides a value in all statement instances (i.e. its domain). The domain is commonly gist'ed within the parameter context to contain fewer constraints. However, statement instances outside the context are no valid executions, hence the value provided can be undefined. Refine the check for valid loads to only needed to be defined within the SCoP context. In addition, the JSONImporter had to be changed to allow importing access relations that are broader than the current access relation, but still defined over all statement instances. This should fix the compiler crash in test-suite's oggenc of the -polly-process-unprofitable buildbot. llvm-svn: 329655
2018-04-10[CodeGen] Convert BlockGenerator::generateScalarLoads to isl++. NFC.Michael Kruse
llvm-svn: 329654
2018-03-21Update for LLVM header movementDavid Blaikie
llvm-svn: 328169
2018-02-20Use isl::manage_copy to simplify calls to isl::manage(isl_.._copy())Tobias Grosser
As part of this cleanup a couple of unnecessary isl::manage(obj.copy()) pattern are eliminated as well. We checked for all potential cleanups by scanning for: "grep -R isl::manage\( lib/ | grep copy" llvm-svn: 325558
2017-11-21Run polly-update-format. NFC.Michael Kruse
polly-check-format has been failing since at least r318517, due to more than one cause. llvm-svn: 318795
2017-09-07[CodeGen] Bitcast scalar writes to actual value.Michael Kruse
The type of NewValue might change due to ScalarEvolution looking though bitcasts. The synthesized NewValue therefore becomes the type before the bitcast. llvm-svn: 312718
2017-08-31[BlockGenerator] Generate entry block of regions from instruction listsTobias Grosser
The adds code generation support for the previous commit. This patch has been re-applied, after the memory issue in the previous patch has been fixed. llvm-svn: 312211