File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
include/swift/SILAnalysis
lib/SILPasses/UtilityPasses Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ class BottomUpFunctionOrder {
31
31
typedef TinyPtrVector<SILFunction *> SCC;
32
32
33
33
private:
34
+ SILModule &M;
34
35
llvm::SmallVector<SCC, 32 > TheSCCs;
36
+ llvm::SmallVector<SILFunction *, 32 > TheFunctions;
35
37
36
38
// The callee analysis we use to determine the callees at each call site.
37
39
BasicCalleeAnalysis *BCA;
@@ -43,11 +45,29 @@ class BottomUpFunctionOrder {
43
45
44
46
public:
45
47
BottomUpFunctionOrder (SILModule &M, BasicCalleeAnalysis *BCA)
46
- : BCA(BCA), NextDFSNum(0 ) {
48
+ : M(M), BCA(BCA), NextDFSNum(0 ) {}
49
+
50
+ // / Get the SCCs in bottom-up order.
51
+ ArrayRef<SCC> getSCCsBottomUp () {
52
+ if (!TheSCCs.empty ())
53
+ return TheSCCs;
54
+
47
55
FindSCCs (M);
56
+ return TheSCCs;
48
57
}
49
58
50
- ArrayRef<SCC> getBottomUpSCCs () { return TheSCCs; }
59
+ // / Get a flattened view of all functions in all the SCCs in
60
+ // / bottom-up order
61
+ ArrayRef<SILFunction *> getFunctionsBottomUp () {
62
+ if (!TheFunctions.empty ())
63
+ return TheFunctions;
64
+
65
+ for (auto SCC : getSCCsBottomUp ())
66
+ for (auto *F : SCC)
67
+ TheFunctions.push_back (F);
68
+
69
+ return TheFunctions;
70
+ }
51
71
52
72
private:
53
73
void DFS (SILFunction *F);
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ class FunctionOrderPrinterPass : public SILModuleTransform {
39
39
BottomUpFunctionOrder Orderer (M, BCA);
40
40
41
41
llvm::outs () << " Bottom up function order:\n " ;
42
- auto SCCs = Orderer.getBottomUpSCCs ();
42
+ auto SCCs = Orderer.getSCCsBottomUp ();
43
43
for (auto &SCC : SCCs) {
44
44
std::string Indent;
45
45
You can’t perform that action at this time.
0 commit comments