[llvm-commits] CVS: llvm/lib/Transforms/Utils/CodeExtractor.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed May 12 11:08:07 PDT 2004
Changes in directory llvm/lib/Transforms/Utils:
CodeExtractor.cpp updated: 1.21 -> 1.22
---
Log message:
Implement support for code extracting basic blocks that have a return
instruction in them.
---
Diffs of the changes: (+12 -2)
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.21 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.22
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.21 Wed May 12 10:29:13 2004
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Wed May 12 11:07:41 2004
@@ -77,6 +77,7 @@
}
void severSplitPHINodes(BasicBlock *&Header);
+ void splitReturnBlocks();
void findInputsOutputs(Values &inputs, Values &outputs);
Function *constructFunction(const Values &inputs,
@@ -184,8 +185,13 @@
}
}
}
+}
- verifyFunction(*NewBB->getParent());
+void CodeExtractor::splitReturnBlocks() {
+ for (std::set<BasicBlock*>::iterator I = BlocksToExtract.begin(),
+ E = BlocksToExtract.end(); I != E; ++I)
+ if (ReturnInst *RI = dyn_cast<ReturnInst>((*I)->getTerminator()))
+ (*I)->splitBasicBlock(RI, (*I)->getName()+".ret");
}
// findInputsOutputs - Find inputs to, outputs from the code region.
@@ -596,8 +602,12 @@
"No blocks in this region may have entries from outside the region"
" except for the first block!");
- // If we have to split PHI nodes, do so now.
+ // If we have to split PHI nodes or the entry block, do so now.
severSplitPHINodes(header);
+
+ // If we have any return instructions in the region, split those blocks so
+ // that the return is not in the region.
+ splitReturnBlocks();
Function *oldFunction = header->getParent();
More information about the llvm-commits
mailing list