Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 33 additions & 37 deletions llvm/include/llvm/IR/DiagnosticInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ class DiagnosticInfoOptimizationBase : public DiagnosticInfoWithLocationBase {

/// \p PassName is the name of the pass emitting this diagnostic. \p
/// RemarkName is a textual identifier for the remark (single-word,
/// camel-case). \p Fn is the function where the diagnostic is being emitted.
/// CamelCase). \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.
Expand Down Expand Up @@ -588,7 +588,7 @@ class DiagnosticInfoOptimizationBase : public DiagnosticInfoWithLocationBase {
/// be emitted.
const char *PassName;

/// Textual identifier for the remark (single-word, camel-case). Can be used
/// Textual identifier for the remark (single-word, CamelCase). Can be used
/// by external tools reading the output file for optimization remarks to
/// identify the remark.
StringRef RemarkName;
Expand Down Expand Up @@ -663,18 +663,17 @@ class DiagnosticInfoIROptimization : public DiagnosticInfoOptimizationBase {
public:
/// \p PassName is the name of the pass emitting this diagnostic. \p
/// RemarkName is a textual identifier for the remark (single-word,
/// camel-case). \p Fn is the function where the diagnostic is being emitted.
/// CamelCase). \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 CodeRegion is IR value (currently basic block) that the
/// optimization operates on. This is currently used to provide run-time
/// hotness information with PGO.
/// location. \p CodeRegion is IR value that the optimization operates on.
/// This is currently used to provide run-time hotness information with PGO.
DiagnosticInfoIROptimization(enum DiagnosticKind Kind,
enum DiagnosticSeverity Severity,
const char *PassName, StringRef RemarkName,
const Function &Fn,
const DiagnosticLocation &Loc,
const Value *CodeRegion = nullptr)
const BasicBlock *CodeRegion = nullptr)
: DiagnosticInfoOptimizationBase(Kind, Severity, PassName, RemarkName, Fn,
Loc),
CodeRegion(CodeRegion) {}
Expand Down Expand Up @@ -712,16 +711,16 @@ class DiagnosticInfoIROptimization : public DiagnosticInfoOptimizationBase {
*this << Msg.str();
}

const Value *getCodeRegion() const { return CodeRegion; }
const BasicBlock *getCodeRegion() const { return CodeRegion; }

static bool classof(const DiagnosticInfo *DI) {
return DI->getKind() >= DK_FirstRemark && DI->getKind() <= DK_LastRemark;
}

private:
/// The IR value (currently basic block) that the optimization operates on.
/// The IR value that the optimization operates on.
/// This is currently used to provide run-time hotness information with PGO.
const Value *CodeRegion = nullptr;
const BasicBlock *CodeRegion = nullptr;
};

/// Diagnostic information for applied optimization remarks.
Expand All @@ -730,11 +729,11 @@ class OptimizationRemark : public DiagnosticInfoIROptimization {
/// \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 (single-
/// word, camel-case). \p Loc is the debug location and \p CodeRegion is the
/// region that the optimization operates on (currently only block is
/// supported).
/// word, CamelCase). \p Loc is the debug location and \p CodeRegion is the
/// region that the optimization operates on.
OptimizationRemark(const char *PassName, StringRef RemarkName,
const DiagnosticLocation &Loc, const Value *CodeRegion);
const DiagnosticLocation &Loc,
const BasicBlock *CodeRegion);

/// Same as above, but the debug location and code region are derived from \p
/// Instr.
Expand Down Expand Up @@ -775,12 +774,11 @@ class OptimizationRemarkMissed : public DiagnosticInfoIROptimization {
/// \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
/// remark (single-word, camel-case). \p Loc is the debug location and \p
/// CodeRegion is the region that the optimization operates on (currently only
/// block is supported).
/// remark (single-word, CamelCase). \p Loc is the debug location and \p
/// CodeRegion is the region that the optimization operates on.
OptimizationRemarkMissed(const char *PassName, StringRef RemarkName,
const DiagnosticLocation &Loc,
const Value *CodeRegion);
const BasicBlock *CodeRegion);

/// Same as above but \p Inst is used to derive code region and debug
/// location.
Expand Down Expand Up @@ -821,12 +819,11 @@ class OptimizationRemarkAnalysis : public DiagnosticInfoIROptimization {
/// \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 (single-word, camel-case). \p Loc is the debug location and \p
/// CodeRegion is the region that the optimization operates on (currently only
/// block is supported).
/// remark (single-word, CamelCase). \p Loc is the debug location and \p
/// CodeRegion is the region that the optimization operates on.
OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
const DiagnosticLocation &Loc,
const Value *CodeRegion);
const BasicBlock *CodeRegion);

/// This is ctor variant allows a pass to build an optimization remark
/// from an existing remark.
Expand Down Expand Up @@ -869,7 +866,7 @@ class OptimizationRemarkAnalysis : public DiagnosticInfoIROptimization {
OptimizationRemarkAnalysis(enum DiagnosticKind Kind, const char *PassName,
StringRef RemarkName,
const DiagnosticLocation &Loc,
const Value *CodeRegion);
const BasicBlock *CodeRegion);

private:
/// This is deprecated now and only used by the function API below.
Expand All @@ -895,14 +892,14 @@ class OptimizationRemarkAnalysisFPCommute : public OptimizationRemarkAnalysis {
/// \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 (single-word, camel-case). \p Loc is the debug location and \p
/// CodeRegion is the region that the optimization operates on (currently only
/// block is supported). The front-end will append its own message related to
/// options that address floating-point non-commutativity.
/// remark (single-word, CamelCase). \p Loc is the debug location and \p
/// CodeRegion is the region that the optimization operates on. The front-end
/// will append its own message related to options that address floating-point
/// non-commutativity.
OptimizationRemarkAnalysisFPCommute(const char *PassName,
StringRef RemarkName,
const DiagnosticLocation &Loc,
const Value *CodeRegion)
const BasicBlock *CodeRegion)
: OptimizationRemarkAnalysis(DK_OptimizationRemarkAnalysisFPCommute,
PassName, RemarkName, Loc, CodeRegion) {}

Expand Down Expand Up @@ -937,13 +934,13 @@ class OptimizationRemarkAnalysisAliasing : public OptimizationRemarkAnalysis {
/// \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 (single-word, camel-case). \p Loc is the debug location and \p
/// CodeRegion is the region that the optimization operates on (currently only
/// block is supported). The front-end will append its own message related to
/// options that address pointer aliasing legality.
/// remark (single-word, CamelCase). \p Loc is the debug location and \p
/// CodeRegion is the region that the optimization operates on. The front-end
/// will append its own message related to options that address pointer
/// aliasing legality.
OptimizationRemarkAnalysisAliasing(const char *PassName, StringRef RemarkName,
const DiagnosticLocation &Loc,
const Value *CodeRegion)
const BasicBlock *CodeRegion)
: OptimizationRemarkAnalysis(DK_OptimizationRemarkAnalysisAliasing,
PassName, RemarkName, Loc, CodeRegion) {}

Expand Down Expand Up @@ -1044,12 +1041,11 @@ class DiagnosticInfoOptimizationFailure : public DiagnosticInfoIROptimization {

/// \p PassName is the name of the pass emitting this diagnostic. \p
/// RemarkName is a textual identifier for the remark (single-word,
/// camel-case). \p Loc is the debug location and \p CodeRegion is the
/// region that the optimization operates on (currently basic block is
/// supported).
/// CamelCase). \p Loc is the debug location and \p CodeRegion is the
/// region that the optimization operates on.
DiagnosticInfoOptimizationFailure(const char *PassName, StringRef RemarkName,
const DiagnosticLocation &Loc,
const Value *CodeRegion);
const BasicBlock *CodeRegion);

static bool classof(const DiagnosticInfo *DI) {
return DI->getKind() == DK_OptimizationFailure;
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Analysis/LoopAccessAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2746,7 +2746,7 @@ OptimizationRemarkAnalysis &
LoopAccessInfo::recordAnalysis(StringRef RemarkName, const Instruction *I) {
assert(!Report && "Multiple reports generated");

const Value *CodeRegion = TheLoop->getHeader();
const BasicBlock *CodeRegion = TheLoop->getHeader();
DebugLoc DL = TheLoop->getStartLoc();

if (I) {
Expand All @@ -2757,8 +2757,8 @@ LoopAccessInfo::recordAnalysis(StringRef RemarkName, const Instruction *I) {
DL = I->getDebugLoc();
}

Report = std::make_unique<OptimizationRemarkAnalysis>(DEBUG_TYPE, RemarkName, DL,
CodeRegion);
Report = std::make_unique<OptimizationRemarkAnalysis>(DEBUG_TYPE, RemarkName,
DL, CodeRegion);
return *Report;
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/HardwareLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static void debugHWLoopFailure(const StringRef DebugMsg,

static OptimizationRemarkAnalysis
createHWLoopAnalysis(StringRef RemarkName, Loop *L, Instruction *I) {
Value *CodeRegion = L->getHeader();
BasicBlock *CodeRegion = L->getHeader();
DebugLoc DL = L->getStartLoc();

if (I) {
Expand Down
37 changes: 18 additions & 19 deletions llvm/lib/IR/DiagnosticInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ void DiagnosticInfoOptimizationBase::print(DiagnosticPrinter &DP) const {
OptimizationRemark::OptimizationRemark(const char *PassName,
StringRef RemarkName,
const DiagnosticLocation &Loc,
const Value *CodeRegion)
: DiagnosticInfoIROptimization(
DK_OptimizationRemark, DS_Remark, PassName, RemarkName,
*cast<BasicBlock>(CodeRegion)->getParent(), Loc, CodeRegion) {}
const BasicBlock *CodeRegion)
: DiagnosticInfoIROptimization(DK_OptimizationRemark, DS_Remark, PassName,
RemarkName, *CodeRegion->getParent(), Loc,
CodeRegion) {}

OptimizationRemark::OptimizationRemark(const char *PassName,
StringRef RemarkName,
Expand Down Expand Up @@ -315,10 +315,10 @@ bool OptimizationRemark::isEnabled() const {

OptimizationRemarkMissed::OptimizationRemarkMissed(
const char *PassName, StringRef RemarkName, const DiagnosticLocation &Loc,
const Value *CodeRegion)
: DiagnosticInfoIROptimization(
DK_OptimizationRemarkMissed, DS_Remark, PassName, RemarkName,
*cast<BasicBlock>(CodeRegion)->getParent(), Loc, CodeRegion) {}
const BasicBlock *CodeRegion)
: DiagnosticInfoIROptimization(DK_OptimizationRemarkMissed, DS_Remark,
PassName, RemarkName,
*CodeRegion->getParent(), Loc, CodeRegion) {}

OptimizationRemarkMissed::OptimizationRemarkMissed(const char *PassName,
StringRef RemarkName,
Expand All @@ -343,10 +343,10 @@ bool OptimizationRemarkMissed::isEnabled() const {

OptimizationRemarkAnalysis::OptimizationRemarkAnalysis(
const char *PassName, StringRef RemarkName, const DiagnosticLocation &Loc,
const Value *CodeRegion)
: DiagnosticInfoIROptimization(
DK_OptimizationRemarkAnalysis, DS_Remark, PassName, RemarkName,
*cast<BasicBlock>(CodeRegion)->getParent(), Loc, CodeRegion) {}
const BasicBlock *CodeRegion)
: DiagnosticInfoIROptimization(DK_OptimizationRemarkAnalysis, DS_Remark,
PassName, RemarkName,
*CodeRegion->getParent(), Loc, CodeRegion) {}

OptimizationRemarkAnalysis::OptimizationRemarkAnalysis(const char *PassName,
StringRef RemarkName,
Expand All @@ -358,10 +358,9 @@ OptimizationRemarkAnalysis::OptimizationRemarkAnalysis(const char *PassName,

OptimizationRemarkAnalysis::OptimizationRemarkAnalysis(
enum DiagnosticKind Kind, const char *PassName, StringRef RemarkName,
const DiagnosticLocation &Loc, const Value *CodeRegion)
const DiagnosticLocation &Loc, const BasicBlock *CodeRegion)
: DiagnosticInfoIROptimization(Kind, DS_Remark, PassName, RemarkName,
*cast<BasicBlock>(CodeRegion)->getParent(),
Loc, CodeRegion) {}
*CodeRegion->getParent(), Loc, CodeRegion) {}

OptimizationRemarkAnalysis::OptimizationRemarkAnalysis(const char *PassName,
StringRef RemarkName,
Expand All @@ -387,10 +386,10 @@ void DiagnosticInfoSrcMgr::print(DiagnosticPrinter &DP) const {

DiagnosticInfoOptimizationFailure::DiagnosticInfoOptimizationFailure(
const char *PassName, StringRef RemarkName, const DiagnosticLocation &Loc,
const Value *CodeRegion)
: DiagnosticInfoIROptimization(
DK_OptimizationFailure, DS_Warning, PassName, RemarkName,
*cast<BasicBlock>(CodeRegion)->getParent(), Loc, CodeRegion) {}
const BasicBlock *CodeRegion)
: DiagnosticInfoIROptimization(DK_OptimizationFailure, DS_Warning, PassName,
RemarkName, *CodeRegion->getParent(), Loc,
CodeRegion) {}

bool DiagnosticInfoOptimizationFailure::isEnabled() const {
// Only print warnings.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ static void debugVectorizationMessage(const StringRef Prefix,
static OptimizationRemarkAnalysis
createLVAnalysis(const char *PassName, StringRef RemarkName, Loop *TheLoop,
Instruction *I, DebugLoc DL = {}) {
Value *CodeRegion = I ? I->getParent() : TheLoop->getHeader();
BasicBlock *CodeRegion = I ? I->getParent() : TheLoop->getHeader();
// If debug location is attached to the instruction, use it. Otherwise if DL
// was not provided, use the loop's.
if (I && I->getDebugLoc())
Expand Down
Loading