mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
OSSA: SimplifyCFG. Add DeadEndBlocks and pass it to jump-threading.
This commit is contained in:
@@ -42,6 +42,13 @@ class CheckedCastBrJumpThreading {
|
||||
// Dominator information to be used.
|
||||
DominanceInfo *DT;
|
||||
|
||||
// DeadEndBlocks is used by OwnershipRAUW and incrementally updated within
|
||||
// CheckedCastBrJumpThreading.
|
||||
//
|
||||
// TODO: incrementally update dead-end blocks during SimplifyCFG so it doesn't
|
||||
// need to be recomputed each time tryCheckedCastBrJumpThreading is called.
|
||||
DeadEndBlocks *deBlocks;
|
||||
|
||||
// Enable non-trivial terminator rewriting in OSSA.
|
||||
bool EnableOSSARewriteTerminator;
|
||||
|
||||
@@ -123,10 +130,10 @@ class CheckedCastBrJumpThreading {
|
||||
|
||||
public:
|
||||
CheckedCastBrJumpThreading(
|
||||
SILFunction *Fn, DominanceInfo *DT,
|
||||
SILFunction *Fn, DominanceInfo *DT, DeadEndBlocks *deBlocks,
|
||||
SmallVectorImpl<SILBasicBlock *> &BlocksForWorklist,
|
||||
bool EnableOSSARewriteTerminator)
|
||||
: Fn(Fn), DT(DT),
|
||||
: Fn(Fn), DT(DT), deBlocks(deBlocks),
|
||||
EnableOSSARewriteTerminator(EnableOSSARewriteTerminator),
|
||||
BlocksForWorklist(BlocksForWorklist), BlocksToEdit(Fn),
|
||||
BlocksToClone(Fn) {}
|
||||
@@ -673,7 +680,7 @@ void CheckedCastBrJumpThreading::optimizeFunction() {
|
||||
Fn->verifyCriticalEdges();
|
||||
|
||||
for (Edit *edit : Edits) {
|
||||
BasicBlockCloner Cloner(edit->CCBBlock);
|
||||
BasicBlockCloner Cloner(edit->CCBBlock, deBlocks);
|
||||
if (!Cloner.canCloneBlock())
|
||||
continue;
|
||||
|
||||
@@ -698,11 +705,12 @@ void CheckedCastBrJumpThreading::optimizeFunction() {
|
||||
namespace swift {
|
||||
|
||||
bool tryCheckedCastBrJumpThreading(
|
||||
SILFunction *Fn, DominanceInfo *DT,
|
||||
SILFunction *Fn, DominanceInfo *DT, DeadEndBlocks *deBlocks,
|
||||
SmallVectorImpl<SILBasicBlock *> &BlocksForWorklist,
|
||||
bool EnableOSSARewriteTerminator) {
|
||||
|
||||
CheckedCastBrJumpThreading CCBJumpThreading(Fn, DT, BlocksForWorklist,
|
||||
CheckedCastBrJumpThreading CCBJumpThreading(Fn, DT, deBlocks,
|
||||
BlocksForWorklist,
|
||||
EnableOSSARewriteTerminator);
|
||||
CCBJumpThreading.optimizeFunction();
|
||||
return !BlocksForWorklist.empty();
|
||||
|
||||
Reference in New Issue
Block a user