@@ -123,9 +123,9 @@ static cl::opt<unsigned>
123123 " frames through tail calls." ));
124124
125125// By default enable cloning of callsites involved with recursive cycles
126- static cl::opt<bool > SkipRecursiveCallsites (
127- " memprof-skip -recursive-callsites" , cl::init(false ), cl::Hidden,
128- cl::desc(" Prevent cloning of callsites involved in recursive cycles" ));
126+ static cl::opt<bool > AllowRecursiveCallsites (
127+ " memprof-allow -recursive-callsites" , cl::init(true ), cl::Hidden,
128+ cl::desc(" Allow cloning of callsites involved in recursive cycles" ));
129129
130130// When enabled, try to detect and prevent cloning of recursive contexts.
131131// This is only necessary until we support cloning through recursive cycles.
@@ -1252,7 +1252,7 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::addStackNodesForMIB(
12521252 }
12531253 // Marking a node recursive will prevent its cloning completely, even for
12541254 // non-recursive contexts flowing through it.
1255- if (SkipRecursiveCallsites ) {
1255+ if (!AllowRecursiveCallsites ) {
12561256 auto Ins = StackIdSet.insert (StackId);
12571257 if (!Ins.second )
12581258 StackNode->Recursive = true ;
@@ -1393,10 +1393,10 @@ static void checkNode(const ContextNode<DerivedCCG, FuncTy, CallTy> *Node,
13931393 set_union (CallerEdgeContextIds, Edge->ContextIds );
13941394 }
13951395 // Node can have more context ids than callers if some contexts terminate at
1396- // node and some are longer. If we are not skipping recursive callsites but
1396+ // node and some are longer. If we are allowing recursive callsites but
13971397 // haven't enabled skipping of recursive contexts, this will be violated for
13981398 // incompletely cloned recursive cycles, so skip the checking in that case.
1399- assert (!(SkipRecursiveCallsites || SkipRecursiveContexts) ||
1399+ assert ((AllowRecursiveCallsites && ! SkipRecursiveContexts) ||
14001400 NodeContextIds == CallerEdgeContextIds ||
14011401 set_is_subset (CallerEdgeContextIds, NodeContextIds));
14021402 }
@@ -3392,12 +3392,14 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::identifyClones(
33923392 assert (Node->AllocTypes != (uint8_t )AllocationType::None);
33933393
33943394 DenseSet<uint32_t > RecursiveContextIds;
3395- // If we are not skipping recursive callsites, and have also enabled
3395+ // If we are allowing recursive callsites, and have also enabled
33963396 // skipping of recursive contexts, look for context ids that show up in
33973397 // multiple caller edges.
3398- if (!SkipRecursiveCallsites && SkipRecursiveContexts) {
3398+ if (AllowRecursiveCallsites && SkipRecursiveContexts) {
33993399 DenseSet<uint32_t > AllCallerContextIds;
34003400 for (auto &CE : Node->CallerEdges ) {
3401+ // Resize to the largest set of caller context ids, since we know the
3402+ // final set will be at least that large.
34013403 AllCallerContextIds.reserve (CE->getContextIds ().size ());
34023404 for (auto Id : CE->getContextIds ())
34033405 if (!AllCallerContextIds.insert (Id).second )
0 commit comments