[llvm] r295812 - OptDiag: Add const to some interfaces that don't modify anything. NFC
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 21 23:38:18 PST 2017
Author: bogner
Date: Wed Feb 22 01:38:17 2017
New Revision: 295812
URL: http://llvm.org/viewvc/llvm-project?rev=295812&view=rev
Log:
OptDiag: Add const to some interfaces that don't modify anything. NFC
This needed a const_cast for the dominator tree recalculation in
OptimizationRemarkEmitter, but we do that all over the place already
and it's safe.
Modified:
llvm/trunk/include/llvm/Analysis/OptimizationDiagnosticInfo.h
llvm/trunk/include/llvm/IR/DiagnosticInfo.h
llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp
llvm/trunk/lib/IR/DiagnosticInfo.cpp
Modified: llvm/trunk/include/llvm/Analysis/OptimizationDiagnosticInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/OptimizationDiagnosticInfo.h?rev=295812&r1=295811&r2=295812&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/OptimizationDiagnosticInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/OptimizationDiagnosticInfo.h Wed Feb 22 01:38:17 2017
@@ -38,7 +38,7 @@ class Value;
/// enabled in the LLVM context.
class OptimizationRemarkEmitter {
public:
- OptimizationRemarkEmitter(Function *F, BlockFrequencyInfo *BFI)
+ OptimizationRemarkEmitter(const Function *F, BlockFrequencyInfo *BFI)
: F(F), BFI(BFI) {}
/// \brief This variant can be used to generate ORE on demand (without the
@@ -52,7 +52,7 @@ public:
/// 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.
- OptimizationRemarkEmitter(Function *F);
+ OptimizationRemarkEmitter(const Function *F);
OptimizationRemarkEmitter(OptimizationRemarkEmitter &&Arg)
: F(Arg.F), BFI(Arg.BFI) {}
@@ -216,7 +216,7 @@ public:
}
private:
- Function *F;
+ const Function *F;
BlockFrequencyInfo *BFI;
Modified: llvm/trunk/include/llvm/IR/DiagnosticInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DiagnosticInfo.h?rev=295812&r1=295811&r2=295812&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DiagnosticInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DiagnosticInfo.h Wed Feb 22 01:38:17 2017
@@ -526,7 +526,7 @@ public:
const char *PassName, StringRef RemarkName,
const Function &Fn,
const DiagnosticLocation &Loc,
- Value *CodeRegion = nullptr)
+ const Value *CodeRegion = nullptr)
: DiagnosticInfoOptimizationBase(Kind, Severity, PassName, RemarkName, Fn,
Loc),
CodeRegion(CodeRegion) {}
@@ -566,7 +566,7 @@ public:
*this << Msg.str();
}
- Value *getCodeRegion() const { return CodeRegion; }
+ const Value *getCodeRegion() const { return CodeRegion; }
static bool classof(const DiagnosticInfo *DI) {
return DI->getKind() >= DK_FirstRemark && DI->getKind() <= DK_LastRemark;
@@ -575,7 +575,7 @@ public:
private:
/// The IR value (currently basic block) that the optimization operates on.
/// This is currently used to provide run-time hotness information with PGO.
- Value *CodeRegion;
+ const Value *CodeRegion;
};
/// Diagnostic information for applied optimization remarks.
@@ -601,7 +601,7 @@ public:
/// Loc is the debug location and \p CodeRegion is the region that the
/// optimization operates on (currently on block is supported).
OptimizationRemark(const char *PassName, StringRef RemarkName,
- const DiagnosticLocation &Loc, Value *CodeRegion);
+ const DiagnosticLocation &Loc, const Value *CodeRegion);
/// Same as above but the debug location and code region is derived from \p
/// Instr.
Modified: llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp?rev=295812&r1=295811&r2=295812&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp Wed Feb 22 01:38:17 2017
@@ -23,14 +23,14 @@
using namespace llvm;
-OptimizationRemarkEmitter::OptimizationRemarkEmitter(Function *F)
+OptimizationRemarkEmitter::OptimizationRemarkEmitter(const Function *F)
: F(F), BFI(nullptr) {
if (!F->getContext().getDiagnosticHotnessRequested())
return;
// First create a dominator tree.
DominatorTree DT;
- DT.recalculate(*F);
+ DT.recalculate(*const_cast<Function *>(F));
// Generate LoopInfo from it.
LoopInfo LI;
@@ -146,7 +146,7 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(DiagnosticI
void OptimizationRemarkEmitter::computeHotness(
DiagnosticInfoIROptimization &OptDiag) {
- Value *V = OptDiag.getCodeRegion();
+ const Value *V = OptDiag.getCodeRegion();
if (V)
OptDiag.setHotness(computeHotness(V));
}
Modified: llvm/trunk/lib/IR/DiagnosticInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DiagnosticInfo.cpp?rev=295812&r1=295811&r2=295812&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DiagnosticInfo.cpp (original)
+++ llvm/trunk/lib/IR/DiagnosticInfo.cpp Wed Feb 22 01:38:17 2017
@@ -222,7 +222,7 @@ void DiagnosticInfoOptimizationBase::pri
OptimizationRemark::OptimizationRemark(const char *PassName,
StringRef RemarkName,
const DiagnosticLocation &Loc,
- Value *CodeRegion)
+ const Value *CodeRegion)
: DiagnosticInfoIROptimization(
DK_OptimizationRemark, DS_Remark, PassName, RemarkName,
*cast<BasicBlock>(CodeRegion)->getParent(), Loc, CodeRegion) {}
More information about the llvm-commits
mailing list