[polly] r211770 - Support for LLVM-style RTTI isa<...>, dyn_cast<...> et al.

Andreas Simbuerger simbuerg at fim.uni-passau.de
Thu Jun 26 03:19:57 PDT 2014


Author: simbuerg
Date: Thu Jun 26 05:19:57 2014
New Revision: 211770

URL: http://llvm.org/viewvc/llvm-project?rev=211770&view=rev
Log:
Support for LLVM-style RTTI isa<...>, dyn_cast<...> et al.

Modified:
    polly/trunk/include/polly/ScopDetectionDiagnostic.h
    polly/trunk/lib/Analysis/ScopDetection.cpp
    polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp

Modified: polly/trunk/include/polly/ScopDetectionDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetectionDiagnostic.h?rev=211770&r1=211769&r2=211770&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopDetectionDiagnostic.h (original)
+++ polly/trunk/include/polly/ScopDetectionDiagnostic.h Thu Jun 26 05:19:57 2014
@@ -28,6 +28,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
+#include "llvm/Support/Casting.h"
 
 #include <string>
 #include <memory>
@@ -66,6 +67,54 @@ void emitRejectionRemarks(const llvm::Fu
 /// @param F The function we emit remarks for
 /// @param R The region that marks a valid Scop
 void emitValidRemarks(const llvm::Function &F, const Region *R);
+
+// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
+enum RejectReasonKind {
+  // CFG Category
+  rrkCFG,
+  rrkNonBranchTerminator,
+  rrkCondition,
+  rrkLastCFG,
+
+  // Non-Affinity
+  rrkAffFunc,
+  rrkUndefCond,
+  rrkInvalidCond,
+  rrkUndefOperand,
+  rrkNonAffBranch,
+  rrkNoBasePtr,
+  rrkUndefBasePtr,
+  rrkVariantBasePtr,
+  rrkNonAffineAccess,
+  rrkLastAffFunc,
+
+  // IndVar
+  rrkIndVar,
+  rrkPhiNodeRefInRegion,
+  rrkNonCanonicalPhiNode,
+  rrkLoopHeader,
+  rrkLastIndVar,
+
+  rrkIndEdge,
+
+  rrkLoopBound,
+
+  rrkFuncCall,
+
+  rrkAlias,
+
+  rrkSimpleLoop,
+
+  // Other
+  rrkOther,
+  rrkIntToPtr,
+  rrkAlloca,
+  rrkUnknownInst,
+  rrkPHIinExit,
+  rrkEntry,
+  rrkLastOther
+};
+
 //===----------------------------------------------------------------------===//
 /// @brief Base class of all reject reasons found during Scop detection.
 ///
@@ -74,7 +123,14 @@ void emitValidRemarks(const llvm::Functi
 /// went wrong in the Scop detection.
 class RejectReason {
   //===--------------------------------------------------------------------===//
+private:
+  const RejectReasonKind Kind;
+
 public:
+  RejectReasonKind getKind() const { return Kind; }
+
+  RejectReason(RejectReasonKind K) : Kind(K) {}
+
   virtual ~RejectReason() {}
 
   /// @brief Generate a reasonable diagnostic message describing this error.
@@ -128,14 +184,27 @@ public:
 class ReportCFG : public RejectReason {
   //===--------------------------------------------------------------------===//
 public:
-  ReportCFG();
+  ReportCFG(const RejectReasonKind K);
+
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
 };
 
+//===----------------------------------------------------------------------===//
+/// @brief Captures a non-branch terminator within a Scop candidate.
 class ReportNonBranchTerminator : public ReportCFG {
   BasicBlock *BB;
 
 public:
-  ReportNonBranchTerminator(BasicBlock *BB) : ReportCFG(), BB(BB) {}
+  ReportNonBranchTerminator(BasicBlock *BB)
+      : ReportCFG(rrkNonBranchTerminator), BB(BB) {}
+
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
 
   /// @name RejectReason interface
   //@{
@@ -153,7 +222,12 @@ class ReportCondition : public ReportCFG
   BasicBlock *BB;
 
 public:
-  ReportCondition(BasicBlock *BB) : ReportCFG(), BB(BB) {}
+  ReportCondition(BasicBlock *BB) : ReportCFG(rrkCondition), BB(BB) {}
+
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
 
   /// @name RejectReason interface
   //@{
@@ -174,11 +248,19 @@ class ReportAffFunc : public RejectReaso
   const Instruction *Inst;
 
 public:
-  ReportAffFunc(const Instruction *Inst);
+  ReportAffFunc(const RejectReasonKind K, const Instruction *Inst);
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
+  /// @name RejectReason interface
+  //@{
   virtual const DebugLoc &getDebugLoc() const override {
     return Inst->getDebugLoc();
-  }
+  };
+  //@}
 };
 
 //===----------------------------------------------------------------------===//
@@ -191,7 +273,12 @@ class ReportUndefCond : public ReportAff
 
 public:
   ReportUndefCond(const Instruction *Inst, BasicBlock *BB)
-      : ReportAffFunc(Inst), BB(BB) {}
+      : ReportAffFunc(rrkUndefCond, Inst), BB(BB) {}
+
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
 
   /// @name RejectReason interface
   //@{
@@ -211,7 +298,12 @@ class ReportInvalidCond : public ReportA
 
 public:
   ReportInvalidCond(const Instruction *Inst, BasicBlock *BB)
-      : ReportAffFunc(Inst), BB(BB) {}
+      : ReportAffFunc(rrkInvalidCond, Inst), BB(BB) {}
+
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
 
   /// @name RejectReason interface
   //@{
@@ -229,7 +321,12 @@ class ReportUndefOperand : public Report
 
 public:
   ReportUndefOperand(BasicBlock *BB, const Instruction *Inst)
-      : ReportAffFunc(Inst), BB(BB) {}
+      : ReportAffFunc(rrkUndefOperand, Inst), BB(BB) {}
+
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
 
   /// @name RejectReason interface
   //@{
@@ -254,11 +351,16 @@ class ReportNonAffBranch : public Report
 public:
   ReportNonAffBranch(BasicBlock *BB, const SCEV *LHS, const SCEV *RHS,
                      const Instruction *Inst)
-      : ReportAffFunc(Inst), BB(BB), LHS(LHS), RHS(RHS) {}
+      : ReportAffFunc(rrkNonAffBranch, Inst), BB(BB), LHS(LHS), RHS(RHS) {}
 
   const SCEV *lhs() { return LHS; }
   const SCEV *rhs() { return RHS; }
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -270,7 +372,13 @@ public:
 class ReportNoBasePtr : public ReportAffFunc {
   //===--------------------------------------------------------------------===//
 public:
-  ReportNoBasePtr(const Instruction *Inst) : ReportAffFunc(Inst) {}
+  ReportNoBasePtr(const Instruction *Inst)
+      : ReportAffFunc(rrkNoBasePtr, Inst) {}
+
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
 
   /// @name RejectReason interface
   //@{
@@ -283,7 +391,13 @@ public:
 class ReportUndefBasePtr : public ReportAffFunc {
   //===--------------------------------------------------------------------===//
 public:
-  ReportUndefBasePtr(const Instruction *Inst) : ReportAffFunc(Inst) {}
+  ReportUndefBasePtr(const Instruction *Inst)
+      : ReportAffFunc(rrkUndefBasePtr, Inst) {}
+
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
 
   /// @name RejectReason interface
   //@{
@@ -301,7 +415,12 @@ class ReportVariantBasePtr : public Repo
 
 public:
   ReportVariantBasePtr(Value *BaseValue, const Instruction *Inst)
-      : ReportAffFunc(Inst), BaseValue(BaseValue) {}
+      : ReportAffFunc(rrkVariantBasePtr, Inst), BaseValue(BaseValue) {}
+
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
 
   /// @name RejectReason interface
   //@{
@@ -319,10 +438,16 @@ class ReportNonAffineAccess : public Rep
 
 public:
   ReportNonAffineAccess(const SCEV *AccessFunction, const Instruction *Inst)
-      : ReportAffFunc(Inst), AccessFunction(AccessFunction) {}
+      : ReportAffFunc(rrkNonAffineAccess, Inst),
+        AccessFunction(AccessFunction) {}
 
   const SCEV *get() { return AccessFunction; }
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -337,7 +462,7 @@ public:
 class ReportIndVar : public RejectReason {
   //===--------------------------------------------------------------------===//
 public:
-  ReportIndVar();
+  ReportIndVar(const RejectReasonKind K);
 };
 
 //===----------------------------------------------------------------------===//
@@ -351,6 +476,11 @@ class ReportPhiNodeRefInRegion : public
 public:
   ReportPhiNodeRefInRegion(Instruction *Inst);
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -369,6 +499,11 @@ class ReportNonCanonicalPhiNode : public
 public:
   ReportNonCanonicalPhiNode(Instruction *Inst);
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -387,6 +522,11 @@ class ReportLoopHeader : public ReportIn
 public:
   ReportLoopHeader(Loop *L);
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -404,6 +544,11 @@ class ReportIndEdge : public RejectReaso
 public:
   ReportIndEdge(BasicBlock *BB);
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -427,6 +572,11 @@ public:
 
   const SCEV *loopCount() { return LoopCount; }
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -445,6 +595,11 @@ class ReportFuncCall : public RejectReas
 public:
   ReportFuncCall(Instruction *Inst);
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -463,11 +618,18 @@ class ReportAlias : public RejectReason
   /// @param AS The invalid alias set to format.
   std::string formatInvalidAlias(AliasSet &AS) const;
 
-  AliasSet *AS;
   Instruction *Inst;
+  AliasSet &AS;
 
 public:
-  ReportAlias(Instruction *Inst, AliasSet *AS);
+  ReportAlias(Instruction *Inst, AliasSet &AS);
+
+  AliasSet &getAliasSet() { return AS; }
+
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
 
   /// @name RejectReason interface
   //@{
@@ -483,6 +645,11 @@ class ReportSimpleLoop : public RejectRe
 public:
   ReportSimpleLoop();
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -494,7 +661,12 @@ public:
 class ReportOther : public RejectReason {
   //===--------------------------------------------------------------------===//
 public:
-  ReportOther();
+  ReportOther(const RejectReasonKind K);
+
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
 
   /// @name RejectReason interface
   //@{
@@ -513,6 +685,11 @@ class ReportIntToPtr : public ReportOthe
 public:
   ReportIntToPtr(Instruction *BaseValue);
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -529,6 +706,11 @@ class ReportAlloca : public ReportOther
 public:
   ReportAlloca(Instruction *Inst);
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -545,6 +727,11 @@ class ReportUnknownInst : public ReportO
 public:
   ReportUnknownInst(Instruction *Inst);
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -561,6 +748,11 @@ class ReportPHIinExit : public ReportOth
 public:
   ReportPHIinExit(Instruction *Inst);
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
@@ -577,6 +769,11 @@ class ReportEntry : public ReportOther {
 public:
   ReportEntry(BasicBlock *BB);
 
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=211770&r1=211769&r2=211770&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Thu Jun 26 05:19:57 2014
@@ -479,7 +479,7 @@ bool ScopDetection::isValidMemoryAccess(
   // not proof this without -basicaa we would fail. We disable this check to
   // not cause irrelevant verification failures.
   if (!AS.isMustAlias())
-    return invalid<ReportAlias>(Context, /*Assert=*/true, &Inst, &AS);
+    return invalid<ReportAlias>(Context, /*Assert=*/false, &Inst, AS);
 
   return true;
 }

Modified: polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp?rev=211770&r1=211769&r2=211770&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp Thu Jun 26 05:19:57 2014
@@ -127,7 +127,13 @@ const llvm::DebugLoc &RejectReason::getD
 //===----------------------------------------------------------------------===//
 // ReportCFG.
 
-ReportCFG::ReportCFG() { ++BadCFGForScop; }
+ReportCFG::ReportCFG(const RejectReasonKind K) : RejectReason(K) {
+  ++BadCFGForScop;
+}
+
+bool ReportCFG::classof(const RejectReason *RR) {
+  return RR->getKind() >= rrkCFG && RR->getKind() <= rrkLastCFG;
+}
 
 //===----------------------------------------------------------------------===//
 // ReportNonBranchTerminator.
@@ -140,6 +146,10 @@ const DebugLoc &ReportNonBranchTerminato
   return BB->getTerminator()->getDebugLoc();
 }
 
+bool ReportNonBranchTerminator::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkNonBranchTerminator;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportCondition.
 
@@ -151,14 +161,22 @@ const DebugLoc &ReportCondition::getDebu
   return BB->getTerminator()->getDebugLoc();
 }
 
+bool ReportCondition::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkCondition;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportAffFunc.
 
-ReportAffFunc::ReportAffFunc(const Instruction *Inst)
-    : RejectReason(), Inst(Inst) {
+ReportAffFunc::ReportAffFunc(const RejectReasonKind K, const Instruction *Inst)
+    : RejectReason(K), Inst(Inst) {
   ++BadAffFuncForScop;
 }
 
+bool ReportAffFunc::classof(const RejectReason *RR) {
+  return RR->getKind() >= rrkAffFunc && RR->getKind() <= rrkLastAffFunc;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportUndefCond.
 
@@ -166,6 +184,10 @@ std::string ReportUndefCond::getMessage(
   return ("Condition based on 'undef' value in BB: " + BB->getName()).str();
 }
 
+bool ReportUndefCond::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkUndefCond;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportInvalidCond.
 
@@ -174,6 +196,10 @@ std::string ReportInvalidCond::getMessag
          "' neither constant nor an icmp instruction";
 }
 
+bool ReportInvalidCond::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkInvalidCond;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportUndefOperand.
 
@@ -181,6 +207,10 @@ std::string ReportUndefOperand::getMessa
   return ("undef operand in branch at BB: " + BB->getName()).str();
 }
 
+bool ReportUndefOperand::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkUndefOperand;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportNonAffBranch.
 
@@ -189,11 +219,19 @@ std::string ReportNonAffBranch::getMessa
          *LHS + " and RHS: " + *RHS;
 }
 
+bool ReportNonAffBranch::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkNonAffBranch;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportNoBasePtr.
 
 std::string ReportNoBasePtr::getMessage() const { return "No base pointer"; }
 
+bool ReportNoBasePtr::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkNoBasePtr;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportUndefBasePtr.
 
@@ -201,6 +239,10 @@ std::string ReportUndefBasePtr::getMessa
   return "Undefined base pointer";
 }
 
+bool ReportUndefBasePtr::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkUndefBasePtr;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportVariantBasePtr.
 
@@ -208,6 +250,10 @@ std::string ReportVariantBasePtr::getMes
   return "Base address not invariant in current region:" + *BaseValue;
 }
 
+bool ReportVariantBasePtr::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkVariantBasePtr;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportNonAffineAccess.
 
@@ -215,16 +261,22 @@ std::string ReportNonAffineAccess::getMe
   return "Non affine access function: " + *AccessFunction;
 }
 
+bool ReportNonAffineAccess::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkNonAffineAccess;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportIndVar.
 
-ReportIndVar::ReportIndVar() : RejectReason() { ++BadIndVarForScop; }
+ReportIndVar::ReportIndVar(const RejectReasonKind K) : RejectReason(K) {
+  ++BadIndVarForScop;
+}
 
 //===----------------------------------------------------------------------===//
 // ReportPhiNodeRefInRegion.
 
 ReportPhiNodeRefInRegion::ReportPhiNodeRefInRegion(Instruction *Inst)
-    : ReportIndVar(), Inst(Inst) {}
+    : ReportIndVar(rrkPhiNodeRefInRegion), Inst(Inst) {}
 
 std::string ReportPhiNodeRefInRegion::getMessage() const {
   return "SCEV of PHI node refers to SSA names in region: " + *Inst;
@@ -234,11 +286,15 @@ const DebugLoc &ReportPhiNodeRefInRegion
   return Inst->getDebugLoc();
 }
 
+bool ReportPhiNodeRefInRegion::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkPhiNodeRefInRegion;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportNonCanonicalPhiNode.
 
 ReportNonCanonicalPhiNode::ReportNonCanonicalPhiNode(Instruction *Inst)
-    : ReportIndVar(), Inst(Inst) {}
+    : ReportIndVar(rrkNonCanonicalPhiNode), Inst(Inst) {}
 
 std::string ReportNonCanonicalPhiNode::getMessage() const {
   return "Non canonical PHI node: " + *Inst;
@@ -248,10 +304,15 @@ const DebugLoc &ReportNonCanonicalPhiNod
   return Inst->getDebugLoc();
 }
 
+bool ReportNonCanonicalPhiNode::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkNonCanonicalPhiNode;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportLoopHeader.
 
-ReportLoopHeader::ReportLoopHeader(Loop *L) : ReportIndVar(), L(L) {}
+ReportLoopHeader::ReportLoopHeader(Loop *L)
+    : ReportIndVar(rrkLoopHeader), L(L) {}
 
 std::string ReportLoopHeader::getMessage() const {
   return ("No canonical IV at loop header: " + L->getHeader()->getName()).str();
@@ -262,10 +323,15 @@ const DebugLoc &ReportLoopHeader::getDeb
   return BB->getTerminator()->getDebugLoc();
 }
 
+bool ReportLoopHeader::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkLoopHeader;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportIndEdge.
 
-ReportIndEdge::ReportIndEdge(BasicBlock *BB) : RejectReason(), BB(BB) {
+ReportIndEdge::ReportIndEdge(BasicBlock *BB)
+    : RejectReason(rrkIndEdge), BB(BB) {
   ++BadIndEdgeForScop;
 }
 
@@ -277,11 +343,15 @@ const DebugLoc &ReportIndEdge::getDebugL
   return BB->getTerminator()->getDebugLoc();
 }
 
+bool ReportIndEdge::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkIndEdge;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportLoopBound.
 
 ReportLoopBound::ReportLoopBound(Loop *L, const SCEV *LoopCount)
-    : RejectReason(), L(L), LoopCount(LoopCount) {
+    : RejectReason(rrkLoopBound), L(L), LoopCount(LoopCount) {
   ++BadLoopBoundForScop;
 }
 
@@ -295,10 +365,15 @@ const DebugLoc &ReportLoopBound::getDebu
   return BB->getTerminator()->getDebugLoc();
 }
 
+bool ReportLoopBound::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkLoopBound;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportFuncCall.
 
-ReportFuncCall::ReportFuncCall(Instruction *Inst) : RejectReason(), Inst(Inst) {
+ReportFuncCall::ReportFuncCall(Instruction *Inst)
+    : RejectReason(rrkFuncCall), Inst(Inst) {
   ++BadFuncCallForScop;
 }
 
@@ -315,11 +390,15 @@ std::string ReportFuncCall::getEndUserMe
          "Try to inline it.";
 }
 
+bool ReportFuncCall::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkFuncCall;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportAlias.
 
-ReportAlias::ReportAlias(Instruction *Inst, AliasSet *AS)
-    : RejectReason(), AS(AS), Inst(Inst) {
+ReportAlias::ReportAlias(Instruction *Inst, AliasSet &AS)
+    : RejectReason(rrkAlias), Inst(Inst), AS(AS) {
   ++BadAliasForScop;
 }
 
@@ -357,14 +436,18 @@ std::string ReportAlias::formatInvalidAl
   return OS.str();
 }
 
-std::string ReportAlias::getMessage() const { return formatInvalidAlias(*AS); }
+std::string ReportAlias::getMessage() const { return formatInvalidAlias(AS); }
 
 const DebugLoc &ReportAlias::getDebugLoc() const { return Inst->getDebugLoc(); }
 
+bool ReportAlias::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkAlias;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportSimpleLoop.
 
-ReportSimpleLoop::ReportSimpleLoop() : RejectReason() {
+ReportSimpleLoop::ReportSimpleLoop() : RejectReason(rrkSimpleLoop) {
   ++BadSimpleLoopForScop;
 }
 
@@ -372,17 +455,27 @@ std::string ReportSimpleLoop::getMessage
   return "Loop not in simplify form is invalid!";
 }
 
+bool ReportSimpleLoop::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkSimpleLoop;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportOther.
 
 std::string ReportOther::getMessage() const { return "Unknown reject reason"; }
 
-ReportOther::ReportOther() : RejectReason() { ++BadOtherForScop; }
+ReportOther::ReportOther(const RejectReasonKind K) : RejectReason(K) {
+  ++BadOtherForScop;
+}
+
+bool ReportOther::classof(const RejectReason *RR) {
+  return RR->getKind() >= rrkOther && RR->getKind() <= rrkLastOther;
+}
 
 //===----------------------------------------------------------------------===//
 // ReportIntToPtr.
 ReportIntToPtr::ReportIntToPtr(Instruction *BaseValue)
-    : ReportOther(), BaseValue(BaseValue) {}
+    : ReportOther(rrkIntToPtr), BaseValue(BaseValue) {}
 
 std::string ReportIntToPtr::getMessage() const {
   return "Find bad intToptr prt: " + *BaseValue;
@@ -392,10 +485,15 @@ const DebugLoc &ReportIntToPtr::getDebug
   return BaseValue->getDebugLoc();
 }
 
+bool ReportIntToPtr::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkIntToPtr;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportAlloca.
 
-ReportAlloca::ReportAlloca(Instruction *Inst) : ReportOther(), Inst(Inst) {}
+ReportAlloca::ReportAlloca(Instruction *Inst)
+    : ReportOther(rrkAlloca), Inst(Inst) {}
 
 std::string ReportAlloca::getMessage() const {
   return "Alloca instruction: " + *Inst;
@@ -405,11 +503,15 @@ const DebugLoc &ReportAlloca::getDebugLo
   return Inst->getDebugLoc();
 }
 
+bool ReportAlloca::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkAlloca;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportUnknownInst.
 
 ReportUnknownInst::ReportUnknownInst(Instruction *Inst)
-    : ReportOther(), Inst(Inst) {}
+    : ReportOther(rrkUnknownInst), Inst(Inst) {}
 
 std::string ReportUnknownInst::getMessage() const {
   return "Unknown instruction: " + *Inst;
@@ -419,11 +521,15 @@ const DebugLoc &ReportUnknownInst::getDe
   return Inst->getDebugLoc();
 }
 
+bool ReportUnknownInst::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkUnknownInst;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportPHIinExit.
 
 ReportPHIinExit::ReportPHIinExit(Instruction *Inst)
-    : ReportOther(), Inst(Inst) {}
+    : ReportOther(rrkPHIinExit), Inst(Inst) {}
 
 std::string ReportPHIinExit::getMessage() const {
   return "PHI node in exit BB";
@@ -433,9 +539,13 @@ const DebugLoc &ReportPHIinExit::getDebu
   return Inst->getDebugLoc();
 }
 
+bool ReportPHIinExit::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkPHIinExit;
+}
+
 //===----------------------------------------------------------------------===//
 // ReportEntry.
-ReportEntry::ReportEntry(BasicBlock *BB) : ReportOther(), BB(BB) {}
+ReportEntry::ReportEntry(BasicBlock *BB) : ReportOther(rrkEntry), BB(BB) {}
 
 std::string ReportEntry::getMessage() const {
   return "Region containing entry block of function is invalid!";
@@ -444,4 +554,8 @@ std::string ReportEntry::getMessage() co
 const DebugLoc &ReportEntry::getDebugLoc() const {
   return BB->getTerminator()->getDebugLoc();
 }
+
+bool ReportEntry::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkEntry;
+}
 } // namespace polly





More information about the llvm-commits mailing list