Skip to content

Commit 00754b7

Browse files
[SYCL][NFC] Modernize use of StringRef::startswith (#12406)
The method was deprecated in favor of `StringRef::starts_with` in llvm/llvm-project#75491
1 parent 82a83f0 commit 00754b7

10 files changed

+39
-39
lines changed

llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ attributeToExecModeMetadata(const Attribute &Attr, Function &F) {
309309
return std::nullopt;
310310
StringRef AttrKindStr = Attr.getKindAsString();
311311
// Early exit if it is not a sycl-* attribute.
312-
if (!AttrKindStr.startswith("sycl-"))
312+
if (!AttrKindStr.starts_with("sycl-"))
313313
return std::nullopt;
314314

315315
auto AddFPControlMetadataForWidth = [&](int32_t SPIRVFPControl,

llvm/lib/SYCLLowerIR/ESIMD/ESIMDRemoveHostCode.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ PreservedAnalyses ESIMDRemoveHostCodePass::run(Module &M,
5050
id::OutputBuffer NameBuf;
5151
NameNode->print(NameBuf);
5252
StringRef Name(NameBuf.getBuffer(), NameBuf.getCurrentPosition());
53-
if (!Name.startswith("sycl::_V1::ext::intel::esimd::") &&
54-
!Name.startswith("sycl::_V1::ext::intel::experimental::esimd::"))
53+
if (!Name.starts_with("sycl::_V1::ext::intel::esimd::") &&
54+
!Name.starts_with("sycl::_V1::ext::intel::experimental::esimd::"))
5555
continue;
5656
SmallVector<BasicBlock *> BBV;
5757
for (BasicBlock &BB : F) {

llvm/lib/SYCLLowerIR/ESIMD/ESIMDUtils.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,31 @@ constexpr char SLM_ALLOCATOR_DTOR_SUFFIX[] = "EED2Ev";
3333

3434
bool isSlmAllocatorConstructor(const Function &F) {
3535
auto Name = F.getName();
36-
return Name.startswith(SLM_ALLOCATOR_CTOR_DTOR_PREFIX) &&
36+
return Name.starts_with(SLM_ALLOCATOR_CTOR_DTOR_PREFIX) &&
3737
Name.endswith(SLM_ALLOCATOR_CTOR_SUFFIX);
3838
}
3939

4040
bool isSlmAllocatorDestructor(const Function &F) {
4141
auto Name = F.getName();
42-
return Name.startswith(SLM_ALLOCATOR_CTOR_DTOR_PREFIX) &&
42+
return Name.starts_with(SLM_ALLOCATOR_CTOR_DTOR_PREFIX) &&
4343
Name.endswith(SLM_ALLOCATOR_DTOR_SUFFIX);
4444
}
4545

4646
bool isSlmInit(const Function &F) {
47-
return F.getName().startswith(SLM_INIT_PREFIX);
47+
return F.getName().starts_with(SLM_INIT_PREFIX);
4848
}
4949

5050
bool isSlmAlloc(const Function &F) {
51-
return F.getName().startswith(SLM_ALLOC_PREFIX);
51+
return F.getName().starts_with(SLM_ALLOC_PREFIX);
5252
}
5353

5454
bool isSlmFree(const Function &F) {
55-
return F.getName().startswith(SLM_FREE_PREFIX);
55+
return F.getName().starts_with(SLM_FREE_PREFIX);
5656
}
5757

5858
bool isAssertFail(const Function &F) {
59-
return F.getName().startswith("__assert_fail") ||
60-
F.getName().startswith("__devicelib_assert_fail");
59+
return F.getName().starts_with("__assert_fail") ||
60+
F.getName().starts_with("__devicelib_assert_fail");
6161
}
6262

6363
bool isESIMD(const Function &F) {

llvm/lib/SYCLLowerIR/ESIMD/ESIMDVerifier.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ class ESIMDVerifierImpl {
150150

151151
// We are interested in functions defined in SYCL namespace, but
152152
// outside of ESIMD namespaces.
153-
if (!Name.startswith("sycl::_V1::") ||
154-
Name.startswith("sycl::_V1::detail::") ||
155-
Name.startswith("sycl::_V1::ext::intel::esimd::") ||
156-
Name.startswith("sycl::_V1::ext::intel::experimental::esimd::"))
153+
if (!Name.starts_with("sycl::_V1::") ||
154+
Name.starts_with("sycl::_V1::detail::") ||
155+
Name.starts_with("sycl::_V1::ext::intel::esimd::") ||
156+
Name.starts_with("sycl::_V1::ext::intel::experimental::esimd::"))
157157
continue;
158158

159159
// Check if function name matches any allowed SYCL function name.

llvm/lib/SYCLLowerIR/ESIMD/LowerESIMD.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -704,17 +704,17 @@ static std::string mangleFunction(StringRef FunctionName) {
704704
// These functions are defined as extern "C" which Demangler that is used
705705
// fails to handle properly.
706706
if (isDevicelibFunction(FunctionName)) {
707-
if (FunctionName.startswith("__devicelib_ConvertFToBF16INTEL")) {
707+
if (FunctionName.starts_with("__devicelib_ConvertFToBF16INTEL")) {
708708
return (Twine("_Z31") + FunctionName + "RKf").str();
709709
}
710-
if (FunctionName.startswith("__devicelib_ConvertBF16ToFINTEL")) {
710+
if (FunctionName.starts_with("__devicelib_ConvertBF16ToFINTEL")) {
711711
return (Twine("_Z31") + FunctionName + "RKt").str();
712712
}
713713
}
714714
// Every inserted vstore gets its own function with the same name,
715715
// so they are mangled with ".[0-9]+". Just use the
716716
// raw name to pass through the demangler.
717-
if (FunctionName.startswith(ESIMD_INSERTED_VSTORE_FUNC_NAME))
717+
if (FunctionName.starts_with(ESIMD_INSERTED_VSTORE_FUNC_NAME))
718718
return ESIMD_INSERTED_VSTORE_FUNC_NAME;
719719
return FunctionName.str();
720720
}
@@ -1968,36 +1968,36 @@ size_t SYCLLowerESIMDPass::runOnFunction(Function &F,
19681968
// process ESIMD builtins that go through special handling instead of
19691969
// the translation procedure
19701970

1971-
if (Name.startswith("__esimd_svm_block_ld") ||
1972-
Name.startswith("__esimd_slm_block_ld")) {
1973-
translateBlockLoad(*CI, Name.startswith("__esimd_slm_block_ld"));
1971+
if (Name.starts_with("__esimd_svm_block_ld") ||
1972+
Name.starts_with("__esimd_slm_block_ld")) {
1973+
translateBlockLoad(*CI, Name.starts_with("__esimd_slm_block_ld"));
19741974
ToErase.push_back(CI);
19751975
continue;
19761976
}
1977-
if (Name.startswith("__esimd_svm_block_st") ||
1978-
Name.startswith("__esimd_slm_block_st")) {
1979-
translateBlockStore(*CI, Name.startswith("__esimd_slm_block_st"));
1977+
if (Name.starts_with("__esimd_svm_block_st") ||
1978+
Name.starts_with("__esimd_slm_block_st")) {
1979+
translateBlockStore(*CI, Name.starts_with("__esimd_slm_block_st"));
19801980
ToErase.push_back(CI);
19811981
continue;
19821982
}
1983-
if (Name.startswith("__esimd_gather_ld") ||
1984-
Name.startswith("__esimd_slm_gather_ld")) {
1985-
translateGatherLoad(*CI, Name.startswith("__esimd_slm_gather_ld"));
1983+
if (Name.starts_with("__esimd_gather_ld") ||
1984+
Name.starts_with("__esimd_slm_gather_ld")) {
1985+
translateGatherLoad(*CI, Name.starts_with("__esimd_slm_gather_ld"));
19861986
ToErase.push_back(CI);
19871987
continue;
19881988
}
19891989

1990-
if (Name.startswith("__esimd_nbarrier_init")) {
1990+
if (Name.starts_with("__esimd_nbarrier_init")) {
19911991
translateNbarrierInit(*CI);
19921992
ToErase.push_back(CI);
19931993
continue;
19941994
}
1995-
if (Name.startswith("__esimd_pack_mask")) {
1995+
if (Name.starts_with("__esimd_pack_mask")) {
19961996
translatePackMask(*CI);
19971997
ToErase.push_back(CI);
19981998
continue;
19991999
}
2000-
if (Name.startswith("__esimd_unpack_mask")) {
2000+
if (Name.starts_with("__esimd_unpack_mask")) {
20012001
translateUnPackMask(*CI);
20022002
ToErase.push_back(CI);
20032003
continue;
@@ -2006,21 +2006,21 @@ size_t SYCLLowerESIMDPass::runOnFunction(Function &F,
20062006
// those globals marked as genx_volatile, We can translate
20072007
// them directly into generic load/store inst. In this way
20082008
// those insts can be optimized by llvm ASAP.
2009-
if (Name.startswith("__esimd_vload")) {
2009+
if (Name.starts_with("__esimd_vload")) {
20102010
if (translateVLoad(*CI, GVTS)) {
20112011
ToErase.push_back(CI);
20122012
continue;
20132013
}
20142014
}
2015-
if (Name.startswith("__esimd_vstore")) {
2015+
if (Name.starts_with("__esimd_vstore")) {
20162016
if (translateVStore(*CI, GVTS)) {
20172017
ToErase.push_back(CI);
20182018
continue;
20192019
}
20202020
}
20212021

20222022
if (Name.empty() ||
2023-
(!Name.startswith(ESIMD_INTRIN_PREF1) && !isDevicelibFunction(Name)))
2023+
(!Name.starts_with(ESIMD_INTRIN_PREF1) && !isDevicelibFunction(Name)))
20242024
continue;
20252025
// this is ESIMD intrinsic - record for later translation
20262026
ESIMDIntrCalls.push_back(CI);
@@ -2045,7 +2045,7 @@ size_t SYCLLowerESIMDPass::runOnFunction(Function &F,
20452045
}
20462046

20472047
if (!isa<GlobalVariable>(SpirvGlobal) ||
2048-
!SpirvGlobal->getName().startswith(SPIRV_INTRIN_PREF))
2048+
!SpirvGlobal->getName().starts_with(SPIRV_INTRIN_PREF))
20492049
continue;
20502050

20512051
auto PrefLen = StringRef(SPIRV_INTRIN_PREF).size();

llvm/lib/SYCLLowerIR/LowerInvokeSimd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ std::pair<Value *, Value *>
8888
getHelperAndInvokeeIfInvokeSimdCall(const CallInst *CI) {
8989
Function *F = CI->getCalledFunction();
9090

91-
if (F && F->getName().startswith(esimd::INVOKE_SIMD_PREF)) {
91+
if (F && F->getName().starts_with(esimd::INVOKE_SIMD_PREF)) {
9292
return {CI->getArgOperand(0), CI->getArgOperand(1)};
9393
}
9494
return {nullptr, nullptr};
@@ -426,7 +426,7 @@ PreservedAnalyses SYCLLowerInvokeSimdPass::run(Module &M,
426426

427427
for (Function &F : M) {
428428
if (!F.isDeclaration() ||
429-
!F.getName().startswith(esimd::INVOKE_SIMD_PREF)) {
429+
!F.getName().starts_with(esimd::INVOKE_SIMD_PREF)) {
430430
continue;
431431
}
432432
SmallVector<User *, 4> Users(F.users());

llvm/lib/SYCLLowerIR/MutatePrintfAddrspace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ SYCLMutatePrintfAddrspacePass::run(Module &M, ModuleAnalysisManager &MAM) {
7878
for (Function &F : M) {
7979
if (!F.isDeclaration())
8080
continue;
81-
if (!F.getName().startswith("_Z18__spirv_ocl_printf"))
81+
if (!F.getName().starts_with("_Z18__spirv_ocl_printf"))
8282
continue;
8383
if (F.getArg(0)->getType() == CASLiteralType)
8484
// No need to replace the literal type and its printf users

llvm/lib/SYCLLowerIR/RenameKernelSYCLNativeCPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static bool isSpirvSyclBuiltin(StringRef FName) {
2323
// now skip the digits
2424
FName = FName.drop_while([](char C) { return std::isdigit(C); });
2525

26-
return FName.startswith("__spirv_") || FName.startswith("__sycl_");
26+
return FName.starts_with("__spirv_") || FName.starts_with("__sycl_");
2727
}
2828

2929
PreservedAnalyses

llvm/lib/SYCLLowerIR/SYCLPropagateAspectsUsage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ bool isSpirvSyclBuiltin(StringRef FName) {
508508
// now skip the digits
509509
FName = FName.drop_while([](char C) { return std::isdigit(C); });
510510

511-
return FName.startswith("__spirv_") || FName.startswith("__sycl_");
511+
return FName.starts_with("__spirv_") || FName.starts_with("__sycl_");
512512
}
513513

514514
bool isEntryPoint(const Function &F) {

llvm/lib/SYCLLowerIR/SYCLPropagateJointMatrixUsage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ bool isSpirvSyclBuiltin(StringRef FName) {
4141
// now skip the digits
4242
FName = FName.drop_while([](char C) { return std::isdigit(C); });
4343

44-
return FName.startswith("__spirv_") || FName.startswith("__sycl_");
44+
return FName.starts_with("__spirv_") || FName.starts_with("__sycl_");
4545
}
4646

4747
bool isEntryPoint(const Function &F) {

0 commit comments

Comments
 (0)