mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Remove some of unneeded functionality in CallerAnalysis
We really only need the analysis to tell whether a function has caller inside the module or not. We do not need to know the callsites. Remove them for now to make the analysis more memory efficient. Add a note to indicate it can be extended.
This commit is contained in:
@@ -20,26 +20,22 @@ using namespace swift;
|
||||
|
||||
void CallerAnalysis::processFunctionCallSites(SILFunction *F) {
|
||||
// Scan the whole module and search Apply sites.
|
||||
CallerAnalysisFunctionInfo &CallerInfo = CallInfo.FindAndConstruct(F).second;
|
||||
for (auto &BB : *F) {
|
||||
for (auto &II : BB) {
|
||||
if (auto Apply = FullApplySite::isa(&II)) {
|
||||
SILFunction *CalleeFn = Apply.getCalleeFunction();
|
||||
if (!CalleeFn)
|
||||
continue;
|
||||
|
||||
// Update the callee information for this function.
|
||||
CallerInfo.Callees.push_back(CalleeFn);
|
||||
CallerAnalysisFunctionInfo &CallerInfo
|
||||
= CallInfo.FindAndConstruct(F).second;
|
||||
CallerInfo.Callees.insert(CalleeFn);
|
||||
|
||||
// Update the callsite information for the callee.
|
||||
CallerAnalysisFunctionInfo &CalleeInfo
|
||||
= CallInfo.FindAndConstruct(CalleeFn).second;
|
||||
|
||||
// Record it if this is the first time we see this caller.
|
||||
if (CalleeInfo.CallSites.find(F) == CalleeInfo.CallSites.end())
|
||||
CalleeInfo.Callers.push_back(F);
|
||||
|
||||
// Record the callsite.
|
||||
CalleeInfo.CallSites[F].push_back(Apply);
|
||||
= CallInfo.FindAndConstruct(CalleeFn).second;
|
||||
CalleeInfo.Callers.insert(F);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,8 +44,9 @@ void CallerAnalysis::processFunctionCallSites(SILFunction *F) {
|
||||
void CallerAnalysis::invalidateExistingCalleeRelation(SILFunction *F) {
|
||||
CallerAnalysisFunctionInfo &CallerInfo = CallInfo.FindAndConstruct(F).second;
|
||||
for (auto Callee : CallerInfo.Callees) {
|
||||
CallerAnalysisFunctionInfo &CalleeInfo = CallInfo.find(Callee)->second;
|
||||
CalleeInfo.CallSites[F].clear();
|
||||
CallerAnalysisFunctionInfo &CalleeInfo
|
||||
= CallInfo.FindAndConstruct(Callee).second;
|
||||
CalleeInfo.Callers.remove(F);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user