1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

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.

llvm-svn: 295812
This commit is contained in:
Justin Bogner 2017-02-22 07:38:17 +00:00
parent a1d1885fcc
commit dbcb2141ed
4 changed files with 11 additions and 11 deletions

View File

@ -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;

View File

@ -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.

View File

@ -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(DiagnosticInfoOptimizationBase::Argument)
void OptimizationRemarkEmitter::computeHotness(
DiagnosticInfoIROptimization &OptDiag) {
Value *V = OptDiag.getCodeRegion();
const Value *V = OptDiag.getCodeRegion();
if (V)
OptDiag.setHotness(computeHotness(V));
}

View File

@ -222,7 +222,7 @@ void DiagnosticInfoOptimizationBase::print(DiagnosticPrinter &DP) const {
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) {}