1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

Make sure that the landing pads themselves have no PHI instructions in them.

The assumption in the back-end is that PHIs are not allowed at the start of the
landing pad block for SjLj exceptions.
<rdar://problem/10313708>

llvm-svn: 142689
This commit is contained in:
Bill Wendling 2011-10-21 22:08:56 +00:00
parent 917737037d
commit 34a9073d67

View File

@ -908,6 +908,27 @@ void SjLjEHPass::lowerAcrossUnwindEdges(Function &F,
} }
} }
} }
// Go through the landing pads and remove any PHIs there.
for (unsigned i = 0, e = Invokes.size(); i != e; ++i) {
BasicBlock *UnwindBlock = Invokes[i]->getUnwindDest();
LandingPadInst *LPI = UnwindBlock->getLandingPadInst();
// Place PHIs into a set to avoid invalidating the iterator.
SmallPtrSet<PHINode*, 8> PHIsToDemote;
for (BasicBlock::iterator
PN = UnwindBlock->begin(); isa<PHINode>(PN); ++PN)
PHIsToDemote.insert(cast<PHINode>(PN));
if (PHIsToDemote.empty()) continue;
// Demote the PHIs to the stack.
for (SmallPtrSet<PHINode*, 8>::iterator
I = PHIsToDemote.begin(), E = PHIsToDemote.end(); I != E; ++I)
DemotePHIToStack(*I);
// Move the landingpad instruction back to the top of the landing pad block.
LPI->moveBefore(UnwindBlock->begin());
}
} }
/// setupEntryBlockAndCallSites - Setup the entry block by creating and filling /// setupEntryBlockAndCallSites - Setup the entry block by creating and filling