CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
153 lines
4.5 KiB
C++
153 lines
4.5 KiB
C++
//===- GraphPrinter.cpp - Create a DOT output describing the Scop. --------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Create a DOT output describing the Scop.
|
|
//
|
|
// For each function a dot file is created that shows the control flow graph of
|
|
// the function and highlights the detected Scops.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "polly/ScopGraphPrinter.h"
|
|
#include "polly/ScopDetection.h"
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
using namespace polly;
|
|
using namespace llvm;
|
|
|
|
namespace polly {
|
|
std::string ViewFilter;
|
|
bool ViewAll;
|
|
} // namespace polly
|
|
|
|
static cl::opt<std::string, true>
|
|
XViewFilter("polly-view-only",
|
|
cl::desc("Only view functions that match this pattern"),
|
|
cl::location(ViewFilter), cl::Hidden, cl::init(""));
|
|
|
|
static cl::opt<bool, true>
|
|
XViewAll("polly-view-all",
|
|
cl::desc("Also show functions without any scops"),
|
|
cl::location(ViewAll), cl::Hidden, cl::init(false));
|
|
|
|
namespace llvm {
|
|
|
|
std::string DOTGraphTraits<ScopDetection *>::getEdgeAttributes(
|
|
RegionNode *srcNode, GraphTraits<RegionInfo *>::ChildIteratorType CI,
|
|
ScopDetection *SD) {
|
|
RegionNode *destNode = *CI;
|
|
|
|
if (srcNode->isSubRegion() || destNode->isSubRegion())
|
|
return "";
|
|
|
|
// In case of a backedge, do not use it to define the layout of the nodes.
|
|
BasicBlock *srcBB = srcNode->getNodeAs<BasicBlock>();
|
|
BasicBlock *destBB = destNode->getNodeAs<BasicBlock>();
|
|
|
|
RegionInfo *RI = SD->getRI();
|
|
Region *R = RI->getRegionFor(destBB);
|
|
|
|
while (R && R->getParent())
|
|
if (R->getParent()->getEntry() == destBB)
|
|
R = R->getParent();
|
|
else
|
|
break;
|
|
|
|
if (R && R->getEntry() == destBB && R->contains(srcBB))
|
|
return "constraint=false";
|
|
|
|
return "";
|
|
}
|
|
|
|
std::string
|
|
DOTGraphTraits<ScopDetection *>::escapeString(llvm::StringRef String) {
|
|
std::string Escaped;
|
|
|
|
for (const auto &C : String) {
|
|
if (C == '"')
|
|
Escaped += '\\';
|
|
|
|
Escaped += C;
|
|
}
|
|
return Escaped;
|
|
}
|
|
|
|
void DOTGraphTraits<ScopDetection *>::printRegionCluster(ScopDetection *SD,
|
|
const Region *R,
|
|
raw_ostream &O,
|
|
unsigned depth) {
|
|
O.indent(2 * depth) << "subgraph cluster_" << static_cast<const void *>(R)
|
|
<< " {\n";
|
|
unsigned LineBegin, LineEnd;
|
|
std::string FileName;
|
|
|
|
getDebugLocation(R, LineBegin, LineEnd, FileName);
|
|
|
|
std::string Location;
|
|
if (LineBegin != (unsigned)-1) {
|
|
Location = escapeString(FileName + ":" + std::to_string(LineBegin) + "-" +
|
|
std::to_string(LineEnd) + "\n");
|
|
}
|
|
|
|
std::string ErrorMessage = SD->regionIsInvalidBecause(R);
|
|
ErrorMessage = escapeString(ErrorMessage);
|
|
O.indent(2 * (depth + 1))
|
|
<< "label = \"" << Location << ErrorMessage << "\";\n";
|
|
|
|
if (SD->isMaxRegionInScop(*R)) {
|
|
O.indent(2 * (depth + 1)) << "style = filled;\n";
|
|
|
|
// Set color to green.
|
|
O.indent(2 * (depth + 1)) << "color = 3";
|
|
} else {
|
|
O.indent(2 * (depth + 1)) << "style = solid;\n";
|
|
|
|
int color = (R->getDepth() * 2 % 12) + 1;
|
|
|
|
// We do not want green again.
|
|
if (color == 3)
|
|
color = 6;
|
|
|
|
O.indent(2 * (depth + 1)) << "color = " << color << "\n";
|
|
}
|
|
|
|
for (const auto &SubRegion : *R)
|
|
printRegionCluster(SD, SubRegion.get(), O, depth + 1);
|
|
|
|
RegionInfo *RI = R->getRegionInfo();
|
|
|
|
for (BasicBlock *BB : R->blocks())
|
|
if (RI->getRegionFor(BB) == R)
|
|
O.indent(2 * (depth + 1))
|
|
<< "Node"
|
|
<< static_cast<void *>(RI->getTopLevelRegion()->getBBNode(BB))
|
|
<< ";\n";
|
|
|
|
O.indent(2 * depth) << "}\n";
|
|
}
|
|
|
|
void DOTGraphTraits<ScopDetection *>::addCustomGraphFeatures(
|
|
ScopDetection *SD, GraphWriter<ScopDetection *> &GW) {
|
|
raw_ostream &O = GW.getOStream();
|
|
O << "\tcolorscheme = \"paired12\"\n";
|
|
printRegionCluster(SD, SD->getRI()->getTopLevelRegion(), O, 4);
|
|
}
|
|
|
|
} // namespace llvm
|
|
|
|
bool ScopViewer::processFunction(Function &F, const ScopDetection &SD) {
|
|
if (ViewFilter != "" && !F.getName().count(ViewFilter))
|
|
return false;
|
|
|
|
if (ViewAll)
|
|
return true;
|
|
|
|
// Check that at least one scop was detected.
|
|
return std::distance(SD.begin(), SD.end()) > 0;
|
|
}
|