Skip to content

Commit d2edaee

Browse files
committed
Remove CallGraphEditor.
We no longer use it.
1 parent c1e4519 commit d2edaee

File tree

2 files changed

+0
-162
lines changed

2 files changed

+0
-162
lines changed

include/swift/SILAnalysis/CallGraph.h

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ class CallGraph {
345345
friend struct OrderedCallGraph;
346346
#endif
347347

348-
friend class CallGraphEditor;
349348
friend class CallGraphLinkerEditor;
350349

351350
CallGraph(SILModule *M, bool completeModule);
@@ -514,87 +513,6 @@ class CallGraph {
514513
void computeBottomUpFunctionOrder();
515514
};
516515

517-
class CallGraphEditor {
518-
CallGraph *CG;
519-
public:
520-
CallGraphEditor(CallGraph *CG) : CG(CG) {}
521-
522-
void replaceApplyWithNew(FullApplySite Old, FullApplySite New);
523-
void replaceApplyWithCallSites(FullApplySite Old,
524-
llvm::SmallVectorImpl<SILInstruction *> &NewCallSites);
525-
526-
/// Detaches the call graph node from function \p Old and attaches it to
527-
/// function \a New.
528-
void moveNodeToNewFunction(SILFunction *Old, SILFunction *New);
529-
530-
/// Removes all callee edges from function.
531-
void removeAllCalleeEdgesFrom(SILFunction *F);
532-
533-
/// Removes all caller edges from function.
534-
void removeAllCallerEdgesFrom(SILFunction *F);
535-
536-
/// Creates a new node for function \p F and adds callee edges for all
537-
/// call sites in the function.
538-
void addNewFunction(SILFunction *F) {
539-
if (CG && !CG->tryGetCallGraphNode(F)) {
540-
CG->addCallGraphNode(F);
541-
CG->addEdges(F);
542-
}
543-
}
544-
545-
/// Removes the call graph node of function \p F. The node may have any
546-
/// adjacent caller or callee edges.
547-
void removeCallGraphNode(SILFunction *F) {
548-
if (CG)
549-
CG->removeNode(CG->getCallGraphNode(F));
550-
}
551-
552-
/// Removes edges for the instruction \p I.
553-
void removeEdgesForInstruction(SILInstruction *I) {
554-
if (CG)
555-
CG->removeEdgesForInstruction(I);
556-
}
557-
558-
/// Checks which function(s) are called by instruction \p I and adds
559-
/// edges to the call graph for it.
560-
void addEdgesForInstruction(SILInstruction *I) {
561-
if (CG)
562-
CG->addEdgesForInstruction(I);
563-
}
564-
565-
/// Update uses of a changed apply site which is not a full apply
566-
/// site. If a use is a full apply site, its call graph edge is
567-
/// updated.
568-
void updatePartialApplyUses(ApplySite AI);
569-
570-
void addEdgesForFunction(SILFunction *F) {
571-
if (CG)
572-
CG->addEdges(F);
573-
}
574-
575-
void removeEdgeIfPresent(SILInstruction *I) {
576-
if (CG)
577-
if (auto *Edge = CG->tryGetCallGraphEdge(I))
578-
CG->removeEdgeFromFunction(Edge, I->getFunction());
579-
}
580-
581-
/// Drops all references in function and removes the references to
582-
/// instructions in the function from the call graph.
583-
void dropAllReferences(SILFunction *F) {
584-
F->dropAllReferences();
585-
586-
if (CG) {
587-
removeAllCalleeEdgesFrom(F);
588-
removeAllCallerEdgesFrom(F);
589-
CG->removeFunctionFromCalleeSets(F);
590-
}
591-
}
592-
593-
/// Erase the function from the module and any references to it from
594-
/// the call graph.
595-
void eraseFunction(SILFunction *F);
596-
};
597-
598516
class CallGraphLinkerEditor {
599517
CallGraph *CG;
600518

lib/SILAnalysis/CallGraph.cpp

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -786,86 +786,6 @@ void CallGraph::computeBottomUpFunctionOrder() {
786786
BottomUpFunctionOrder.push_back(Fn);
787787
}
788788

789-
//===----------------------------------------------------------------------===//
790-
// CallGraphEditor
791-
//===----------------------------------------------------------------------===//
792-
793-
void CallGraphEditor::replaceApplyWithNew(FullApplySite Old,
794-
FullApplySite New) {
795-
if (!CG)
796-
return;
797-
798-
if (auto *Edge = CG->tryGetCallGraphEdge(Old.getInstruction()))
799-
CG->removeEdgeFromFunction(Edge, Old.getInstruction()->getFunction());
800-
801-
CG->addEdgesForInstruction(New.getInstruction());
802-
}
803-
804-
void CallGraphEditor::replaceApplyWithCallSites(FullApplySite Old,
805-
llvm::SmallVectorImpl<SILInstruction *> &NewCallSites) {
806-
if (!CG)
807-
return;
808-
809-
if (auto *Edge = CG->tryGetCallGraphEdge(Old.getInstruction()))
810-
CG->removeEdgeFromFunction(Edge, Old.getInstruction()->getFunction());
811-
812-
for (auto NewApply : NewCallSites)
813-
CG->addEdgesForInstruction(NewApply);
814-
}
815-
816-
void CallGraphEditor::moveNodeToNewFunction(SILFunction *Old,
817-
SILFunction *New) {
818-
if (!CG)
819-
return;
820-
821-
auto Iter = CG->FunctionToNodeMap.find(Old);
822-
assert(Iter != CG->FunctionToNodeMap.end());
823-
auto *Node = Iter->second;
824-
CG->FunctionToNodeMap.erase(Iter);
825-
CG->FunctionToNodeMap[New] = Node;
826-
}
827-
828-
void CallGraphEditor::removeAllCalleeEdgesFrom(SILFunction *F) {
829-
if (!CG)
830-
return;
831-
832-
auto &CalleeEdges = CG->getCallGraphNode(F)->getCalleeEdges();
833-
while (!CalleeEdges.empty()) {
834-
auto *Edge = *CalleeEdges.begin();
835-
CG->removeEdgeFromFunction(Edge, F);
836-
}
837-
}
838-
839-
void CallGraphEditor::removeAllCallerEdgesFrom(SILFunction *F) {
840-
if (!CG)
841-
return;
842-
843-
auto &CallerEdges = CG->getCallGraphNode(F)->getCallerEdges();
844-
while (!CallerEdges.empty()) {
845-
auto *Edge = *CallerEdges.begin();
846-
auto Apply = Edge->getInstruction();
847-
CG->removeEdgeFromFunction(Edge, Apply->getFunction());
848-
}
849-
}
850-
851-
void CallGraphEditor::updatePartialApplyUses(swift::ApplySite AI) {
852-
if (!CG)
853-
return;
854-
855-
for (auto *Use : AI.getInstruction()->getUses()) {
856-
if (auto FAS = FullApplySite::isa(Use->getUser()))
857-
replaceApplyWithNew(FAS, FAS);
858-
}
859-
}
860-
861-
void CallGraphEditor::eraseFunction(SILFunction *F) {
862-
auto &M = F->getModule();
863-
M.eraseFunction(F);
864-
865-
if (CG)
866-
removeCallGraphNode(F);
867-
}
868-
869789
//===----------------------------------------------------------------------===//
870790
// CallGraph Verification
871791
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)