@@ -1736,18 +1736,10 @@ FlowGraph::Destroy(void)
17361736 FOREACH_BLOCK (block, this )
17371737 {
17381738 Region * region = block->GetFirstInstr ()->AsLabelInstr ()->GetRegion ();
1739- Region * predRegion = nullptr ;
17401739 FOREACH_PREDECESSOR_BLOCK (predBlock, block)
17411740 {
17421741 BasicBlock* intermediateBlock = block;
1743- // Skip blocks inserted for airlock/masking purposes
1744- while ((predBlock->isAirLockBlock || predBlock->isAirLockCompensationBlock ) && predBlock->GetFirstInstr ()->AsLabelInstr ()->GetRegion () == region)
1745- {
1746- Assert (predBlock->GetPredList ()->HasOne ());
1747- intermediateBlock = predBlock;
1748- predBlock = predBlock->GetPredList ()->Head ()->GetPred ();
1749- }
1750- predRegion = predBlock->GetFirstInstr ()->AsLabelInstr ()->GetRegion ();
1742+ Region * predRegion = predBlock->GetFirstInstr ()->AsLabelInstr ()->GetRegion ();
17511743 if (predBlock->GetLastInstr () == nullptr )
17521744 {
17531745 AssertMsg (region == predRegion, " Bad region propagation through empty block" );
@@ -2255,7 +2247,7 @@ FlowGraph::InsertCompBlockToLoopList(Loop *loop, BasicBlock* compBlock, BasicBlo
22552247
22562248// Insert a block on the given edge
22572249BasicBlock *
2258- FlowGraph::InsertAirlockBlock (FlowEdge * edge)
2250+ FlowGraph::InsertAirlockBlock (FlowEdge * edge, bool afterForward /* = false */ )
22592251{
22602252 BasicBlock * airlockBlock = BasicBlock::New (this );
22612253 BasicBlock * sourceBlock = edge->GetPred ();
@@ -2341,7 +2333,12 @@ FlowGraph::InsertAirlockBlock(FlowEdge * edge)
23412333 airlockBlock->SetLastInstr (airlockBr);
23422334
23432335 airlockLabel->SetByteCodeOffset (sinkLabel);
2344- airlockLabel->SetRegion (sinkLabel->GetRegion ());
2336+
2337+ // If we have regions in play, we should update them on the airlock block appropriately
2338+ if (afterForward)
2339+ {
2340+ airlockLabel->SetRegion (sinkLabel->GetRegion ());
2341+ }
23452342
23462343 // Fixup flow out of sourceBlock
23472344 IR::BranchInstr *sourceBr = sourceLastInstr->AsBranchInstr ();
@@ -2362,7 +2359,7 @@ FlowGraph::InsertAirlockBlock(FlowEdge * edge)
23622359 FlowEdge *dstEdge = this ->FindEdge (sinkPrevBlock, sinkBlock);
23632360 if (dstEdge) // Possibility that sourceblock may be same as sinkPrevBlock
23642361 {
2365- BasicBlock* compensationBlock = this ->InsertCompensationCodeForBlockMove (dstEdge, true /* insert comp block to loop list*/ , true );
2362+ BasicBlock* compensationBlock = this ->InsertCompensationCodeForBlockMove (dstEdge, true /* insert comp block to loop list*/ , true , afterForward );
23662363 compensationBlock->IncrementDataUseCount ();
23672364 // We need to skip airlock compensation block in globopt as its inserted while globopt is iteration over the blocks.
23682365 compensationBlock->isAirLockCompensationBlock = true ;
@@ -2379,7 +2376,7 @@ FlowGraph::InsertAirlockBlock(FlowEdge * edge)
23792376
23802377// Insert a block on the given edge
23812378BasicBlock *
2382- FlowGraph::InsertCompensationCodeForBlockMove (FlowEdge * edge, bool insertToLoopList, bool sinkBlockLoop)
2379+ FlowGraph::InsertCompensationCodeForBlockMove (FlowEdge * edge, bool insertToLoopList /* =false */ , bool sinkBlockLoop /* =false */ , bool afterForward /* =false */ )
23832380{
23842381 BasicBlock * compBlock = BasicBlock::New (this );
23852382 BasicBlock * sourceBlock = edge->GetPred ();
@@ -2463,7 +2460,6 @@ FlowGraph::InsertCompensationCodeForBlockMove(FlowEdge * edge, bool insertToLoo
24632460 compBlock->SetLastInstr (compBr);
24642461
24652462 compLabel->SetByteCodeOffset (sinkLabel);
2466- compLabel->SetRegion (sinkLabel->GetRegion ());
24672463
24682464 // Fixup flow out of sourceBlock
24692465 if (sourceLastInstr->IsBranchInstr ())
@@ -2477,13 +2473,20 @@ FlowGraph::InsertCompensationCodeForBlockMove(FlowEdge * edge, bool insertToLoo
24772473 }
24782474 }
24792475
2480- bool assignRegionsBeforeGlobopt = this ->func ->HasTry () && (this ->func ->DoOptimizeTry () ||
2481- (this ->func ->IsSimpleJit () && this ->func ->hasBailout ) ||
2482- this ->func ->IsLoopBodyInTryFinally ());
2476+ if (!afterForward)
2477+ {
2478+ bool assignRegionsBeforeGlobopt = this ->func ->HasTry () && (this ->func ->DoOptimizeTry () ||
2479+ (this ->func ->IsSimpleJit () && this ->func ->hasBailout ) ||
2480+ this ->func ->IsLoopBodyInTryFinally ());
24832481
2484- if (assignRegionsBeforeGlobopt)
2482+ if (assignRegionsBeforeGlobopt)
2483+ {
2484+ UpdateRegionForBlockFromEHPred (compBlock);
2485+ }
2486+ }
2487+ else
24852488 {
2486- UpdateRegionForBlockFromEHPred (compBlock );
2489+ compLabel-> SetRegion (sinkLabel-> GetRegion () );
24872490 }
24882491
24892492 return compBlock;
0 commit comments