summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2016-08-08 15:25:46 +0000
committerTobias Grosser <tobias@grosser.es>2016-08-08 15:25:46 +0000
commit000db70754841d2e86b7a72029f21e3e2fbdc981 (patch)
tree8aefcc9cdc3b1e08d1963ce8918c0f27ba6e3811
parent4fbc3f4a376f7902757c210aaf55962c6b09e829 (diff)
downloadbcm5719-llvm-000db70754841d2e86b7a72029f21e3e2fbdc981.tar.gz
bcm5719-llvm-000db70754841d2e86b7a72029f21e3e2fbdc981.zip
[IslNodeBuilder] Directly use the insert location of our Builder
... instead of adding instructions at the end of the basic block the builder is currently at. This makes it easier to reason about where IR is generated, as with the IRBuilder there is just a single location that specificies where IR is generated. llvm-svn: 278013
-rw-r--r--polly/lib/CodeGen/IslNodeBuilder.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp
index e46304fe2e6..b8a83ab0b88 100644
--- a/polly/lib/CodeGen/IslNodeBuilder.cpp
+++ b/polly/lib/CodeGen/IslNodeBuilder.cpp
@@ -1222,7 +1222,20 @@ void IslNodeBuilder::addParameters(__isl_take isl_set *Context) {
}
Value *IslNodeBuilder::generateSCEV(const SCEV *Expr) {
- Instruction *InsertLocation = &*--(Builder.GetInsertBlock()->end());
+ /// We pass the insert location of our Builder, as Polly ensures during IR
+ /// generation that there is always a valid CFG into which instructions are
+ /// inserted. As a result, the insertpoint is known to be always followed by a
+ /// terminator instruction. This means the insert point may be specified by a
+ /// terminator instruction, but it can never point to an ->end() iterator
+ /// which does not have a corresponding instruction. Hence, dereferencing
+ /// the insertpoint to obtain an instruction is known to be save.
+ ///
+ /// We also do not need to update the Builder here, as new instructions are
+ /// always inserted _before_ the given InsertLocation. As a result, the
+ /// insert location remains valid.
+ assert(Builder.GetInsertBlock()->end() != Builder.getInsertPoint() &&
+ "Insert location points after last valid instruction");
+ Instruction *InsertLocation = &*Builder.GetInsertPoint();
return expandCodeFor(S, SE, DL, "polly", Expr, Expr->getType(),
InsertLocation, &ValueMap);
}
OpenPOWER on IntegriCloud