58
58
#include " llvm/Support/CommandLine.h"
59
59
#include " llvm/Support/Debug.h"
60
60
61
- // This is temporarily used for testing until Swift 5.5 branches to reduce risk.
62
- llvm::cl::opt<bool > EnableOSSASimplifyCFG (
63
- " enable-ossa-simplify-cfg" ,
64
- llvm::cl::desc (
65
- " Enable non-trivial OSSA simplify-cfg and simple jump threading "
66
- " (staging)." ));
67
-
68
- // This requires new OwnershipOptUtilities which aren't well tested yet.
69
- llvm::cl::opt<bool > EnableOSSARewriteTerminator (
70
- " enable-ossa-rewriteterminator" ,
71
- llvm::cl::desc (
72
- " Enable OSSA simplify-cfg with non-trivial terminator rewriting "
73
- " (staging)." ));
61
+ llvm::cl::opt<bool > EnableOSSACheckedCastBrJumpThreading (
62
+ " enable-ossa-checked-cast-br-jump-threading" ,
63
+ llvm::cl::desc (" Enable OSSA checked cast branch jump threading "
64
+ " (staging)." ),
65
+ llvm::cl::init(true ));
66
+
67
+ llvm::cl::opt<bool > EnableOSSASimpleJumpThreading (
68
+ " enable-ossa-simple-jump-threading" ,
69
+ llvm::cl::desc (" Enable OSSA simple jump threading (staging)." ),
70
+ llvm::cl::init(true ));
71
+
72
+ llvm::cl::opt<bool > EnableOSSADominatorBasedSimplify (
73
+ " enable-ossa-dominator-based-simplify" ,
74
+ llvm::cl::desc (" Enable OSSA dominator based simplifications (staging)." ),
75
+ llvm::cl::init(true ));
74
76
75
77
llvm::cl::opt<bool > IsInfiniteJumpThreadingBudget (
76
78
" sil-infinite-jump-threading-budget" ,
@@ -536,7 +538,7 @@ bool SimplifyCFG::dominatorBasedSimplify(DominanceAnalysis *DA) {
536
538
// Get the dominator tree.
537
539
DT = DA->get (&Fn);
538
540
539
- if (!EnableOSSASimplifyCFG && Fn.hasOwnership ())
541
+ if (!EnableOSSADominatorBasedSimplify && Fn.hasOwnership ())
540
542
return false ;
541
543
542
544
// Split all critical edges such that we can move code onto edges. This is
@@ -560,7 +562,7 @@ bool SimplifyCFG::dominatorBasedSimplify(DominanceAnalysis *DA) {
560
562
// and MUST NOT change the CFG without updating the dominator tree to
561
563
// reflect such change.
562
564
if (tryCheckedCastBrJumpThreading (&Fn, DT, deBlocks, BlocksForWorklist,
563
- EnableOSSARewriteTerminator )) {
565
+ EnableOSSACheckedCastBrJumpThreading )) {
564
566
for (auto BB: BlocksForWorklist)
565
567
addToWorklist (BB);
566
568
@@ -907,19 +909,13 @@ static bool hasInjectedEnumAtEndOfBlock(SILBasicBlock *block, SILValue enumAddr)
907
909
// / tryJumpThreading - Check to see if it looks profitable to duplicate the
908
910
// / destination of an unconditional jump into the bottom of this block.
909
911
bool SimplifyCFG::tryJumpThreading (BranchInst *BI) {
910
- if (!EnableOSSASimplifyCFG && Fn.hasOwnership ())
912
+ if (!EnableOSSASimpleJumpThreading && Fn.hasOwnership ())
911
913
return false ;
912
914
913
915
auto *DestBB = BI->getDestBB ();
914
916
auto *SrcBB = BI->getParent ();
915
917
TermInst *destTerminator = DestBB->getTerminator ();
916
- if (!EnableOSSARewriteTerminator && Fn.hasOwnership ()) {
917
- if (llvm::any_of (DestBB->getArguments (), [this ](SILValue op) {
918
- return !op->getType ().isTrivial (Fn);
919
- })) {
920
- return false ;
921
- }
922
- }
918
+
923
919
// If the destination block ends with a return, we don't want to duplicate it.
924
920
// We want to maintain the canonical form of a single return where possible.
925
921
if (destTerminator->isFunctionExiting ())
0 commit comments