[llvm] [NFC] Add `const` (PR #116611)
Piotr Fusik via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 05:28:19 PST 2024
https://github.com/pfusik created https://github.com/llvm/llvm-project/pull/116611
None
>From 6dfc795d2b3263378d2367dbea9a0b8d5f8b3a1a Mon Sep 17 00:00:00 2001
From: Piotr Fusik <p.fusik at samsung.com>
Date: Mon, 18 Nov 2024 14:26:21 +0100
Subject: [PATCH] [NFC] Add `const`
---
llvm/include/llvm/CodeGen/LiveInterval.h | 2 +-
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp | 2 +-
.../Transforms/Vectorize/LoopVectorize.cpp | 55 ++++++++++---------
3 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/LiveInterval.h b/llvm/include/llvm/CodeGen/LiveInterval.h
index 236a439b80a24c..1339316b666277 100644
--- a/llvm/include/llvm/CodeGen/LiveInterval.h
+++ b/llvm/include/llvm/CodeGen/LiveInterval.h
@@ -67,7 +67,7 @@ namespace llvm {
VNInfo(unsigned i, const VNInfo &orig) : id(i), def(orig.def) {}
/// Copy from the parameter into this VNInfo.
- void copyFrom(VNInfo &src) {
+ void copyFrom(const VNInfo &src) {
def = src.def;
}
diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index 052b4a61298223..496334301404a4 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -228,7 +228,7 @@ struct DemandedFields {
}
// Return true if any property of VL was used
- bool usedVL() {
+ bool usedVL() const {
return VLAny || VLZeroness;
}
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 1d9e4f5a19f5ce..ca89d767667715 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -581,7 +581,7 @@ class InnerLoopVectorizer {
virtual void printDebugTracesAtEnd() {}
/// The original loop.
- Loop *OrigLoop;
+ Loop *const OrigLoop;
/// A wrapper around ScalarEvolution used to add runtime SCEV checks. Applies
/// dynamic knowledge to simplify SCEV expressions and converts them to a
@@ -589,22 +589,22 @@ class InnerLoopVectorizer {
PredicatedScalarEvolution &PSE;
/// Loop Info.
- LoopInfo *LI;
+ LoopInfo *const LI;
/// Dominator Tree.
- DominatorTree *DT;
+ DominatorTree *const DT;
/// Target Library Info.
- const TargetLibraryInfo *TLI;
+ const TargetLibraryInfo *const TLI;
/// Target Transform Info.
- const TargetTransformInfo *TTI;
+ const TargetTransformInfo *const TTI;
/// Assumption Cache.
- AssumptionCache *AC;
+ AssumptionCache *const AC;
/// Interface to emit optimization remarks.
- OptimizationRemarkEmitter *ORE;
+ OptimizationRemarkEmitter *const ORE;
/// The vectorization SIMD factor to use. Each vector will have this many
/// vector elements.
@@ -801,7 +801,7 @@ class EpilogueVectorizerEpilogueLoop : public InnerLoopAndEpilogueVectorizer {
} // end namespace llvm
/// Look for a meaningful debug location on the instruction or its operands.
-static DebugLoc getDebugLocFromInstOrOperands(Instruction *I) {
+static DebugLoc getDebugLocFromInstOrOperands(const Instruction *I) {
if (!I)
return DebugLoc();
@@ -809,8 +809,8 @@ static DebugLoc getDebugLocFromInstOrOperands(Instruction *I) {
if (I->getDebugLoc() != Empty)
return I->getDebugLoc();
- for (Use &Op : I->operands()) {
- if (Instruction *OpInst = dyn_cast<Instruction>(Op))
+ for (const Use &Op : I->operands()) {
+ if (const Instruction *OpInst = dyn_cast<Instruction>(Op))
if (OpInst->getDebugLoc() != Empty)
return OpInst->getDebugLoc();
}
@@ -823,7 +823,7 @@ static DebugLoc getDebugLocFromInstOrOperands(Instruction *I) {
#ifndef NDEBUG
static void debugVectorizationMessage(const StringRef Prefix,
const StringRef DebugMsg,
- Instruction *I) {
+ const Instruction *I) {
dbgs() << "LV: " << Prefix << DebugMsg;
if (I != nullptr)
dbgs() << " " << *I;
@@ -841,9 +841,9 @@ static void debugVectorizationMessage(const StringRef Prefix,
/// the location of the remark. If \p DL is passed, use it as debug location for
/// the remark. \return the remark object that can be streamed to.
static OptimizationRemarkAnalysis
-createLVAnalysis(const char *PassName, StringRef RemarkName, Loop *TheLoop,
- Instruction *I, DebugLoc DL = {}) {
- Value *CodeRegion = I ? I->getParent() : TheLoop->getHeader();
+createLVAnalysis(const char *PassName, StringRef RemarkName,
+ const Loop *TheLoop, const Instruction *I, DebugLoc DL = {}) {
+ const Value *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())
@@ -885,7 +885,8 @@ void reportVectorizationFailure(const StringRef DebugMsg,
/// remark. If \p DL is passed, use it as debug location for the remark.
static void reportVectorizationInfo(const StringRef Msg, const StringRef ORETag,
OptimizationRemarkEmitter *ORE,
- Loop *TheLoop, Instruction *I = nullptr,
+ Loop *TheLoop,
+ const Instruction *I = nullptr,
DebugLoc DL = {}) {
LLVM_DEBUG(debugVectorizationMessage("", Msg, I));
LoopVectorizeHints Hints(TheLoop, true /* doesn't matter */, *ORE);
@@ -1726,36 +1727,36 @@ class LoopVectorizationCostModel {
public:
/// The loop that we evaluate.
- Loop *TheLoop;
+ Loop *const TheLoop;
/// Predicated scalar evolution analysis.
PredicatedScalarEvolution &PSE;
/// Loop Info analysis.
- LoopInfo *LI;
+ LoopInfo *const LI;
/// Vectorization legality.
- LoopVectorizationLegality *Legal;
+ LoopVectorizationLegality *const Legal;
/// Vector target information.
const TargetTransformInfo &TTI;
/// Target Library Info.
- const TargetLibraryInfo *TLI;
+ const TargetLibraryInfo *const TLI;
/// Demanded bits analysis.
- DemandedBits *DB;
+ DemandedBits *const DB;
/// Assumption cache.
- AssumptionCache *AC;
+ AssumptionCache *const AC;
/// Interface to emit optimization remarks.
- OptimizationRemarkEmitter *ORE;
+ OptimizationRemarkEmitter *const ORE;
- const Function *TheFunction;
+ const Function *const TheFunction;
/// Loop Vectorize Hint.
- const LoopVectorizeHints *Hints;
+ const LoopVectorizeHints *const Hints;
/// The interleave access information contains groups of interleaved accesses
/// with the same stride and close to each other.
@@ -1795,9 +1796,9 @@ class GeneratedRTChecks {
/// they have been used.
Value *MemRuntimeCheckCond = nullptr;
- DominatorTree *DT;
- LoopInfo *LI;
- TargetTransformInfo *TTI;
+ DominatorTree *const DT;
+ LoopInfo *const LI;
+ TargetTransformInfo *const TTI;
SCEVExpander SCEVExp;
SCEVExpander MemCheckExp;
More information about the llvm-commits
mailing list