[llvm-branch-commits] [polly] r246029 - Only use instructions as insert locations for SCEVExpander
Tobias Grosser via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Aug 26 04:01:16 PDT 2015
Author: grosser
Date: Wed Aug 26 06:01:14 2015
New Revision: 246029
URL: http://llvm.org/viewvc/llvm-project?rev=246029&view=rev
Log:
Only use instructions as insert locations for SCEVExpander
SCEVExpander, which we are using during code generation, only allows
instructions as insert locations, but breaks in case BasicBlock->end() iterators
are passed to it due to it trying to obtain the basic block in which code should
be generated by calling Instruction->getParent(), which is not defined for
->end() iterators.
This change adds an assert to Polly that ensures we only pass valid instructions
to SCEVExpander and it fixes one case, where we used IRBuilder->SetInsertBlock()
to set an ->end() insert location which was later passed to SCEVExpander.
In general, Polly is always trying to build up the CFG first, before we actually
insert instructions into the CFG sceleton. As a result, each basic block should
already have at least one branch instruction before we start adding code. Hence,
always requiring the IRBuilder insert location to be set to a real instruction
should always be possible.
Thanks Utpal Bora <cs14mtech11017 at iith.ac.in> for his help with test case
reduction.
This is a backport from r243830 as it was committed on trunk.
Added:
polly/branches/release_37/test/Isl/CodeGen/non-affine-phi-node-expansion.ll
Modified:
polly/branches/release_37/lib/CodeGen/BlockGenerators.cpp
Modified: polly/branches/release_37/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_37/lib/CodeGen/BlockGenerators.cpp?rev=246029&r1=246028&r2=246029&view=diff
==============================================================================
--- polly/branches/release_37/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/branches/release_37/lib/CodeGen/BlockGenerators.cpp Wed Aug 26 06:01:14 2015
@@ -123,6 +123,8 @@ Value *BlockGenerator::getNewValue(ScopS
->getParent()
->getDataLayout(),
"polly");
+ assert(Builder.GetInsertPoint() != Builder.GetInsertBlock()->end() &&
+ "Only instructions can be insert points for SCEVExpander");
Value *Expanded = Expander.expandCodeFor(NewScev, Old->getType(),
Builder.GetInsertPoint());
@@ -1116,7 +1118,7 @@ void RegionGenerator::copyStmt(ScopStmt
ValueMapT &RegionMap = RegionMaps[BBCopy];
RegionMap.insert(BlockMap.begin(), BlockMap.end());
- Builder.SetInsertPoint(BBCopy);
+ Builder.SetInsertPoint(BICopy);
copyInstScalar(Stmt, BI, RegionMap, GlobalMap, LTS);
BICopy->eraseFromParent();
}
Added: polly/branches/release_37/test/Isl/CodeGen/non-affine-phi-node-expansion.ll
URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_37/test/Isl/CodeGen/non-affine-phi-node-expansion.ll?rev=246029&view=auto
==============================================================================
--- polly/branches/release_37/test/Isl/CodeGen/non-affine-phi-node-expansion.ll (added)
+++ polly/branches/release_37/test/Isl/CodeGen/non-affine-phi-node-expansion.ll Wed Aug 26 06:01:14 2015
@@ -0,0 +1,54 @@
+; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+%struct.wombat = type {[4 x i32]}
+
+; CHECK: polly.stmt.bb3.entry: ; preds = %polly.start
+; CHECK: br label %polly.stmt.bb3
+
+; CHECK: polly.stmt.bb3: ; preds = %polly.stmt.bb3.entry
+; CHECK: %polly.subregion.iv = phi i32 [ 0, %polly.stmt.bb3.entry ]
+; CHECK: %polly.subregion.iv.inc = add i32 %polly.subregion.iv, 1
+; CHECK: br i1 true, label %polly.stmt.bb4, label %polly.stmt.bb5
+
+; CHECK: polly.stmt.bb4: ; preds = %polly.stmt.bb3
+; CHECK: br label %polly.stmt.bb13.exit
+
+; CHECK: polly.stmt.bb5: ; preds = %polly.stmt.bb3
+; CHECK: %tmp7_p_scalar_ = load i32, i32* %B, !alias.scope !0, !noalias !2
+; CHECK: store i32 %tmp7_p_scalar_, i32* %polly.access.cast.arg2, !alias.scope !3, !noalias !4
+; CHECK: br label %polly.stmt.bb13.exit
+
+; Function Attrs: nounwind uwtable
+define void @quux(%struct.wombat* %arg, i32* %B) {
+bb:
+ br i1 undef, label %bb2, label %bb1
+
+bb1: ; preds = %bb
+ br label %bb2
+
+bb2: ; preds = %bb1, %bb
+ %tmp = phi i1 [ true, %bb ], [ undef, %bb1 ]
+ br label %bb3
+
+bb3: ; preds = %bb13, %bb2
+ br i1 %tmp, label %bb4, label %bb5
+
+bb4: ; preds = %bb3
+ br label %bb13
+
+bb5: ; preds = %bb3
+ %tmp7 = load i32, i32* %B
+ %tmp12 = getelementptr inbounds %struct.wombat, %struct.wombat* %arg, i64 0, i32 0, i64 0
+ store i32 %tmp7, i32* %tmp12
+ br label %bb13
+
+bb13: ; preds = %bb5, %bb4
+ br i1 false, label %bb3, label %bb14
+
+bb14: ; preds = %bb13
+ br label %bb15
+
+bb15: ; preds = %bb14
+ unreachable
+}
More information about the llvm-branch-commits
mailing list