20#ifndef POLLY_SCOPDETECTIONDIAGNOSTIC_H
21#define POLLY_SCOPDETECTIONDIAGNOSTIC_H
23#include "llvm/Analysis/LoopInfo.h"
24#include "llvm/IR/DebugLoc.h"
25#include "llvm/IR/Instruction.h"
31class OptimizationRemarkEmitter;
38using llvm::BasicBlock;
40using llvm::Instruction;
42using llvm::OptimizationRemarkEmitter;
43using llvm::raw_ostream;
46using llvm::SmallVector;
50using BBPair = std::pair<BasicBlock *, BasicBlock *>;
67 OptimizationRemarkEmitter &ORE);
173 using iterator = SmallVector<RejectReasonPtr, 1>::const_iterator;
184 void print(raw_ostream &OS,
int level = 0)
const;
414 const Instruction *
Inst)
598 Loc(
L->getStartLoc()) {}
626 Loc(
L->getStartLoc()) {}
654 Loc(
L->getStartLoc()) {}
707 std::string Suffix =
"")
const;
Stores all errors that occurred during the detection.
void report(RejectReasonPtr Reject)
void print(raw_ostream &OS, int level=0) const
const Region * region() const
bool hasErrors() const
Returns true, if we store at least one error.
SmallVector< RejectReasonPtr, 1 >::const_iterator iterator
SmallVector< RejectReasonPtr, 1 > ErrorReports
Base class of all reject reasons found during Scop detection.
virtual std::string getRemarkName() const =0
Generate the remark name to identify this remark.
virtual std::string getMessage() const =0
Generate a reasonable diagnostic message describing this error.
const RejectReasonKind Kind
static const DebugLoc Unknown
virtual ~RejectReason()=default
virtual std::string getEndUserMessage() const
Generate a message for the end-user describing this error.
RejectReasonKind getKind() const
virtual const Value * getRemarkBB() const =0
Get the Basic Block containing this remark.
virtual const DebugLoc & getDebugLoc() const
Get the source location of this error.
Base class for non-affine reject reasons.
static bool classof(const RejectReason *RR)
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
Captures errors with aliasing.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
static bool classof(const RejectReason *RR)
const PointerSnapshotTy & getPointers() const
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
std::vector< const Value * > PointerSnapshotTy
std::string getRemarkName() const override
Generate the remark name to identify this remark.
std::string formatInvalidAlias(std::string Prefix="", std::string Suffix="") const
Format an invalid alias set.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
PointerSnapshotTy Pointers
Captures errors with alloca instructions.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
static bool classof(const RejectReason *RR)
Base class for CFG related reject reasons.
static bool classof(const RejectReason *RR)
Report array accesses with differing element size.
static bool classof(const RejectReason *RR)
ReportDifferentArrayElementSize(const Instruction *Inst, const Value *V)
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
Captures errors with regions containing the function entry block.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
static bool classof(const RejectReason *RR)
Captures errors with non-side-effect-known function calls.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
static bool classof(const RejectReason *RR)
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
Captures regions with an IndirectBr predecessor.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
ReportIndirectPredecessor(Instruction *Inst, DebugLoc DbgLoc)
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
static bool classof(const RejectReason *RR)
Captures errors with bad IntToPtr instructions.
static bool classof(const RejectReason *RR)
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
Captures an invalid condition.
ReportInvalidCond(const Instruction *Inst, BasicBlock *BB)
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
static bool classof(const RejectReason *RR)
Captures bad terminator within a Scop candidate.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
ReportInvalidTerminator(BasicBlock *BB)
std::string getRemarkName() const override
Generate the remark name to identify this remark.
static bool classof(const RejectReason *RR)
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
Captures irreducible regions in CFG.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
static bool classof(const RejectReason *RR)
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
ReportIrreducibleRegion(Region *R, DebugLoc DbgLoc)
Captures errors with non affine loop bounds.
static bool classof(const RejectReason *RR)
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
Captures errors when a loop has multiple exists.
static bool classof(const RejectReason *RR)
std::string getRemarkName() const override
Generate the remark name to identify this remark.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
ReportLoopHasMultipleExits(Loop *L)
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
Loop * L
The loop that has multiple exits.
Captures errors when loop has no exit.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
Loop * L
The loop that has no exit.
static bool classof(const RejectReason *RR)
ReportLoopHasNoExit(Loop *L)
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
Captures errors when not all loop latches are part of the scop.
Loop * L
The loop for which not all loop latches are part of the scop.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
ReportLoopOnlySomeLatches(Loop *L)
static bool classof(const RejectReason *RR)
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
Captures a missing base pointer.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
static bool classof(const RejectReason *RR)
ReportNoBasePtr(const Instruction *Inst)
Captures a non-affine branch.
ReportNonAffBranch(BasicBlock *BB, const SCEV *LHS, const SCEV *RHS, const Instruction *Inst)
const SCEV * LHS
LHS & RHS of the failed condition.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
static bool classof(const RejectReason *RR)
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
Captures a non-affine access function.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
const SCEV * AccessFunction
static bool classof(const RejectReason *RR)
ReportNonAffineAccess(const SCEV *AccessFunction, const Instruction *Inst, const Value *V)
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
Captures errors with non-simple memory accesses.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
static bool classof(const RejectReason *RR)
Base class for otherwise ungrouped reject reasons.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
static bool classof(const RejectReason *RR)
Captures an undefined base pointer.
ReportUndefBasePtr(const Instruction *Inst)
static bool classof(const RejectReason *RR)
std::string getRemarkName() const override
Generate the remark name to identify this remark.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
Captures a condition that is based on an 'undef' value.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
static bool classof(const RejectReason *RR)
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
ReportUndefCond(const Instruction *Inst, BasicBlock *BB)
std::string getRemarkName() const override
Generate the remark name to identify this remark.
Captures an undefined operand.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
ReportUndefOperand(BasicBlock *BB, const Instruction *Inst)
static bool classof(const RejectReason *RR)
std::string getRemarkName() const override
Generate the remark name to identify this remark.
Captures errors with unknown instructions.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
static bool classof(const RejectReason *RR)
Report regions that seem not profitable to be optimized.
static bool classof(const RejectReason *RR)
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
std::string getRemarkName() const override
Generate the remark name to identify this remark.
Captures regions with an unreachable in the exit block.
ReportUnreachableInExit(BasicBlock *BB, DebugLoc DbgLoc)
std::string getRemarkName() const override
Generate the remark name to identify this remark.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
static bool classof(const RejectReason *RR)
const DebugLoc & getDebugLoc() const override
Get the source location of this error.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
Captures a base pointer that is not invariant in the region.
const Value * getRemarkBB() const override
Get the Basic Block containing this remark.
std::string getEndUserMessage() const override
Generate a message for the end-user describing this error.
ReportVariantBasePtr(Value *BaseValue, const Instruction *Inst)
static bool classof(const RejectReason *RR)
std::string getRemarkName() const override
Generate the remark name to identify this remark.
std::string getMessage() const override
Generate a reasonable diagnostic message describing this error.
This file contains the declaration of the PolyhedralInfo class, which will provide an interface to ex...
std::pair< llvm::BasicBlock *, llvm::BasicBlock * > BBPair
Type to hold region delimiters (entry & exit block).
std::shared_ptr< RejectReason > RejectReasonPtr
void getDebugLocations(const BBPair &P, DebugLoc &Begin, DebugLoc &End)
Set the begin and end source location for the region limited by P.
@ Value
MemoryKind::Value: Models an llvm::Value.
void emitRejectionRemarks(const BBPair &P, const RejectLog &Log, OptimizationRemarkEmitter &ORE)
Emit optimization remarks about the rejected regions to the user.
BBPair getBBPairForRegion(const Region *R)
Return the region delimiters (entry & exit block) of R.