mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-27 13:30:05 +00:00
If we are extracting a block that has multiple successors that are the same
block (common in a switch), make sure to remove extra edges in successor blocks. This fixes CodeExtractor/2004-08-12-BlockExtractPHI.ll and should be pulled into LLVM 1.3 (though the regression test need not be, as that would require pulling in the LoopExtract.cpp changes). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15717 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
337772832b
commit
a670c684a6
@ -657,10 +657,19 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) {
|
||||
succ_end(codeReplacer));
|
||||
for (unsigned i = 0, e = Succs.size(); i != e; ++i)
|
||||
for (BasicBlock::iterator I = Succs[i]->begin();
|
||||
PHINode *PN = dyn_cast<PHINode>(I); ++I)
|
||||
PHINode *PN = dyn_cast<PHINode>(I); ++I) {
|
||||
std::set<BasicBlock*> ProcessedPreds;
|
||||
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
|
||||
if (BlocksToExtract.count(PN->getIncomingBlock(i)))
|
||||
PN->setIncomingBlock(i, codeReplacer);
|
||||
if (ProcessedPreds.insert(PN->getIncomingBlock(i)).second)
|
||||
PN->setIncomingBlock(i, codeReplacer);
|
||||
else {
|
||||
// There were multiple entries in the PHI for this block, now there
|
||||
// is only one, so remove the duplicated entries.
|
||||
PN->removeIncomingValue(i, false);
|
||||
--i; --e;
|
||||
}
|
||||
}
|
||||
|
||||
//std::cerr << "NEW FUNCTION: " << *newFunction;
|
||||
// verifyFunction(*newFunction);
|
||||
|
Loading…
Reference in New Issue
Block a user