Skip to content

Commit

Permalink
[ORE] Unify spelling as "diagnostics hotness"
Browse files Browse the repository at this point in the history
Summary:
To enable profile hotness information in diagnostics output, Clang takes
the option `-fdiagnostics-show-hotness` -- that's "diagnostics", with an
"s" at the end. Clang also defines `CodeGenOptions::DiagnosticsWithHotness`.

LLVM, on the other hand, defines
`LLVMContext::getDiagnosticHotnessRequested` -- that's "diagnostic", not
"diagnostics". It's a small difference, but it's confusing, typo-inducing, and
frustrating.

Add a new method with the spelling "diagnostics", and "deprecate" the
old spelling.

Reviewers: anemet, davidxl

Reviewed By: anemet

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D34864

llvm-svn: 306848
  • Loading branch information
modocache committed Jun 30, 2017
1 parent 724990a commit 44e5f6c
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 16 deletions.
6 changes: 3 additions & 3 deletions llvm/include/llvm/Analysis/OptimizationDiagnosticInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Value;
///
/// It allows reporting when optimizations are performed and when they are not
/// along with the reasons for it. Hotness information of the corresponding
/// code region can be included in the remark if DiagnosticHotnessRequested is
/// code region can be included in the remark if DiagnosticsHotnessRequested is
/// enabled in the LLVM context.
class OptimizationRemarkEmitter {
public:
Expand All @@ -45,10 +45,10 @@ class OptimizationRemarkEmitter {
/// analysis pass).
///
/// Note that this ctor has a very different cost depending on whether
/// F->getContext().getDiagnosticHotnessRequested() is on or not. If it's off
/// F->getContext().getDiagnosticsHotnessRequested() is on or not. If it's off
/// the operation is free.
///
/// Whereas if DiagnosticHotnessRequested is on, it is fairly expensive
/// Whereas if DiagnosticsHotnessRequested is on, it is fairly expensive
/// operation since BFI and all its required analyses are computed. This is
/// for example useful for CGSCC passes that can't use function analyses
/// passes in the old PM.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ using MNV = DiagnosticInfoMIROptimization::MachineArgument;
///
/// It allows reporting when optimizations are performed and when they are not
/// along with the reasons for it. Hotness information of the corresponding
/// code region can be included in the remark if DiagnosticHotnessRequested is
/// code region can be included in the remark if DiagnosticsHotnessRequested is
/// enabled in the LLVM context.
class MachineOptimizationRemarkEmitter {
public:
Expand Down
13 changes: 11 additions & 2 deletions llvm/include/llvm/IR/LLVMContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,21 @@ class LLVMContext {
void *getDiagnosticContext() const;

/// \brief Return if a code hotness metric should be included in optimization
/// diagnostics.
/// diagnostics. This method is deprecated; use getDiagnosticsHotnessRequested
/// instead.
bool getDiagnosticHotnessRequested() const;
/// \brief Set if a code hotness metric should be included in optimization
/// diagnostics.
/// diagnostics. This method is deprecated; use setDiagnosticsHotnessRequested
/// instead.
void setDiagnosticHotnessRequested(bool Requested);

/// \brief Return if a code hotness metric should be included in optimization
/// diagnostics.
bool getDiagnosticsHotnessRequested() const;
/// \brief Set if a code hotness metric should be included in optimization
/// diagnostics.
void setDiagnosticsHotnessRequested(bool Requested);

/// \brief Return the YAML file used by the backend to save optimization
/// diagnostics. If null, diagnostics are not saved in a file but only
/// emitted via the diagnostic handler.
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using namespace llvm;

OptimizationRemarkEmitter::OptimizationRemarkEmitter(const Function *F)
: F(F), BFI(nullptr) {
if (!F->getContext().getDiagnosticHotnessRequested())
if (!F->getContext().getDiagnosticsHotnessRequested())
return;

// First create a dominator tree.
Expand Down Expand Up @@ -176,7 +176,7 @@ OptimizationRemarkEmitterWrapperPass::OptimizationRemarkEmitterWrapperPass()
bool OptimizationRemarkEmitterWrapperPass::runOnFunction(Function &Fn) {
BlockFrequencyInfo *BFI;

if (Fn.getContext().getDiagnosticHotnessRequested())
if (Fn.getContext().getDiagnosticsHotnessRequested())
BFI = &getAnalysis<LazyBlockFrequencyInfoPass>().getBFI();
else
BFI = nullptr;
Expand All @@ -198,7 +198,7 @@ OptimizationRemarkEmitterAnalysis::run(Function &F,
FunctionAnalysisManager &AM) {
BlockFrequencyInfo *BFI;

if (F.getContext().getDiagnosticHotnessRequested())
if (F.getContext().getDiagnosticsHotnessRequested())
BFI = &AM.getResult<BlockFrequencyAnalysis>(F);
else
BFI = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool MachineOptimizationRemarkEmitterPass::runOnMachineFunction(
MachineFunction &MF) {
MachineBlockFrequencyInfo *MBFI;

if (MF.getFunction()->getContext().getDiagnosticHotnessRequested())
if (MF.getFunction()->getContext().getDiagnosticsHotnessRequested())
MBFI = &getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI();
else
MBFI = nullptr;
Expand Down
11 changes: 9 additions & 2 deletions llvm/lib/IR/LLVMContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,17 @@ void LLVMContext::setDiagnosticHandler(DiagnosticHandlerTy DiagnosticHandler,
}

void LLVMContext::setDiagnosticHotnessRequested(bool Requested) {
pImpl->DiagnosticHotnessRequested = Requested;
pImpl->DiagnosticsHotnessRequested = Requested;
}
bool LLVMContext::getDiagnosticHotnessRequested() const {
return pImpl->DiagnosticHotnessRequested;
return pImpl->DiagnosticsHotnessRequested;
}

void LLVMContext::setDiagnosticsHotnessRequested(bool Requested) {
pImpl->DiagnosticsHotnessRequested = Requested;
}
bool LLVMContext::getDiagnosticsHotnessRequested() const {
return pImpl->DiagnosticsHotnessRequested;
}

yaml::Output *LLVMContext::getDiagnosticsOutputFile() {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/LLVMContextImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ class LLVMContextImpl {
LLVMContext::DiagnosticHandlerTy DiagnosticHandler = nullptr;
void *DiagnosticContext = nullptr;
bool RespectDiagnosticFilters = false;
bool DiagnosticHotnessRequested = false;
bool DiagnosticsHotnessRequested = false;
std::unique_ptr<yaml::Output> DiagnosticsOutputFile;

LLVMContext::YieldCallbackTy YieldCallback = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/LTO/LTO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ lto::setupOptimizationRemarks(LLVMContext &Context,
Context.setDiagnosticsOutputFile(
llvm::make_unique<yaml::Output>(DiagnosticFile->os()));
if (LTOPassRemarksWithHotness)
Context.setDiagnosticHotnessRequested(true);
Context.setDiagnosticsHotnessRequested(true);
DiagnosticFile->keep();
return std::move(DiagnosticFile);
}
2 changes: 1 addition & 1 deletion llvm/tools/llc/llc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ int main(int argc, char **argv) {
Context.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, &HasError);

if (PassRemarksWithHotness)
Context.setDiagnosticHotnessRequested(true);
Context.setDiagnosticsHotnessRequested(true);

std::unique_ptr<tool_output_file> YamlFile;
if (RemarksFilename != "") {
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/opt/opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ int main(int argc, char **argv) {
Context.enableDebugTypeODRUniquing();

if (PassRemarksWithHotness)
Context.setDiagnosticHotnessRequested(true);
Context.setDiagnosticsHotnessRequested(true);

std::unique_ptr<tool_output_file> YamlFile;
if (RemarksFilename != "") {
Expand Down

0 comments on commit 44e5f6c

Please sign in to comment.