Skip to content

[ANALYSIS][CODEGEN] Added const reference for params with size >= 16 bytes #125090

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/include/llvm/Analysis/AliasSetTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/Analysis/AssumeBundleQueries.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/Analysis/SparsePropagation.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ template <class LatticeKey, class LatticeVal> class AbstractLatticeFunction {
SparseSolver<LatticeKey, LatticeVal> &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);
Expand Down Expand Up @@ -203,7 +203,7 @@ class SparseSolver {

template <class LatticeKey, class LatticeVal>
void AbstractLatticeFunction<LatticeKey, LatticeVal>::PrintLatticeVal(
LatticeVal V, raw_ostream &OS) {
const LatticeVal &V, raw_ostream &OS) {
if (V == UndefVal)
OS << "undefined";
else if (V == OverdefinedVal)
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/CGData/CodeGenData.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ std::unique_ptr<Module> loadModuleForTwoRounds(BitcodeModule &OrigModule,
Expected<stable_hash> mergeCodeGenData(ArrayRef<StringRef> 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

Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/CodeGen/AsmPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<StringError>(
Twine("invalid profile " + MBuf->getBufferIdentifier() + " at line " +
Twine(LineIt.line_number()) + ": " + Message),
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/CodeGen/MachineFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/CodeGen/SelectionDAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/AliasSetTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CGData/CodeGenData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Expected<Header> Header::readFromBuffer(const unsigned char *Curr) {

namespace cgdata {

void warn(Twine Message, std::string Whence, std::string Hint) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why isn't Whence / Hint StringRef?

void warn(const Twine &Message, const std::string &Whence, const std::string &Hint) {
WithColor::warning();
if (!Whence.empty())
errs() << Whence << ": ";
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's going on here? bitcastToAPInt doesn't return a reference


// First print a comment with what we think the original floating-point value
// should have been.
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<VariableID>(Variables.insert(V));
}

Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned>
getMinUselessShift(KnownBits ValueKB, unsigned Opcode,
getMinUselessShift(const KnownBits &ValueKB, unsigned Opcode,
std::optional<int64_t> &Result) {
assert(Opcode == TargetOpcode::G_SHL || Opcode == TargetOpcode::G_LSHR ||
Opcode == TargetOpcode::G_ASHR && "Expect G_SHL, G_LSHR or G_ASHR.");
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MachineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down