[LV] Port OptimizationRemarkAnalysisFPCommute and

OptimizationRemarkAnalysisAliasing to new streaming API for opt remarks

llvm-svn: 282742
This commit is contained in:
Adam Nemet 2016-09-29 18:04:47 +00:00
parent c94946a838
commit 3628282a77
3 changed files with 50 additions and 10 deletions

View File

@ -600,6 +600,10 @@ protected:
const Twine &Msg, Optional<uint64_t> Hotness)
: DiagnosticInfoOptimizationBase(Kind, DS_Remark, PassName, Fn, DLoc, Msg,
Hotness) {}
OptimizationRemarkAnalysis(enum DiagnosticKind Kind, const char *PassName,
StringRef RemarkName, const DebugLoc &DLoc,
Value *CodeRegion);
};
/// Diagnostic information for optimization analysis remarks related to
@ -622,6 +626,19 @@ public:
: OptimizationRemarkAnalysis(DK_OptimizationRemarkAnalysisFPCommute,
PassName, Fn, DLoc, Msg, Hotness) {}
/// \p PassName is the name of the pass emitting this diagnostic. If this name
/// matches the regular expression given in -Rpass-analysis=, then the
/// diagnostic will be emitted. \p RemarkName is a textual identifier for the
/// remark. \p DLoc is the debug location and \p CodeRegion is the region
/// that the optimization operates on (currently on block is supported). The
/// front-end will append its own message related to options that address
/// floating-point non-commutativity.
OptimizationRemarkAnalysisFPCommute(const char *PassName,
StringRef RemarkName,
const DebugLoc &DLoc, Value *CodeRegion)
: OptimizationRemarkAnalysis(DK_OptimizationRemarkAnalysisFPCommute,
PassName, RemarkName, DLoc, CodeRegion) {}
static bool classof(const DiagnosticInfo *DI) {
return DI->getKind() == DK_OptimizationRemarkAnalysisFPCommute;
}
@ -647,6 +664,18 @@ public:
: OptimizationRemarkAnalysis(DK_OptimizationRemarkAnalysisAliasing,
PassName, Fn, DLoc, Msg, Hotness) {}
/// \p PassName is the name of the pass emitting this diagnostic. If this name
/// matches the regular expression given in -Rpass-analysis=, then the
/// diagnostic will be emitted. \p RemarkName is a textual identifier for the
/// remark. \p DLoc is the debug location and \p CodeRegion is the region
/// that the optimization operates on (currently on block is supported). The
/// front-end will append its own message related to options that address
/// pointer aliasing legality.
OptimizationRemarkAnalysisAliasing(const char *PassName, StringRef RemarkName,
const DebugLoc &DLoc, Value *CodeRegion)
: OptimizationRemarkAnalysis(DK_OptimizationRemarkAnalysisAliasing,
PassName, RemarkName, DLoc, CodeRegion) {}
static bool classof(const DiagnosticInfo *DI) {
return DI->getKind() == DK_OptimizationRemarkAnalysisAliasing;
}

View File

@ -232,6 +232,15 @@ OptimizationRemarkAnalysis::OptimizationRemarkAnalysis(const char *PassName,
*Inst->getParent()->getParent(),
Inst->getDebugLoc(), Inst->getParent()) {}
OptimizationRemarkAnalysis::OptimizationRemarkAnalysis(enum DiagnosticKind Kind,
const char *PassName,
StringRef RemarkName,
const DebugLoc &DLoc,
Value *CodeRegion)
: DiagnosticInfoOptimizationBase(Kind, DS_Remark, PassName, RemarkName,
*cast<BasicBlock>(CodeRegion)->getParent(),
DLoc, CodeRegion) {}
bool OptimizationRemarkAnalysis::isEnabled() const {
return shouldAlwaysPrint() ||
(PassRemarksAnalysisOptLoc.Pattern &&

View File

@ -1978,14 +1978,15 @@ public:
void addRuntimePointerChecks(unsigned Num) { NumRuntimePointerChecks = Num; }
bool doesNotMeet(Function *F, Loop *L, const LoopVectorizeHints &Hints) {
const char *Name = Hints.vectorizeAnalysisPassName();
const char *PassName = Hints.vectorizeAnalysisPassName();
bool Failed = false;
if (UnsafeAlgebraInst && !Hints.allowReordering()) {
ORE.emitOptimizationRemarkAnalysisFPCommute(
Name, UnsafeAlgebraInst->getDebugLoc(),
UnsafeAlgebraInst->getParent(),
VectorizationReport() << "cannot prove it is safe to reorder "
"floating-point operations");
ORE.emit(
OptimizationRemarkAnalysisFPCommute(PassName, "CantReorderFPOps",
UnsafeAlgebraInst->getDebugLoc(),
UnsafeAlgebraInst->getParent())
<< "loop not vectorized: cannot prove it is safe to reorder "
"floating-point operations");
Failed = true;
}
@ -1996,10 +1997,11 @@ public:
NumRuntimePointerChecks > VectorizerParams::RuntimeMemoryCheckThreshold;
if ((ThresholdReached && !Hints.allowReordering()) ||
PragmaThresholdReached) {
ORE.emitOptimizationRemarkAnalysisAliasing(
Name, L,
VectorizationReport()
<< "cannot prove it is safe to reorder memory operations");
ORE.emit(OptimizationRemarkAnalysisAliasing(PassName, "CantReorderMemOps",
L->getStartLoc(),
L->getHeader())
<< "loop not vectorized: cannot prove it is safe to reorder "
"memory operations");
DEBUG(dbgs() << "LV: Too many memory checks needed.\n");
Failed = true;
}