Skip to content
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

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

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/Transforms/Coroutines/CoroSplit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1846,11 +1846,10 @@ static void splitAsyncCoroutine(Function &F, coro::Shape &Shape,
auto ProjectionFunctionName =
Suspend->getAsyncContextProjectionFunction()->getName();
bool UseSwiftMangling = false;
if (ProjectionFunctionName.equals("__swift_async_resume_project_context")) {
if (ProjectionFunctionName == "__swift_async_resume_project_context") {
ResumeNameSuffix = "TQ";
UseSwiftMangling = true;
} else if (ProjectionFunctionName.equals(
"__swift_async_resume_get_context")) {
} else if (ProjectionFunctionName == "__swift_async_resume_get_context") {
ResumeNameSuffix = "TY";
UseSwiftMangling = true;
}
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/IPO/BlockExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ bool BlockExtractor::runOnModule(Module &M) {
report_fatal_error("Invalid function name specified in the input file",
/*GenCrashDiag=*/false);
for (const auto &BBInfo : BInfo.second) {
auto Res = llvm::find_if(*F, [&](const BasicBlock &BB) {
return BB.getName().equals(BBInfo);
});
auto Res = llvm::find_if(
*F, [&](const BasicBlock &BB) { return BB.getName() == BBInfo; });
if (Res == F->end())
report_fatal_error("Invalid block name specified in the input file",
/*GenCrashDiag=*/false);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,7 @@ static bool annotateAllFunctions(
HotFunctions.push_back(&F);
if (PGOViewCounts != PGOVCT_None &&
(ViewBlockFreqFuncName.empty() ||
F.getName().equals(ViewBlockFreqFuncName))) {
F.getName() == ViewBlockFreqFuncName)) {
LoopInfo LI{DominatorTree(F)};
std::unique_ptr<BranchProbabilityInfo> NewBPI =
std::make_unique<BranchProbabilityInfo>(F, LI);
Expand All @@ -2140,7 +2140,7 @@ static bool annotateAllFunctions(
}
if (PGOViewRawCounts != PGOVCT_None &&
(ViewBlockFreqFuncName.empty() ||
F.getName().equals(ViewBlockFreqFuncName))) {
F.getName() == ViewBlockFreqFuncName)) {
if (PGOViewRawCounts == PGOVCT_Graph)
if (ViewBlockFreqFuncName.empty())
WriteGraph(&Func, Twine("PGORawCounts_") + Func.getFunc().getName());
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/ADCE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ bool AggressiveDeadCodeElimination::isInstrumentsConstant(Instruction &I) {
// TODO -- move this test into llvm::isInstructionTriviallyDead
if (CallInst *CI = dyn_cast<CallInst>(&I))
if (Function *Callee = CI->getCalledFunction())
if (Callee->getName().equals(getInstrProfValueProfFuncName()))
if (Callee->getName() == getInstrProfValueProfFuncName())
if (isa<Constant>(CI->getArgOperand(0)))
return true;
return false;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ static Instruction *findLocationForEntrySafepoint(Function &F,
const char GCSafepointPollName[] = "gc.safepoint_poll";

static bool isGCSafepointPoll(Function &F) {
return F.getName().equals(GCSafepointPollName);
return F.getName() == GCSafepointPollName;
}

/// Returns true if this function should be rewritten to include safepoint
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1685,10 +1685,10 @@ makeStatepointExplicitImpl(CallBase *Call, /* to replace */

// Pass through the requested lowering if any. The default is live-through.
StringRef DeoptLowering = getDeoptLowering(Call);
if (DeoptLowering.equals("live-in"))
if (DeoptLowering == "live-in")
Flags |= uint32_t(StatepointFlags::DeoptLiveIn);
else {
assert(DeoptLowering.equals("live-through") && "Unsupported value!");
assert(DeoptLowering == "live-through" && "Unsupported value!");
}

FunctionCallee CallTarget(Call->getFunctionType(), Call->getCalledOperand());
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/LoopUnroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ MDNode *llvm::GetUnrollMetadata(MDNode *LoopID, StringRef Name) {
if (!S)
continue;

if (Name.equals(S->getString()))
if (Name == S->getString())
return MD;
}
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/LoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void llvm::addStringMetadataToLoop(Loop *TheLoop, const char *StringMD,
// If it is of form key = value, try to parse it.
if (Node->getNumOperands() == 2) {
MDString *S = dyn_cast<MDString>(Node->getOperand(0));
if (S && S->getString().equals(StringMD)) {
if (S && S->getString() == StringMD) {
ConstantInt *IntMD =
mdconst::extract_or_null<ConstantInt>(Node->getOperand(1));
if (IntMD && IntMD->getSExtValue() == V)
Expand Down
26 changes: 13 additions & 13 deletions llvm/lib/Transforms/Utils/SymbolRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ bool RewriteMapParser::parseEntry(yaml::Stream &YS, yaml::KeyValueNode &Entry,
}

RewriteType = Key->getValue(KeyStorage);
if (RewriteType.equals("function"))
if (RewriteType == "function")
return parseRewriteFunctionDescriptor(YS, Key, Value, DL);
else if (RewriteType.equals("global variable"))
else if (RewriteType == "global variable")
return parseRewriteGlobalVariableDescriptor(YS, Key, Value, DL);
else if (RewriteType.equals("global alias"))
else if (RewriteType == "global alias")
return parseRewriteGlobalAliasDescriptor(YS, Key, Value, DL);

YS.printError(Entry.getKey(), "unknown rewrite type");
Expand Down Expand Up @@ -348,19 +348,19 @@ parseRewriteFunctionDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
}

KeyValue = Key->getValue(KeyStorage);
if (KeyValue.equals("source")) {
if (KeyValue == "source") {
std::string Error;

Source = std::string(Value->getValue(ValueStorage));
if (!Regex(Source).isValid(Error)) {
YS.printError(Field.getKey(), "invalid regex: " + Error);
return false;
}
} else if (KeyValue.equals("target")) {
} else if (KeyValue == "target") {
Target = std::string(Value->getValue(ValueStorage));
} else if (KeyValue.equals("transform")) {
} else if (KeyValue == "transform") {
Transform = std::string(Value->getValue(ValueStorage));
} else if (KeyValue.equals("naked")) {
} else if (KeyValue == "naked") {
std::string Undecorated;

Undecorated = std::string(Value->getValue(ValueStorage));
Expand Down Expand Up @@ -417,17 +417,17 @@ parseRewriteGlobalVariableDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
}

KeyValue = Key->getValue(KeyStorage);
if (KeyValue.equals("source")) {
if (KeyValue == "source") {
std::string Error;

Source = std::string(Value->getValue(ValueStorage));
if (!Regex(Source).isValid(Error)) {
YS.printError(Field.getKey(), "invalid regex: " + Error);
return false;
}
} else if (KeyValue.equals("target")) {
} else if (KeyValue == "target") {
Target = std::string(Value->getValue(ValueStorage));
} else if (KeyValue.equals("transform")) {
} else if (KeyValue == "transform") {
Transform = std::string(Value->getValue(ValueStorage));
} else {
YS.printError(Field.getKey(), "unknown Key for Global Variable");
Expand Down Expand Up @@ -480,17 +480,17 @@ parseRewriteGlobalAliasDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
}

KeyValue = Key->getValue(KeyStorage);
if (KeyValue.equals("source")) {
if (KeyValue == "source") {
std::string Error;

Source = std::string(Value->getValue(ValueStorage));
if (!Regex(Source).isValid(Error)) {
YS.printError(Field.getKey(), "invalid regex: " + Error);
return false;
}
} else if (KeyValue.equals("target")) {
} else if (KeyValue == "target") {
Target = std::string(Value->getValue(ValueStorage));
} else if (KeyValue.equals("transform")) {
} else if (KeyValue == "transform") {
Transform = std::string(Value->getValue(ValueStorage));
} else {
YS.printError(Field.getKey(), "unknown key for Global Alias");
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Transforms/Utils/LocalTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ TEST(Local, SimplifyCFGWithNullAC) {
// Obtain BasicBlock of interest to this test, %test.bb.
BasicBlock *TestBB = nullptr;
for (BasicBlock &BB : F) {
if (BB.getName().equals("test.bb")) {
if (BB.getName() == "test.bb") {
TestBB = &BB;
break;
}
Expand Down
Loading