mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-12 21:28:48 +00:00
Show the reason a region is not a SCoP in the DOT graphs.
llvm-svn: 141458
This commit is contained in:
parent
c4a0bd13ad
commit
4f129a6b43
@ -109,6 +109,7 @@ class ScopDetection : public FunctionPass {
|
||||
// Remember the invalid functions producted by backends;
|
||||
typedef std::set<const Function*> FunctionSet;
|
||||
FunctionSet InvalidFunctions;
|
||||
mutable std::string LastFailure;
|
||||
|
||||
// Try to expand the region R. If R can be expanded return the expanded
|
||||
// region, NULL otherwise.
|
||||
@ -233,6 +234,13 @@ public:
|
||||
/// @return Return true if R is the maximum Region in a Scop, false otherwise.
|
||||
bool isMaxRegionInScop(const Region &R) const;
|
||||
|
||||
/// @brief Get a message why a region is invalid
|
||||
///
|
||||
/// @param R The region for which we get the error message
|
||||
///
|
||||
/// @return The error or "" if no error appeared.
|
||||
std::string regionIsInvalidBecause(const Region *R) const;
|
||||
|
||||
/// @name Maximum Region In Scops Iterators
|
||||
///
|
||||
/// These iterators iterator over all maximum region in Scops of this
|
||||
|
@ -77,6 +77,11 @@ STATISTIC(ValidRegion, "Number of regions that a valid part of Scop");
|
||||
|
||||
#define INVALID(NAME, MESSAGE) \
|
||||
do { \
|
||||
std::string Buf; \
|
||||
raw_string_ostream fmt(Buf); \
|
||||
fmt << MESSAGE; \
|
||||
fmt.flush(); \
|
||||
LastFailure = Buf; \
|
||||
DEBUG(dbgs() << MESSAGE); \
|
||||
DEBUG(dbgs() << "\n"); \
|
||||
STATSCOP(NAME); \
|
||||
@ -102,6 +107,14 @@ bool ScopDetection::isMaxRegionInScop(const Region &R) const {
|
||||
return ValidRegions.count(&R);
|
||||
}
|
||||
|
||||
std::string ScopDetection::regionIsInvalidBecause(const Region *R) const {
|
||||
if (!InvalidRegions.count(R))
|
||||
return "";
|
||||
|
||||
return InvalidRegions.find(R)->second;
|
||||
}
|
||||
|
||||
|
||||
bool ScopDetection::isValidAffineFunction(const SCEV *S, Region &RefRegion,
|
||||
Value **BasePtr) const {
|
||||
assert(S && "S must not be null!");
|
||||
@ -438,6 +451,8 @@ void ScopDetection::findScops(Region &R) {
|
||||
return;
|
||||
}
|
||||
|
||||
InvalidRegions[&R] = LastFailure;
|
||||
|
||||
for (Region::iterator I = R.begin(), E = R.end(); I != E; ++I)
|
||||
findScops(**I);
|
||||
|
||||
@ -583,6 +598,7 @@ void ScopDetection::print(raw_ostream &OS, const Module *) const {
|
||||
|
||||
void ScopDetection::releaseMemory() {
|
||||
ValidRegions.clear();
|
||||
InvalidRegions.clear();
|
||||
// Do not clear the invalid function set.
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,8 @@ struct DOTGraphTraits<ScopDetection*> : public DOTGraphTraits<RegionNode*> {
|
||||
raw_ostream &O, unsigned depth = 0) {
|
||||
O.indent(2 * depth) << "subgraph cluster_" << static_cast<const void*>(R)
|
||||
<< " {\n";
|
||||
O.indent(2 * (depth + 1)) << "label = \"\";\n";
|
||||
std::string ErrorMessage = SD->regionIsInvalidBecause(R);
|
||||
O.indent(2 * (depth + 1)) << "label = \"" << ErrorMessage << "\";\n";
|
||||
|
||||
if (SD->isMaxRegionInScop(*R)) {
|
||||
O.indent(2 * (depth + 1)) << "style = filled;\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user