@@ -223,15 +223,20 @@ class IndirectCallTransformer
223223 // and insert in into the basic block list.
224224 //
225225 // Arguments:
226- // jumpKind - jump kind for the new basic block
226+ // jumpKind - jump kind for the new basic block
227227 // insertAfter - basic block, after which compiler has to insert the new one.
228+ // flagsSource - basic block to copy BBF_SPLIT_GAINED flags from
228229 //
229230 // Return Value:
230231 // new basic block.
231- BasicBlock* CreateAndInsertBasicBlock (BBKinds jumpKind, BasicBlock* insertAfter)
232+ BasicBlock* CreateAndInsertBasicBlock (BBKinds jumpKind, BasicBlock* insertAfter, BasicBlock* flagsSource )
232233 {
233234 BasicBlock* block = compiler->fgNewBBafter (jumpKind, insertAfter, true );
234235 block->SetFlags (BBF_IMPORTED );
236+ if (flagsSource != nullptr )
237+ {
238+ block->CopyFlags (flagsSource, BBF_SPLIT_GAINED );
239+ }
235240 return block;
236241 }
237242
@@ -380,7 +385,7 @@ class IndirectCallTransformer
380385 {
381386 assert (checkIdx == 0 );
382387
383- checkBlock = CreateAndInsertBasicBlock (BBJ_ALWAYS , currBlock);
388+ checkBlock = CreateAndInsertBasicBlock (BBJ_ALWAYS , currBlock, currBlock );
384389 GenTree* fatPointerMask = new (compiler, GT_CNS_INT ) GenTreeIntCon (TYP_I_IMPL , FAT_POINTER_MASK );
385390 GenTree* fptrAddressCopy = compiler->gtCloneExpr (fptrAddress);
386391 GenTree* fatPointerAnd = compiler->gtNewOperNode (GT_AND , TYP_I_IMPL , fptrAddressCopy, fatPointerMask);
@@ -398,7 +403,7 @@ class IndirectCallTransformer
398403 virtual void CreateThen (uint8_t checkIdx)
399404 {
400405 assert (remainderBlock != nullptr );
401- thenBlock = CreateAndInsertBasicBlock (BBJ_ALWAYS , checkBlock);
406+ thenBlock = CreateAndInsertBasicBlock (BBJ_ALWAYS , checkBlock, currBlock );
402407 Statement* copyOfOriginalStmt = compiler->gtCloneStmt (stmt);
403408 compiler->fgInsertStmtAtEnd (thenBlock, copyOfOriginalStmt);
404409 }
@@ -408,7 +413,7 @@ class IndirectCallTransformer
408413 //
409414 virtual void CreateElse ()
410415 {
411- elseBlock = CreateAndInsertBasicBlock (BBJ_ALWAYS , thenBlock);
416+ elseBlock = CreateAndInsertBasicBlock (BBJ_ALWAYS , thenBlock, currBlock );
412417
413418 GenTree* fixedFptrAddress = GetFixedFptrAddress ();
414419 GenTree* actualCallAddress = compiler->gtNewIndir (pointerType, fixedFptrAddress);
@@ -605,7 +610,7 @@ class IndirectCallTransformer
605610 // In case of multiple checks, append to the previous thenBlock block
606611 // (Set jump target of new checkBlock in CreateThen())
607612 BasicBlock* prevCheckBlock = checkBlock;
608- checkBlock = CreateAndInsertBasicBlock (BBJ_ALWAYS , thenBlock);
613+ checkBlock = CreateAndInsertBasicBlock (BBJ_ALWAYS , thenBlock, currBlock );
609614 checkFallsThrough = false ;
610615
611616 // We computed the "then" likelihood in CreateThen, so we
@@ -1059,8 +1064,7 @@ class IndirectCallTransformer
10591064
10601065 // thenBlock always jumps to remainderBlock
10611066 //
1062- thenBlock = CreateAndInsertBasicBlock (BBJ_ALWAYS , checkBlock);
1063- thenBlock->CopyFlags (currBlock, BBF_SPLIT_GAINED );
1067+ thenBlock = CreateAndInsertBasicBlock (BBJ_ALWAYS , checkBlock, currBlock);
10641068 thenBlock->inheritWeight (checkBlock);
10651069 thenBlock->scaleBBWeight (adjustedThenLikelihood);
10661070 FlowEdge* const thenRemainderEdge = compiler->fgAddRefPred (remainderBlock, thenBlock);
@@ -1091,8 +1095,7 @@ class IndirectCallTransformer
10911095 //
10921096 virtual void CreateElse ()
10931097 {
1094- elseBlock = CreateAndInsertBasicBlock (BBJ_ALWAYS , thenBlock);
1095- elseBlock->CopyFlags (currBlock, BBF_SPLIT_GAINED );
1098+ elseBlock = CreateAndInsertBasicBlock (BBJ_ALWAYS , thenBlock, currBlock);
10961099
10971100 // We computed the "then" likelihood in CreateThen, so we
10981101 // just use that to figure out the "else" likelihood.
0 commit comments