forked from OSchip/llvm-project
[LV] Convert emitRemark to new opt remark streaming interface
Also renamed the function to emitRemarkWithHints to better reflect what the function actually does. llvm-svn: 282723
This commit is contained in:
parent
32ea7504ef
commit
9a1a5ef212
|
@ -389,6 +389,8 @@ public:
|
||||||
explicit Argument(StringRef Str = "") : Key("String"), Val(Str) {}
|
explicit Argument(StringRef Str = "") : Key("String"), Val(Str) {}
|
||||||
Argument(StringRef Key, Value *V) : Key(Key), Val(V->getName()) {}
|
Argument(StringRef Key, Value *V) : Key(Key), Val(V->getName()) {}
|
||||||
Argument(StringRef Key, int N);
|
Argument(StringRef Key, int N);
|
||||||
|
Argument(StringRef Key, unsigned N);
|
||||||
|
Argument(StringRef Key, bool B) : Key(Key), Val(B ? "true" : "false") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \p PassName is the name of the pass emitting this diagnostic. \p
|
/// \p PassName is the name of the pass emitting this diagnostic. \p
|
||||||
|
@ -571,7 +573,13 @@ public:
|
||||||
/// \p PassName is the name of the pass emitting this diagnostic. If this name
|
/// \p PassName is the name of the pass emitting this diagnostic. If this name
|
||||||
/// matches the regular expression given in -Rpass-analysis=, then the
|
/// matches the regular expression given in -Rpass-analysis=, then the
|
||||||
/// diagnostic will be emitted. \p RemarkName is a textual identifier for the
|
/// diagnostic will be emitted. \p RemarkName is a textual identifier for the
|
||||||
/// remark. \p Inst is the instruction that the optimization operates on.
|
/// remark. \p DLoc is the debug location and \p CodeRegion is the region
|
||||||
|
/// that the optimization operates on (currently on block is supported).
|
||||||
|
OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
|
||||||
|
const DebugLoc &DLoc, Value *CodeRegion);
|
||||||
|
|
||||||
|
/// \brief Same as above but \p Inst is used to derive code region and debug
|
||||||
|
/// location.
|
||||||
OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
|
OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
|
||||||
Instruction *Inst);
|
Instruction *Inst);
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,9 @@ const std::string DiagnosticInfoWithDebugLocBase::getLocationStr() const {
|
||||||
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, int N)
|
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, int N)
|
||||||
: Key(Key), Val(itostr(N)) {}
|
: Key(Key), Val(itostr(N)) {}
|
||||||
|
|
||||||
|
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, unsigned N)
|
||||||
|
: Key(Key), Val(utostr(N)) {}
|
||||||
|
|
||||||
void DiagnosticInfoOptimizationBase::print(DiagnosticPrinter &DP) const {
|
void DiagnosticInfoOptimizationBase::print(DiagnosticPrinter &DP) const {
|
||||||
DP << getLocationStr() << ": " << getMsg();
|
DP << getLocationStr() << ": " << getMsg();
|
||||||
if (Hotness)
|
if (Hotness)
|
||||||
|
@ -213,6 +216,14 @@ bool OptimizationRemarkMissed::isEnabled() const {
|
||||||
PassRemarksMissedOptLoc.Pattern->match(getPassName());
|
PassRemarksMissedOptLoc.Pattern->match(getPassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OptimizationRemarkAnalysis::OptimizationRemarkAnalysis(const char *PassName,
|
||||||
|
StringRef RemarkName,
|
||||||
|
const DebugLoc &DLoc,
|
||||||
|
Value *CodeRegion)
|
||||||
|
: DiagnosticInfoOptimizationBase(
|
||||||
|
DK_OptimizationRemarkAnalysis, DS_Remark, PassName, RemarkName,
|
||||||
|
*cast<BasicBlock>(CodeRegion)->getParent(), DLoc, CodeRegion) {}
|
||||||
|
|
||||||
OptimizationRemarkAnalysis::OptimizationRemarkAnalysis(const char *PassName,
|
OptimizationRemarkAnalysis::OptimizationRemarkAnalysis(const char *PassName,
|
||||||
StringRef RemarkName,
|
StringRef RemarkName,
|
||||||
Instruction *Inst)
|
Instruction *Inst)
|
||||||
|
|
|
@ -1235,15 +1235,13 @@ public:
|
||||||
bool allowVectorization(Function *F, Loop *L, bool AlwaysVectorize) const {
|
bool allowVectorization(Function *F, Loop *L, bool AlwaysVectorize) const {
|
||||||
if (getForce() == LoopVectorizeHints::FK_Disabled) {
|
if (getForce() == LoopVectorizeHints::FK_Disabled) {
|
||||||
DEBUG(dbgs() << "LV: Not vectorizing: #pragma vectorize disable.\n");
|
DEBUG(dbgs() << "LV: Not vectorizing: #pragma vectorize disable.\n");
|
||||||
ORE.emitOptimizationRemarkAnalysis(vectorizeAnalysisPassName(), L,
|
emitRemarkWithHints();
|
||||||
emitRemark());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AlwaysVectorize && getForce() != LoopVectorizeHints::FK_Enabled) {
|
if (!AlwaysVectorize && getForce() != LoopVectorizeHints::FK_Enabled) {
|
||||||
DEBUG(dbgs() << "LV: Not vectorizing: No #pragma vectorize enable.\n");
|
DEBUG(dbgs() << "LV: Not vectorizing: No #pragma vectorize enable.\n");
|
||||||
ORE.emitOptimizationRemarkAnalysis(vectorizeAnalysisPassName(), L,
|
emitRemarkWithHints();
|
||||||
emitRemark());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1266,23 +1264,28 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dumps all the hint information.
|
/// Dumps all the hint information.
|
||||||
std::string emitRemark() const {
|
void emitRemarkWithHints() const {
|
||||||
VectorizationReport R;
|
using namespace ore;
|
||||||
if (Force.Value == LoopVectorizeHints::FK_Disabled)
|
if (Force.Value == LoopVectorizeHints::FK_Disabled)
|
||||||
R << "vectorization is explicitly disabled";
|
ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedExplicitlyDisabled",
|
||||||
|
TheLoop->getStartLoc(),
|
||||||
|
TheLoop->getHeader())
|
||||||
|
<< "loop not vectorized: vectorization is explicitly disabled");
|
||||||
else {
|
else {
|
||||||
R << "use -Rpass-analysis=loop-vectorize for more info";
|
OptimizationRemarkMissed R(LV_NAME, "MissedDetails",
|
||||||
|
TheLoop->getStartLoc(), TheLoop->getHeader());
|
||||||
|
R << "loop not vectorized: use -Rpass-analysis=loop-vectorize for more "
|
||||||
|
"info";
|
||||||
if (Force.Value == LoopVectorizeHints::FK_Enabled) {
|
if (Force.Value == LoopVectorizeHints::FK_Enabled) {
|
||||||
R << " (Force=true";
|
R << " (Force=" << NV("Force", true);
|
||||||
if (Width.Value != 0)
|
if (Width.Value != 0)
|
||||||
R << ", Vector Width=" << Width.Value;
|
R << ", Vector Width=" << NV("VectorWidth", Width.Value);
|
||||||
if (Interleave.Value != 0)
|
if (Interleave.Value != 0)
|
||||||
R << ", Interleave Count=" << Interleave.Value;
|
R << ", Interleave Count=" << NV("InterleaveCount", Interleave.Value);
|
||||||
R << ")";
|
R << ")";
|
||||||
}
|
}
|
||||||
|
ORE.emit(R);
|
||||||
}
|
}
|
||||||
|
|
||||||
return R.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned getWidth() const { return Width.Value; }
|
unsigned getWidth() const { return Width.Value; }
|
||||||
|
@ -1452,7 +1455,7 @@ static void emitAnalysisDiag(const Loop *TheLoop,
|
||||||
static void emitMissedWarning(Function *F, Loop *L,
|
static void emitMissedWarning(Function *F, Loop *L,
|
||||||
const LoopVectorizeHints &LH,
|
const LoopVectorizeHints &LH,
|
||||||
OptimizationRemarkEmitter *ORE) {
|
OptimizationRemarkEmitter *ORE) {
|
||||||
ORE->emitOptimizationRemarkMissed(LV_NAME, L, LH.emitRemark());
|
LH.emitRemarkWithHints();
|
||||||
|
|
||||||
if (LH.getForce() == LoopVectorizeHints::FK_Enabled) {
|
if (LH.getForce() == LoopVectorizeHints::FK_Enabled) {
|
||||||
if (LH.getWidth() != 1)
|
if (LH.getWidth() != 1)
|
||||||
|
|
Loading…
Reference in New Issue