Skip to content

Commit e4afefc

Browse files
committed
Address comments
1 parent 5e40901 commit e4afefc

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

llvm/test/ThinLTO/X86/memprof-recursive.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
; RUN: -r=%t.o,_Znam, \
3333
; RUN: -memprof-verify-ccg -memprof-verify-nodes \
3434
; RUN: -pass-remarks=memprof-context-disambiguation \
35-
; RUN: -memprof-skip-recursive-callsites \
35+
; RUN: -memprof-allow-recursive-callsites=false \
3636
; RUN: -o %t.out 2>&1 | FileCheck %s --allow-empty \
3737
; RUN: --implicit-check-not "memprof_recursive3.cc:12:10: call in clone _Z1Ci.memprof.1 assigned" \
3838
; RUN: --implicit-check-not="created clone" \

llvm/test/Transforms/MemProfContextDisambiguation/recursive.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
5050
; RUN: -memprof-verify-ccg -memprof-verify-nodes \
5151
; RUN: -pass-remarks=memprof-context-disambiguation \
52-
; RUN: -memprof-skip-recursive-callsites \
52+
; RUN: -memprof-allow-recursive-callsites=false \
5353
; RUN: %s -S 2>&1 | FileCheck %s \
5454
; RUN: --implicit-check-not "memprof_recursive3.cc:12:10: call in clone _Z1Ci.memprof.1 assigned" \
5555
; RUN: --implicit-check-not="created clone" \

0 commit comments

Comments
 (0)