From 0f085888b66f12294d5ea0b583b6bea5ed15a15c Mon Sep 17 00:00:00 2001 From: Adam Nemet Date: Thu, 23 Feb 2017 23:11:11 +0000 Subject: [PATCH] [OptDiag] Hide legacy remark ctors These are only used when emitting remarks without ORE directly using the free functions emitOptimizationRemark*. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296037 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DiagnosticInfo.h | 164 +++++++++++++--------- lib/Transforms/IPO/WholeProgramDevirt.cpp | 6 +- 2 files changed, 104 insertions(+), 66 deletions(-) diff --git a/include/llvm/IR/DiagnosticInfo.h b/include/llvm/IR/DiagnosticInfo.h index a327399b813..968b300b341 100644 --- a/include/llvm/IR/DiagnosticInfo.h +++ b/include/llvm/IR/DiagnosticInfo.h @@ -581,20 +581,6 @@ private: /// Diagnostic information for applied optimization remarks. class OptimizationRemark : public DiagnosticInfoIROptimization { public: - /// \p PassName is the name of the pass emitting this diagnostic. If - /// this name matches the regular expression given in -Rpass=, then the - /// diagnostic will be emitted. \p Fn is the function where the diagnostic - /// is being emitted. \p Loc is the location information to use in the - /// diagnostic. If line table information is available, the diagnostic - /// will include the source code location. \p Msg is the message to show. - /// Note that this class does not copy this message, so this reference - /// must be valid for the whole life time of the diagnostic. - OptimizationRemark(const char *PassName, const Function &Fn, - const DiagnosticLocation &Loc, const Twine &Msg, - Optional Hotness = None) - : DiagnosticInfoIROptimization(DK_OptimizationRemark, DS_Remark, PassName, - Fn, Loc, Msg, Hotness) {} - /// \p PassName is the name of the pass emitting this diagnostic. If this name /// matches the regular expression given in -Rpass=, then the diagnostic will /// be emitted. \p RemarkName is a textual identifier for the remark. \p @@ -616,25 +602,32 @@ public: /// \see DiagnosticInfoOptimizationBase::isEnabled. bool isEnabled() const override { return isEnabled(getPassName()); } -}; -/// Diagnostic information for missed-optimization remarks. -class OptimizationRemarkMissed : public DiagnosticInfoIROptimization { -public: +private: + /// This is deprecated now and only used by the function API below. /// \p PassName is the name of the pass emitting this diagnostic. If - /// this name matches the regular expression given in -Rpass-missed=, then the + /// this name matches the regular expression given in -Rpass=, then the /// diagnostic will be emitted. \p Fn is the function where the diagnostic /// is being emitted. \p Loc is the location information to use in the /// diagnostic. If line table information is available, the diagnostic /// will include the source code location. \p Msg is the message to show. /// Note that this class does not copy this message, so this reference /// must be valid for the whole life time of the diagnostic. - OptimizationRemarkMissed(const char *PassName, const Function &Fn, - const DiagnosticLocation &Loc, const Twine &Msg, - Optional Hotness = None) - : DiagnosticInfoIROptimization(DK_OptimizationRemarkMissed, DS_Remark, - PassName, Fn, Loc, Msg, Hotness) {} + OptimizationRemark(const char *PassName, const Function &Fn, + const DiagnosticLocation &Loc, const Twine &Msg, + Optional Hotness = None) + : DiagnosticInfoIROptimization(DK_OptimizationRemark, DS_Remark, PassName, + Fn, Loc, Msg, Hotness) {} + friend void emitOptimizationRemark(LLVMContext &Ctx, const char *PassName, + const Function &Fn, + const DiagnosticLocation &Loc, + const Twine &Msg); +}; + +/// Diagnostic information for missed-optimization remarks. +class OptimizationRemarkMissed : public DiagnosticInfoIROptimization { +public: /// \p PassName is the name of the pass emitting this diagnostic. If this name /// matches the regular expression given in -Rpass-missed=, then the /// diagnostic will be emitted. \p RemarkName is a textual identifier for the @@ -657,25 +650,33 @@ public: /// \see DiagnosticInfoOptimizationBase::isEnabled. bool isEnabled() const override { return isEnabled(getPassName()); } -}; -/// Diagnostic information for optimization analysis remarks. -class OptimizationRemarkAnalysis : public DiagnosticInfoIROptimization { -public: +private: + /// This is deprecated now and only used by the function API below. /// \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 Fn is the function where the diagnostic + /// this name matches the regular expression given in -Rpass-missed=, then the + /// diagnostic will be emitted. \p Fn is the function where the diagnostic /// is being emitted. \p Loc is the location information to use in the - /// diagnostic. If line table information is available, the diagnostic will - /// include the source code location. \p Msg is the message to show. Note that - /// this class does not copy this message, so this reference must be valid for - /// the whole life time of the diagnostic. - OptimizationRemarkAnalysis(const char *PassName, const Function &Fn, - const DiagnosticLocation &Loc, const Twine &Msg, - Optional Hotness = None) - : DiagnosticInfoIROptimization(DK_OptimizationRemarkAnalysis, DS_Remark, + /// diagnostic. If line table information is available, the diagnostic + /// will include the source code location. \p Msg is the message to show. + /// Note that this class does not copy this message, so this reference + /// must be valid for the whole life time of the diagnostic. + OptimizationRemarkMissed(const char *PassName, const Function &Fn, + const DiagnosticLocation &Loc, const Twine &Msg, + Optional Hotness = None) + : DiagnosticInfoIROptimization(DK_OptimizationRemarkMissed, DS_Remark, PassName, Fn, Loc, Msg, Hotness) {} + friend void emitOptimizationRemarkMissed(LLVMContext &Ctx, + const char *PassName, + const Function &Fn, + const DiagnosticLocation &Loc, + const Twine &Msg); +}; + +/// Diagnostic information for optimization analysis remarks. +class OptimizationRemarkAnalysis : public DiagnosticInfoIROptimization { +public: /// \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 @@ -727,29 +728,34 @@ protected: StringRef RemarkName, const DiagnosticLocation &Loc, const Value *CodeRegion); -}; -/// Diagnostic information for optimization analysis remarks related to -/// floating-point non-commutativity. -class OptimizationRemarkAnalysisFPCommute : public OptimizationRemarkAnalysis { -public: +private: + /// This is deprecated now and only used by the function API below. /// \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 Fn is the function where the diagnostic /// is being emitted. \p Loc is the location information to use in the /// diagnostic. If line table information is available, the diagnostic will - /// include the source code location. \p Msg is the message to show. The - /// front-end will append its own message related to options that address - /// floating-point non-commutativity. Note that this class does not copy this - /// message, so this reference must be valid for the whole life time of the - /// diagnostic. - OptimizationRemarkAnalysisFPCommute(const char *PassName, const Function &Fn, - const DiagnosticLocation &Loc, - const Twine &Msg, - Optional Hotness = None) - : OptimizationRemarkAnalysis(DK_OptimizationRemarkAnalysisFPCommute, - PassName, Fn, Loc, Msg, Hotness) {} + /// include the source code location. \p Msg is the message to show. Note that + /// this class does not copy this message, so this reference must be valid for + /// the whole life time of the diagnostic. + OptimizationRemarkAnalysis(const char *PassName, const Function &Fn, + const DiagnosticLocation &Loc, const Twine &Msg, + Optional Hotness = None) + : DiagnosticInfoIROptimization(DK_OptimizationRemarkAnalysis, DS_Remark, + PassName, Fn, Loc, Msg, Hotness) {} + friend void emitOptimizationRemarkAnalysis(LLVMContext &Ctx, + const char *PassName, + const Function &Fn, + const DiagnosticLocation &Loc, + const Twine &Msg); +}; + +/// Diagnostic information for optimization analysis remarks related to +/// floating-point non-commutativity. +class OptimizationRemarkAnalysisFPCommute : public OptimizationRemarkAnalysis { +public: /// \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 @@ -767,12 +773,9 @@ public: static bool classof(const DiagnosticInfo *DI) { return DI->getKind() == DK_OptimizationRemarkAnalysisFPCommute; } -}; -/// Diagnostic information for optimization analysis remarks related to -/// pointer aliasing. -class OptimizationRemarkAnalysisAliasing : public OptimizationRemarkAnalysis { -public: +private: + /// This is deprecated now and only used by the function API below. /// \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 Fn is the function where the diagnostic @@ -780,16 +783,24 @@ public: /// diagnostic. If line table information is available, the diagnostic will /// include the source code location. \p Msg is the message to show. The /// front-end will append its own message related to options that address - /// pointer aliasing legality. Note that this class does not copy this + /// floating-point non-commutativity. Note that this class does not copy this /// message, so this reference must be valid for the whole life time of the /// diagnostic. - OptimizationRemarkAnalysisAliasing(const char *PassName, const Function &Fn, - const DiagnosticLocation &Loc, - const Twine &Msg, - Optional Hotness = None) - : OptimizationRemarkAnalysis(DK_OptimizationRemarkAnalysisAliasing, + OptimizationRemarkAnalysisFPCommute(const char *PassName, const Function &Fn, + const DiagnosticLocation &Loc, + const Twine &Msg, + Optional Hotness = None) + : OptimizationRemarkAnalysis(DK_OptimizationRemarkAnalysisFPCommute, PassName, Fn, Loc, Msg, Hotness) {} + friend void emitOptimizationRemarkAnalysisFPCommute( + LLVMContext &Ctx, const char *PassName, const Function &Fn, + const DiagnosticLocation &Loc, const Twine &Msg); +}; +/// Diagnostic information for optimization analysis remarks related to +/// pointer aliasing. +class OptimizationRemarkAnalysisAliasing : public OptimizationRemarkAnalysis { +public: /// \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 @@ -806,6 +817,29 @@ public: static bool classof(const DiagnosticInfo *DI) { return DI->getKind() == DK_OptimizationRemarkAnalysisAliasing; } + +private: + /// This is deprecated now and only used by the function API below. + /// \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 Fn is the function where the diagnostic + /// is being emitted. \p Loc is the location information to use in the + /// diagnostic. If line table information is available, the diagnostic will + /// include the source code location. \p Msg is the message to show. The + /// front-end will append its own message related to options that address + /// pointer aliasing legality. Note that this class does not copy this + /// message, so this reference must be valid for the whole life time of the + /// diagnostic. + OptimizationRemarkAnalysisAliasing(const char *PassName, const Function &Fn, + const DiagnosticLocation &Loc, + const Twine &Msg, + Optional Hotness = None) + : OptimizationRemarkAnalysis(DK_OptimizationRemarkAnalysisAliasing, + PassName, Fn, Loc, Msg, Hotness) {} + + friend void emitOptimizationRemarkAnalysisAliasing( + LLVMContext &Ctx, const char *PassName, const Function &Fn, + const DiagnosticLocation &Loc, const Twine &Msg); }; /// Diagnostic information for machine IR parser. diff --git a/lib/Transforms/IPO/WholeProgramDevirt.cpp b/lib/Transforms/IPO/WholeProgramDevirt.cpp index c6457211c9e..6b9bfc02fa5 100644 --- a/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -896,7 +896,11 @@ bool DevirtModule::areRemarksEnabled() { if (FL.empty()) return false; const Function &Fn = FL.front(); - auto DI = OptimizationRemark(DEBUG_TYPE, Fn, DebugLoc(), ""); + + const auto &BBL = Fn.getBasicBlockList(); + if (BBL.empty()) + return false; + auto DI = OptimizationRemark(DEBUG_TYPE, "", DebugLoc(), &BBL.front()); return DI.isEnabled(); } -- 2.50.1