[ScopDetectionDiagnostic] Collect statistics for each diagnostic type
Our original statistics were added before we introduced a more fine-grained
diagnostic system, but the granularity of our statistics has never been
increased accordingly. This change introduces now one statistic counter per
diagnostic to enable us to collect fine-grained statistics about who certain
scops are not detected. In case coarser grained statistics are needed, the
user is expected to combine counters manually.
llvm-svn: 287968
diff --git a/polly/include/polly/ScopDetectionDiagnostic.h b/polly/include/polly/ScopDetectionDiagnostic.h
index b7d8ae5..220482a 100644
--- a/polly/include/polly/ScopDetectionDiagnostic.h
+++ b/polly/include/polly/ScopDetectionDiagnostic.h
@@ -117,7 +117,7 @@
public:
RejectReasonKind getKind() const { return Kind; }
- RejectReason(RejectReasonKind K) : Kind(K) {}
+ RejectReason(RejectReasonKind K);
virtual ~RejectReason() {}
diff --git a/polly/lib/Analysis/ScopDetectionDiagnostic.cpp b/polly/lib/Analysis/ScopDetectionDiagnostic.cpp
index 2307be3..e4ebdc7 100644
--- a/polly/lib/Analysis/ScopDetectionDiagnostic.cpp
+++ b/polly/lib/Analysis/ScopDetectionDiagnostic.cpp
@@ -38,15 +38,36 @@
using namespace llvm;
-#define BADSCOP_STAT(NAME, DESC) \
- STATISTIC(Bad##NAME##ForScop, "Number of bad regions for Scop: " DESC)
+#define SCOP_STAT(NAME, DESC) \
+ { "polly-detect", "NAME", "Number of rejected regions: " DESC, {0}, false }
-BADSCOP_STAT(CFG, "CFG too complex");
-BADSCOP_STAT(LoopBound, "Loop bounds can not be computed");
-BADSCOP_STAT(FuncCall, "Function call with side effects appeared");
-BADSCOP_STAT(AffFunc, "Expression not affine");
-BADSCOP_STAT(Alias, "Found base address alias");
-BADSCOP_STAT(Other, "Others");
+llvm::Statistic RejectStatistics[] = {
+ SCOP_STAT(CFG, ""),
+ SCOP_STAT(InvalidTerminator, "Unsupported terminator instruction"),
+ SCOP_STAT(IrreducibleRegion, "Irreducible loops"), SCOP_STAT(LastCFG, ""),
+ SCOP_STAT(AffFunc, ""), SCOP_STAT(UndefCond, "Undefined branch condition"),
+ SCOP_STAT(InvalidCond, "Non-integer branch condition"),
+ SCOP_STAT(UndefOperand, "Undefined operands in comparison"),
+ SCOP_STAT(NonAffBranch, "Non-affine branch condition"),
+ SCOP_STAT(NoBasePtr, "No base pointer"),
+ SCOP_STAT(UndefBasePtr, "Undefined base pointer"),
+ SCOP_STAT(VariantBasePtr, "Variant base pointer"),
+ SCOP_STAT(NonAffineAccess, "Non-affine memory accesses"),
+ SCOP_STAT(DifferentElementSize, "Accesses with differing sizes"),
+ SCOP_STAT(LastAffFunc, ""),
+ SCOP_STAT(LoopBound, "Uncomputable loop bounds"),
+ SCOP_STAT(LoopHasNoExit, "Loop without exit"),
+ SCOP_STAT(FuncCall, "Function call with side effects"),
+ SCOP_STAT(NonSimpleMemoryAccess,
+ "Compilated access semantics (volatile or atomic)"),
+ SCOP_STAT(Alias, "Base address aliasing"), SCOP_STAT(Other, ""),
+ SCOP_STAT(IntToPtr, "Integer to pointer conversions"),
+ SCOP_STAT(Alloca, "Stack allocations"),
+ SCOP_STAT(UnknownInst, "Unknown Instructions"),
+ SCOP_STAT(Entry, "Contains entry block"),
+ SCOP_STAT(Unprofitable, "Assumed to be unprofitable"),
+ SCOP_STAT(LastOther, ""),
+};
namespace polly {
/// Small string conversion via raw_string_stream.
@@ -118,6 +139,11 @@
//===----------------------------------------------------------------------===//
// RejectReason.
+
+RejectReason::RejectReason(RejectReasonKind K) : Kind(K) {
+ RejectStatistics[static_cast<int>(K)]++;
+}
+
const DebugLoc RejectReason::Unknown = DebugLoc();
const llvm::DebugLoc &RejectReason::getDebugLoc() const {
@@ -135,9 +161,7 @@
//===----------------------------------------------------------------------===//
// ReportCFG.
-ReportCFG::ReportCFG(const RejectReasonKind K) : RejectReason(K) {
- ++BadCFGForScop;
-}
+ReportCFG::ReportCFG(const RejectReasonKind K) : RejectReason(K) {}
bool ReportCFG::classof(const RejectReason *RR) {
return RR->getKind() >= RejectReasonKind::CFG &&
@@ -180,9 +204,7 @@
// ReportAffFunc.
ReportAffFunc::ReportAffFunc(const RejectReasonKind K, const Instruction *Inst)
- : RejectReason(K), Inst(Inst) {
- ++BadAffFuncForScop;
-}
+ : RejectReason(K), Inst(Inst) {}
bool ReportAffFunc::classof(const RejectReason *RR) {
return RR->getKind() >= RejectReasonKind::AffFunc &&
@@ -310,9 +332,7 @@
ReportLoopBound::ReportLoopBound(Loop *L, const SCEV *LoopCount)
: RejectReason(RejectReasonKind::LoopBound), L(L), LoopCount(LoopCount),
- Loc(L->getStartLoc()) {
- ++BadLoopBoundForScop;
-}
+ Loc(L->getStartLoc()) {}
std::string ReportLoopBound::getMessage() const {
return "Non affine loop bound '" + *LoopCount + "' in loop: " +
@@ -350,9 +370,7 @@
// ReportFuncCall.
ReportFuncCall::ReportFuncCall(Instruction *Inst)
- : RejectReason(RejectReasonKind::FuncCall), Inst(Inst) {
- ++BadFuncCallForScop;
-}
+ : RejectReason(RejectReasonKind::FuncCall), Inst(Inst) {}
std::string ReportFuncCall::getMessage() const {
return "Call instruction: " + *Inst;
@@ -402,8 +420,6 @@
for (const auto &I : AS)
Pointers.push_back(I.getValue());
-
- ++BadAliasForScop;
}
std::string ReportAlias::formatInvalidAlias(std::string Prefix,
@@ -457,9 +473,7 @@
std::string ReportOther::getMessage() const { return "Unknown reject reason"; }
-ReportOther::ReportOther(const RejectReasonKind K) : RejectReason(K) {
- ++BadOtherForScop;
-}
+ReportOther::ReportOther(const RejectReasonKind K) : RejectReason(K) {}
bool ReportOther::classof(const RejectReason *RR) {
return RR->getKind() >= RejectReasonKind::Other &&
diff --git a/polly/test/ScopInfo/Alias-0.ll b/polly/test/ScopInfo/Alias-0.ll
index 39d9783..4077266 100644
--- a/polly/test/ScopInfo/Alias-0.ll
+++ b/polly/test/ScopInfo/Alias-0.ll
@@ -33,4 +33,4 @@
; RTA: 1 polly-detect - Number of regions that a valid part of Scop
-; NORTA: 1 polly-detect - Number of bad regions for Scop: Found base address alias
+; NORTA: 1 polly-detect - Number of rejected regions: Base address aliasing
diff --git a/polly/test/ScopInfo/Alias-1.ll b/polly/test/ScopInfo/Alias-1.ll
index 1e610e1..13d566f 100644
--- a/polly/test/ScopInfo/Alias-1.ll
+++ b/polly/test/ScopInfo/Alias-1.ll
@@ -34,4 +34,4 @@
; RTA: 1 polly-detect - Number of regions that a valid part of Scop
-; NORTA: 1 polly-detect - Number of bad regions for Scop: Found base address alias
+; NORTA: 1 polly-detect - Number of rejected regions: Base address aliasing
diff --git a/polly/test/ScopInfo/Alias-2.ll b/polly/test/ScopInfo/Alias-2.ll
index be78719..b308aef 100644
--- a/polly/test/ScopInfo/Alias-2.ll
+++ b/polly/test/ScopInfo/Alias-2.ll
@@ -32,4 +32,4 @@
}
; RTA: 1 polly-detect - Number of regions that a valid part of Scop
-; NORTA: 1 polly-detect - Number of bad regions for Scop: Found base address alias
+; NORTA: 1 polly-detect - Number of rejected regions: Base address aliasing
diff --git a/polly/test/ScopInfo/Alias-3.ll b/polly/test/ScopInfo/Alias-3.ll
index d161fb0..4db5f04 100644
--- a/polly/test/ScopInfo/Alias-3.ll
+++ b/polly/test/ScopInfo/Alias-3.ll
@@ -25,4 +25,4 @@
; RTA: 1 polly-detect - Number of regions that a valid part of Scop
-; NORTA: 1 polly-detect - Number of bad regions for Scop: Found base address alias
+; NORTA: 1 polly-detect - Number of rejected regions: Base address aliasing
diff --git a/polly/test/ScopInfo/Alias-4.ll b/polly/test/ScopInfo/Alias-4.ll
index 7f493cf..7cd4d39 100644
--- a/polly/test/ScopInfo/Alias-4.ll
+++ b/polly/test/ScopInfo/Alias-4.ll
@@ -25,4 +25,4 @@
; RTA: 1 polly-detect - Number of regions that a valid part of Scop
-; NORTA: 1 polly-detect - Number of bad regions for Scop: Found base address alias
+; NORTA: 1 polly-detect - Number of rejected regions: Base address aliasing