2014-05-24 17:24:53 +08:00
|
|
|
//=== ScopDetectionDiagnostic.cpp - Error diagnostics --------- -*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Small set of diagnostic helper classes to encapsulate any errors occurred
|
|
|
|
// during the detection of Scops.
|
|
|
|
//
|
|
|
|
// The ScopDetection defines a set of error classes (via Statistic variables)
|
|
|
|
// that groups a number of individual errors into a group, e.g. non-affinity
|
|
|
|
// related errors.
|
|
|
|
// On error we generate an object that carries enough additional information
|
|
|
|
// to diagnose the error and generate a helpful error message.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "polly/ScopDetectionDiagnostic.h"
|
|
|
|
|
|
|
|
#include "llvm/Analysis/LoopInfo.h"
|
|
|
|
#include "llvm/Analysis/AliasSetTracker.h"
|
|
|
|
#include "llvm/IR/BasicBlock.h"
|
2014-06-26 18:06:40 +08:00
|
|
|
#include "llvm/IR/DebugInfo.h"
|
|
|
|
#include "llvm/IR/DebugLoc.h"
|
|
|
|
#include "llvm/IR/DiagnosticInfo.h"
|
|
|
|
#include "llvm/IR/LLVMContext.h"
|
2014-05-24 17:24:53 +08:00
|
|
|
#include "llvm/IR/Value.h"
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
#include "llvm/ADT/Statistic.h"
|
|
|
|
|
2014-06-12 15:23:04 +08:00
|
|
|
#include "llvm/Analysis/RegionInfo.h"
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
#define DEBUG_TYPE "polly-detect"
|
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#define BADSCOP_STAT(NAME, DESC) \
|
|
|
|
STATISTIC(Bad##NAME##ForScop, "Number of bad regions for Scop: " DESC)
|
|
|
|
|
|
|
|
BADSCOP_STAT(CFG, "CFG too complex");
|
|
|
|
BADSCOP_STAT(IndVar, "Non canonical induction variable in loop");
|
|
|
|
BADSCOP_STAT(IndEdge, "Found invalid region entering edges");
|
|
|
|
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(SimpleLoop, "Loop not in -loop-simplify form");
|
|
|
|
BADSCOP_STAT(Other, "Others");
|
|
|
|
|
|
|
|
namespace polly {
|
|
|
|
/// @brief Small string conversion via raw_string_stream.
|
|
|
|
template <typename T> std::string operator+(Twine LHS, const T &RHS) {
|
|
|
|
std::string Buf;
|
|
|
|
raw_string_ostream fmt(Buf);
|
|
|
|
fmt << RHS;
|
|
|
|
fmt.flush();
|
|
|
|
|
|
|
|
return LHS.concat(Buf).str();
|
|
|
|
}
|
|
|
|
|
2014-06-12 15:23:04 +08:00
|
|
|
void getDebugLocation(const Region *R, unsigned &LineBegin, unsigned &LineEnd,
|
|
|
|
std::string &FileName) {
|
|
|
|
LineBegin = -1;
|
|
|
|
LineEnd = 0;
|
|
|
|
|
|
|
|
for (const BasicBlock *BB : R->blocks())
|
|
|
|
for (const Instruction &Inst : *BB) {
|
|
|
|
DebugLoc DL = Inst.getDebugLoc();
|
|
|
|
if (DL.isUnknown())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
DIScope Scope(DL.getScope(Inst.getContext()));
|
|
|
|
|
|
|
|
if (FileName.empty())
|
|
|
|
FileName = Scope.getFilename();
|
|
|
|
|
|
|
|
unsigned NewLine = DL.getLine();
|
|
|
|
|
|
|
|
LineBegin = std::min(LineBegin, NewLine);
|
|
|
|
LineEnd = std::max(LineEnd, NewLine);
|
|
|
|
}
|
|
|
|
}
|
2014-08-14 16:53:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
// @brief Lexicographic order on (line, col) of our debug locations.
|
|
|
|
static bool operator<(const llvm::DebugLoc &LHS, const llvm::DebugLoc &RHS) {
|
|
|
|
return LHS.getLine() < RHS.getLine() ||
|
|
|
|
(LHS.getLine() == RHS.getLine() && LHS.getCol() < RHS.getCol());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace polly {
|
|
|
|
static void getDebugLocations(const Region *R, DebugLoc &Begin, DebugLoc &End) {
|
|
|
|
for (const BasicBlock *BB : R->blocks())
|
|
|
|
for (const Instruction &Inst : *BB) {
|
|
|
|
DebugLoc DL = Inst.getDebugLoc();
|
|
|
|
if (DL.isUnknown())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Begin = Begin.isUnknown() ? DL : std::min(Begin, DL);
|
|
|
|
End = End.isUnknown() ? DL : std::max(End, DL);
|
|
|
|
}
|
|
|
|
}
|
2014-06-12 15:23:04 +08:00
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
void emitRejectionRemarks(const llvm::Function &F, const RejectLog &Log) {
|
|
|
|
LLVMContext &Ctx = F.getContext();
|
|
|
|
|
|
|
|
const Region *R = Log.region();
|
2014-08-14 16:53:06 +08:00
|
|
|
DebugLoc Begin, End;
|
|
|
|
|
|
|
|
getDebugLocations(R, Begin, End);
|
2014-06-26 18:06:40 +08:00
|
|
|
|
|
|
|
emitOptimizationRemarkMissed(
|
2014-08-14 16:53:06 +08:00
|
|
|
Ctx, DEBUG_TYPE, F, Begin,
|
2014-06-26 18:06:40 +08:00
|
|
|
"The following errors keep this region from being a Scop.");
|
2014-08-14 16:53:06 +08:00
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
for (RejectReasonPtr RR : Log) {
|
|
|
|
const DebugLoc &Loc = RR->getDebugLoc();
|
|
|
|
if (!Loc.isUnknown())
|
|
|
|
emitOptimizationRemarkMissed(Ctx, DEBUG_TYPE, F, Loc,
|
|
|
|
RR->getEndUserMessage());
|
|
|
|
}
|
2014-08-14 16:53:06 +08:00
|
|
|
|
|
|
|
emitOptimizationRemarkMissed(Ctx, DEBUG_TYPE, F, End,
|
|
|
|
"Invalid Scop candidate ends here.");
|
2014-06-26 18:06:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void emitValidRemarks(const llvm::Function &F, const Region *R) {
|
|
|
|
LLVMContext &Ctx = F.getContext();
|
|
|
|
|
2014-08-14 16:53:06 +08:00
|
|
|
DebugLoc Begin, End;
|
|
|
|
getDebugLocations(R, Begin, End);
|
2014-06-26 18:06:40 +08:00
|
|
|
|
|
|
|
emitOptimizationRemark(Ctx, DEBUG_TYPE, F, Begin,
|
|
|
|
"A valid Scop begins here.");
|
|
|
|
emitOptimizationRemark(Ctx, DEBUG_TYPE, F, End, "A valid Scop ends here.");
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// RejectReason.
|
2014-06-26 19:09:13 +08:00
|
|
|
const DebugLoc RejectReason::Unknown = DebugLoc();
|
2014-06-26 18:06:40 +08:00
|
|
|
|
|
|
|
const llvm::DebugLoc &RejectReason::getDebugLoc() const {
|
|
|
|
// Allocate an empty DebugLoc and return it a reference to it.
|
2014-06-26 19:09:13 +08:00
|
|
|
return Unknown;
|
2014-06-26 18:06:40 +08:00
|
|
|
}
|
|
|
|
|
2014-08-14 16:53:18 +08:00
|
|
|
// RejectLog.
|
|
|
|
void RejectLog::print(raw_ostream &OS, int level) const {
|
|
|
|
int j = 0;
|
|
|
|
for (auto Reason : ErrorReports)
|
|
|
|
OS.indent(level) << "[" << j++ << "] " << Reason->getMessage() << "\n";
|
|
|
|
}
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportCFG.
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
ReportCFG::ReportCFG(const RejectReasonKind K) : RejectReason(K) {
|
|
|
|
++BadCFGForScop;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ReportCFG::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() >= rrkCFG && RR->getKind() <= rrkLastCFG;
|
|
|
|
}
|
2014-05-24 17:24:53 +08:00
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportNonBranchTerminator.
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportNonBranchTerminator::getMessage() const {
|
|
|
|
return ("Non branch instruction terminates BB: " + BB->getName()).str();
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
const DebugLoc &ReportNonBranchTerminator::getDebugLoc() const {
|
|
|
|
return BB->getTerminator()->getDebugLoc();
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportNonBranchTerminator::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkNonBranchTerminator;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportCondition.
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportCondition::getMessage() const {
|
|
|
|
return ("Not well structured condition at BB: " + BB->getName()).str();
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
const DebugLoc &ReportCondition::getDebugLoc() const {
|
|
|
|
return BB->getTerminator()->getDebugLoc();
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportCondition::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkCondition;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportAffFunc.
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
ReportAffFunc::ReportAffFunc(const RejectReasonKind K, const Instruction *Inst)
|
|
|
|
: RejectReason(K), Inst(Inst) {
|
2014-06-26 18:06:40 +08:00
|
|
|
++BadAffFuncForScop;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportAffFunc::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() >= rrkAffFunc && RR->getKind() <= rrkLastAffFunc;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportUndefCond.
|
2014-05-24 17:24:53 +08:00
|
|
|
|
|
|
|
std::string ReportUndefCond::getMessage() const {
|
|
|
|
return ("Condition based on 'undef' value in BB: " + BB->getName()).str();
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportUndefCond::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkUndefCond;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportInvalidCond.
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportInvalidCond::getMessage() const {
|
|
|
|
return ("Condition in BB '" + BB->getName()).str() +
|
|
|
|
"' neither constant nor an icmp instruction";
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportInvalidCond::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkInvalidCond;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportUndefOperand.
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportUndefOperand::getMessage() const {
|
|
|
|
return ("undef operand in branch at BB: " + BB->getName()).str();
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportUndefOperand::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkUndefOperand;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportNonAffBranch.
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportNonAffBranch::getMessage() const {
|
|
|
|
return ("Non affine branch in BB '" + BB->getName()).str() + "' with LHS: " +
|
|
|
|
*LHS + " and RHS: " + *RHS;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportNonAffBranch::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkNonAffBranch;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportNoBasePtr.
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportNoBasePtr::getMessage() const { return "No base pointer"; }
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportNoBasePtr::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkNoBasePtr;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportUndefBasePtr.
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportUndefBasePtr::getMessage() const {
|
|
|
|
return "Undefined base pointer";
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportUndefBasePtr::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkUndefBasePtr;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportVariantBasePtr.
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportVariantBasePtr::getMessage() const {
|
|
|
|
return "Base address not invariant in current region:" + *BaseValue;
|
|
|
|
}
|
|
|
|
|
2014-06-26 21:33:35 +08:00
|
|
|
std::string ReportVariantBasePtr::getEndUserMessage() const {
|
|
|
|
return "The base address of this array is not invariant inside the loop";
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportVariantBasePtr::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkVariantBasePtr;
|
|
|
|
}
|
|
|
|
|
2014-09-13 22:47:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportDifferentArrayElementSize
|
|
|
|
|
|
|
|
std::string ReportDifferentArrayElementSize::getMessage() const {
|
|
|
|
return "Access to one array through data types of different size";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ReportDifferentArrayElementSize::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkDifferentElementSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ReportDifferentArrayElementSize::getEndUserMessage() const {
|
|
|
|
llvm::StringRef BaseName = BaseValue->getName();
|
|
|
|
std::string Name = (BaseName.size() > 0) ? BaseName : "UNKNOWN";
|
|
|
|
return "The array \"" + Name + "\" is accessed through elements that differ "
|
|
|
|
"in size";
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportNonAffineAccess.
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportNonAffineAccess::getMessage() const {
|
|
|
|
return "Non affine access function: " + *AccessFunction;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportNonAffineAccess::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkNonAffineAccess;
|
|
|
|
}
|
|
|
|
|
2014-08-17 18:09:11 +08:00
|
|
|
std::string ReportNonAffineAccess::getEndUserMessage() const {
|
|
|
|
llvm::StringRef BaseName = BaseValue->getName();
|
|
|
|
std::string Name = (BaseName.size() > 0) ? BaseName : "UNKNOWN";
|
|
|
|
return "The array subscript of \"" + Name + "\" is not affine";
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportIndVar.
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
ReportIndVar::ReportIndVar(const RejectReasonKind K) : RejectReason(K) {
|
|
|
|
++BadIndVarForScop;
|
|
|
|
}
|
2014-06-26 18:06:40 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportPhiNodeRefInRegion.
|
|
|
|
|
|
|
|
ReportPhiNodeRefInRegion::ReportPhiNodeRefInRegion(Instruction *Inst)
|
2014-06-26 18:19:57 +08:00
|
|
|
: ReportIndVar(rrkPhiNodeRefInRegion), Inst(Inst) {}
|
2014-05-24 17:24:53 +08:00
|
|
|
|
|
|
|
std::string ReportPhiNodeRefInRegion::getMessage() const {
|
|
|
|
return "SCEV of PHI node refers to SSA names in region: " + *Inst;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
const DebugLoc &ReportPhiNodeRefInRegion::getDebugLoc() const {
|
|
|
|
return Inst->getDebugLoc();
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportPhiNodeRefInRegion::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkPhiNodeRefInRegion;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportIndEdge.
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
ReportIndEdge::ReportIndEdge(BasicBlock *BB)
|
|
|
|
: RejectReason(rrkIndEdge), BB(BB) {
|
2014-06-26 18:06:40 +08:00
|
|
|
++BadIndEdgeForScop;
|
|
|
|
}
|
2014-05-24 17:24:53 +08:00
|
|
|
|
|
|
|
std::string ReportIndEdge::getMessage() const {
|
|
|
|
return "Region has invalid entering edges!";
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
const DebugLoc &ReportIndEdge::getDebugLoc() const {
|
|
|
|
return BB->getTerminator()->getDebugLoc();
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportIndEdge::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkIndEdge;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportLoopBound.
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
ReportLoopBound::ReportLoopBound(Loop *L, const SCEV *LoopCount)
|
2014-08-17 18:09:15 +08:00
|
|
|
: RejectReason(rrkLoopBound), L(L), LoopCount(LoopCount),
|
|
|
|
Loc(L->getStartLoc()) {
|
2014-05-24 17:24:53 +08:00
|
|
|
++BadLoopBoundForScop;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ReportLoopBound::getMessage() const {
|
|
|
|
return "Non affine loop bound '" + *LoopCount + "' in loop: " +
|
|
|
|
L->getHeader()->getName();
|
|
|
|
}
|
|
|
|
|
2014-08-17 18:09:15 +08:00
|
|
|
const DebugLoc &ReportLoopBound::getDebugLoc() const { return Loc; }
|
2014-06-26 18:06:40 +08:00
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportLoopBound::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkLoopBound;
|
|
|
|
}
|
|
|
|
|
2014-08-17 18:09:15 +08:00
|
|
|
std::string ReportLoopBound::getEndUserMessage() const {
|
|
|
|
return "Failed to derive an affine function from the loop bounds.";
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportFuncCall.
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
ReportFuncCall::ReportFuncCall(Instruction *Inst)
|
|
|
|
: RejectReason(rrkFuncCall), Inst(Inst) {
|
2014-05-24 17:24:53 +08:00
|
|
|
++BadFuncCallForScop;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ReportFuncCall::getMessage() const {
|
|
|
|
return "Call instruction: " + *Inst;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
const DebugLoc &ReportFuncCall::getDebugLoc() const {
|
|
|
|
return Inst->getDebugLoc();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ReportFuncCall::getEndUserMessage() const {
|
2014-12-20 00:49:39 +08:00
|
|
|
return "This function call cannot be handled. "
|
2014-06-26 18:06:40 +08:00
|
|
|
"Try to inline it.";
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportFuncCall::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkFuncCall;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportAlias.
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
ReportAlias::ReportAlias(Instruction *Inst, AliasSet &AS)
|
2014-08-14 16:53:12 +08:00
|
|
|
: RejectReason(rrkAlias), Inst(Inst) {
|
|
|
|
|
|
|
|
for (const auto &I : AS)
|
|
|
|
Pointers.push_back(I.getValue());
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
++BadAliasForScop;
|
|
|
|
}
|
2014-05-24 17:24:53 +08:00
|
|
|
|
2014-08-17 18:09:07 +08:00
|
|
|
std::string ReportAlias::formatInvalidAlias(std::string Prefix,
|
|
|
|
std::string Suffix) const {
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string Message;
|
|
|
|
raw_string_ostream OS(Message);
|
|
|
|
|
2014-08-17 18:09:07 +08:00
|
|
|
OS << Prefix;
|
2014-05-24 17:24:53 +08:00
|
|
|
|
2014-08-14 16:53:12 +08:00
|
|
|
for (PointerSnapshotTy::const_iterator PI = Pointers.begin(),
|
|
|
|
PE = Pointers.end();
|
2014-05-24 17:24:53 +08:00
|
|
|
;) {
|
2014-08-14 16:53:12 +08:00
|
|
|
const Value *V = *PI;
|
|
|
|
assert(V && "Diagnostic info does not match found LLVM-IR anymore.");
|
2014-05-24 17:24:53 +08:00
|
|
|
|
|
|
|
if (V->getName().size() == 0)
|
|
|
|
OS << "\"" << *V << "\"";
|
|
|
|
else
|
|
|
|
OS << "\"" << V->getName() << "\"";
|
|
|
|
|
|
|
|
++PI;
|
|
|
|
|
|
|
|
if (PI != PE)
|
|
|
|
OS << ", ";
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-08-17 18:09:07 +08:00
|
|
|
OS << Suffix;
|
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
return OS.str();
|
|
|
|
}
|
|
|
|
|
2014-08-17 18:09:07 +08:00
|
|
|
std::string ReportAlias::getMessage() const {
|
|
|
|
return formatInvalidAlias("Possible aliasing: ");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ReportAlias::getEndUserMessage() const {
|
|
|
|
return formatInvalidAlias("Accesses to the arrays ",
|
|
|
|
" may access the same memory.");
|
|
|
|
}
|
2014-05-24 17:24:53 +08:00
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
const DebugLoc &ReportAlias::getDebugLoc() const { return Inst->getDebugLoc(); }
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportAlias::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkAlias;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportSimpleLoop.
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
ReportSimpleLoop::ReportSimpleLoop() : RejectReason(rrkSimpleLoop) {
|
2014-06-26 18:06:40 +08:00
|
|
|
++BadSimpleLoopForScop;
|
|
|
|
}
|
2014-05-24 17:24:53 +08:00
|
|
|
|
|
|
|
std::string ReportSimpleLoop::getMessage() const {
|
|
|
|
return "Loop not in simplify form is invalid!";
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportSimpleLoop::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkSimpleLoop;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportOther.
|
|
|
|
|
|
|
|
std::string ReportOther::getMessage() const { return "Unknown reject reason"; }
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
ReportOther::ReportOther(const RejectReasonKind K) : RejectReason(K) {
|
|
|
|
++BadOtherForScop;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ReportOther::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() >= rrkOther && RR->getKind() <= rrkLastOther;
|
|
|
|
}
|
2014-06-26 18:06:40 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportIntToPtr.
|
|
|
|
ReportIntToPtr::ReportIntToPtr(Instruction *BaseValue)
|
2014-06-26 18:19:57 +08:00
|
|
|
: ReportOther(rrkIntToPtr), BaseValue(BaseValue) {}
|
2014-05-24 17:24:53 +08:00
|
|
|
|
|
|
|
std::string ReportIntToPtr::getMessage() const {
|
|
|
|
return "Find bad intToptr prt: " + *BaseValue;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
const DebugLoc &ReportIntToPtr::getDebugLoc() const {
|
|
|
|
return BaseValue->getDebugLoc();
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportIntToPtr::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkIntToPtr;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportAlloca.
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
ReportAlloca::ReportAlloca(Instruction *Inst)
|
|
|
|
: ReportOther(rrkAlloca), Inst(Inst) {}
|
2014-06-26 18:06:40 +08:00
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportAlloca::getMessage() const {
|
|
|
|
return "Alloca instruction: " + *Inst;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
const DebugLoc &ReportAlloca::getDebugLoc() const {
|
|
|
|
return Inst->getDebugLoc();
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportAlloca::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkAlloca;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportUnknownInst.
|
|
|
|
|
|
|
|
ReportUnknownInst::ReportUnknownInst(Instruction *Inst)
|
2014-06-26 18:19:57 +08:00
|
|
|
: ReportOther(rrkUnknownInst), Inst(Inst) {}
|
2014-06-26 18:06:40 +08:00
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportUnknownInst::getMessage() const {
|
|
|
|
return "Unknown instruction: " + *Inst;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
const DebugLoc &ReportUnknownInst::getDebugLoc() const {
|
|
|
|
return Inst->getDebugLoc();
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportUnknownInst::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkUnknownInst;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportPHIinExit.
|
|
|
|
|
|
|
|
ReportPHIinExit::ReportPHIinExit(Instruction *Inst)
|
2014-06-26 18:19:57 +08:00
|
|
|
: ReportOther(rrkPHIinExit), Inst(Inst) {}
|
2014-06-26 18:06:40 +08:00
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportPHIinExit::getMessage() const {
|
|
|
|
return "PHI node in exit BB";
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
const DebugLoc &ReportPHIinExit::getDebugLoc() const {
|
|
|
|
return Inst->getDebugLoc();
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:19:57 +08:00
|
|
|
bool ReportPHIinExit::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkPHIinExit;
|
|
|
|
}
|
|
|
|
|
2014-06-26 18:06:40 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportEntry.
|
2014-06-26 18:19:57 +08:00
|
|
|
ReportEntry::ReportEntry(BasicBlock *BB) : ReportOther(rrkEntry), BB(BB) {}
|
2014-06-26 18:06:40 +08:00
|
|
|
|
2014-05-24 17:24:53 +08:00
|
|
|
std::string ReportEntry::getMessage() const {
|
|
|
|
return "Region containing entry block of function is invalid!";
|
|
|
|
}
|
2014-06-26 18:06:40 +08:00
|
|
|
|
|
|
|
const DebugLoc &ReportEntry::getDebugLoc() const {
|
|
|
|
return BB->getTerminator()->getDebugLoc();
|
|
|
|
}
|
2014-06-26 18:19:57 +08:00
|
|
|
|
|
|
|
bool ReportEntry::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkEntry;
|
|
|
|
}
|
2015-02-19 13:31:07 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ReportUnprofitable.
|
|
|
|
ReportUnprofitable::ReportUnprofitable() : ReportOther(rrkUnprofitable) {}
|
|
|
|
|
|
|
|
std::string ReportUnprofitable::getMessage() const {
|
|
|
|
return "Region can not profitably be optimized!";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ReportUnprofitable::classof(const RejectReason *RR) {
|
|
|
|
return RR->getKind() == rrkUnprofitable;
|
|
|
|
}
|
2014-05-24 17:24:53 +08:00
|
|
|
} // namespace polly
|