Skip to content

Commit 9a4e12c

Browse files
committed
---
yaml --- r: 349409 b: refs/heads/master-next c: 0dc3c0e h: refs/heads/master i: 349407: e23d442
1 parent 5103efa commit 9a4e12c

File tree

3 files changed

+101
-43
lines changed

3 files changed

+101
-43
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: fc64075469c0ae1b9bc7de0c0a12d8fb9a5882a1
3+
refs/heads/master-next: 0dc3c0e8bba19dd5897677dfeb83859817ec905e
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/SILOptimizer/UtilityPasses/LoopRegionPrinter.cpp

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,66 @@
2020
#include "swift/SILOptimizer/Analysis/LoopRegionAnalysis.h"
2121
#include "swift/SILOptimizer/PassManager/Passes.h"
2222
#include "swift/SILOptimizer/PassManager/Transforms.h"
23+
#include "llvm/Support/CommandLine.h"
2324

2425
using namespace swift;
2526

27+
static llvm::cl::opt<std::string>
28+
SILViewCFGOnlyFun("sil-loop-region-view-cfg-only-function",
29+
llvm::cl::init(""),
30+
llvm::cl::desc("Only produce a graphviz file for the "
31+
"loop region info of this function"));
32+
33+
static llvm::cl::opt<std::string>
34+
SILViewCFGOnlyFuns("sil-loop-region-view-cfg-only-functions",
35+
llvm::cl::init(""),
36+
llvm::cl::desc("Only produce a graphviz file for the "
37+
"loop region info for the functions "
38+
"whose name contains this substring"));
39+
2640
namespace {
2741

2842
class LoopRegionViewText : public SILModuleTransform {
2943
void run() override {
3044
invalidateAll();
31-
LoopRegionAnalysis *LRA = PM->getAnalysis<LoopRegionAnalysis>();
32-
for (auto &Fn : *getModule()) {
33-
if (Fn.isExternalDeclaration()) continue;
45+
auto *lra = PM->getAnalysis<LoopRegionAnalysis>();
46+
47+
for (auto &fn : *getModule()) {
48+
if (fn.isExternalDeclaration())
49+
continue;
50+
if (!SILViewCFGOnlyFun.empty() && fn.getName() != SILViewCFGOnlyFun)
51+
continue;
52+
if (!SILViewCFGOnlyFuns.empty() &&
53+
fn.getName().find(SILViewCFGOnlyFuns, 0) == StringRef::npos)
54+
continue;
3455

35-
llvm::outs() << "@" << Fn.getName() << "@\n";
36-
LRA->get(&Fn)->dump();
37-
llvm::outs() << "\n";
56+
// Ok, we are going to analyze this function. Invalidate all state
57+
// associated with it so we recompute the loop regions.
58+
llvm::outs() << "Start @" << fn.getName() << "@\n";
59+
lra->get(&fn)->dump();
60+
llvm::outs() << "End @" << fn.getName() << "@\n";
3861
llvm::outs().flush();
3962
}
4063
}
41-
4264
};
4365

4466
class LoopRegionViewCFG : public SILModuleTransform {
4567
void run() override {
68+
invalidateAll();
69+
auto *lra = PM->getAnalysis<LoopRegionAnalysis>();
4670

47-
LoopRegionAnalysis *LRA = PM->getAnalysis<LoopRegionAnalysis>();
48-
49-
auto *M = getModule();
50-
for (auto &Fn : M->getFunctions()) {
51-
if (Fn.isExternalDeclaration())
71+
for (auto &fn : *getModule()) {
72+
if (fn.isExternalDeclaration())
5273
continue;
53-
LRA->get(&Fn)->viewLoopRegions();
74+
if (!SILViewCFGOnlyFun.empty() && fn.getName() != SILViewCFGOnlyFun)
75+
continue;
76+
if (!SILViewCFGOnlyFuns.empty() &&
77+
fn.getName().find(SILViewCFGOnlyFuns, 0) == StringRef::npos)
78+
continue;
79+
80+
// Ok, we are going to analyze this function. Invalidate all state
81+
// associated with it so we recompute the loop regions.
82+
lra->get(&fn)->viewLoopRegions();
5483
}
5584
}
5685
};

0 commit comments

Comments
 (0)