From e2c924366c9f3ed78bd813a37b9298549c72bbf2 Mon Sep 17 00:00:00 2001 From: Andreas Simbuerger Date: Thu, 26 Jun 2014 10:19:57 +0000 Subject: [PATCH] Support for LLVM-style RTTI isa<...>, dyn_cast<...> et al. llvm-svn: 211770 --- polly/include/polly/ScopDetectionDiagnostic.h | 231 +++++++++++++++++++++++-- polly/lib/Analysis/ScopDetection.cpp | 2 +- polly/lib/Analysis/ScopDetectionDiagnostic.cpp | 154 ++++++++++++++--- 3 files changed, 349 insertions(+), 38 deletions(-) diff --git a/polly/include/polly/ScopDetectionDiagnostic.h b/polly/include/polly/ScopDetectionDiagnostic.h index 78ee71f..f7f826b 100644 --- a/polly/include/polly/ScopDetectionDiagnostic.h +++ b/polly/include/polly/ScopDetectionDiagnostic.h @@ -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 #include @@ -66,6 +67,54 @@ void emitRejectionRemarks(const llvm::Function &F, const RejectLog &Log); /// @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::Function &F, const Region *R); /// 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 RejectReason { 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 ReportAffFunc { 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 ReportAffFunc { 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 ReportAffFunc { 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 ReportAffFunc { 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 ReportAffFunc { 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 ReportAffFunc { 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 ReportIndVar { 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 ReportIndVar { 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 ReportIndVar { 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 RejectReason { 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 RejectReason { 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 RejectReason { 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 ReportOther { 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 ReportOther { 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 ReportOther { 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; diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index 06b16c4..d63db25 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -479,7 +479,7 @@ bool ScopDetection::isValidMemoryAccess(Instruction &Inst, // not proof this without -basicaa we would fail. We disable this check to // not cause irrelevant verification failures. if (!AS.isMustAlias()) - return invalid(Context, /*Assert=*/true, &Inst, &AS); + return invalid(Context, /*Assert=*/false, &Inst, AS); return true; } diff --git a/polly/lib/Analysis/ScopDetectionDiagnostic.cpp b/polly/lib/Analysis/ScopDetectionDiagnostic.cpp index c18cab3..8fde51a 100644 --- a/polly/lib/Analysis/ScopDetectionDiagnostic.cpp +++ b/polly/lib/Analysis/ScopDetectionDiagnostic.cpp @@ -127,7 +127,13 @@ const llvm::DebugLoc &RejectReason::getDebugLoc() const { //===----------------------------------------------------------------------===// // 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 &ReportNonBranchTerminator::getDebugLoc() const { return BB->getTerminator()->getDebugLoc(); } +bool ReportNonBranchTerminator::classof(const RejectReason *RR) { + return RR->getKind() == rrkNonBranchTerminator; +} + //===----------------------------------------------------------------------===// // ReportCondition. @@ -151,14 +161,22 @@ const DebugLoc &ReportCondition::getDebugLoc() const { 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() const { 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::getMessage() const { "' neither constant nor an icmp instruction"; } +bool ReportInvalidCond::classof(const RejectReason *RR) { + return RR->getKind() == rrkInvalidCond; +} + //===----------------------------------------------------------------------===// // ReportUndefOperand. @@ -181,6 +207,10 @@ std::string ReportUndefOperand::getMessage() const { 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::getMessage() const { *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::getMessage() const { return "Undefined base pointer"; } +bool ReportUndefBasePtr::classof(const RejectReason *RR) { + return RR->getKind() == rrkUndefBasePtr; +} + //===----------------------------------------------------------------------===// // ReportVariantBasePtr. @@ -208,6 +250,10 @@ std::string ReportVariantBasePtr::getMessage() const { 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::getMessage() const { 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::getDebugLoc() const { 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 &ReportNonCanonicalPhiNode::getDebugLoc() const { 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::getDebugLoc() const { 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::getDebugLoc() const { 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::getDebugLoc() const { 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::getEndUserMessage() const { "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::formatInvalidAlias(AliasSet &AS) const { 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() const { 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::getDebugLoc() const { 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::getDebugLoc() const { 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::getDebugLoc() const { 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::getDebugLoc() const { 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() const { const DebugLoc &ReportEntry::getDebugLoc() const { return BB->getTerminator()->getDebugLoc(); } + +bool ReportEntry::classof(const RejectReason *RR) { + return RR->getKind() == rrkEntry; +} } // namespace polly -- 2.7.4