diff --git a/llvm/include/llvm/Support/BinaryStreamWriter.h b/llvm/include/llvm/Support/BinaryStreamWriter.h index bc1d7949841d6..41256b3a31f7b 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 90120156ec2ea..d3f6619d5e7c2 100644 --- a/llvm/include/llvm/Support/Error.h +++ b/llvm/include/llvm/Support/Error.h @@ -1049,7 +1049,7 @@ Expected handleExpected(Expected 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 337e229efcf37..6d528cf6671b3 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 { void seen(Instruction *I, ConstantRange R); ConstantRange badRange(); ConstantRange unknownRange(); - ConstantRange validateRange(ConstantRange R); + ConstantRange validateRange(const ConstantRange &R); std::optional 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 c8be390799836..7d98de57c3785 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 { /// Given a local dependency (Def or Clobber) determine if a value is /// available for the load. std::optional - 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 18cd923d5601d..f3b040171ea7a 100644 --- a/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h +++ b/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h @@ -62,7 +62,7 @@ class FunctionImportGlobalProcessing { DenseMap 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 6e3f99d78b932..f930d88131ce0 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((*OpIt).get())) ++OpIt; return OpIt; diff --git a/llvm/lib/Support/AMDGPUMetadata.cpp b/llvm/lib/Support/AMDGPUMetadata.cpp index e24cbde38795b..853eff0333e4a 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::max()); YamlOutput << HSAMetadata; diff --git a/llvm/lib/Support/BinaryStreamWriter.cpp b/llvm/lib/Support/BinaryStreamWriter.cpp index dff08fee3fefa..839acd2abbfb9 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 baa3c322e9dae..3f6c5d4c8b60b 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 1782e24287860..86fb25aed677e 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 58b8f1f779f72..48ad3a27a91ca 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 &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 &Worklist) { SmallSetVector PotentialCopies; SmallSetVector 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 &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 &Worklist, SmallMapVector &LivenessAAs) { if (auto *CI = dyn_cast(&I)) diff --git a/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp b/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp index 66ae0706d638c..0cd51c522bd07 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 17f946e5acdf8..544ec27dcbe6f 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 &CachedPrevailingSummary, function_ref IsPrevailing) { @@ -1714,7 +1714,7 @@ class AttributeInferer { SmallVector 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 c3d0a1a3a046e..80a52ceb95c92 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 e0861fbedc560..1f71c970384a0 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 9d23c89943009..3676664e659f9 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 21eb7f741d7c8..0de1dc9271e18 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 -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 b05ae00a1e0ea..099775d3c6fcc 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 baaad8bb48f33..a9ebeff3d246d 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 ae1af943bc11c..4780d6d4f8e0b 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.