summaryrefslogtreecommitdiffstats
path: root/polly/lib/CodeGen/BlockGenerators.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [CodeGen] Fix getArrayAccessFor crashes as in bug 32534 with ↵Michael Kruse2019-11-121-2/+2
| | | | | | | | | | | | | | | | | | -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
* [Alignment][NFC] Remove StoreInst::setAlignment(unsigned)Guillaume Chatelet2019-10-031-1/+1
| | | | | | | | | | | | | | | | | 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
* [Alignment] Fix polly buildGuillaume Chatelet2019-09-301-2/+2
| | | | llvm-svn: 373199
* [CodeGen] Fix order of PHINode and MA Write generation.Michael Kruse2019-05-201-1/+18
| | | | | | | | | | | | | | | | 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
* Apply include-what-you-use #include removal suggestions. NFC.Michael Kruse2019-03-281-8/+0
| | | | | | | | | | | | 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
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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
* Fix formattingTobias Grosser2018-06-051-1/+1
| | | | llvm-svn: 333988
* Update for a header file move in LLVMDavid Blaikie2018-06-041-1/+1
| | | | llvm-svn: 333956
* [CodeGen] Print executed statement instances at runtime.Michael Kruse2018-04-251-0/+115
| | | | | | | | | | | | | 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
* [CodeGen] Allow undefined loads in statement instances outside context.Michael Kruse2018-04-101-1/+2
| | | | | | | | | | | | | | | | | | | | 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
* [CodeGen] Convert BlockGenerator::generateScalarLoads to isl++. NFC.Michael Kruse2018-04-101-5/+3
| | | | llvm-svn: 329654
* Update for LLVM header movementDavid Blaikie2018-03-211-1/+1
| | | | llvm-svn: 328169
* Use isl::manage_copy to simplify calls to isl::manage(isl_.._copy())Tobias Grosser2018-02-201-4/+4
| | | | | | | | | | | 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
* Run polly-update-format. NFC.Michael Kruse2017-11-211-2/+0
| | | | | | | polly-check-format has been failing since at least r318517, due to more than one cause. llvm-svn: 318795
* [CodeGen] Bitcast scalar writes to actual value.Michael Kruse2017-09-071-0/+7
| | | | | | | | 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
* [BlockGenerator] Generate entry block of regions from instruction listsTobias Grosser2017-08-311-1/+6
| | | | | | | | | 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
* Revert "[BlockGenerator] Generate entry block of regions from instruction lists"Tobias Grosser2017-08-311-6/+1
| | | | | | This reverts commit r312129. It caused some memory issues. llvm-svn: 312208
* [BlockGenerator] Generate entry block of regions from instruction listsTobias Grosser2017-08-301-1/+6
| | | | | | The adds code generation support for the previous commit. llvm-svn: 312129
* [CodeGen] Detect impossible partial write conditions more reliably.Michael Kruse2017-08-241-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Whether a partial write is tautological/unsatisfiable not only depends on the access domain, but also on the domain covered by its node in the AST. In the example below, there are two instances of Stmt_cond_false. It may have a partial write access that is not executed in instance Stmt_cond_false(0). for (int c0 = 0; c0 < tmp5; c0 += 1) { Stmt_for_body344(c0); if (tmp5 >= c0 + 2) Stmt_cond_false(c0); Stmt_cond_end(c0); } if (tmp5 <= 0) { Stmt_for_body344(0); Stmt_cond_false(0); Stmt_cond_end(0); } Isl cannot derive a subscript for an array element that is never accessed. This caused an error in that no subscript expression has been generated in IslNodeBuilder::createNewAccesses, but BlockGenerator expected one to exist because there is an execution of that write, just not in that ast node. Fixed by instead of determining whether the access domain is empty, inspect whether isl generated a constant "false" ast expression in the current ast node. This should fix a compiler crash of the aosp buildbot. llvm-svn: 311663
* [ScopInfo] Translate Scop::getContext to isl++ [NFC]Tobias Grosser2017-08-061-1/+1
| | | | llvm-svn: 310221
* [ScopInfo] Move ScopStmt::setAstBuild/getAstBuild to isl++Tobias Grosser2017-08-061-1/+1
| | | | llvm-svn: 310216
* Move ScopInfo::getDomain(), getDomainSpace(), getDomainId() to isl++Tobias Grosser2017-08-061-3/+3
| | | | llvm-svn: 310209
* Fix code format on r309826Singapuram Sanjay Srivallabh2017-08-021-2/+1
| | | | | | | | | | | | | | | | | Summary: Fix code format on r309826 / D35458 Reviewers: grosser, bollu Reviewed By: grosser Subscribers: pollydev Tags: #polly Differential Revision: https://reviews.llvm.org/D36232 llvm-svn: 309845
* Remove debug metadata from copied instruction to prevent GPUModule ↵Singapuram Sanjay Srivallabh2017-08-021-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | verification failure Summary: **Remove debug metadata from instruction to be copied to prevent the source file's debug metadata being copied into GPUModule and eventually failing Module verification and ASM string codegeneration.** When copying the instruction onto the Module meant for the GPU, debug metadata attached to an instruction causes all related metadata to be pulled into the Module, including the DICompileUnit, which is not listed in llvm.dbg.cu of the Module. This fails the verification of the Module and generation of the ASM string. The only debug metadata of the instruction, the DebugLoc, is unset by this patch. This patch reattempts https://reviews.llvm.org/D35630 by targeting only those instructions that are to end up in a Module meant for the GPU. Reviewers: grosser, bollu Reviewed By: grosser Subscribers: pollydev Tags: #polly Differential Revision: https://reviews.llvm.org/D36161 llvm-svn: 309822
* Revert "Remove Debug metadata from copied instruction to prevent Module ↵Tobias Grosser2017-07-311-8/+0
| | | | | | | | | | | verification failure" This reverts commit r309490 as it triggers on our AOSP buildbut error messages of the form: inlinable function call in a function with debug info must have a !dbg location llvm-svn: 309556
* Remove Debug metadata from copied instruction to prevent Module verification ↵Singapuram Sanjay Srivallabh2017-07-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | failure Summary: **Remove debug metadata from instruction to be copied to prevent the source file's debug metadata being copied into GPUModule and eventually failing Module verification and ASM string codegeneration.** When copying the instruction onto the Module meant for the GPU, debug metadata attached to an instruction causes all related metadata to be pulled into the Module, including the DICompileUnit, which is not listed in llvm.dbg.cu of the Module. This fails the verification of the Module and generation of the ASM string. The only debug metadata of the instruction, the DebugLoc, is unset by this patch. Reviewers: grosser, bollu, Meinersbur Reviewed By: grosser, bollu Subscribers: pollydev Tags: #polly Differential Revision: https://reviews.llvm.org/D35630 llvm-svn: 309490
* [ScopInfo] Rename ScopStmt::contains(BB) to represents(BB). NFC.Michael Kruse2017-07-251-2/+2
| | | | | | | | | | | In future, there will be no more a 1:1 correspondence between statements and basic blocks, the name `contains` does not correctly capture their relationship. A BB may infact comprise of multiple statements; hence we describe a statement 'representing' a basic block. Differential Revision: https://reviews.llvm.org/D35838 llvm-svn: 308982
* Move MemoryAccess::isStride* to isl++Tobias Grosser2017-07-241-4/+4
| | | | llvm-svn: 308927
* Move MemoryAccess::NewAccessRelation to isl++Tobias Grosser2017-07-231-4/+4
| | | | | | We also move related accessor functions llvm-svn: 308840
* Move MemoryAccess::id to isl++Tobias Grosser2017-07-231-51/+54
| | | | llvm-svn: 308836
* Fix a lot of typos. NFC.Michael Kruse2017-06-081-4/+4
| | | | llvm-svn: 304974
* [Polly] [BlockGen] Support partial writes in regionsTobias Grosser2017-06-061-35/+46
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The RegionGenerator traditionally kept a BlockMap that mapped from original basic blocks to newly generated basic blocks. With the introduction of partial writes such a 1:1 mapping is not possible any more, as a single basic block can be code generated into multiple basic blocks. Hence, depending on the use case we need to either use the first basic block or the last basic block. This is intended to address the last four cases of incorrect code generation in our AOSP buildbot and hopefully should turn it green. Reviewers: Meinersbur, bollu, gareevroman, efriedma, huihuiz, sebpop, simbuerg Reviewed By: Meinersbur Subscribers: pollydev, llvm-commits Tags: #polly Differential Revision: https://reviews.llvm.org/D33767 llvm-svn: 304808
* [CodeGen] Iterate over explicit instruction list for block statements. NFCMichael Kruse2017-06-021-2/+6
| | | | | | | | | | | | For when statements do not contain all instructions of a BasicBlock anymore, the block generator needs to go through the explicit list of instructions it contains. Contributed-by: Nandini Singhal <cs15mtech01004@iith.ac.in> Differential Revision: https://reviews.llvm.org/D33653 llvm-svn: 304502
* [BlockGenerator] Take context into account when identifying partial writesTobias Grosser2017-06-011-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | A partial write is a write where the domain of the values written is a subset of the execution domain of the parent statement containing the write. Originally, we directly checked this subset relation whereas it is indeed only important that the subset relation holds for the parameter values that are known to be valid in the execution context of the scop. We update our check to avoid the unnecessary introduction of partial writes in situations where the write appears to be partial without context information, but where context information allows us to understand that a full write can be generated. This change fixes (hides) a recent regression introduced in r303517, which broke our AOSP builds. The part that is correctly fixed in this change is that we do not any more unnecessarily generate a partial write. This is good performance wise and, as we currently do not yet explicitly introduce partial writes in the default configuration, this also hides possible bugs in the partial writes implementation. The crashes that we have originally seen were caused by such a bug, where partial writes were incorrectly generated in region statements. An additional patch in a subsequent commit is needed to address this problem. Reported-by: Reported-by: Eli Friedman <efriedma@codeaurora.org> Differential Revision: https://reviews.llvm.org/D33759 llvm-svn: 304398
* [BlockGenerator] Translate buildContainsCondition to idiomatic isl C++Tobias Grosser2017-05-311-18/+11
| | | | llvm-svn: 304354
* [CodeGen] Add invalidation of the loop SCEVs after merge block generation.Michael Kruse2017-05-221-0/+12
| | | | | | | | | | | | | The SCEVs of loops surrounding the escape users of a merge blocks are forgotten, so that loop trip counts based on old values can be revoked. This fixes llvm.org//PR32536 Contributed-by: Baranidharan Mohan <mbdharan@gmail.com> Differential Revision: https://reviews.llvm.org/D33195 llvm-svn: 303561
* [CodeGen] Support partial write accesses.Michael Kruse2017-05-211-56/+138
| | | | | | | | | | | | | | | | | | | Allow the BlockGenerator to generate memory writes that are not defined over the complete statement domain, but only over a subset of it. It generates a condition that evaluates to 1 if executing the subdomain, and only then execute the access. Only write accesses are supported. Read accesses would require a PHINode which has a value if the access is not executed. Partial write makes DeLICM able to apply mappings that are not defined over the entire domain (for instance, a branch that leaves a loop with a PHINode in its header; a MemoryKind::PHI write when leaving is never read by its PHI read). Differential Revision: https://reviews.llvm.org/D33255 llvm-svn: 303517
* [IR] De-virtualize ~Value to save a vptrReid Kleckner2017-05-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Implements PR889 Removing the virtual table pointer from Value saves 1% of RSS when doing LTO of llc on Linux. The impact on time was positive, but too noisy to conclusively say that performance improved. Here is a link to the spreadsheet with the original data: https://docs.google.com/spreadsheets/d/1F4FHir0qYnV0MEp2sYYp_BuvnJgWlWPhWOwZ6LbW7W4/edit?usp=sharing This change makes it invalid to directly delete a Value, User, or Instruction pointer. Instead, such code can be rewritten to a null check and a call Value::deleteValue(). Value objects tend to have their lifetimes managed through iplist, so for the most part, this isn't a big deal. However, there are some places where LLVM deletes values, and those places had to be migrated to deleteValue. I have also created llvm::unique_value, which has a custom deleter, so it can be used in place of std::unique_ptr<Value>. I had to add the "DerivedUser" Deleter escape hatch for MemorySSA, which derives from User outside of lib/IR. Code in IR cannot include MemorySSA headers or call the MemoryAccess object destructors without introducing a circular dependency, so we need some level of indirection. Unfortunately, no class derived from User may have any virtual methods, because adding a virtual method would break User::getHungOffOperands(), which assumes that it can find the use list immediately prior to the User object. I've added a static_assert to the appropriate OperandTraits templates to help people avoid this trap. Reviewers: chandlerc, mehdi_amini, pete, dberlin, george.burgess.iv Reviewed By: chandlerc Subscribers: krytarowski, eraman, george.burgess.iv, mzolotukhin, Prazek, nlewycky, hans, inglorion, pcc, tejohnson, dberlin, llvm-commits Differential Revision: https://reviews.llvm.org/D31261 llvm-svn: 303362
* Introduce VirtualUse. NFC.Michael Kruse2017-05-041-32/+106
| | | | | | | | | | | | | | | | | | | If a ScopStmt references a (scalar) value, there are multiple possibilities where this value can come. The decision about what kind of use it is must be handled consistently at different places, which can be error-prone. VirtualUse is meant to centralize the handling of the different types of value uses. This patch makes ScopBuilder and CodeGeneration use VirtualUse. This already helps to show inconsistencies with the value handling. In order to keep this patch NFC, exceptions to the general rules are added. These might be fixed later if they turn to problems. Overall, this should result in fewer post-codegen IR-verification errors, but instead assertion failures in `getNewValue` that are closer to the actual error. Differential Revision: https://reviews.llvm.org/D32667 llvm-svn: 302157
* Exploit BasicBlock::getModule to shorten codeTobias Grosser2017-04-111-2/+1
| | | | | Suggested-by: Roman Gareev <gareevroman@gmail.com> llvm-svn: 299914
* SAdjust to recent change in constructor definition of AllocaInstTobias Grosser2017-04-111-2/+2
| | | | llvm-svn: 299913
* Update for alloca construction changesMatt Arsenault2017-04-111-1/+5
| | | | llvm-svn: 299905
* [ScopInfo] Introduce ScopStmt::contains(BB*). NFC.Michael Kruse2017-03-231-4/+2
| | | | | | | | | Provide an common way for testing if a statement contains something for region and block statements. First user is RegionGenerator::addOperandToPHI. Suggested-by: Tobias Grosser <tobias@grosser.es> llvm-svn: 298617
* [IslExprBuilder] Print accessed memory locations with RuntimeDebugBuilderTobias Grosser2017-03-181-4/+6
| | | | | | | | | | | | | | | | | | | After this change, enabling -polly-codegen-add-debug-printing in combination with -polly-codegen-generate-expressions allows us to instrument the compiled binaries to not only print the values stored and loaded to a given memory access, but also to print the accessed location with array name and per-dimension offset: MemRef_A[3][2] Store to 6299784: 5.000000 MemRef_A[3][3] Load from 6299788: 0.000000 MemRef_A[3][3] Store to 6299788: 6.000000 This can be very helpful for debugging. llvm-svn: 298194
* [Simplify] Add -polly-simplify pass.Michael Kruse2017-03-101-0/+8
| | | | | | | | | | | | | | | | | This new pass removes unnecessary accesses and writes. It currently supports 2 simplifications, but more are planned. It removes write accesses that write a loaded value back to the location it was loaded from. It is a typical artifact from DeLICM. Removing it will get rid of bogus dependencies later in dependency analysis. It also removes statements without side-effects. ScopInfo already removes these, but the removal of unnecessary writes can result in more side-effect free statements. Differential Revision: https://reviews.llvm.org/D30820 llvm-svn: 297473
* [BlockGenerator] Use MemoryAccess::getAccessValue to get load instructionTobias Grosser2017-02-091-2/+2
| | | | | | | | | | | | | | | | | | | | When generating code in the BlockGenerator we copy all (interesting) instructions and keep track of the new values in a basic block map. To obtain the original llvm::Value that belongs to a load memory access, we use getAccessValue() instead of getOriginalBaseAddr(). The former always references the instruction we use to load values from. The latter, on the other hand, is obtaine from the corresponding ScopArrayInfo and would not be unique in case ScopArrayInfo objects at some point allow memory accesses with different base addresses. This change is an update on r294566, which only clarified that we need the original memory access, but where we still remained dependent to have one base pointer per scop. This change removes unnecessary uses of MemoryAddress::getOriginalBaseAddr() in preparation for https://reviews.llvm.org/D28518. llvm-svn: 294669
* [BlockGenerator] BBMap uses original BaseAddress for scalar loads [NFC]Tobias Grosser2017-02-091-2/+2
| | | | | | | | | | | | | | | | | When regenerating code in the BlockGenerator we copy instructions that may references scalar values, for which the new value of a given scalar is looked up in BBMap using the original scalar llvm::Value as index. It is consequently necessary that (re)loaded scalar values are made available in BBMap using the original llvm::Value as key independently if the llvm::Value was (re)loaded from the original scalar or a new access function has been specified that caused the value to be reloaded from an array with a differnet base address. We make this clear by using MemoryAccess::getOriginalBaseAddr() instead of MemoryAccess::getBaseAddr() as index to BBMap. This change removes unnecessary uses of MemoryAddress::getBaseAddr() in preparation for https://reviews.llvm.org/D28518. llvm-svn: 294566
* [BlockGenerator] Comment corretions for r293374 [NFC]Tobias Grosser2017-01-281-6/+9
| | | | | | | This addresses some additional comments from Michael Kruse for commit r293374 as expressed in https://reviews.llvm.org/D28901. llvm-svn: 293378
* [Polly] [BlockGenerator] Unify ScalarMap and PhiOpsMapTobias Grosser2017-01-281-52/+47
| | | | | | | | | | | | | | | | | | | | | | | | | Instead of keeping two separate maps from Value to Allocas, one for MemoryType::Value and the other for MemoryType::PHI, we introduce a single map from ScopArrayInfo to the corresponding Alloca. This change is intended, both as a general simplification and cleanup, but also to reduce our use of MemoryAccess::getBaseAddr(). Moving away from using getBaseAddr() makes sure we have only a single place where the array (and its base pointer) for which we generate code for is specified, which means we can more easily introduce new access functions that use a different ScopArrayInfo as base. We already today experiment with modifiable access functions, so this change does not address a specific bug, but it just reduces the scope one needs to reason about. Another motivation for this patch is https://reviews.llvm.org/D28518, where memory accesses with different base pointers could possibly be mapped to a single ScopArrayInfo object. Such a mapping is currently not possible, as we currently generate alloca instructions according to the base addresses of the memory accesses, not according to the ScopArrayInfo object they belong to. By making allocas ScopArrayInfo specific, a mapping to a single ScopArrayInfo object will automatically mean that the same stack slot is used for these arrays. For D28518 this is not a problem, as only MemoryType::Array objects are mapping, but resolving this inconsistency will hopefully avoid confusion. llvm-svn: 293374
OpenPOWER on IntegriCloud