Skip to content

Commit e46f03b

Browse files
[MemProf] Remove unnecessary data structure (NFC) (#107643)
Recent change #106623 added the CallToFunc map, but I subsequently realized the same information is already available for the calls being examined in the StackIdToMatchingCalls map we're iterating through.
1 parent 86e5c54 commit e46f03b

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,6 @@ class CallsiteContextGraph {
464464
/// iteration.
465465
MapVector<FuncTy *, std::vector<CallInfo>> FuncToCallsWithMetadata;
466466

467-
/// Records the function each call is located in.
468-
DenseMap<CallInfo, const FuncTy *> CallToFunc;
469-
470467
/// Map from callsite node to the enclosing caller function.
471468
std::map<const ContextNode *, const FuncTy *> NodeToCallingFunc;
472469

@@ -1575,15 +1572,13 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::updateStackNodes() {
15751572
continue;
15761573
}
15771574

1578-
const FuncTy *CallFunc = CallToFunc[Call];
1579-
15801575
// If the prior call had the same stack ids this map would not be empty.
15811576
// Check if we already have a call that "matches" because it is located
15821577
// in the same function.
1583-
if (FuncToCallMap.contains(CallFunc)) {
1578+
if (FuncToCallMap.contains(Func)) {
15841579
// Record the matching call found for this call, and skip it. We
15851580
// will subsequently combine it into the same node.
1586-
CallToMatchingCall[Call] = FuncToCallMap[CallFunc];
1581+
CallToMatchingCall[Call] = FuncToCallMap[Func];
15871582
continue;
15881583
}
15891584

@@ -1623,7 +1618,7 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::updateStackNodes() {
16231618
// Record the call with its function, so we can locate it the next time
16241619
// we find a call from this function when processing the calls with the
16251620
// same stack ids.
1626-
FuncToCallMap[CallFunc] = Call;
1621+
FuncToCallMap[Func] = Call;
16271622
}
16281623
}
16291624

@@ -1741,7 +1736,6 @@ ModuleCallsiteContextGraph::ModuleCallsiteContextGraph(
17411736
continue;
17421737
if (auto *MemProfMD = I.getMetadata(LLVMContext::MD_memprof)) {
17431738
CallsWithMetadata.push_back(&I);
1744-
CallToFunc[&I] = &F;
17451739
auto *AllocNode = addAllocNode(&I, &F);
17461740
auto *CallsiteMD = I.getMetadata(LLVMContext::MD_callsite);
17471741
assert(CallsiteMD);
@@ -1765,7 +1759,6 @@ ModuleCallsiteContextGraph::ModuleCallsiteContextGraph(
17651759
// For callsite metadata, add to list for this function for later use.
17661760
else if (I.getMetadata(LLVMContext::MD_callsite)) {
17671761
CallsWithMetadata.push_back(&I);
1768-
CallToFunc[&I] = &F;
17691762
}
17701763
}
17711764
}
@@ -1823,7 +1816,6 @@ IndexCallsiteContextGraph::IndexCallsiteContextGraph(
18231816
continue;
18241817
IndexCall AllocCall(&AN);
18251818
CallsWithMetadata.push_back(AllocCall);
1826-
CallToFunc[AllocCall] = FS;
18271819
auto *AllocNode = addAllocNode(AllocCall, FS);
18281820
// Pass an empty CallStack to the CallsiteContext (second)
18291821
// parameter, since for ThinLTO we already collapsed out the inlined
@@ -1858,7 +1850,6 @@ IndexCallsiteContextGraph::IndexCallsiteContextGraph(
18581850
for (auto &SN : FS->mutableCallsites()) {
18591851
IndexCall StackNodeCall(&SN);
18601852
CallsWithMetadata.push_back(StackNodeCall);
1861-
CallToFunc[StackNodeCall] = FS;
18621853
}
18631854

18641855
if (!CallsWithMetadata.empty())
@@ -1942,9 +1933,6 @@ void CallsiteContextGraph<DerivedCCG, FuncTy,
19421933
// want to do this during iteration over that map, so save the calls
19431934
// that need updated entries.
19441935
NewCallToNode.push_back({ThisCall, Node});
1945-
// We should only have shared this node between calls from the same
1946-
// function.
1947-
assert(NodeToCallingFunc[Node] == CallToFunc[Node->Call]);
19481936
}
19491937
break;
19501938
}

0 commit comments

Comments
 (0)