Move the call-graph utility to Utils/Local

Swift SVN r11665
This commit is contained in:
Nadav Rotem
2013-12-27 04:54:56 +00:00
parent 471c496066
commit a9f9440544
3 changed files with 21 additions and 18 deletions

View File

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