@@ -2891,16 +2891,10 @@ bool Compiler::optCreatePreheader(FlowGraphNaturalLoop* loop)
28912891 }
28922892 }
28932893
2894- BasicBlock* insertBefore = loop->GetLexicallyTopMostBlock ();
2895- if (!BasicBlock::sameEHRegion (insertBefore, header))
2896- {
2897- insertBefore = header;
2898- }
2899-
2900- BasicBlock* preheader = fgNewBBbefore (BBJ_ALWAYS, insertBefore, false );
2894+ BasicBlock* preheader = fgNewBBbefore (BBJ_ALWAYS, header, false );
29012895 preheader->SetFlags (BBF_INTERNAL);
29022896 fgSetEHRegionForNewPreheaderOrExit (preheader);
2903- preheader->bbCodeOffs = insertBefore ->bbCodeOffs ;
2897+ preheader->bbCodeOffs = header ->bbCodeOffs ;
29042898
29052899 JITDUMP (" Created new preheader " FMT_BB " for " FMT_LP " \n " , preheader->bbNum , loop->GetIndex ());
29062900
@@ -3003,21 +2997,11 @@ bool Compiler::optCanonicalizeExit(FlowGraphNaturalLoop* loop, BasicBlock* exit)
30032997 {
30042998 // Branches to a BBJ_CALLFINALLY _must_ come from inside its associated
30052999 // try region, and when we have callfinally thunks the BBJ_CALLFINALLY
3006- // is outside it. First try to see if the lexically bottom most block
3007- // is part of the try; if so, inserting after that is a good choice .
3000+ // is outside it. Thus, insert newExit at the end of the finally's
3001+ // try region .
30083002 BasicBlock* finallyBlock = exit->GetTarget ();
30093003 assert (finallyBlock->hasHndIndex ());
3010- BasicBlock* bottom = loop->GetLexicallyBottomMostBlock ();
3011- if (bottom->hasTryIndex () && (bottom->getTryIndex () == finallyBlock->getHndIndex ()) && !bottom->hasHndIndex ())
3012- {
3013- newExit = fgNewBBafter (BBJ_ALWAYS, bottom, true );
3014- }
3015- else
3016- {
3017- // Otherwise just do the heavy-handed thing and insert it anywhere in the right region.
3018- newExit = fgNewBBinRegion (BBJ_ALWAYS, finallyBlock->bbHndIndex , 0 , nullptr , /* putInFilter */ false ,
3019- /* runRarely */ false , /* insertAtEnd */ true );
3020- }
3004+ newExit = fgNewBBatTryRegionEnd (BBJ_ALWAYS, finallyBlock->getHndIndex ());
30213005 }
30223006 else
30233007 {
0 commit comments