diff options
author | Andrew Trick <atrick@apple.com> | 2012-03-20 21:24:52 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-03-20 21:24:52 +0000 |
commit | f7711010e12503f0bd6e8c7a15c648fcd02d358b (patch) | |
tree | d47448bf0b8ed58c40e83e94bd5b4af89fefe765 /llvm/lib/Transforms/Utils/LoopSimplify.cpp | |
parent | bb01cbb312ee99a800bd72af1142f01d22ded582 (diff) | |
download | bcm5719-llvm-f7711010e12503f0bd6e8c7a15c648fcd02d358b.tar.gz bcm5719-llvm-f7711010e12503f0bd6e8c7a15c648fcd02d358b.zip |
LoopSimplify bug fix. Handle indirect loop back edges.
Do not call SplitBlockPredecessors on a loop preheader when one of the
predecessors is an indirectbr. Otherwise, you will hit this assert:
!isa<IndirectBrInst>(Preds[i]->getTerminator()) && "Cannot split an edge from an IndirectBrInst"
llvm-svn: 153134
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopSimplify.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index 1b6a19d9b66..0bc185d8b72 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -538,8 +538,7 @@ void LoopSimplify::PlaceSplitBlockCarefully(BasicBlock *NewBB, /// Loop *LoopSimplify::SeparateNestedLoop(Loop *L, LPPassManager &LPM, BasicBlock *Preheader) { - // Don't try to separate loops without a preheader (this excludes - // loop headers which are targeted by an indirectbr). + // Don't try to separate loops without a preheader. if (!Preheader) return 0; @@ -554,11 +553,15 @@ Loop *LoopSimplify::SeparateNestedLoop(Loop *L, LPPassManager &LPM, // handles the case when a PHI node has multiple instances of itself as // arguments. SmallVector<BasicBlock*, 8> OuterLoopPreds; - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { if (PN->getIncomingValue(i) != PN || - !L->contains(PN->getIncomingBlock(i))) + !L->contains(PN->getIncomingBlock(i))) { + // We can't split indirectbr edges. + if (isa<IndirectBrInst>(PN->getIncomingBlock(i)->getTerminator())) + return 0; OuterLoopPreds.push_back(PN->getIncomingBlock(i)); - + } + } DEBUG(dbgs() << "LoopSimplify: Splitting out a new outer loop\n"); // If ScalarEvolution is around and knows anything about values in |