@@ -505,9 +505,6 @@ class CallsiteContextGraph {
505
505
ContextNode *getNodeForAlloc (const CallInfo &C);
506
506
ContextNode *getNodeForStackId (uint64_t StackId);
507
507
508
- // / Removes the node information recorded for the given call.
509
- void unsetNodeForInst (const CallInfo &C);
510
-
511
508
// / Computes the alloc type corresponding to the given context ids, by
512
509
// / unioning their recorded alloc types.
513
510
uint8_t computeAllocType (DenseSet<uint32_t > &ContextIds);
@@ -813,15 +810,6 @@ CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::getNodeForStackId(
813
810
return nullptr ;
814
811
}
815
812
816
- template <typename DerivedCCG, typename FuncTy, typename CallTy>
817
- void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::unsetNodeForInst(
818
- const CallInfo &C) {
819
- AllocationCallToContextNodeMap.erase (C) ||
820
- NonAllocationCallToContextNodeMap.erase (C);
821
- assert (!AllocationCallToContextNodeMap.count (C) &&
822
- !NonAllocationCallToContextNodeMap.count (C));
823
- }
824
-
825
813
template <typename DerivedCCG, typename FuncTy, typename CallTy>
826
814
void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::ContextNode::
827
815
addOrUpdateCallerEdge (ContextNode *Caller, AllocationType AllocType,
@@ -1694,11 +1682,10 @@ void CallsiteContextGraph<DerivedCCG, FuncTy,
1694
1682
MapVector<CallInfo, ContextNode *> TailCallToContextNodeMap;
1695
1683
1696
1684
for (auto Entry = NonAllocationCallToContextNodeMap.begin ();
1697
- Entry != NonAllocationCallToContextNodeMap.end ();) {
1685
+ Entry != NonAllocationCallToContextNodeMap.end (); Entry++ ) {
1698
1686
auto *Node = Entry->second ;
1699
1687
assert (Node->Clones .empty ());
1700
1688
// Check all node callees and see if in the same function.
1701
- bool Removed = false ;
1702
1689
auto Call = Node->Call .call ();
1703
1690
for (auto EI = Node->CalleeEdges .begin (); EI != Node->CalleeEdges .end ();) {
1704
1691
auto Edge = *EI;
@@ -1714,15 +1701,18 @@ void CallsiteContextGraph<DerivedCCG, FuncTy,
1714
1701
// Work around by setting Node to have a null call, so it gets
1715
1702
// skipped during cloning. Otherwise assignFunctions will assert
1716
1703
// because its data structures are not designed to handle this case.
1717
- Entry = NonAllocationCallToContextNodeMap.erase (Entry);
1718
1704
Node->setCall (CallInfo ());
1719
- Removed = true ;
1720
1705
break ;
1721
1706
}
1722
- if (!Removed)
1723
- Entry++;
1724
1707
}
1725
1708
1709
+ // Remove all mismatched nodes identified in the above loop from the node map
1710
+ // (checking whether they have a null call which is set above). For a
1711
+ // MapVector like NonAllocationCallToContextNodeMap it is much more efficient
1712
+ // to do the removal via remove_if than by individually erasing entries above.
1713
+ NonAllocationCallToContextNodeMap.remove_if (
1714
+ [](const auto &it) { return !it.second ->hasCall (); });
1715
+
1726
1716
// Add the new nodes after the above loop so that the iteration is not
1727
1717
// invalidated.
1728
1718
for (auto &[Call, Node] : TailCallToContextNodeMap)
0 commit comments