[polly] r215817 - Revert "[Refactor] Cleanup runtime code generation"
Johannes Doerfert
doerfert at cs.uni-saarland.de
Tue Aug 19 19:58:00 PDT 2014
Hey Tobias,
I looked into the problem and I attached a revised version of the same
patch. I also added a test case for the compile time crash which caused
the test-suite/lnt to fail.
I did not see any other problems in the test-suite output but I'm not
even sure if I run it correctly. Could you take a look/run lnt and see
if we also pass that?
Best regards from Fresno (CA),
Johannes
On 08/16, Tobias Grosser wrote:
> Author: grosser
> Date: Sat Aug 16 04:09:15 2014
> New Revision: 215817
>
> URL: http://llvm.org/viewvc/llvm-project?rev=215817&view=rev
> Log:
> Revert "[Refactor] Cleanup runtime code generation"
>
> This reverts commit 215466 (and 215528, a trivial formatting fix).
>
> The intention of these commits is a good one, but unfortunately they broke
> our LNT buildbot:
>
> http://lab.llvm.org:8011/builders/perf-x86_64-penryn-O3-polly-codegen-isl
>
> Several of the cleanup changes that have been combined in this 'fixup' are
> trivial and could probably be committed as obvious changes without risking to
> break the build. The remaining changes are little and it should be easy to
> figure out what went wrong.
>
> Modified:
> polly/trunk/include/polly/CodeGen/IRBuilder.h
> polly/trunk/include/polly/CodeGen/Utils.h
> polly/trunk/include/polly/ScopInfo.h
> polly/trunk/lib/CodeGen/CodeGeneration.cpp
> polly/trunk/lib/CodeGen/IslCodeGeneration.cpp
> polly/trunk/lib/CodeGen/Utils.cpp
> polly/trunk/test/Isl/CodeGen/multidim_2d_parametric_array_static_loop_bounds.ll
> polly/trunk/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll
>
> Modified: polly/trunk/include/polly/CodeGen/IRBuilder.h
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/IRBuilder.h?rev=215817&r1=215816&r2=215817&view=diff
> ==============================================================================
> --- polly/trunk/include/polly/CodeGen/IRBuilder.h (original)
> +++ polly/trunk/include/polly/CodeGen/IRBuilder.h Sat Aug 16 04:09:15 2014
> @@ -101,14 +101,5 @@ private:
> // PollyIRBuilder;
> typedef PollyBuilderInserter<true> IRInserter;
> typedef llvm::IRBuilder<true, llvm::ConstantFolder, IRInserter> PollyIRBuilder;
> -
> -/// @brief Return an IR builder pointed before the @p BB terminator.
> -static inline PollyIRBuilder createPollyIRBuilder(llvm::BasicBlock *BB,
> - LoopAnnotator &LA) {
> - PollyIRBuilder Builder(BB->getContext(), llvm::ConstantFolder(),
> - polly::IRInserter(LA));
> - Builder.SetInsertPoint(BB->getTerminator());
> - return Builder;
> -}
> }
> #endif
>
> Modified: polly/trunk/include/polly/CodeGen/Utils.h
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/Utils.h?rev=215817&r1=215816&r2=215817&view=diff
> ==============================================================================
> --- polly/trunk/include/polly/CodeGen/Utils.h (original)
> +++ polly/trunk/include/polly/CodeGen/Utils.h Sat Aug 16 04:09:15 2014
> @@ -15,7 +15,6 @@
>
> namespace llvm {
> class Pass;
> -class Value;
> class BasicBlock;
> }
>
> @@ -23,12 +22,16 @@ namespace polly {
>
> class Scop;
>
> -/// @brief Execute a Scop conditionally wrt @p RTC.
> +/// @brief Execute a Scop conditionally.
> ///
> /// In the CFG the optimized code of the Scop is generated next to the
> /// original code. Both the new and the original version of the code remain
> -/// in the CFG. A branch statement decides which version is executed based on
> -/// the runtime value of @p RTC.
> +/// in the CFG. A branch statement decides which version is executed.
> +/// For now, we always execute the new version (the old one is dead code
> +/// eliminated by the cleanup passes). In the future we may decide to execute
> +/// the new version only if certain run time checks succeed. This will be
> +/// useful to support constructs for which we cannot prove all assumptions at
> +/// compile time.
> ///
> /// Before transformation:
> ///
> @@ -50,12 +53,9 @@ class Scop;
> /// \ /
> /// bb1 (joinBlock)
> ///
> -/// @param S The Scop to execute conditionally.
> -/// @param P A reference to the pass calling this function.
> -/// @param RTC The runtime condition checked before executing the new SCoP.
> -///
> -/// @return The 'StartBlock' to which new code can be added.
> -llvm::BasicBlock *executeScopConditionally(Scop &S, llvm::Pass *P,
> - llvm::Value *RTC);
> +/// @param S The Scop to execute conditionally.
> +/// @param PassInfo A reference to the pass calling this function.
> +/// @return BasicBlock The 'StartBlock' to which new code can be added.
> +llvm::BasicBlock *executeScopConditionally(Scop &S, llvm::Pass *PassInfo);
> }
> #endif
>
> Modified: polly/trunk/include/polly/ScopInfo.h
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=215817&r1=215816&r2=215817&view=diff
> ==============================================================================
> --- polly/trunk/include/polly/ScopInfo.h (original)
> +++ polly/trunk/include/polly/ScopInfo.h Sat Aug 16 04:09:15 2014
> @@ -615,9 +615,6 @@ public:
> inline const Region &getRegion() const { return R; }
> inline Region &getRegion() { return R; }
>
> - /// @brief Return the entry block for the underlying region.
> - inline llvm::BasicBlock *getRegionEntry() { return R.getEntry(); }
> -
> /// @brief Get the maximum depth of the loop.
> ///
> /// @return The maximum depth of the loop.
>
> Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=215817&r1=215816&r2=215817&view=diff
> ==============================================================================
> --- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
> +++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Sat Aug 16 04:09:15 2014
> @@ -1056,8 +1056,7 @@ public:
>
> simplifyRegion(&S, this);
>
> - Value *RTC = ConstantInt::getTrue(S.getRegionEntry()->getContext());
> - BasicBlock *StartBlock = executeScopConditionally(S, this, RTC);
> + BasicBlock *StartBlock = executeScopConditionally(S, this);
>
> PollyIRBuilder Builder(StartBlock->begin());
>
>
> Modified: polly/trunk/lib/CodeGen/IslCodeGeneration.cpp
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslCodeGeneration.cpp?rev=215817&r1=215816&r2=215817&view=diff
> ==============================================================================
> --- polly/trunk/lib/CodeGen/IslCodeGeneration.cpp (original)
> +++ polly/trunk/lib/CodeGen/IslCodeGeneration.cpp Sat Aug 16 04:09:15 2014
> @@ -568,58 +568,41 @@ public:
>
> IslCodeGeneration() : ScopPass(ID) {}
>
> - /// @name The analysis passes we need to generate code.
> - ///
> - ///{
> - LoopInfo *LI;
> - IslAstInfo *AI;
> - DominatorTree *DT;
> - ScalarEvolution *SE;
> - ///}
> -
> - /// @brief The loop anotator to generate llvm.loop metadata.
> - LoopAnnotator Annotator;
> -
> - /// @brief Build the delinearization runtime condition.
> - ///
> - /// Build the condition that evaluates at run-time to true iff all
> - /// delinearization assumptions taken for the SCoP hold, and to zero
> - /// otherwise.
> - ///
> - /// @return A value evaluating to true/false if delinarization is save/unsave.
> - Value *buildRTC(PollyIRBuilder &Builder, IslExprBuilder &ExprBuilder) {
> - Builder.SetInsertPoint(Builder.GetInsertBlock()->getTerminator());
> - Value *RTC = ExprBuilder.create(AI->getRunCondition());
> - return Builder.CreateIsNotNull(RTC);
> - }
> -
> bool runOnScop(Scop &S) {
> - LI = &getAnalysis<LoopInfo>();
> - AI = &getAnalysis<IslAstInfo>();
> - DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
> - SE = &getAnalysis<ScalarEvolution>();
> + LoopInfo &LI = getAnalysis<LoopInfo>();
> + IslAstInfo &AstInfo = getAnalysis<IslAstInfo>();
> + ScalarEvolution &SE = getAnalysis<ScalarEvolution>();
> + DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
>
> assert(!S.getRegion().isTopLevelRegion() &&
> "Top level regions are not supported");
>
> - PollyIRBuilder Builder =
> - createPollyIRBuilder(S.getRegionEntry(), Annotator);
> -
> - IslNodeBuilder NodeBuilder(Builder, Annotator, this, *LI, *SE, *DT);
> - NodeBuilder.addMemoryAccesses(S);
> - NodeBuilder.addParameters(S.getContext());
> -
> simplifyRegion(&S, this);
> - Builder.SetInsertPoint(
> - S.getRegion().getEnteringBlock()->getFirstInsertionPt());
>
> - Value *RTC = buildRTC(Builder, NodeBuilder.getExprBuilder());
> - BasicBlock *StartBlock = executeScopConditionally(S, this, RTC);
> + BasicBlock *StartBlock = executeScopConditionally(S, this);
> + isl_ast_node *Ast = AstInfo.getAst();
> + LoopAnnotator Annotator;
> + PollyIRBuilder Builder(StartBlock->getContext(), llvm::ConstantFolder(),
> + polly::IRInserter(Annotator));
> Builder.SetInsertPoint(StartBlock->begin());
>
> - NodeBuilder.create(AI->getAst());
> + IslNodeBuilder NodeBuilder(Builder, Annotator, this, LI, SE, DT);
> +
> + Builder.SetInsertPoint(StartBlock->getSinglePredecessor()->begin());
> + NodeBuilder.addMemoryAccesses(S);
> + NodeBuilder.addParameters(S.getContext());
> + // Build condition that evaluates at run-time if all assumptions taken
> + // for the scop hold. If we detect some assumptions do not hold, the
> + // original code is executed.
> + Value *V = NodeBuilder.getExprBuilder().create(AstInfo.getRunCondition());
> + Value *Zero = ConstantInt::get(V->getType(), 0);
> + V = Builder.CreateICmp(CmpInst::ICMP_NE, Zero, V);
> + BasicBlock *PrevBB = StartBlock->getUniquePredecessor();
> + BranchInst *Branch = dyn_cast<BranchInst>(PrevBB->getTerminator());
> + Branch->setCondition(V);
> + Builder.SetInsertPoint(StartBlock->begin());
>
> - DEBUG(StartBlock->getParent()->dump());
> + NodeBuilder.create(Ast);
> return true;
> }
>
>
> Modified: polly/trunk/lib/CodeGen/Utils.cpp
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/Utils.cpp?rev=215817&r1=215816&r2=215817&view=diff
> ==============================================================================
> --- polly/trunk/lib/CodeGen/Utils.cpp (original)
> +++ polly/trunk/lib/CodeGen/Utils.cpp Sat Aug 16 04:09:15 2014
> @@ -20,17 +20,18 @@
>
> using namespace llvm;
>
> -BasicBlock *polly::executeScopConditionally(Scop &S, Pass *P, Value *RTC) {
> +BasicBlock *polly::executeScopConditionally(Scop &S, Pass *PassInfo) {
> BasicBlock *StartBlock, *SplitBlock, *NewBlock;
> Region &R = S.getRegion();
> PollyIRBuilder Builder(R.getEntry());
> - DominatorTree &DT = P->getAnalysis<DominatorTreeWrapperPass>().getDomTree();
> - RegionInfo &RI = P->getAnalysis<RegionInfoPass>().getRegionInfo();
> - LoopInfo &LI = P->getAnalysis<LoopInfo>();
> + DominatorTree &DT =
> + PassInfo->getAnalysis<DominatorTreeWrapperPass>().getDomTree();
> + RegionInfo &RI = PassInfo->getAnalysis<RegionInfoPass>().getRegionInfo();
> + LoopInfo &LI = PassInfo->getAnalysis<LoopInfo>();
>
> // Split the entry edge of the region and generate a new basic block on this
> // edge. This function also updates ScopInfo and RegionInfo.
> - NewBlock = SplitEdge(R.getEnteringBlock(), R.getEntry(), P);
> + NewBlock = SplitEdge(R.getEnteringBlock(), R.getEntry(), PassInfo);
> if (DT.dominates(R.getEntry(), NewBlock)) {
> BasicBlock *OldBlock = R.getEntry();
> std::string OldName = OldBlock->getName();
> @@ -58,7 +59,7 @@ BasicBlock *polly::executeScopConditiona
> StartBlock = BasicBlock::Create(F->getContext(), "polly.start", F);
> SplitBlock->getTerminator()->eraseFromParent();
> Builder.SetInsertPoint(SplitBlock);
> - Builder.CreateCondBr(RTC, StartBlock, R.getEntry());
> + Builder.CreateCondBr(Builder.getTrue(), StartBlock, R.getEntry());
> if (Loop *L = LI.getLoopFor(SplitBlock))
> L->addBasicBlockToLoop(StartBlock, LI.getBase());
> DT.addNewBlock(StartBlock, SplitBlock);
> @@ -71,7 +72,7 @@ BasicBlock *polly::executeScopConditiona
> // PHI nodes that would complicate life.
> MergeBlock = R.getExit();
> else {
> - MergeBlock = SplitEdge(R.getExitingBlock(), R.getExit(), P);
> + MergeBlock = SplitEdge(R.getExitingBlock(), R.getExit(), PassInfo);
> // SplitEdge will never split R.getExit(), as R.getExit() has more than
> // one predecessor. Hence, mergeBlock is always a newly generated block.
> R.replaceExitRecursive(MergeBlock);
>
> Modified: polly/trunk/test/Isl/CodeGen/multidim_2d_parametric_array_static_loop_bounds.ll
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/multidim_2d_parametric_array_static_loop_bounds.ll?rev=215817&r1=215816&r2=215817&view=diff
> ==============================================================================
> --- polly/trunk/test/Isl/CodeGen/multidim_2d_parametric_array_static_loop_bounds.ll (original)
> +++ polly/trunk/test/Isl/CodeGen/multidim_2d_parametric_array_static_loop_bounds.ll Sat Aug 16 04:09:15 2014
> @@ -10,10 +10,11 @@ target triple = "x86_64-unknown-linux-gn
> ; A[i][j] = 1.0;
> ; }
>
> -; CHECK: %[[T0:[._a-zA-Z0-9]]] = icmp sge i64 %m, 150
> -; CHECK: %[[T1:[._a-zA-Z0-9]]] = select i1 %[[T0]], i64 1, i64 0
> -; CHECK: %[[T2:[._a-zA-Z0-9]]] = icmp ne i64 %[[T1]], 0
> -; CHECK: br i1 %[[T2]], label %polly.start, label %for.i
> +; CHECK: polly.split_new_and_old:
> +; CHECK: %0 = icmp sge i64 %m, 150
> +; CHECK: %1 = select i1 %0, i64 1, i64 0
> +; CHECK: %2 = icmp ne i64 0, %1
> +; CHECK: br i1 %2, label %polly.start, label %for.i
>
> define void @foo(i64 %n, i64 %m, double* %A) {
> entry:
>
> Modified: polly/trunk/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll?rev=215817&r1=215816&r2=215817&view=diff
> ==============================================================================
> --- polly/trunk/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll (original)
> +++ polly/trunk/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll Sat Aug 16 04:09:15 2014
> @@ -1,11 +1,10 @@
> ; RUN: opt %loadPolly -polly-codegen-isl -S -polly-delinearize < %s | FileCheck %s
> ; RUN: opt %loadPolly -polly-codegen-isl -S -polly-delinearize -polly-codegen-scev < %s | FileCheck %s
>
> -; CHECK: zext i32 %n to i64
> -; CHECK: %[[T0:[._a-zA-Z0-9]]] = zext i32 %n to i64
> -; CHECK: %[[T1:[._a-zA-Z0-9]]] = icmp sge i64 %[[T0]], 1
> -; CHECK: %[[T2:[._a-zA-Z0-9]]] = select i1 %[[T1]], i64 1, i64 0
> -; CHECK: %[[T3:[._a-zA-Z0-9]]] = icmp ne i64 %[[T2]], 0
> +; CHECK: %1 = zext i32 %n to i64
> +; CHECK: %2 = icmp sge i64 %1, 1
> +; CHECK: %3 = select i1 %2, i64 1, i64 0
> +; CHECK: %4 = icmp ne i64 0, %3
>
> target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> target triple = "x86_64-unknown-linux-gnu"
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
--
Johannes Doerfert
Researcher / PhD Student
Compiler Design Lab (Prof. Hack)
Saarland University, Computer Science
Building E1.3, Room 4.26
Tel. +49 (0)681 302-57521 : doerfert at cs.uni-saarland.de
Fax. +49 (0)681 302-3065 : http://www.cdl.uni-saarland.de/people/doerfert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Refactor-Cleanup-runtime-code-generation.patch
Type: text/x-diff
Size: 15431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140819/62dd7281/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140819/62dd7281/attachment.sig>
More information about the llvm-commits
mailing list