Skip to content

[Analysis, CodeGen, DebugInfo] Use StringRef::operator== instead of StringRef::equals (NFC) #91304

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

Merged
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
5 changes: 2 additions & 3 deletions llvm/lib/Analysis/BlockFrequencyInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,11 @@ void BlockFrequencyInfo::calculate(const Function &F,
BFI.reset(new ImplType);
BFI->calculate(F, BPI, LI);
if (ViewBlockFreqPropagationDAG != GVDT_None &&
(ViewBlockFreqFuncName.empty() ||
F.getName().equals(ViewBlockFreqFuncName))) {
(ViewBlockFreqFuncName.empty() || F.getName() == ViewBlockFreqFuncName)) {
view();
}
if (PrintBFI &&
(PrintBFIFuncName.empty() || F.getName().equals(PrintBFIFuncName))) {
(PrintBFIFuncName.empty() || F.getName() == PrintBFIFuncName)) {
print(dbgs());
}
}
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Analysis/BranchProbabilityInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1273,9 +1273,8 @@ void BranchProbabilityInfo::calculate(const Function &F, const LoopInfo &LoopI,
EstimatedBlockWeight.clear();
SccI.reset();

if (PrintBranchProb &&
(PrintBranchProbFuncName.empty() ||
F.getName().equals(PrintBranchProbFuncName))) {
if (PrintBranchProb && (PrintBranchProbFuncName.empty() ||
F.getName() == PrintBranchProbFuncName)) {
print(dbgs());
}
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/LoopInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ MDNode *llvm::findOptionMDForLoopID(MDNode *LoopID, StringRef Name) {
if (!S)
continue;
// Return the operand node if MDString holds expected metadata.
if (Name.equals(S->getString()))
if (Name == S->getString())
return MD;
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Analysis/MemoryProfileInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ AllocationType llvm::memprof::getMIBAllocType(const MDNode *MIB) {
// types that can be applied based on the allocation profile data.
auto *MDS = dyn_cast<MDString>(MIB->getOperand(1));
assert(MDS);
if (MDS->getString().equals("cold")) {
if (MDS->getString() == "cold") {
return AllocationType::Cold;
} else if (MDS->getString().equals("hot")) {
} else if (MDS->getString() == "hot") {
return AllocationType::Hot;
}
return AllocationType::NotCold;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/MIRSampleProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ bool MIRProfileLoaderPass::runOnMachineFunction(MachineFunction &MF) {
MF.RenumberBlocks();
if (ViewBFIBefore && ViewBlockLayoutWithBFI != GVDT_None &&
(ViewBlockFreqFuncName.empty() ||
MF.getFunction().getName().equals(ViewBlockFreqFuncName))) {
MF.getFunction().getName() == ViewBlockFreqFuncName)) {
MBFI->view("MIR_Prof_loader_b." + MF.getName(), false);
}

Expand All @@ -382,7 +382,7 @@ bool MIRProfileLoaderPass::runOnMachineFunction(MachineFunction &MF) {

if (ViewBFIAfter && ViewBlockLayoutWithBFI != GVDT_None &&
(ViewBlockFreqFuncName.empty() ||
MF.getFunction().getName().equals(ViewBlockFreqFuncName))) {
MF.getFunction().getName() == ViewBlockFreqFuncName)) {
MBFI->view("MIR_prof_loader_a." + MF.getName(), false);
}

Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,11 @@ void MachineBlockFrequencyInfo::calculate(
MBFI.reset(new ImplType);
MBFI->calculate(F, MBPI, MLI);
if (ViewMachineBlockFreqPropagationDAG != GVDT_None &&
(ViewBlockFreqFuncName.empty() ||
F.getName().equals(ViewBlockFreqFuncName))) {
(ViewBlockFreqFuncName.empty() || F.getName() == ViewBlockFreqFuncName)) {
view("MachineBlockFrequencyDAGS." + F.getName());
}
if (PrintMachineBlockFreq &&
(PrintBFIFuncName.empty() || F.getName().equals(PrintBFIFuncName))) {
(PrintBFIFuncName.empty() || F.getName() == PrintBFIFuncName)) {
MBFI->print(dbgs());
}
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MachineBlockPlacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3500,7 +3500,7 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) {
}
if (ViewBlockLayoutWithBFI != GVDT_None &&
(ViewBlockFreqFuncName.empty() ||
F->getFunction().getName().equals(ViewBlockFreqFuncName))) {
F->getFunction().getName() == ViewBlockFreqFuncName)) {
if (RenumberBlocksBeforeView)
MF.RenumberBlocks();
MBFI->view("MBP." + MF.getName(), false);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/TargetLoweringBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2249,7 +2249,7 @@ static int getOpEnabled(bool IsSqrt, EVT VT, StringRef Override) {
if (IsDisabled)
RecipType = RecipType.substr(1);

if (RecipType.equals(VTName) || RecipType.equals(VTNameNoSize))
if (RecipType == VTName || RecipType == VTNameNoSize)
return IsDisabled ? TargetLoweringBase::ReciprocalEstimate::Disabled
: TargetLoweringBase::ReciprocalEstimate::Enabled;
}
Expand Down Expand Up @@ -2299,7 +2299,7 @@ static int getOpRefinementSteps(bool IsSqrt, EVT VT, StringRef Override) {
continue;

RecipType = RecipType.substr(0, RefPos);
if (RecipType.equals(VTName) || RecipType.equals(VTNameNoSize))
if (RecipType == VTName || RecipType == VTNameNoSize)
return RefSteps;
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ MCSection *TargetLoweringObjectFileELF::getSectionForMachineBasicBlock(
// name, or a unique ID for the section.
SmallString<128> Name;
StringRef FunctionSectionName = MBB.getParent()->getSection()->getName();
if (FunctionSectionName.equals(".text") ||
if (FunctionSectionName == ".text" ||
FunctionSectionName.starts_with(".text.")) {
// Function is in a regular .text section.
StringRef FunctionName = MBB.getParent()->getName();
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/DebugInfo/LogicalView/Core/LVOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ bool LVPatterns::matchPattern(StringRef Input, const LVMatchInfo &MatchInfo) {
for (const LVMatch &Match : MatchInfo) {
switch (Match.Mode) {
case LVMatchMode::Match:
Matched = Input.equals(Match.Pattern);
Matched = Input == Match.Pattern;
break;
case LVMatchMode::NoCase:
Matched = Input.equals_insensitive(Match.Pattern);
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,8 @@ void LVBinaryReader::mapVirtualAddress(const object::ObjectFile &Obj) {
consumeError(SectionNameOrErr.takeError());
continue;
}
if ((*SectionNameOrErr).equals(".text") ||
(*SectionNameOrErr).equals("CODE") ||
(*SectionNameOrErr).equals(".code")) {
if (*SectionNameOrErr == ".text" || *SectionNameOrErr == "CODE" ||
*SectionNameOrErr == ".code") {
DotTextSectionIndex = Section.getIndex();
// If the object is WebAssembly, update the address offset that
// will be added to DWARF DW_AT_* attributes.
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ Error LVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
// Symbol was created as 'variable'; determine its real kind.
Symbol->resetIsVariable();

if (Local.Name.equals("this")) {
if (Local.Name == "this") {
Symbol->setIsParameter();
Symbol->setIsArtificial();
} else {
Expand Down Expand Up @@ -885,7 +885,7 @@ Error LVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
Symbol->resetIsVariable();

// Check for the 'this' symbol.
if (Local.Name.equals("this")) {
if (Local.Name == "this") {
Symbol->setIsArtificial();
Symbol->setIsParameter();
} else {
Expand Down Expand Up @@ -1429,7 +1429,7 @@ Error LVSymbolVisitor::visitKnownRecord(CVSymbol &Record, LocalSym &Local) {

// Be sure the 'this' symbol is marked as 'compiler generated'.
if (bool(Local.Flags & LocalSymFlags::IsCompilerGenerated) ||
Local.Name.equals("this")) {
Local.Name == "this") {
Symbol->setIsArtificial();
Symbol->setIsParameter();
} else {
Expand Down Expand Up @@ -1669,7 +1669,7 @@ Error LVSymbolVisitor::visitKnownRecord(CVSymbol &Record, UDTSym &UDT) {
Type->resetIncludeInPrint();
else {
StringRef RecordName = getRecordName(Types, UDT.Type);
if (UDT.Name.equals(RecordName))
if (UDT.Name == RecordName)
Type->resetIncludeInPrint();
Type->setType(LogicalVisitor->getElement(StreamTPI, UDT.Type));
}
Expand Down Expand Up @@ -2740,7 +2740,7 @@ Error LVLogicalVisitor::visitKnownMember(CVMemberRecord &Record,
getInnerComponent(NestedTypeName);
// We have an already created nested type. Add it to the current scope
// and update all its children if any.
if (OuterComponent.size() && OuterComponent.equals(RecordName)) {
if (OuterComponent.size() && OuterComponent == RecordName) {
if (!NestedType->getIsScopedAlready()) {
Scope->addElement(NestedType);
NestedType->setIsScopedAlready();
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ std::vector<object::SectionedAddress>
SymbolizableObjectFile::findSymbol(StringRef Symbol, uint64_t Offset) const {
std::vector<object::SectionedAddress> Result;
for (const SymbolDesc &Sym : Symbols) {
if (Sym.Name.equals(Symbol)) {
if (Sym.Name == Symbol) {
uint64_t Addr = Sym.Addr;
if (Offset < Sym.Size)
Addr += Offset;
Expand Down