aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils/BasicBlockUtils.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-11-05 18:25:44 +0000
committerDan Gohman <gohman@apple.com>2009-11-05 18:25:44 +0000
commit5013522f6bb58c5591e2681e6e293ed9f3bd76e1 (patch)
tree6c48eb9ad6fa85825bbe37dc3804a75d4cd4773a /lib/Transforms/Utils/BasicBlockUtils.cpp
parent586101f58224a041c3fafb356155e42e16ba793e (diff)
downloadexternal_llvm-5013522f6bb58c5591e2681e6e293ed9f3bd76e1.zip
external_llvm-5013522f6bb58c5591e2681e6e293ed9f3bd76e1.tar.gz
external_llvm-5013522f6bb58c5591e2681e6e293ed9f3bd76e1.tar.bz2
Add an assertion to catch indirectbr in SplitBlockPredecessors. This
makes several optimization passes abort in cases where they're currently silently miscompiling code. Remove the indirectbr assertion from SplitEdge. Indirectbr is only a problem for critical edges, and SplitEdge defers to SplitCriticalEdge to handle those, and SplitCriticalEdge has its own assertion for indirectbr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86147 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/BasicBlockUtils.cpp')
-rw-r--r--lib/Transforms/Utils/BasicBlockUtils.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp
index c728c0b..2974592 100644
--- a/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -275,8 +275,6 @@ void llvm::RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) {
/// SplitEdge - Split the edge connecting specified block. Pass P must
/// not be NULL.
BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, Pass *P) {
- assert(!isa<IndirectBrInst>(BB->getTerminator()) &&
- "Cannot split an edge from an IndirectBrInst");
TerminatorInst *LatchTerm = BB->getTerminator();
unsigned SuccNum = 0;
#ifndef NDEBUG
@@ -386,6 +384,12 @@ BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,
bool IsLoopEntry = !!L;
bool SplitMakesNewLoopHeader = false;
for (unsigned i = 0; i != NumPreds; ++i) {
+ // This is slightly more strict than necessary; the minimum requirement
+ // is that there be no more than one indirectbr branching to BB. And
+ // all BlockAddress uses would need to be updated.
+ assert(!isa<IndirectBrInst>(Preds[i]->getTerminator()) &&
+ "Cannot split an edge from an IndirectBrInst");
+
Preds[i]->getTerminator()->replaceUsesOfWith(BB, NewBB);
if (LI) {