Skip to content

[TOOLS][UTILS] Added const reference for params with size >= 16 bytes #125082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/tools/bugpoint/BugDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class BugDriver {
/// MayModifySemantics argument is true, then the cleanups is allowed to
/// modify how the code behaves.
///
std::unique_ptr<Module> performFinalCleanups(std::unique_ptr<Module> M,
std::unique_ptr<Module> performFinalCleanups(const std::unique_ptr<Module> &M,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing unique_ptr by value or const reference are both suspect. I would expect this to take const Module&

bool MayModifySemantics = false);

/// Given a module, extract up to one loop from it into a new function. This
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/bugpoint/ExtractFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ BugDriver::deleteInstructionFromProgram(const Instruction *I,
}

std::unique_ptr<Module>
BugDriver::performFinalCleanups(std::unique_ptr<Module> M,
BugDriver::performFinalCleanups(const std::unique_ptr<Module> &M,
bool MayModifySemantics) {
// Make all functions external, so GlobalDCE doesn't delete them...
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static void dumpDIE(const DWARFDie *DIE, bool Verbose) {

/// Report a warning to the user, optionally including information about a
/// specific \p DIE related to the warning.
void DwarfLinkerForBinary::reportWarning(Twine Warning, Twine Context,
void DwarfLinkerForBinary::reportWarning(const Twine &Warning, const Twine &Context,
const DWARFDie *DIE) const {
// FIXME: implement warning logging which does not block other threads.
if (ErrorHandlerMutex.try_lock()) {
Expand All @@ -129,7 +129,7 @@ void DwarfLinkerForBinary::reportWarning(Twine Warning, Twine Context,
}
}

void DwarfLinkerForBinary::reportError(Twine Error, Twine Context,
void DwarfLinkerForBinary::reportError(const Twine &Error, const Twine &Context,
const DWARFDie *DIE) const {
// FIXME: implement error logging which does not block other threads.
if (ErrorHandlerMutex.try_lock()) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/dsymutil/DwarfLinkerForBinary.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class DwarfLinkerForBinary {
/// Link the contents of the DebugMap.
bool link(const DebugMap &);

void reportWarning(Twine Warning, Twine Context = {},
void reportWarning(const Twine &Warning, const Twine &Context = {},
const DWARFDie *DIE = nullptr) const;
void reportError(Twine Error, Twine Context = {},
void reportError(const Twine &Error, const Twine &Context = {},
const DWARFDie *DIE = nullptr) const;

/// Returns true if input verification is enabled and verification errors were
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llvm-cov/CoverageExporterLcov.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ collectNestedBranches(const coverage::CoverageMapping &Coverage,
return Branches;
}

bool sortLine(llvm::coverage::CountedRegion I,
llvm::coverage::CountedRegion J) {
bool sortLine(const llvm::coverage::CountedRegion &I,
const llvm::coverage::CountedRegion &J) {
return (I.LineStart < J.LineStart) ||
((I.LineStart == J.LineStart) && (I.ColumnStart < J.ColumnStart));
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-exegesis/lib/Assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ BitVector getFunctionReservedRegs(const TargetMachine &TM) {
}

Error assembleToStream(const ExegesisTarget &ET,
std::unique_ptr<TargetMachine> TM,
const std::unique_ptr<TargetMachine> &TM,
ArrayRef<MCRegister> LiveIns, const FillFunction &Fill,
raw_pwrite_stream &AsmStream, const BenchmarkKey &Key,
bool GenerateMemoryInstructions) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-exegesis/lib/Assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ using FillFunction = std::function<void(FunctionFiller &)>;
// epilogue. Once the MachineFunction is ready, it is assembled for TM to
// AsmStream, the temporary function is eventually discarded.
Error assembleToStream(const ExegesisTarget &ET,
std::unique_ptr<TargetMachine> TM,
const std::unique_ptr<TargetMachine> &TM,
ArrayRef<MCRegister> LiveIns, const FillFunction &Fill,
raw_pwrite_stream &AsmStreamm, const BenchmarkKey &Key,
bool GenerateMemoryInstructions);
Expand Down
6 changes: 3 additions & 3 deletions llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ template <> struct MappingTraits<exegesis::Benchmark::TripleAndCpu> {
namespace exegesis {

Expected<std::set<Benchmark::TripleAndCpu>>
Benchmark::readTriplesAndCpusFromYamls(MemoryBufferRef Buffer) {
Benchmark::readTriplesAndCpusFromYamls(const MemoryBufferRef &Buffer) {
// We're only mapping a field, drop other fields and silence the corresponding
// warnings.
yaml::Input Yin(Buffer, nullptr, +[](const SMDiagnostic &, void *Context) {});
Expand All @@ -365,7 +365,7 @@ Benchmark::readTriplesAndCpusFromYamls(MemoryBufferRef Buffer) {
}

Expected<Benchmark> Benchmark::readYaml(const LLVMState &State,
MemoryBufferRef Buffer) {
const MemoryBufferRef &Buffer) {
yaml::Input Yin(Buffer);
YamlContext Context(State);
Benchmark Benchmark;
Expand All @@ -377,7 +377,7 @@ Expected<Benchmark> Benchmark::readYaml(const LLVMState &State,
}

Expected<std::vector<Benchmark>> Benchmark::readYamls(const LLVMState &State,
MemoryBufferRef Buffer) {
const MemoryBufferRef &Buffer) {
yaml::Input Yin(Buffer);
YamlContext Context(State);
std::vector<Benchmark> Benchmarks;
Expand Down
10 changes: 5 additions & 5 deletions llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ struct BenchmarkKey {
struct BenchmarkMeasure {
// A helper to create an unscaled BenchmarkMeasure.
static BenchmarkMeasure
Create(std::string Key, double Value,
std::map<ValidationEvent, int64_t> ValCounters) {
Create(const std::string &Key, double Value,
const std::map<ValidationEvent, int64_t> &ValCounters) {
return {Key, Value, Value, Value, ValCounters};
}
std::string Key;
Expand Down Expand Up @@ -134,10 +134,10 @@ struct Benchmark {

// Read functions.
static Expected<Benchmark> readYaml(const LLVMState &State,
MemoryBufferRef Buffer);
const MemoryBufferRef &Buffer);

static Expected<std::vector<Benchmark>>
readYamls(const LLVMState &State, MemoryBufferRef Buffer);
readYamls(const LLVMState &State, const MemoryBufferRef &Buffer);

// Given a set of serialized instruction benchmarks, returns the set of
// triples and CPUs that appear in the list of benchmarks.
Expand All @@ -149,7 +149,7 @@ struct Benchmark {
}
};
static Expected<std::set<TripleAndCpu>>
readTriplesAndCpusFromYamls(MemoryBufferRef Buffer);
readTriplesAndCpusFromYamls(const MemoryBufferRef &Buffer);

class Error readYamlFrom(const LLVMState &State, StringRef InputContent);

Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ static void
dumpFullTypeStream(LinePrinter &Printer, LazyRandomTypeCollection &Types,
TypeReferenceTracker *RefTracker, uint32_t NumTypeRecords,
uint32_t NumHashBuckets,
FixedStreamArray<support::ulittle32_t> HashValues,
const FixedStreamArray<support::ulittle32_t> &HashValues,
TpiStream *Stream, bool Bytes, bool Extras) {

Printer.formatLine("Showing {0:N} records", NumTypeRecords);
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-readobj/COFFDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class COFFDumper : public ObjDumper {
void printCodeViewTypeSection(StringRef SectionName, const SectionRef &Section);
StringRef getFileNameForFileOffset(uint32_t FileOffset);
void printFileNameForOffset(StringRef Label, uint32_t FileOffset);
void printTypeIndex(StringRef FieldName, TypeIndex TI) {
void printTypeIndex(StringRef FieldName, const TypeIndex &TI) {
// Forward to CVTypeDumper for simplicity.
codeview::printTypeIndex(Writer, FieldName, TI, Types);
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-readobj/ELFDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5840,7 +5840,7 @@ struct CoreNote {
std::vector<CoreFileMapping> Mappings;
};

static Expected<CoreNote> readCoreNote(DataExtractor Desc) {
static Expected<CoreNote> readCoreNote(const DataExtractor &Desc) {
// Expected format of the NT_FILE note description:
// 1. # of file mappings (call it N)
// 2. Page size
Expand Down
10 changes: 5 additions & 5 deletions llvm/tools/llvm-readtapi/DiffEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ std::string SymScalar::getFlagString(const MachO::Symbol *Sym) {
return std::string(Flags);
}

void SymScalar::print(raw_ostream &OS, std::string Indent, MachO::Target Targ) {
void SymScalar::print(raw_ostream &OS, const std::string &Indent, const MachO::Target &Targ) {
if (Val->getKind() == MachO::EncodeKind::ObjectiveCClass) {
if (Targ.Arch == MachO::AK_i386 && Targ.Platform == MachO::PLATFORM_MACOS) {
OS << Indent << "\t\t" << ((Order == lhs) ? "< " : "> ")
Expand Down Expand Up @@ -144,7 +144,7 @@ void addDiffForTargSlice(V Val, Target Targ, DiffOutput &Diff,
}

DiffOutput getSingleAttrDiff(const std::vector<InterfaceFileRef> &IRefVec,
std::string Name, InterfaceInputOrder Order) {
const std::string &Name, InterfaceInputOrder Order) {
DiffOutput Diff(Name);
Diff.Kind = AD_Str_Vec;
for (const auto &IRef : IRefVec)
Expand All @@ -157,7 +157,7 @@ DiffOutput getSingleAttrDiff(const std::vector<InterfaceFileRef> &IRefVec,

DiffOutput
getSingleAttrDiff(const std::vector<std::pair<Target, std::string>> &PairVec,
std::string Name, InterfaceInputOrder Order) {
const std::string &Name, InterfaceInputOrder Order) {
DiffOutput Diff(Name);
Diff.Kind = AD_Str_Vec;
for (const auto &Pair : PairVec)
Expand All @@ -168,7 +168,7 @@ getSingleAttrDiff(const std::vector<std::pair<Target, std::string>> &PairVec,
}

DiffOutput getSingleAttrDiff(InterfaceFile::const_symbol_range SymRange,
std::string Name, InterfaceInputOrder Order) {
const std::string &Name, InterfaceInputOrder Order) {
DiffOutput Diff(Name);
Diff.Kind = AD_Sym_Vec;
for (const auto *Sym : SymRange)
Expand Down Expand Up @@ -305,7 +305,7 @@ DiffOutput recordDifferences(const std::vector<T> &LHS,

DiffOutput recordDifferences(llvm::MachO::InterfaceFile::const_symbol_range LHS,
llvm::MachO::InterfaceFile::const_symbol_range RHS,
std::string Attr) {
const std::string &Attr) {
DiffOutput Diff(Attr);
Diff.Kind = AD_Sym_Vec;
findAndAddDiff(LHS, RHS, Diff, lhs);
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-readtapi/DiffEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SymScalar {

std::string getFlagString(const MachO::Symbol *Sym);

void print(raw_ostream &OS, std::string Indent, MachO::Target Targ);
void print(raw_ostream &OS, const std::string &Indent, const MachO::Target &Targ);

const MachO::Symbol *getVal() const { return Val; }
InterfaceInputOrder getOrder() const { return Order; }
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/FileCheck/FileCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ struct InputAnnotation {
};

/// Get an abbreviation for the check type.
static std::string GetCheckTypeAbbreviation(Check::FileCheckType Ty) {
static std::string GetCheckTypeAbbreviation(const Check::FileCheckType &Ty) {
switch (Ty) {
case Check::CheckPlain:
if (Ty.getCount() > 1)
Expand Down
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/DFAPacketizerEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class DFAPacketizerEmitter {
// Emit code for a subset of itineraries.
void emitForItineraries(raw_ostream &OS,
std::vector<const CodeGenProcModel *> &ProcItinList,
std::string DFAName);
const std::string &DFAName);

void run(raw_ostream &OS);
};
Expand Down Expand Up @@ -231,7 +231,7 @@ void DFAPacketizerEmitter::run(raw_ostream &OS) {

void DFAPacketizerEmitter::emitForItineraries(
raw_ostream &OS, std::vector<const CodeGenProcModel *> &ProcModels,
std::string DFAName) {
const std::string &DFAName) {
OS << "} // end namespace llvm\n\n";
OS << "namespace {\n";
collectAllFuncUnits(ProcModels);
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/DXILEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ static void emitDXILAttributes(const RecordKeeper &Records, raw_ostream &OS) {

// Helper function to determine if the given Attr is defined in the vector
// Attrs, by comparing the names
static bool attrIsDefined(std::vector<const Record *> Attrs,
static bool attrIsDefined(const std::vector<const Record *> &Attrs,
const Record *Attr) {
for (auto CurAttr : Attrs)
if (CurAttr->getName() == Attr->getName())
Expand Down
10 changes: 5 additions & 5 deletions llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,9 @@ class CombineRuleBuilder {
std::optional<LLTCodeGenOrTempType>
getLLTCodeGenOrTempType(const PatternType &PT, RuleMatcher &RM);

void PrintError(Twine Msg) const { ::PrintError(&RuleDef, Msg); }
void PrintWarning(Twine Msg) const { ::PrintWarning(RuleDef.getLoc(), Msg); }
void PrintNote(Twine Msg) const { ::PrintNote(RuleDef.getLoc(), Msg); }
void PrintError(const Twine &Msg) const { ::PrintError(&RuleDef, Msg); }
void PrintWarning(const Twine &Msg) const { ::PrintWarning(RuleDef.getLoc(), Msg); }
void PrintNote(const Twine &Msg) const { ::PrintNote(RuleDef.getLoc(), Msg); }

void print(raw_ostream &OS, const PatternAlternatives &Alts) const;

Expand Down Expand Up @@ -710,7 +710,7 @@ class CombineRuleBuilder {
/// \param AdditionalComment Comment string to be added to the
/// `DebugCommentAction`.
RuleMatcher &addRuleMatcher(const PatternAlternatives &Alts,
Twine AdditionalComment = "");
const Twine &AdditionalComment = "");
bool addFeaturePredicates(RuleMatcher &M);

bool findRoots();
Expand Down Expand Up @@ -1350,7 +1350,7 @@ bool CombineRuleBuilder::checkSemantics() {
}

RuleMatcher &CombineRuleBuilder::addRuleMatcher(const PatternAlternatives &Alts,
Twine AdditionalComment) {
const Twine &AdditionalComment) {
auto &RM = OutRMs.emplace_back(RuleDef.getLoc());
addFeaturePredicates(RM);
RM.setPermanentGISelFlags(GISF_IgnoreCopies);
Expand Down