Skip to content

[Target] Use StringRef::operator== instead of StringRef::equals (NFC) (#91072) #91138

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
6 changes: 3 additions & 3 deletions llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ static std::pair<bool, bool> GetSignReturnAddress(const Function &F) {
}

StringRef Scope = F.getFnAttribute("sign-return-address").getValueAsString();
if (Scope.equals("none"))
if (Scope == "none")
return {false, false};

if (Scope.equals("all"))
if (Scope == "all")
return {true, true};

assert(Scope.equals("non-leaf"));
assert(Scope == "non-leaf");
return {true, false};
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ void AMDGPUAsmPrinter::emitResourceUsageRemarks(
// makes it easier to tell which resource usage go with which kernel since
// the kernel name will always be displayed first.
std::string LabelStr = RemarkLabel.str() + ": ";
if (!RemarkName.equals("FunctionName"))
if (RemarkName != "FunctionName")
LabelStr = Indent + LabelStr;

ORE->emit([&]() {
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ struct AAUniformWorkGroupSizeFunction : public AAUniformWorkGroupSize {

bool InitialValue = false;
if (F->hasFnAttribute("uniform-work-group-size"))
InitialValue = F->getFnAttribute("uniform-work-group-size")
.getValueAsString()
.equals("true");
InitialValue =
F->getFnAttribute("uniform-work-group-size").getValueAsString() ==
"true";

if (InitialValue)
indicateOptimisticFixpoint();
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ SDValue AMDGPUTargetLowering::LowerGlobalAddress(AMDGPUMachineFunction* MFI,
if (G->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS ||
G->getAddressSpace() == AMDGPUAS::REGION_ADDRESS) {
if (!MFI->isModuleEntryFunction() &&
!GV->getName().equals("llvm.amdgcn.module.lds")) {
GV->getName() != "llvm.amdgcn.module.lds") {
SDLoc DL(Op);
const Function &Fn = DAG.getMachineFunction().getFunction();
DiagnosticInfoUnsupported BadLDSDecl(
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2919,7 +2919,7 @@ bool AMDGPULegalizerInfo::legalizeGlobalValue(

if (AS == AMDGPUAS::LOCAL_ADDRESS || AS == AMDGPUAS::REGION_ADDRESS) {
if (!MFI->isModuleEntryFunction() &&
!GV->getName().equals("llvm.amdgcn.module.lds")) {
GV->getName() != "llvm.amdgcn.module.lds") {
const Function &Fn = MF.getFunction();
DiagnosticInfoUnsupported BadLDSDecl(
Fn, "local memory global used by non-kernel function", MI.getDebugLoc(),
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ static std::pair<bool, bool> GetSignReturnAddress(const Function &F) {
}

StringRef Scope = F.getFnAttribute("sign-return-address").getValueAsString();
if (Scope.equals("none"))
if (Scope == "none")
return {false, false};

if (Scope.equals("all"))
if (Scope == "all")
return {true, true};

assert(Scope.equals("non-leaf"));
assert(Scope == "non-leaf");
return {true, false};
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/BPF/BTFDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ void BTFDebug::processDeclAnnotations(DINodeArray Annotations,
for (const Metadata *Annotation : Annotations->operands()) {
const MDNode *MD = cast<MDNode>(Annotation);
const MDString *Name = cast<MDString>(MD->getOperand(0));
if (!Name->getString().equals("btf_decl_tag"))
if (Name->getString() != "btf_decl_tag")
continue;

const MDString *Value = cast<MDString>(MD->getOperand(1));
Expand Down Expand Up @@ -627,7 +627,7 @@ int BTFDebug::genBTFTypeTags(const DIDerivedType *DTy, int BaseTypeId) {
for (const Metadata *Annotations : Annots->operands()) {
const MDNode *MD = cast<MDNode>(Annotations);
const MDString *Name = cast<MDString>(MD->getOperand(0));
if (!Name->getString().equals("btf_type_tag"))
if (Name->getString() != "btf_type_tag")
continue;
MDStrs.push_back(cast<MDString>(MD->getOperand(1)));
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static cl::opt<bool>
static bool isSmallDataSection(StringRef Sec) {
// sectionName is either ".sdata" or ".sbss". Looking for an exact match
// obviates the need for checks for section names such as ".sdatafoo".
if (Sec.equals(".sdata") || Sec.equals(".sbss") || Sec.equals(".scommon"))
if (Sec == ".sdata" || Sec == ".sbss" || Sec == ".scommon")
return true;
// If either ".sdata." or ".sbss." is a substring of the section name
// then put the symbol in small data.
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ StringRef Hexagon_MC::selectHexagonCPU(StringRef CPU) {
// non-tiny subtarget. See: addArchSubtarget
std::pair<StringRef, StringRef> ArchP = ArchV.split('t');
std::pair<StringRef, StringRef> CPUP = CPU.split('t');
if (!ArchP.first.equals(CPUP.first))
if (ArchP.first != CPUP.first)
report_fatal_error("conflicting architectures specified.");
return CPU;
}
Expand Down Expand Up @@ -578,7 +578,7 @@ MCSubtargetInfo *Hexagon_MC::createHexagonMCSubtargetInfo(const Triple &TT,
if (X != nullptr && (CPUName == "hexagonv67t" || CPUName == "hexagon71t"))
addArchSubtarget(X, ArchFS);

if (CPU.equals("help"))
if (CPU == "help")
exit(0);

if (!isCPUValid(CPUName.str())) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2896,7 +2896,7 @@ void PPCAIXAsmPrinter::emitPGORefs(Module &M) {
bool HasNonZeroLengthPrfCntsSection = false;
const DataLayout &DL = M.getDataLayout();
for (GlobalVariable &GV : M.globals())
if (GV.hasSection() && GV.getSection().equals("__llvm_prf_cnts") &&
if (GV.hasSection() && GV.getSection() == "__llvm_prf_cnts" &&
DL.getTypeAllocSize(GV.getValueType()) > 0) {
HasNonZeroLengthPrfCntsSection = true;
break;
Expand Down
7 changes: 4 additions & 3 deletions llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5302,9 +5302,10 @@ void PPCDAGToDAGISel::Select(SDNode *N) {
SDValue MDV = N->getOperand(MDIndex);
const MDNode *MD = cast<MDNodeSDNode>(MDV)->getMD();
assert(MD->getNumOperands() != 0 && "Empty MDNode in operands!");
assert((isa<MDString>(MD->getOperand(0)) && cast<MDString>(
MD->getOperand(0))->getString().equals("ppc-trap-reason"))
&& "Unsupported annotation data type!");
assert((isa<MDString>(MD->getOperand(0)) &&
cast<MDString>(MD->getOperand(0))->getString() ==
"ppc-trap-reason") &&
"Unsupported annotation data type!");
for (unsigned i = 1; i < MD->getNumOperands(); i++) {
assert(isa<MDString>(MD->getOperand(i)) &&
"Invalid data type for annotation ppc-trap-reason!");
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/PowerPC/PPCPreEmitPeephole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ static bool hasPCRelativeForm(MachineInstr &Use) {
bool runOnMachineFunction(MachineFunction &MF) override {
// If the user wants to set the DSCR using command-line options,
// load in the specified value at the start of main.
if (DSCRValue.getNumOccurrences() > 0 && MF.getName().equals("main") &&
if (DSCRValue.getNumOccurrences() > 0 && MF.getName() == "main" &&
MF.getFunction().hasExternalLinkage()) {
DSCRValue = (uint32_t)(DSCRValue & 0x01FFFFFF); // 25-bit DSCR mask
RegScavenger RS;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,7 @@ static bool buildNDRange(const SPIRV::IncomingCall *Call,
if (!MRI->getRegClassOrNull(GWSPtr))
MRI->setRegClass(GWSPtr, &SPIRV::IDRegClass);
// TODO: Maybe simplify generation of the type of the fields.
unsigned Size = Call->Builtin->Name.equals("ndrange_3D") ? 3 : 2;
unsigned Size = Call->Builtin->Name == "ndrange_3D" ? 3 : 2;
unsigned BitWidth = GR->getPointerSize() == 64 ? 64 : 32;
Type *BaseTy = IntegerType::get(MF.getFunction().getContext(), BitWidth);
Type *FieldTy = ArrayType::get(BaseTy, Size);
Expand Down
18 changes: 9 additions & 9 deletions llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,44 +1377,44 @@ MCRegister SparcAsmParser::matchRegisterName(const AsmToken &Tok,
return IntRegs[RegNo];
}

if (Name.equals("xcc")) {
if (Name == "xcc") {
// FIXME:: check 64bit.
RegKind = SparcOperand::rk_Special;
return SP::ICC;
}

// JPS1 extension - aliases for ASRs
// Section A.51 - Read State Register
if (Name.equals("pcr")) {
if (Name == "pcr") {
RegKind = SparcOperand::rk_Special;
return SP::ASR16;
}

if (Name.equals("pic")) {
if (Name == "pic") {
RegKind = SparcOperand::rk_Special;
return SP::ASR17;
}
if (Name.equals("dcr")) {
if (Name == "dcr") {
RegKind = SparcOperand::rk_Special;
return SP::ASR18;
}
if (Name.equals("gsr")) {
if (Name == "gsr") {
RegKind = SparcOperand::rk_Special;
return SP::ASR19;
}
if (Name.equals("softint")) {
if (Name == "softint") {
RegKind = SparcOperand::rk_Special;
return SP::ASR22;
}
if (Name.equals("tick_cmpr")) {
if (Name == "tick_cmpr") {
RegKind = SparcOperand::rk_Special;
return SP::ASR23;
}
if (Name.equals("stick") || Name.equals("sys_tick")) {
if (Name == "stick" || Name == "sys_tick") {
RegKind = SparcOperand::rk_Special;
return SP::ASR24;
}
if (Name.equals("stick_cmpr") || Name.equals("sys_tick_cmpr")) {
if (Name == "stick_cmpr" || Name == "sys_tick_cmpr") {
RegKind = SparcOperand::rk_Special;
return SP::ASR25;
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2296,7 +2296,7 @@ bool X86AsmParser::ParseRoundingModeOp(SMLoc Start, OperandVector &Operands) {
Operands.push_back(X86Operand::CreateImm(RndModeOp, Start, End));
return false;
}
if(Tok.getIdentifier().equals("sae")){
if (Tok.getIdentifier() == "sae") {
Parser.Lex(); // Eat the sae
if (!getLexer().is(AsmToken::RCurly))
return Error(Tok.getLoc(), "Expected } at this point");
Expand Down Expand Up @@ -2567,7 +2567,7 @@ bool X86AsmParser::ParseIntelMemoryOperandSize(unsigned &Size) {
.Default(0);
if (Size) {
const AsmToken &Tok = Lex(); // Eat operand size (e.g., byte, word).
if (!(Tok.getString().equals("PTR") || Tok.getString().equals("ptr")))
if (!(Tok.getString() == "PTR" || Tok.getString() == "ptr"))
return Error(Tok.getLoc(), "Expected 'PTR' or 'ptr' token!");
Lex(); // Eat ptr.
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/X86/X86InstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3570,7 +3570,7 @@ bool X86InstrInfo::canMakeTailCallConditional(
if (Target.isSymbol()) {
StringRef Symbol(Target.getSymbolName());
// this is currently only relevant to r11/kernel indirect thunk.
if (Symbol.equals("__x86_indirect_thunk_r11"))
if (Symbol == "__x86_indirect_thunk_r11")
return false;
}
}
Expand Down