@@ -1539,27 +1539,22 @@ CallInst *replaceCalledFunction(Module &M, OutlinableRegion &Region) {
15391539// / \returns The found or newly created BasicBlock to contain the needed
15401540// / PHINodes to be used as outputs.
15411541static BasicBlock *findOrCreatePHIBlock (OutlinableGroup &Group, Value *RetVal) {
1542- DenseMap<Value *, BasicBlock *>::iterator PhiBlockForRetVal,
1543- ReturnBlockForRetVal;
1544- PhiBlockForRetVal = Group.PHIBlocks .find (RetVal);
1545- ReturnBlockForRetVal = Group.EndBBs .find (RetVal);
1542+ // Find if a PHIBlock exists for this return value already. If it is
1543+ // the first time we are analyzing this, we will not, so we record it.
1544+ auto [PhiBlockForRetVal, Inserted] = Group.PHIBlocks .try_emplace (RetVal);
1545+ if (!Inserted)
1546+ return PhiBlockForRetVal->second ;
1547+
1548+ auto ReturnBlockForRetVal = Group.EndBBs .find (RetVal);
15461549 assert (ReturnBlockForRetVal != Group.EndBBs .end () &&
15471550 " Could not find output value!" );
15481551 BasicBlock *ReturnBB = ReturnBlockForRetVal->second ;
15491552
1550- // Find if a PHIBlock exists for this return value already. If it is
1551- // the first time we are analyzing this, we will not, so we record it.
1552- PhiBlockForRetVal = Group.PHIBlocks .find (RetVal);
1553- if (PhiBlockForRetVal != Group.PHIBlocks .end ())
1554- return PhiBlockForRetVal->second ;
1555-
15561553 // If we did not find a block, we create one, and insert it into the
15571554 // overall function and record it.
1558- bool Inserted = false ;
15591555 BasicBlock *PHIBlock = BasicBlock::Create (ReturnBB->getContext (), " phi_block" ,
15601556 ReturnBB->getParent ());
1561- std::tie (PhiBlockForRetVal, Inserted) =
1562- Group.PHIBlocks .insert (std::make_pair (RetVal, PHIBlock));
1557+ PhiBlockForRetVal->second = PHIBlock;
15631558
15641559 // We find the predecessors of the return block in the newly created outlined
15651560 // function in order to point them to the new PHIBlock rather than the already
0 commit comments