Skip to content

Commit 63ff286

Browse files
committed
Update EscapeAnalysis to use BasicCalleeAnalysis.
1 parent f668a74 commit 63ff286

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

include/swift/SILAnalysis/EscapeAnalysis.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct CGForDotView;
2525

2626
namespace swift {
2727

28+
class BasicCalleeAnalysis;
2829
class CallGraphAnalysis;
2930
class CallGraph;
3031

@@ -568,6 +569,9 @@ class EscapeAnalysis : public SILAnalysis {
568569
/// The Array<Element> type of the stdlib.
569570
NominalTypeDecl *ArrayType;
570571

572+
/// Callee analysis, used for determining the callees at call sites.
573+
BasicCalleeAnalysis *BCA;
574+
571575
/// This analysis depends on the call graph.
572576
CallGraphAnalysis *CGA;
573577

@@ -601,6 +605,10 @@ class EscapeAnalysis : public SILAnalysis {
601605
/// mergeAllCallees.
602606
void buildConnectionGraphs(FunctionInfo *FInfo);
603607

608+
/// Returns true if all called functions from an apply site are known and not
609+
/// external.
610+
bool allCalleeFunctionsVisible(FullApplySite FAS);
611+
604612
/// Updates the graph by analysing instruction \p I.
605613
void analyzeInstruction(SILInstruction *I, FunctionInfo *FInfo);
606614

lib/SILAnalysis/EscapeAnalysis.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#define DEBUG_TYPE "sil-escape"
1414
#include "swift/SILAnalysis/EscapeAnalysis.h"
15+
#include "swift/SILAnalysis/BasicCalleeAnalysis.h"
1516
#include "swift/SILAnalysis/CallGraphAnalysis.h"
1617
#include "swift/SILAnalysis/ArraySemantic.h"
1718
#include "swift/SILPasses/PassManager.h"
@@ -834,6 +835,7 @@ EscapeAnalysis::EscapeAnalysis(SILModule *M) :
834835

835836

836837
void EscapeAnalysis::initialize(SILPassManager *PM) {
838+
BCA = PM->getAnalysis<BasicCalleeAnalysis>();
837839
CGA = PM->getAnalysis<CallGraphAnalysis>();
838840
}
839841

@@ -975,13 +977,11 @@ void EscapeAnalysis::buildConnectionGraphs(FunctionInfo *FInfo) {
975977
FInfo->Valid = true;
976978
}
977979

978-
/// Returns true if all called functions from an apply site are known and not
979-
/// external.
980-
static bool allCalleeFunctionsVisible(FullApplySite FAS, CallGraph &CG) {
981-
if (CG.canCallUnknownFunction(FAS.getInstruction()))
980+
bool EscapeAnalysis::allCalleeFunctionsVisible(FullApplySite FAS) {
981+
auto Callees = BCA->getCalleeList(FAS);
982+
if (Callees.isIncomplete())
982983
return false;
983984

984-
auto Callees = CG.getCallees(FAS.getInstruction());
985985
for (SILFunction *Callee : Callees) {
986986
if (Callee->isExternalDeclaration())
987987
return false;
@@ -1047,7 +1047,7 @@ void EscapeAnalysis::analyzeInstruction(SILInstruction *I,
10471047
break;
10481048
}
10491049

1050-
if (allCalleeFunctionsVisible(FAS, CGA->getCallGraph())) {
1050+
if (allCalleeFunctionsVisible(FAS)) {
10511051
// We handle this apply site afterwards by merging the callee graph(s)
10521052
// into the caller graph.
10531053
FInfo->KnownCallees.push_back(FAS);

0 commit comments

Comments
 (0)