[llvm-commits] [release_13] CVS: llvm/lib/Transforms/Utils/CodeExtractor.cpp ValueMapper.cpp
John Criswell
criswell at cs.uiuc.edu
Fri Aug 13 11:52:16 PDT 2004
Changes in directory llvm/lib/Transforms/Utils:
CodeExtractor.cpp updated: 1.27.2.1 -> 1.27.2.2
ValueMapper.cpp updated: 1.17 -> 1.17.2.1
---
Log message:
Merged from mainline.
---
Diffs of the changes: (+17 -3)
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.27.2.1 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.27.2.2
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.27.2.1 Thu Aug 12 09:28:44 2004
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Fri Aug 13 13:52:00 2004
@@ -622,7 +622,7 @@
Function *oldFunction = header->getParent();
// This takes place of the original loop
- BasicBlock *codeReplacer = new BasicBlock("codeRepl", oldFunction);
+ BasicBlock *codeReplacer = new BasicBlock("codeRepl", oldFunction, header);
// The new function needs a root node because other nodes can branch to the
// head of the region, but the entry node of a function cannot have preds.
@@ -657,10 +657,19 @@
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);
Index: llvm/lib/Transforms/Utils/ValueMapper.cpp
diff -u llvm/lib/Transforms/Utils/ValueMapper.cpp:1.17 llvm/lib/Transforms/Utils/ValueMapper.cpp:1.17.2.1
--- llvm/lib/Transforms/Utils/ValueMapper.cpp:1.17 Wed Aug 4 03:22:15 2004
+++ llvm/lib/Transforms/Utils/ValueMapper.cpp Fri Aug 13 13:52:00 2004
@@ -81,6 +81,11 @@
for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i)
Idx.push_back(cast<Constant>(MapValue(CE->getOperand(i), VM)));
return VMSlot = ConstantExpr::getGetElementPtr(MV, Idx);
+ } else if (CE->getOpcode() == Instruction::Select) {
+ Constant *MV1 = cast<Constant>(MapValue(CE->getOperand(0), VM));
+ Constant *MV2 = cast<Constant>(MapValue(CE->getOperand(1), VM));
+ Constant *MV3 = cast<Constant>(MapValue(CE->getOperand(2), VM));
+ return VMSlot = ConstantExpr::getSelect(MV1, MV2, MV3);
} else {
assert(CE->getNumOperands() == 2 && "Must be binary operator?");
Constant *MV1 = cast<Constant>(MapValue(CE->getOperand(0), VM));
More information about the llvm-commits
mailing list