From: Adam Nemet Date: Thu, 29 Sep 2016 18:04:47 +0000 (+0000) Subject: [LV] Port OptimizationRemarkAnalysisFPCommute and X-Git-Tag: llvmorg-4.0.0-rc1~8604 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3628282a77d27f27e0f3dcb5b800b5b065d36a20;p=platform%2Fupstream%2Fllvm.git [LV] Port OptimizationRemarkAnalysisFPCommute and OptimizationRemarkAnalysisAliasing to new streaming API for opt remarks llvm-svn: 282742 --- diff --git a/llvm/include/llvm/IR/DiagnosticInfo.h b/llvm/include/llvm/IR/DiagnosticInfo.h index a91a813..015f304 100644 --- a/llvm/include/llvm/IR/DiagnosticInfo.h +++ b/llvm/include/llvm/IR/DiagnosticInfo.h @@ -600,6 +600,10 @@ protected: const Twine &Msg, Optional 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; } diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp index 3c2ed08..8e15014 100644 --- a/llvm/lib/IR/DiagnosticInfo.cpp +++ b/llvm/lib/IR/DiagnosticInfo.cpp @@ -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(CodeRegion)->getParent(), + DLoc, CodeRegion) {} + bool OptimizationRemarkAnalysis::isEnabled() const { return shouldAlwaysPrint() || (PassRemarksAnalysisOptLoc.Pattern && diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 44af9bb..bc92441 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -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; }