mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Move the call-graph utility to Utils/Local
Swift SVN r11665
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
//
|
||||
//===---------------------------------------------------------------------===//
|
||||
#include "swift/SILPasses/Utils/Local.h"
|
||||
#include "swift/SIL/CallGraph.h"
|
||||
#include "swift/SIL/SILModule.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/IR/Intrinsics.h"
|
||||
#include <deque>
|
||||
@@ -146,3 +148,17 @@ void swift::eraseUsesOfInstruction(SILInstruction *Inst) {
|
||||
User->eraseFromParent();
|
||||
}
|
||||
}
|
||||
|
||||
void swift::BottomUpCallGraphOrder(SILModule *M,
|
||||
std::vector<SILFunction*> &order) {
|
||||
CallGraphSorter<SILFunction*> sorter;
|
||||
for (auto &Caller : *M)
|
||||
for (auto &BB : Caller)
|
||||
for (auto &I : BB)
|
||||
if (FunctionRefInst *FRI = dyn_cast<FunctionRefInst>(&I)) {
|
||||
SILFunction *Callee = FRI->getReferencedFunction();
|
||||
sorter.addEdge(&Caller, Callee);
|
||||
}
|
||||
|
||||
sorter.sort(order);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user