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:
Xin Tong
2016-03-17 21:10:27 -07:00
parent afcf0e34e0
commit fd353df19e
4 changed files with 36 additions and 66 deletions

View File

@@ -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);
}
}