[llvm] [TRANSFORMS][SUPPORT] Added const reference for params with size >= 16 bytes (PR #125085)
Herman Semenoff via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 08:21:52 PST 2025
https://github.com/GermanAizek created https://github.com/llvm/llvm-project/pull/125085
Reference: https://github.com/llvm/llvm-project/pull/125074
>From 97b4814d112af4739ab09c98db50e20461be418f Mon Sep 17 00:00:00 2001
From: Herman Semenov <GermanAizek at yandex.ru>
Date: Thu, 30 Jan 2025 16:21:25 +0300
Subject: [PATCH] [TRANSFORMS][SUPPORT] Added const reference for params with
size >= 16 bytes
---
llvm/include/llvm/Support/BinaryStreamWriter.h | 4 ++--
llvm/include/llvm/Support/Error.h | 2 +-
llvm/include/llvm/Transforms/Scalar/Float2Int.h | 2 +-
llvm/include/llvm/Transforms/Scalar/GVN.h | 2 +-
llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h | 2 +-
.../Vectorize/SandboxVectorizer/DependencyGraph.h | 2 +-
llvm/lib/Support/AMDGPUMetadata.cpp | 2 +-
llvm/lib/Support/BinaryStreamWriter.cpp | 4 ++--
llvm/lib/Support/Error.cpp | 2 +-
llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp | 2 +-
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | 8 ++++----
llvm/lib/Transforms/IPO/CalledValuePropagation.cpp | 2 +-
llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 4 ++--
llvm/lib/Transforms/IPO/FunctionImport.cpp | 2 +-
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp | 2 +-
llvm/lib/Transforms/Scalar/Float2Int.cpp | 2 +-
llvm/lib/Transforms/Scalar/GVN.cpp | 4 ++--
llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp | 2 +-
llvm/lib/Transforms/Utils/CodeLayout.cpp | 4 ++--
llvm/lib/Transforms/Utils/FunctionImportUtils.cpp | 2 +-
20 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/llvm/include/llvm/Support/BinaryStreamWriter.h b/llvm/include/llvm/Support/BinaryStreamWriter.h
index bc1d7949841d6f..41256b3a31f7b1 100644
--- a/llvm/include/llvm/Support/BinaryStreamWriter.h
+++ b/llvm/include/llvm/Support/BinaryStreamWriter.h
@@ -109,7 +109,7 @@ class BinaryStreamWriter {
///
/// \returns a success error code if the data was successfully written,
/// otherwise returns an appropriate error code.
- Error writeStreamRef(BinaryStreamRef Ref);
+ Error writeStreamRef(const BinaryStreamRef &Ref);
/// Efficiently reads \p Size bytes from \p Ref, and writes it to this stream.
/// This operation will not invoke any copies of the source data, regardless
@@ -117,7 +117,7 @@ class BinaryStreamWriter {
///
/// \returns a success error code if the data was successfully written,
/// otherwise returns an appropriate error code.
- Error writeStreamRef(BinaryStreamRef Ref, uint64_t Size);
+ Error writeStreamRef(const BinaryStreamRef &Ref, uint64_t Size);
/// Writes the object \p Obj to the underlying stream, as if by using memcpy.
/// It is up to the caller to ensure that type of \p Obj can be safely copied
diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h
index 90120156ec2ead..d3f6619d5e7c2c 100644
--- a/llvm/include/llvm/Support/Error.h
+++ b/llvm/include/llvm/Support/Error.h
@@ -1049,7 +1049,7 @@ Expected<T> handleExpected(Expected<T> ValOrErr, RecoveryFtor &&RecoveryPath,
/// This is useful in the base level of your program to allow clean termination
/// (allowing clean deallocation of resources, etc.), while reporting error
/// information to the user.
-void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner = {});
+void logAllUnhandledErrors(Error E, raw_ostream &OS, const Twine &ErrorBanner = {});
/// Write all error messages (if any) in E to a string. The newline character
/// is used to separate error messages.
diff --git a/llvm/include/llvm/Transforms/Scalar/Float2Int.h b/llvm/include/llvm/Transforms/Scalar/Float2Int.h
index 337e229efcf379..6d528cf6671b3b 100644
--- a/llvm/include/llvm/Transforms/Scalar/Float2Int.h
+++ b/llvm/include/llvm/Transforms/Scalar/Float2Int.h
@@ -40,7 +40,7 @@ class Float2IntPass : public PassInfoMixin<Float2IntPass> {
void seen(Instruction *I, ConstantRange R);
ConstantRange badRange();
ConstantRange unknownRange();
- ConstantRange validateRange(ConstantRange R);
+ ConstantRange validateRange(const ConstantRange &R);
std::optional<ConstantRange> calcRange(Instruction *I);
void walkBackwards();
void walkForwards();
diff --git a/llvm/include/llvm/Transforms/Scalar/GVN.h b/llvm/include/llvm/Transforms/Scalar/GVN.h
index c8be390799836e..7d98de57c3785c 100644
--- a/llvm/include/llvm/Transforms/Scalar/GVN.h
+++ b/llvm/include/llvm/Transforms/Scalar/GVN.h
@@ -337,7 +337,7 @@ class GVNPass : public PassInfoMixin<GVNPass> {
/// Given a local dependency (Def or Clobber) determine if a value is
/// available for the load.
std::optional<gvn::AvailableValue>
- AnalyzeLoadAvailability(LoadInst *Load, MemDepResult DepInfo, Value *Address);
+ AnalyzeLoadAvailability(LoadInst *Load, const MemDepResult &DepInfo, Value *Address);
/// Given a list of non-local dependencies, determine if a value is
/// available for the load in each specified block. If it is, add it to
diff --git a/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h b/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h
index 18cd923d5601d0..f3b040171ea7a7 100644
--- a/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h
@@ -62,7 +62,7 @@ class FunctionImportGlobalProcessing {
DenseMap<const Comdat *, Comdat *> RenamedComdats;
/// Check if we should promote the given local value to global scope.
- bool shouldPromoteLocalToGlobal(const GlobalValue *SGV, ValueInfo VI);
+ bool shouldPromoteLocalToGlobal(const GlobalValue *SGV, const ValueInfo &VI);
#ifndef NDEBUG
/// Check if the given value is a local that can't be renamed (promoted).
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
index 6e3f99d78b9329..f930d88131ce04 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
@@ -48,7 +48,7 @@ class DependencyGraph;
/// While OpIt points to a Value that is not an Instruction keep incrementing
/// it. \Returns the first iterator that points to an Instruction, or end.
[[nodiscard]] static User::op_iterator skipNonInstr(User::op_iterator OpIt,
- User::op_iterator OpItE) {
+ const User::op_iterator &OpItE) {
while (OpIt != OpItE && !isa<Instruction>((*OpIt).get()))
++OpIt;
return OpIt;
diff --git a/llvm/lib/Support/AMDGPUMetadata.cpp b/llvm/lib/Support/AMDGPUMetadata.cpp
index e24cbde38795b0..853eff0333e4a1 100644
--- a/llvm/lib/Support/AMDGPUMetadata.cpp
+++ b/llvm/lib/Support/AMDGPUMetadata.cpp
@@ -217,7 +217,7 @@ std::error_code fromString(StringRef String, Metadata &HSAMetadata) {
return YamlInput.error();
}
-std::error_code toString(Metadata HSAMetadata, std::string &String) {
+std::error_code toString(Metadata &HSAMetadata, std::string &String) {
raw_string_ostream YamlStream(String);
yaml::Output YamlOutput(YamlStream, nullptr, std::numeric_limits<int>::max());
YamlOutput << HSAMetadata;
diff --git a/llvm/lib/Support/BinaryStreamWriter.cpp b/llvm/lib/Support/BinaryStreamWriter.cpp
index dff08fee3fefaa..839acd2abbfb94 100644
--- a/llvm/lib/Support/BinaryStreamWriter.cpp
+++ b/llvm/lib/Support/BinaryStreamWriter.cpp
@@ -58,11 +58,11 @@ Error BinaryStreamWriter::writeFixedString(StringRef Str) {
return writeBytes(arrayRefFromStringRef(Str));
}
-Error BinaryStreamWriter::writeStreamRef(BinaryStreamRef Ref) {
+Error BinaryStreamWriter::writeStreamRef(const BinaryStreamRef &Ref) {
return writeStreamRef(Ref, Ref.getLength());
}
-Error BinaryStreamWriter::writeStreamRef(BinaryStreamRef Ref, uint64_t Length) {
+Error BinaryStreamWriter::writeStreamRef(const BinaryStreamRef &Ref, uint64_t Length) {
BinaryStreamReader SrcReader(Ref.slice(0, Length));
// This is a bit tricky. If we just call readBytes, we are requiring that it
// return us the entire stream as a contiguous buffer. There is no guarantee
diff --git a/llvm/lib/Support/Error.cpp b/llvm/lib/Support/Error.cpp
index baa3c322e9dae1..3f6c5d4c8b60b5 100644
--- a/llvm/lib/Support/Error.cpp
+++ b/llvm/lib/Support/Error.cpp
@@ -62,7 +62,7 @@ char ECError::ID = 0;
char StringError::ID = 0;
char FileError::ID = 0;
-void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner) {
+void logAllUnhandledErrors(Error E, raw_ostream &OS, const Twine &ErrorBanner) {
if (!E)
return;
OS << ErrorBanner;
diff --git a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
index 1782e242878606..86fb25aed677ea 100644
--- a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
+++ b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
@@ -83,7 +83,7 @@ MachineTypes getEmulation(StringRef S) {
.Default(IMAGE_FILE_MACHINE_UNKNOWN);
}
-MachineTypes getMachine(Triple T) {
+MachineTypes getMachine(const Triple &T) {
switch (T.getArch()) {
case Triple::x86:
return COFF::IMAGE_FILE_MACHINE_I386;
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 58b8f1f779f729..48ad3a27a91ca6 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -7536,7 +7536,7 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
/// Extract values from \p Base according to the type \p PrivType at the
/// call position \p ACS. The values are appended to \p ReplacementValues.
void createReplacementValues(Align Alignment, Type *PrivType,
- AbstractCallSite ACS, Value *Base,
+ const AbstractCallSite &ACS, Value *Base,
SmallVectorImpl<Value *> &ReplacementValues) {
assert(Base && "Expected base value!");
assert(PrivType && "Expected privatizable type!");
@@ -11156,7 +11156,7 @@ struct AAPotentialValuesFloating : AAPotentialValuesImpl {
return true;
}
- bool handleLoadInst(Attributor &A, LoadInst &LI, ItemInfo II,
+ bool handleLoadInst(Attributor &A, LoadInst &LI, const ItemInfo &II,
SmallVectorImpl<ItemInfo> &Worklist) {
SmallSetVector<Value *, 4> PotentialCopies;
SmallSetVector<Instruction *, 4> PotentialValueOrigins;
@@ -11280,7 +11280,7 @@ struct AAPotentialValuesFloating : AAPotentialValuesImpl {
/// Use the generic, non-optimistic InstSimplfy functionality if we managed to
/// simplify any operand of the instruction \p I. Return true if successful,
/// in that case Worklist will be updated.
- bool handleGenericInst(Attributor &A, Instruction &I, ItemInfo II,
+ bool handleGenericInst(Attributor &A, Instruction &I, const ItemInfo &II,
SmallVectorImpl<ItemInfo> &Worklist) {
bool SomeSimplified = false;
bool UsedAssumedInformation = false;
@@ -11330,7 +11330,7 @@ struct AAPotentialValuesFloating : AAPotentialValuesImpl {
}
bool simplifyInstruction(
- Attributor &A, Instruction &I, ItemInfo II,
+ Attributor &A, Instruction &I, const ItemInfo &II,
SmallVectorImpl<ItemInfo> &Worklist,
SmallMapVector<const Function *, LivenessInfo, 4> &LivenessAAs) {
if (auto *CI = dyn_cast<CmpInst>(&I))
diff --git a/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp b/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp
index 66ae0706d638c2..0cd51c522bd071 100644
--- a/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp
+++ b/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp
@@ -190,7 +190,7 @@ class CVPLatticeFunc
}
/// Print the given CVPLatticeVal to the specified stream.
- void PrintLatticeVal(CVPLatticeVal LV, raw_ostream &OS) override {
+ void PrintLatticeVal(const CVPLatticeVal &LV, raw_ostream &OS) override {
if (LV == getUndefVal())
OS << "Undefined ";
else if (LV == getOverdefinedVal())
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 17f946e5acdf84..544ec27dcbe6ff 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -301,7 +301,7 @@ static void addMemoryAttrs(const SCCNodeSet &SCCNodes, AARGetterT &&AARGetter,
// Compute definitive function attributes for a function taking into account
// prevailing definitions and linkage types
static FunctionSummary *calculatePrevailingSummary(
- ValueInfo VI,
+ const ValueInfo &VI,
DenseMap<ValueInfo, FunctionSummary *> &CachedPrevailingSummary,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
IsPrevailing) {
@@ -1714,7 +1714,7 @@ class AttributeInferer {
SmallVector<InferenceDescriptor, 4> InferenceDescriptors;
public:
- void registerAttrInference(InferenceDescriptor AttrInference) {
+ void registerAttrInference(const InferenceDescriptor &AttrInference) {
InferenceDescriptors.push_back(AttrInference);
}
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index c3d0a1a3a046eb..80a52ceb95c920 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -1085,7 +1085,7 @@ void ModuleImportsManager::computeImportForModule(
}
#ifndef NDEBUG
-static bool isGlobalVarSummary(const ModuleSummaryIndex &Index, ValueInfo VI) {
+static bool isGlobalVarSummary(const ModuleSummaryIndex &Index, const ValueInfo &VI) {
auto SL = VI.getSummaryList();
return SL.empty()
? false
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index e0861fbedc560a..1f71c970384a03 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -141,7 +141,7 @@ struct FactOrCheck {
static FactOrCheck getConditionFact(DomTreeNode *DTN, CmpPredicate Pred,
Value *Op0, Value *Op1,
- ConditionTy Precond = {}) {
+ const ConditionTy &Precond = {}) {
return FactOrCheck(DTN, Pred, Op0, Op1, Precond);
}
diff --git a/llvm/lib/Transforms/Scalar/Float2Int.cpp b/llvm/lib/Transforms/Scalar/Float2Int.cpp
index 9d23c899430095..3676664e659f93 100644
--- a/llvm/lib/Transforms/Scalar/Float2Int.cpp
+++ b/llvm/lib/Transforms/Scalar/Float2Int.cpp
@@ -125,7 +125,7 @@ ConstantRange Float2IntPass::badRange() {
ConstantRange Float2IntPass::unknownRange() {
return ConstantRange::getEmpty(MaxIntegerBW + 1);
}
-ConstantRange Float2IntPass::validateRange(ConstantRange R) {
+ConstantRange Float2IntPass::validateRange(const ConstantRange &R) {
if (R.getBitWidth() > MaxIntegerBW + 1)
return badRange();
return R;
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 21eb7f741d7c82..0de1dc9271e18c 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -1171,7 +1171,7 @@ static bool liesBetween(const Instruction *From, Instruction *Between,
/// Try to locate the three instruction involved in a missed
/// load-elimination case that is due to an intervening store.
-static void reportMayClobberedLoad(LoadInst *Load, MemDepResult DepInfo,
+static void reportMayClobberedLoad(LoadInst *Load, const MemDepResult &DepInfo,
DominatorTree *DT,
OptimizationRemarkEmitter *ORE) {
using namespace ore;
@@ -1254,7 +1254,7 @@ static Value *findDominatingValue(const MemoryLocation &Loc, Type *LoadTy,
}
std::optional<AvailableValue>
-GVNPass::AnalyzeLoadAvailability(LoadInst *Load, MemDepResult DepInfo,
+GVNPass::AnalyzeLoadAvailability(LoadInst *Load, const MemDepResult &DepInfo,
Value *Address) {
assert(Load->isUnordered() && "rules below are incorrect for ordered access");
assert(DepInfo.isLocal() && "expected a local dependence");
diff --git a/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp b/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
index b05ae00a1e0ea0..099775d3c6fccc 100644
--- a/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
+++ b/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
@@ -113,7 +113,7 @@ struct AssumeBuilderState {
AssumptionCache *AC = nullptr, DominatorTree *DT = nullptr)
: M(M), InstBeingModified(I), AC(AC), DT(DT) {}
- bool tryToPreserveWithoutAddingAssume(RetainedKnowledge RK) {
+ bool tryToPreserveWithoutAddingAssume(const RetainedKnowledge &RK) const {
if (!InstBeingModified || !RK.WasOn)
return false;
bool HasBeenPreserved = false;
diff --git a/llvm/lib/Transforms/Utils/CodeLayout.cpp b/llvm/lib/Transforms/Utils/CodeLayout.cpp
index baaad8bb48f33d..a9ebeff3d246d9 100644
--- a/llvm/lib/Transforms/Utils/CodeLayout.cpp
+++ b/llvm/lib/Transforms/Utils/CodeLayout.cpp
@@ -407,7 +407,7 @@ struct ChainEdge {
return Src == SrcChain ? CachedGainForward : CachedGainBackward;
}
- void setCachedMergeGain(ChainT *Src, ChainT *Dst, MergeGainT MergeGain) {
+ void setCachedMergeGain(ChainT *Src, ChainT *Dst, const MergeGainT &MergeGain) {
if (Src == SrcChain) {
CachedGainForward = MergeGain;
CacheValidForward = true;
@@ -422,7 +422,7 @@ struct ChainEdge {
CacheValidBackward = false;
}
- void setMergeGain(MergeGainT Gain) { CachedGain = Gain; }
+ void setMergeGain(const MergeGainT &Gain) { CachedGain = Gain; }
MergeGainT getMergeGain() const { return CachedGain; }
diff --git a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
index ae1af943bc11c7..4780d6d4f8e0b5 100644
--- a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
+++ b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
@@ -43,7 +43,7 @@ bool FunctionImportGlobalProcessing::doImportAsDefinition(
}
bool FunctionImportGlobalProcessing::shouldPromoteLocalToGlobal(
- const GlobalValue *SGV, ValueInfo VI) {
+ const GlobalValue *SGV, const ValueInfo &VI) {
assert(SGV->hasLocalLinkage());
// Ifuncs and ifunc alias does not have summary.
More information about the llvm-commits
mailing list