19#include "llvm/Support/CommandLine.h"
23static cl::opt<std::string>
25 cl::desc(
"Only view functions that match this pattern"),
26 cl::Hidden, cl::init(
""));
28static cl::opt<bool>
ViewAll(
"polly-view-all",
29 cl::desc(
"Also show functions without any scops"),
30 cl::Hidden, cl::init(
false));
37 RegionNode *destNode = *CI;
39 if (srcNode->isSubRegion() || destNode->isSubRegion())
43 BasicBlock *srcBB = srcNode->getNodeAs<BasicBlock>();
44 BasicBlock *destBB = destNode->getNodeAs<BasicBlock>();
46 RegionInfo *RI = SD->
getRI();
47 Region *R = RI->getRegionFor(destBB);
49 while (R && R->getParent())
50 if (R->getParent()->getEntry() == destBB)
55 if (R && R->getEntry() == destBB && R->contains(srcBB))
56 return "constraint=false";
65 for (
const auto &
C : String) {
78 O.indent(2 * depth) <<
"subgraph cluster_" <<
static_cast<const void *
>(R)
80 unsigned LineBegin, LineEnd;
86 if (LineBegin != (
unsigned)-1) {
87 Location = escapeString(FileName +
":" + std::to_string(LineBegin) +
"-" +
88 std::to_string(LineEnd) +
"\n");
92 ErrorMessage = escapeString(ErrorMessage);
93 O.indent(2 * (depth + 1))
94 <<
"label = \"" << Location << ErrorMessage <<
"\";\n";
97 O.indent(2 * (depth + 1)) <<
"style = filled;\n";
100 O.indent(2 * (depth + 1)) <<
"color = 3";
102 O.indent(2 * (depth + 1)) <<
"style = solid;\n";
104 int color = (R->getDepth() * 2 % 12) + 1;
110 O.indent(2 * (depth + 1)) <<
"color = " << color <<
"\n";
113 for (
const auto &SubRegion : *R)
114 printRegionCluster(SD, SubRegion.get(), O, depth + 1);
116 RegionInfo *RI = R->getRegionInfo();
118 for (BasicBlock *BB : R->blocks())
119 if (RI->getRegionFor(BB) == R)
120 O.indent(2 * (depth + 1))
122 <<
static_cast<void *
>(RI->getTopLevelRegion()->getBBNode(BB))
125 O.indent(2 * depth) <<
"}\n";
130 raw_ostream &O = GW.getOStream();
131 O <<
"\tcolorscheme = \"paired12\"\n";
132 printRegionCluster(SD, SD->
getRI()->getTopLevelRegion(), O, 4);
139 return &Analysis->
getSD();
146 ScopDetectionAnalysisGraphTraits> {
169 ScopDetectionAnalysisGraphTraits> {
182 ScopDetectionAnalysisGraphTraits> {
195 ScopDetectionAnalysisGraphTraits> {
205static RegisterPass<ScopViewerWrapperPass>
X(
"view-scops",
206 "Polly - View Scops of function");
208static RegisterPass<ScopOnlyViewerWrapperPass>
210 "Polly - View Scops of function (with no function bodies)");
212static RegisterPass<ScopPrinterWrapperPass>
213 M(
"dot-scops",
"Polly - Print Scops of function");
215static RegisterPass<ScopOnlyPrinterWrapperPass>
217 "Polly - Print Scops of function (with no function bodies)");
243 return std::distance(SD.
begin(), SD.
end()) > 0;
static cl::opt< bool > ViewAll("polly-view-all", cl::desc("Also show functions without any scops"), cl::Hidden, cl::init(false))
static RegisterPass< ScopViewerWrapperPass > X("view-scops", "Polly - View Scops of function")
static RegisterPass< ScopOnlyPrinterWrapperPass > N("dot-scops-only", "Polly - Print Scops of function (with no function bodies)")
static cl::opt< std::string > ViewFilter("polly-view-only", cl::desc("Only view functions that match this pattern"), cl::Hidden, cl::init(""))
static RegisterPass< ScopOnlyViewerWrapperPass > Y("view-scops-only", "Polly - View Scops of function (with no function bodies)")
static RegisterPass< ScopPrinterWrapperPass > M("dot-scops", "Polly - Print Scops of function")
ScopDetection & getSD() const
Pass to detect the maximal static control parts (Scops) of a function.
RegionInfo * getRI() const
Get the RegionInfo stored in this pass.
std::string regionIsInvalidBecause(const Region *R) const
Get a message why a region is invalid.
bool isMaxRegionInScop(const Region &R, bool Verify=true)
Is the region is the maximum region of a Scop?
This file contains the declaration of the PolyhedralInfo class, which will provide an interface to ex...
llvm::Pass * createDOTViewerWrapperPass()
llvm::Pass * createDOTOnlyViewerWrapperPass()
void getDebugLocation(const llvm::Region *R, unsigned &LineBegin, unsigned &LineEnd, std::string &FileName)
Get the location of a region from the debug info.
llvm::Pass * createDOTPrinterWrapperPass()
llvm::Pass * createDOTOnlyPrinterWrapperPass()
static ScopDetection * getGraph(ScopDetectionWrapperPass *Analysis)
ScopOnlyPrinterWrapperPass()
ScopOnlyViewerWrapperPass()
bool processFunction(Function &F, ScopDetectionWrapperPass &SD) override
bool processFunction(Function &F, const ScopDetection &SD) override