From 60123ef266d45c7e9ce586eaecb939c66785a162 Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Thu, 30 Jan 2025 16:28:41 +0300 Subject: [PATCH] [ANALYSIS][CODEGEN] Added const reference for params with size >= 16 bytes --- llvm/include/llvm/Analysis/AliasSetTracker.h | 2 +- llvm/include/llvm/Analysis/AssumeBundleQueries.h | 6 +++--- llvm/include/llvm/Analysis/SparsePropagation.h | 4 ++-- llvm/include/llvm/CGData/CodeGenData.h | 2 +- llvm/include/llvm/CodeGen/AsmPrinter.h | 6 +++--- .../llvm/CodeGen/BasicBlockSectionsProfileReader.h | 2 +- llvm/include/llvm/CodeGen/MachineFunction.h | 2 +- llvm/include/llvm/CodeGen/SelectionDAG.h | 2 +- llvm/lib/Analysis/AliasSetTracker.cpp | 2 +- llvm/lib/CGData/CodeGenData.cpp | 2 +- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 8 ++++---- llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp | 2 +- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 4 ++-- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h | 4 ++-- llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp | 6 +++--- llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | 2 +- llvm/lib/CodeGen/MachineFunction.cpp | 2 +- 17 files changed, 29 insertions(+), 29 deletions(-) diff --git a/llvm/include/llvm/Analysis/AliasSetTracker.h b/llvm/include/llvm/Analysis/AliasSetTracker.h index e5817d2409bc6..917df86d8d01d 100644 --- a/llvm/include/llvm/Analysis/AliasSetTracker.h +++ b/llvm/include/llvm/Analysis/AliasSetTracker.h @@ -249,7 +249,7 @@ class AliasSetTracker { } } - AliasSet &addMemoryLocation(MemoryLocation Loc, AliasSet::AccessLattice E); + AliasSet &addMemoryLocation(const MemoryLocation &Loc, AliasSet::AccessLattice E); AliasSet *mergeAliasSetsForMemoryLocation(const MemoryLocation &MemLoc, AliasSet *PtrAS, bool &MustAliasAll); diff --git a/llvm/include/llvm/Analysis/AssumeBundleQueries.h b/llvm/include/llvm/Analysis/AssumeBundleQueries.h index f7a893708758c..3acdd46e86a6e 100644 --- a/llvm/include/llvm/Analysis/AssumeBundleQueries.h +++ b/llvm/include/llvm/Analysis/AssumeBundleQueries.h @@ -100,14 +100,14 @@ struct RetainedKnowledge { Attribute::AttrKind AttrKind = Attribute::None; uint64_t ArgValue = 0; Value *WasOn = nullptr; - bool operator==(RetainedKnowledge Other) const { + bool operator==(const RetainedKnowledge &Other) const { return AttrKind == Other.AttrKind && WasOn == Other.WasOn && ArgValue == Other.ArgValue; } - bool operator!=(RetainedKnowledge Other) const { return !(*this == Other); } + bool operator!=(const RetainedKnowledge &Other) const { return !(*this == Other); } /// This is only intended for use in std::min/std::max between attribute that /// only differ in ArgValue. - bool operator<(RetainedKnowledge Other) const { + bool operator<(const RetainedKnowledge &Other) const { assert(((AttrKind == Other.AttrKind && WasOn == Other.WasOn) || AttrKind == Attribute::None || Other.AttrKind == Attribute::None) && "This is only intend for use in min/max to select the best for " diff --git a/llvm/include/llvm/Analysis/SparsePropagation.h b/llvm/include/llvm/Analysis/SparsePropagation.h index cc79870229873..e17bdd6f8cbf3 100644 --- a/llvm/include/llvm/Analysis/SparsePropagation.h +++ b/llvm/include/llvm/Analysis/SparsePropagation.h @@ -92,7 +92,7 @@ template class AbstractLatticeFunction { SparseSolver &SS) = 0; /// PrintLatticeVal - Render the given LatticeVal to the specified stream. - virtual void PrintLatticeVal(LatticeVal LV, raw_ostream &OS); + virtual void PrintLatticeVal(const LatticeVal &LV, raw_ostream &OS); /// PrintLatticeKey - Render the given LatticeKey to the specified stream. virtual void PrintLatticeKey(LatticeKey Key, raw_ostream &OS); @@ -203,7 +203,7 @@ class SparseSolver { template void AbstractLatticeFunction::PrintLatticeVal( - LatticeVal V, raw_ostream &OS) { + const LatticeVal &V, raw_ostream &OS) { if (V == UndefVal) OS << "undefined"; else if (V == OverdefinedVal) diff --git a/llvm/include/llvm/CGData/CodeGenData.h b/llvm/include/llvm/CGData/CodeGenData.h index da0e412f2a0e0..ba62f7332818f 100644 --- a/llvm/include/llvm/CGData/CodeGenData.h +++ b/llvm/include/llvm/CGData/CodeGenData.h @@ -265,7 +265,7 @@ std::unique_ptr loadModuleForTwoRounds(BitcodeModule &OrigModule, Expected mergeCodeGenData(ArrayRef ObjectFiles); void warn(Error E, StringRef Whence = ""); -void warn(Twine Message, std::string Whence = "", std::string Hint = ""); +void warn(const Twine &Message, const std::string &Whence = "", const std::string &Hint = ""); } // end namespace cgdata diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 5291369b3b9f1..18a99186bafe8 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -632,7 +632,7 @@ class AsmPrinter : public MachineFunctionPass { StringRef Suffix) const; /// Return the MCSymbol for the specified ExternalSymbol. - MCSymbol *GetExternalSymbolSymbol(Twine Sym) const; + MCSymbol *GetExternalSymbolSymbol(const Twine &Sym) const; /// Return the symbol for the specified jump table entry. MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const; @@ -723,10 +723,10 @@ class AsmPrinter : public MachineFunctionPass { /// emitDwarfSymbolReference(). /// /// The length of the emitted value depends on the DWARF format. - void emitDwarfStringOffset(DwarfStringPoolEntry S) const; + void emitDwarfStringOffset(const DwarfStringPoolEntry &S) const; /// Emit the 4-or 8-byte offset of a string from the start of its section. - void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const { + void emitDwarfStringOffset(const DwarfStringPoolEntryRef &S) const { emitDwarfStringOffset(S.getEntry()); } diff --git a/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h b/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h index 08e6a0e3ef629..814879860b1b2 100644 --- a/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h +++ b/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h @@ -105,7 +105,7 @@ class BasicBlockSectionsProfileReader { } // Returns a profile parsing error for the current line. - Error createProfileParseError(Twine Message) const { + Error createProfileParseError(const Twine &Message) const { return make_error( Twine("invalid profile " + MBuf->getBufferIdentifier() + " at line " + Twine(LineIt.line_number()) + ": " + Message), diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h index c3eb27b946287..861db8147438f 100644 --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -1059,7 +1059,7 @@ class LLVM_ABI MachineFunction { AtomicOrdering Ordering = AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic); MachineMemOperand *getMachineMemOperand( - MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LocationSize Size, + const MachinePointerInfo &PtrInfo, MachineMemOperand::Flags F, LocationSize Size, Align BaseAlignment, const AAMDNodes &AAInfo = AAMDNodes(), const MDNode *Ranges = nullptr, SyncScope::ID SSID = SyncScope::System, AtomicOrdering Ordering = AtomicOrdering::NotAtomic, diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h index 461c0c1ead16d..2f0472661bf26 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAG.h +++ b/llvm/include/llvm/CodeGen/SelectionDAG.h @@ -1408,7 +1408,7 @@ class SelectionDAG { const MDNode *Ranges = nullptr); inline SDValue getLoad( ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &dl, - SDValue Chain, SDValue Ptr, SDValue Offset, MachinePointerInfo PtrInfo, + SDValue Chain, SDValue Ptr, SDValue Offset, const MachinePointerInfo &PtrInfo, EVT MemVT, MaybeAlign Alignment = MaybeAlign(), MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, const AAMDNodes &AAInfo = AAMDNodes(), const MDNode *Ranges = nullptr) { diff --git a/llvm/lib/Analysis/AliasSetTracker.cpp b/llvm/lib/Analysis/AliasSetTracker.cpp index 6d1dafbae60b9..cb8149c0ffdfe 100644 --- a/llvm/lib/Analysis/AliasSetTracker.cpp +++ b/llvm/lib/Analysis/AliasSetTracker.cpp @@ -491,7 +491,7 @@ AliasSet &AliasSetTracker::mergeAllAliasSets() { return *AliasAnyAS; } -AliasSet &AliasSetTracker::addMemoryLocation(MemoryLocation Loc, +AliasSet &AliasSetTracker::addMemoryLocation(const MemoryLocation &Loc, AliasSet::AccessLattice E) { AliasSet &AS = getAliasSetFor(Loc); AS.Access |= E; diff --git a/llvm/lib/CGData/CodeGenData.cpp b/llvm/lib/CGData/CodeGenData.cpp index 88dcdfd1f931a..3c6a2e2300d77 100644 --- a/llvm/lib/CGData/CodeGenData.cpp +++ b/llvm/lib/CGData/CodeGenData.cpp @@ -204,7 +204,7 @@ Expected
Header::readFromBuffer(const unsigned char *Curr) { namespace cgdata { -void warn(Twine Message, std::string Whence, std::string Hint) { +void warn(const Twine &Message, const std::string &Whence, const std::string &Hint) { WithColor::warning(); if (!Whence.empty()) errs() << Whence << ": "; diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index b2a4721f37b26..ec5ad5449448c 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -3508,7 +3508,7 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *C, AsmPrinter::AliasMapTy *AliasList = nullptr); static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP); -static void emitGlobalConstantFP(APFloat APF, Type *ET, AsmPrinter &AP); +static void emitGlobalConstantFP(const APFloat &APF, Type *ET, AsmPrinter &AP); /// isRepeatedByteSequence - Determine whether the given value is /// composed of a repeated sequence of identical bytes and return the @@ -3705,9 +3705,9 @@ static void emitGlobalConstantStruct(const DataLayout &DL, "Layout of constant struct may be incorrect!"); } -static void emitGlobalConstantFP(APFloat APF, Type *ET, AsmPrinter &AP) { +static void emitGlobalConstantFP(const APFloat &APF, Type *ET, AsmPrinter &AP) { assert(ET && "Unknown float type"); - APInt API = APF.bitcastToAPInt(); + const APInt &API = APF.bitcastToAPInt(); // First print a comment with what we think the original floating-point value // should have been. @@ -4118,7 +4118,7 @@ MCSymbol *AsmPrinter::getSymbolWithGlobalValueBase(const GlobalValue *GV, } /// Return the MCSymbol for the specified ExternalSymbol. -MCSymbol *AsmPrinter::GetExternalSymbolSymbol(Twine Sym) const { +MCSymbol *AsmPrinter::GetExternalSymbolSymbol(const Twine &Sym) const { SmallString<60> NameStr; Mangler::getNameWithPrefix(NameStr, Sym, getDataLayout()); return OutContext.getOrCreateSymbol(NameStr); diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp index 2a146eb15f709..d76a735e52bb8 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp @@ -151,7 +151,7 @@ void AsmPrinter::emitDwarfSymbolReference(const MCSymbol *Label, getDwarfOffsetByteSize()); } -void AsmPrinter::emitDwarfStringOffset(DwarfStringPoolEntry S) const { +void AsmPrinter::emitDwarfStringOffset(const DwarfStringPoolEntry &S) const { if (doesDwarfUseRelocationsAcrossSections()) { assert(S.Symbol && "No symbol available"); emitDwarfSymbolReference(S.Symbol); diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index bda0e266d01de..311a0e15ffe53 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -474,7 +474,7 @@ TypeIndex CodeViewDebug::getMemberFunctionType(const DISubprogram *SP, } TypeIndex CodeViewDebug::recordTypeIndexForDINode(const DINode *Node, - TypeIndex TI, + const TypeIndex &TI, const DIType *ClassTy) { auto InsertResult = TypeIndices.insert({{Node, ClassTy}, TI}); (void)InsertResult; @@ -2208,7 +2208,7 @@ static ClassOptions getCommonClassOptions(const DICompositeType *Ty) { return CO; } -void CodeViewDebug::addUDTSrcLine(const DIType *Ty, TypeIndex TI) { +void CodeViewDebug::addUDTSrcLine(const DIType *Ty, const TypeIndex &TI) { switch (Ty->getTag()) { case dwarf::DW_TAG_class_type: case dwarf::DW_TAG_structure_type: diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h index 7a138a0332b6d..d706a05bfe778 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h @@ -433,7 +433,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { void addToUDTs(const DIType *Ty); - void addUDTSrcLine(const DIType *Ty, codeview::TypeIndex TI); + void addUDTSrcLine(const DIType *Ty, const codeview::TypeIndex &TI); codeview::TypeIndex lowerType(const DIType *Ty, const DIType *ClassTy); codeview::TypeIndex lowerTypeAlias(const DIDerivedType *Ty); @@ -482,7 +482,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { /// Inserts {{Node, ClassTy}, TI} into TypeIndices and checks for duplicates. codeview::TypeIndex recordTypeIndexForDINode(const DINode *Node, - codeview::TypeIndex TI, + const codeview::TypeIndex &TI, const DIType *ClassTy = nullptr); /// Collect the names of parent scopes, innermost to outermost. Return the diff --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp index dbc724629d3be..85ba3b62ec1b7 100644 --- a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp +++ b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp @@ -111,7 +111,7 @@ class FunctionVarLocsBuilder { unsigned getNumVariables() const { return Variables.size(); } /// Find or insert \p V and return the ID. - VariableID insertVariable(DebugVariable V) { + VariableID insertVariable(const DebugVariable &V) { return static_cast(Variables.insert(V)); } @@ -135,7 +135,7 @@ class FunctionVarLocsBuilder { } /// Add a def for a variable that is valid for its lifetime. - void addSingleLocVar(DebugVariable Var, DIExpression *Expr, DebugLoc DL, + void addSingleLocVar(const DebugVariable &Var, DIExpression *Expr, DebugLoc DL, RawLocationWrapper R) { VarLocInfo VarLoc; VarLoc.VariableID = insertVariable(Var); @@ -146,7 +146,7 @@ class FunctionVarLocsBuilder { } /// Add a def to the wedge of defs just before /p Before. - void addVarLoc(VarLocInsertPt Before, DebugVariable Var, DIExpression *Expr, + void addVarLoc(VarLocInsertPt Before, const DebugVariable &Var, DIExpression *Expr, DebugLoc DL, RawLocationWrapper R) { VarLocInfo VarLoc; VarLoc.VariableID = insertVariable(Var); diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp index b193d8bb0aa18..3446238e5b5ba 100644 --- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp @@ -6593,7 +6593,7 @@ bool CombinerHelper::matchRedundantBinOpInEquality(MachineInstr &MI, /// Return the minimum useless shift amount that results in complete loss of the /// source value. Return std::nullopt when it cannot determine a value. static std::optional -getMinUselessShift(KnownBits ValueKB, unsigned Opcode, +getMinUselessShift(const KnownBits &ValueKB, unsigned Opcode, std::optional &Result) { assert(Opcode == TargetOpcode::G_SHL || Opcode == TargetOpcode::G_LSHR || Opcode == TargetOpcode::G_ASHR && "Expect G_SHL, G_LSHR or G_ASHR."); diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index ab3609b6141b8..983bbae57b007 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -520,7 +520,7 @@ void MachineFunction::deleteMachineBasicBlock(MachineBasicBlock *MBB) { } MachineMemOperand *MachineFunction::getMachineMemOperand( - MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LocationSize Size, + const MachinePointerInfo &PtrInfo, MachineMemOperand::Flags F, LocationSize Size, Align BaseAlignment, const AAMDNodes &AAInfo, const MDNode *Ranges, SyncScope::ID SSID, AtomicOrdering Ordering, AtomicOrdering FailureOrdering) {