Skip to content

Commit adf1f52

Browse files
authored
Update for StringRef::{starts,ends}with deprecation (#2272)
Replace with the {starts,ends}_with variants, after LLVM commit 5ac12951b4e9 ("[ADT] Deprecate StringRef::{starts,ends}with (#75491)", 2023-12-17). This is a mechanical change applied using: git grep -l startswith | xargs sed -i -e 's/startswith/starts_with/g' git grep -l endswith | xargs sed -i -e 's/endswith/ends_with/g'
1 parent 8e6f467 commit adf1f52

12 files changed

+127
-127
lines changed

lib/SPIRV/LLVMSPIRVOpts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ bool TranslatorOpts::isUnknownIntrinsicAllowed(IntrinsicInst *II) const
5454
const auto &IntrinsicPrefixList = SPIRVAllowUnknownIntrinsics.value();
5555
StringRef IntrinsicName = II->getCalledOperand()->getName();
5656
for (const auto &Prefix : IntrinsicPrefixList) {
57-
if (IntrinsicName.startswith(Prefix)) // Also true if `Prefix` is empty
57+
if (IntrinsicName.starts_with(Prefix)) // Also true if `Prefix` is empty
5858
return true;
5959
}
6060
return false;

lib/SPIRV/OCLToSPIRV.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ static Type *getBlockStructType(Value *Parameter) {
9090
/// for a demangled function name, or 0 if the function does not return an
9191
/// integer type (e.g. read_imagef).
9292
static unsigned getImageSignZeroExt(StringRef DemangledName) {
93-
bool IsSigned = !DemangledName.endswith("ui") && DemangledName.back() == 'i';
94-
bool IsUnsigned = DemangledName.endswith("ui");
93+
bool IsSigned = !DemangledName.ends_with("ui") && DemangledName.back() == 'i';
94+
bool IsUnsigned = DemangledName.ends_with("ui");
9595

9696
if (IsSigned)
9797
return ImageOperandsMask::ImageOperandsSignExtendMask;
@@ -327,8 +327,8 @@ void OCLToSPIRVBase::visitCallInst(CallInst &CI) {
327327
}
328328
if (DemangledName == kOCLBuiltinName::Dot ||
329329
DemangledName == kOCLBuiltinName::DotAccSat ||
330-
DemangledName.startswith(kOCLBuiltinName::Dot4x8PackedPrefix) ||
331-
DemangledName.startswith(kOCLBuiltinName::DotAccSat4x8PackedPrefix)) {
330+
DemangledName.starts_with(kOCLBuiltinName::Dot4x8PackedPrefix) ||
331+
DemangledName.starts_with(kOCLBuiltinName::DotAccSat4x8PackedPrefix)) {
332332
if (CI.getOperand(0)->getType()->isVectorTy()) {
333333
auto *VT = (VectorType *)(CI.getOperand(0)->getType());
334334
if (!isa<llvm::IntegerType>(VT->getElementType())) {
@@ -554,9 +554,9 @@ void OCLToSPIRVBase::transMemoryBarrier(CallInst *CI,
554554
void OCLToSPIRVBase::visitCallAtomicLegacy(CallInst *CI, StringRef MangledName,
555555
StringRef DemangledName) {
556556
StringRef Stem = DemangledName;
557-
if (Stem.startswith("atom_"))
557+
if (Stem.starts_with("atom_"))
558558
Stem = Stem.drop_front(strlen("atom_"));
559-
else if (Stem.startswith("atomic_"))
559+
else if (Stem.starts_with("atomic_"))
560560
Stem = Stem.drop_front(strlen("atomic_"));
561561
else
562562
return;
@@ -586,7 +586,7 @@ void OCLToSPIRVBase::visitCallAtomicLegacy(CallInst *CI, StringRef MangledName,
586586
Info.UniqName = "atomic_" + Prefix + Sign + Stem.str() + Postfix;
587587
std::vector<int> PostOps;
588588
PostOps.push_back(OCLLegacyAtomicMemOrder);
589-
if (Stem.startswith("compare_exchange"))
589+
if (Stem.starts_with("compare_exchange"))
590590
PostOps.push_back(OCLLegacyAtomicMemOrder);
591591
PostOps.push_back(OCLLegacyAtomicMemScope);
592592

@@ -601,24 +601,24 @@ void OCLToSPIRVBase::visitCallAtomicLegacy(CallInst *CI, StringRef MangledName,
601601
void OCLToSPIRVBase::visitCallAtomicCpp11(CallInst *CI, StringRef MangledName,
602602
StringRef DemangledName) {
603603
StringRef Stem = DemangledName;
604-
if (Stem.startswith("atomic_"))
604+
if (Stem.starts_with("atomic_"))
605605
Stem = Stem.drop_front(strlen("atomic_"));
606606
else
607607
return;
608608

609609
std::string NewStem(Stem);
610610
std::vector<int> PostOps;
611-
if (Stem.startswith("store") || Stem.startswith("load") ||
612-
Stem.startswith("exchange") || Stem.startswith("compare_exchange") ||
613-
Stem.startswith("fetch") || Stem.startswith("flag")) {
614-
if ((Stem.startswith("fetch_min") || Stem.startswith("fetch_max")) &&
611+
if (Stem.starts_with("store") || Stem.starts_with("load") ||
612+
Stem.starts_with("exchange") || Stem.starts_with("compare_exchange") ||
613+
Stem.starts_with("fetch") || Stem.starts_with("flag")) {
614+
if ((Stem.starts_with("fetch_min") || Stem.starts_with("fetch_max")) &&
615615
containsUnsignedAtomicType(MangledName))
616616
NewStem.insert(NewStem.begin() + strlen("fetch_"), 'u');
617617

618-
if (!Stem.endswith("_explicit")) {
618+
if (!Stem.ends_with("_explicit")) {
619619
NewStem = NewStem + "_explicit";
620620
PostOps.push_back(OCLMO_seq_cst);
621-
if (Stem.startswith("compare_exchange"))
621+
if (Stem.starts_with("compare_exchange"))
622622
PostOps.push_back(OCLMO_seq_cst);
623623
PostOps.push_back(OCLMS_device);
624624
} else {
@@ -793,7 +793,7 @@ void OCLToSPIRVBase::visitCallGroupBuiltin(CallInst *CI,
793793
FuncName = FuncName.drop_front(strlen(kSPIRVName::GroupPrefix));
794794
SPIRSPIRVGroupOperationMap::foreachConditional(
795795
[&](const std::string &S, SPIRVGroupOperationKind G) {
796-
if (!FuncName.startswith(S))
796+
if (!FuncName.starts_with(S))
797797
return true; // continue
798798
PreOps.push_back(G);
799799
StringRef Op =
@@ -887,7 +887,7 @@ void OCLToSPIRVBase::transBuiltin(CallInst *CI, OCLBuiltinTransInfo &Info) {
887887
Op OC = OpNop;
888888
unsigned ExtOp = ~0U;
889889
SPIRVBuiltinVariableKind BVKind = BuiltInMax;
890-
if (StringRef(Info.UniqName).startswith(kSPIRVName::Prefix))
890+
if (StringRef(Info.UniqName).starts_with(kSPIRVName::Prefix))
891891
return;
892892
if (OCLSPIRVBuiltinMap::find(Info.UniqName, &OC)) {
893893
if (OC == OpImageRead) {
@@ -1222,7 +1222,7 @@ void OCLToSPIRVBase::visitCallDot(CallInst *CI, StringRef MangledName,
12221222
// dot(short2, ushort2) _Z3dotDv2_sDv2_t
12231223
// dot(ushort2, short2) _Z3dotDv2_tDv2_s
12241224
// dot(ushort2, ushort2) _Z3dotDv2_tS_
1225-
assert(MangledName.startswith("_Z3dotDv"));
1225+
assert(MangledName.starts_with("_Z3dotDv"));
12261226
if (MangledName[MangledName.size() - 1] == '_') {
12271227
IsFirstSigned = ((MangledName[MangledName.size() - 3] == 'c') ||
12281228
(MangledName[MangledName.size() - 3] == 's'));
@@ -1243,7 +1243,7 @@ void OCLToSPIRVBase::visitCallDot(CallInst *CI, StringRef MangledName,
12431243
// dot_acc_sat(short2, ushort2, int) _Z11dot_acc_satDv4_sDv4_ti
12441244
// dot_acc_sat(ushort2, short2, int) _Z11dot_acc_satDv4_tDv4_si
12451245
// dot_acc_sat(ushort2, ushort2, uint) _Z11dot_acc_satDv4_tS_j
1246-
assert(MangledName.startswith("_Z11dot_acc_satDv"));
1246+
assert(MangledName.starts_with("_Z11dot_acc_satDv"));
12471247
IsFirstSigned = ((MangledName[19] == 'c') || (MangledName[19] == 's'));
12481248
IsSecondSigned = (MangledName[20] == 'S'
12491249
? IsFirstSigned
@@ -1265,10 +1265,10 @@ void OCLToSPIRVBase::visitCallDot(CallInst *CI, StringRef MangledName,
12651265
// _Z28dot_acc_sat_4x8packed_us_intjji
12661266
// dot_acc_sat_4x8packed_uu_uint(uint, uint, uint)
12671267
// _Z29dot_acc_sat_4x8packed_uu_uintjjj
1268-
assert(MangledName.startswith("_Z20dot_4x8packed") ||
1269-
MangledName.startswith("_Z21dot_4x8packed") ||
1270-
MangledName.startswith("_Z28dot_acc_sat_4x8packed") ||
1271-
MangledName.startswith("_Z29dot_acc_sat_4x8packed"));
1268+
assert(MangledName.starts_with("_Z20dot_4x8packed") ||
1269+
MangledName.starts_with("_Z21dot_4x8packed") ||
1270+
MangledName.starts_with("_Z28dot_acc_sat_4x8packed") ||
1271+
MangledName.starts_with("_Z29dot_acc_sat_4x8packed"));
12721272
size_t SignIndex = IsAccSat
12731273
? strlen(kOCLBuiltinName::DotAccSat4x8PackedPrefix)
12741274
: strlen(kOCLBuiltinName::Dot4x8PackedPrefix);
@@ -1582,7 +1582,7 @@ static const char *getSubgroupAVCIntelTyKind(StringRef MangledName) {
15821582
// We're looking for the type name of the last parameter, which will be at the
15831583
// very end of the mangled name. Since we only care about the ending of the
15841584
// name, we don't need to be any more clever than this.
1585-
return MangledName.endswith("_payload_t") ? "payload" : "result";
1585+
return MangledName.ends_with("_payload_t") ? "payload" : "result";
15861586
}
15871587

15881588
static Type *getSubgroupAVCIntelMCEType(Module *M, std::string &TName) {

lib/SPIRV/OCLTypeToSPIRV.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void OCLTypeToSPIRVBase::adaptFunctionArguments(Function *F) {
223223
auto STName = NewTy->getStructName();
224224
if (!hasAccessQualifiedName(STName))
225225
continue;
226-
if (STName.startswith(kSPR2TypeName::ImagePrefix)) {
226+
if (STName.starts_with(kSPR2TypeName::ImagePrefix)) {
227227
auto Ty = STName.str();
228228
auto Acc = getAccessQualifier(Ty);
229229
auto Desc = getImageDescriptor(ParamTys[I]);
@@ -251,7 +251,7 @@ void OCLTypeToSPIRVBase::adaptArgumentsByMetadata(Function *F) {
251251
if (OCLTyStr == OCL_TYPE_NAME_SAMPLER_T) {
252252
addAdaptedType(&(*Arg), getSPIRVType(OpTypeSampler));
253253
Changed = true;
254-
} else if (OCLTyStr.startswith("image") && OCLTyStr.endswith("_t")) {
254+
} else if (OCLTyStr.starts_with("image") && OCLTyStr.ends_with("_t")) {
255255
auto Ty = (Twine("opencl.") + OCLTyStr).str();
256256
if (auto *STy = StructType::getTypeByName(F->getContext(), Ty)) {
257257
auto *ImageTy = TypedPointerType::get(STy, SPIRAS_Global);

lib/SPIRV/OCLUtil.cpp

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ AtomicWorkItemFenceLiterals getAtomicWorkItemFenceLiterals(CallInst *CI) {
676676
}
677677

678678
size_t getAtomicBuiltinNumMemoryOrderArgs(StringRef Name) {
679-
if (Name.startswith("atomic_compare_exchange"))
679+
if (Name.starts_with("atomic_compare_exchange"))
680680
return 2;
681681
return 1;
682682
}
@@ -691,8 +691,8 @@ size_t getSPIRVAtomicBuiltinNumMemoryOrderArgs(Op OC) {
691691
// max]_explicit functions declared in clang headers should be translated
692692
// to corresponding FP-typed Atomic Instructions
693693
bool isComputeAtomicOCLBuiltin(StringRef DemangledName) {
694-
if (!DemangledName.startswith(kOCLBuiltinName::AtomicPrefix) &&
695-
!DemangledName.startswith(kOCLBuiltinName::AtomPrefix))
694+
if (!DemangledName.starts_with(kOCLBuiltinName::AtomicPrefix) &&
695+
!DemangledName.starts_with(kOCLBuiltinName::AtomPrefix))
696696
return false;
697697

698698
return llvm::StringSwitch<bool>(DemangledName)
@@ -1027,12 +1027,12 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
10271027
NameRef = StringRef(TempStorage);
10281028
};
10291029

1030-
if (NameRef.startswith("async_work_group")) {
1030+
if (NameRef.starts_with("async_work_group")) {
10311031
addUnsignedArg(-1);
10321032
setArgAttr(1, SPIR::ATTR_CONST);
1033-
} else if (NameRef.startswith("printf"))
1033+
} else if (NameRef.starts_with("printf"))
10341034
setVarArg(1);
1035-
else if (NameRef.startswith("write_imageui"))
1035+
else if (NameRef.starts_with("write_imageui"))
10361036
addUnsignedArg(2);
10371037
else if (NameRef.equals("prefetch")) {
10381038
addUnsignedArg(1);
@@ -1045,13 +1045,13 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
10451045
FunctionType *InvokeTy = getBlockInvokeTy(F, BlockArgIdx);
10461046
if (InvokeTy->getNumParams() > 1)
10471047
setLocalArgBlock(BlockArgIdx);
1048-
} else if (NameRef.startswith("__enqueue_kernel")) {
1048+
} else if (NameRef.starts_with("__enqueue_kernel")) {
10491049
// clang doesn't mangle enqueue_kernel builtins
10501050
setAsDontMangle();
1051-
} else if (NameRef.startswith("get_") || NameRef.equals("nan") ||
1052-
NameRef.equals("mem_fence") || NameRef.startswith("shuffle")) {
1051+
} else if (NameRef.starts_with("get_") || NameRef.equals("nan") ||
1052+
NameRef.equals("mem_fence") || NameRef.starts_with("shuffle")) {
10531053
addUnsignedArg(-1);
1054-
if (NameRef.startswith(kOCLBuiltinName::GetFence)) {
1054+
if (NameRef.starts_with(kOCLBuiltinName::GetFence)) {
10551055
setArgAttr(0, SPIR::ATTR_CONST);
10561056
addVoidPtrArg(0);
10571057
}
@@ -1062,18 +1062,18 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
10621062
NameRef.equals("intel_work_group_barrier_arrive") ||
10631063
NameRef.equals("intel_work_group_barrier_wait"))
10641064
setEnumArg(1, SPIR::PRIMITIVE_MEMORY_SCOPE);
1065-
} else if (NameRef.startswith("atomic_work_item_fence")) {
1065+
} else if (NameRef.starts_with("atomic_work_item_fence")) {
10661066
addUnsignedArg(0);
10671067
setEnumArg(1, SPIR::PRIMITIVE_MEMORY_ORDER);
10681068
setEnumArg(2, SPIR::PRIMITIVE_MEMORY_SCOPE);
1069-
} else if (NameRef.startswith("atom_")) {
1069+
} else if (NameRef.starts_with("atom_")) {
10701070
setArgAttr(0, SPIR::ATTR_VOLATILE);
1071-
if (NameRef.endswith("_umax") || NameRef.endswith("_umin")) {
1071+
if (NameRef.ends_with("_umax") || NameRef.ends_with("_umin")) {
10721072
addUnsignedArg(-1);
10731073
// We need to remove u to match OpenCL C built-in function name
10741074
EraseSymbol(5);
10751075
}
1076-
} else if (NameRef.startswith("atomic")) {
1076+
} else if (NameRef.starts_with("atomic")) {
10771077
setArgAttr(0, SPIR::ATTR_VOLATILE);
10781078
if (NameRef.contains("_umax") || NameRef.contains("_umin")) {
10791079
addUnsignedArg(-1);
@@ -1085,41 +1085,41 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
10851085
}
10861086
if (NameRef.contains("store_explicit") ||
10871087
NameRef.contains("exchange_explicit") ||
1088-
(NameRef.startswith("atomic_fetch") &&
1088+
(NameRef.starts_with("atomic_fetch") &&
10891089
NameRef.contains("explicit"))) {
10901090
setEnumArg(2, SPIR::PRIMITIVE_MEMORY_ORDER);
10911091
setEnumArg(3, SPIR::PRIMITIVE_MEMORY_SCOPE);
10921092
} else if (NameRef.contains("load_explicit") ||
1093-
(NameRef.startswith("atomic_flag") &&
1093+
(NameRef.starts_with("atomic_flag") &&
10941094
NameRef.contains("explicit"))) {
10951095
setEnumArg(1, SPIR::PRIMITIVE_MEMORY_ORDER);
10961096
setEnumArg(2, SPIR::PRIMITIVE_MEMORY_SCOPE);
1097-
} else if (NameRef.endswith("compare_exchange_strong_explicit") ||
1098-
NameRef.endswith("compare_exchange_weak_explicit")) {
1097+
} else if (NameRef.ends_with("compare_exchange_strong_explicit") ||
1098+
NameRef.ends_with("compare_exchange_weak_explicit")) {
10991099
setEnumArg(3, SPIR::PRIMITIVE_MEMORY_ORDER);
11001100
setEnumArg(4, SPIR::PRIMITIVE_MEMORY_ORDER);
11011101
setEnumArg(5, SPIR::PRIMITIVE_MEMORY_SCOPE);
11021102
}
11031103
// Don't set atomic property to the first argument of 1.2 atomic
11041104
// built-ins.
1105-
if (!NameRef.endswith("xchg") && // covers _cmpxchg too
1105+
if (!NameRef.ends_with("xchg") && // covers _cmpxchg too
11061106
(NameRef.contains("fetch") ||
1107-
!(NameRef.endswith("_add") || NameRef.endswith("_sub") ||
1108-
NameRef.endswith("_inc") || NameRef.endswith("_dec") ||
1109-
NameRef.endswith("_min") || NameRef.endswith("_max") ||
1110-
NameRef.endswith("_and") || NameRef.endswith("_or") ||
1111-
NameRef.endswith("_xor")))) {
1107+
!(NameRef.ends_with("_add") || NameRef.ends_with("_sub") ||
1108+
NameRef.ends_with("_inc") || NameRef.ends_with("_dec") ||
1109+
NameRef.ends_with("_min") || NameRef.ends_with("_max") ||
1110+
NameRef.ends_with("_and") || NameRef.ends_with("_or") ||
1111+
NameRef.ends_with("_xor")))) {
11121112
addAtomicArg(0);
11131113
}
1114-
} else if (NameRef.startswith("uconvert_")) {
1114+
} else if (NameRef.starts_with("uconvert_")) {
11151115
addUnsignedArg(0);
11161116
NameRef = NameRef.drop_front(1);
11171117
UnmangledName.erase(0, 1);
1118-
} else if (NameRef.startswith("s_")) {
1118+
} else if (NameRef.starts_with("s_")) {
11191119
if (NameRef.equals("s_upsample"))
11201120
addUnsignedArg(1);
11211121
NameRef = NameRef.drop_front(2);
1122-
} else if (NameRef.startswith("u_")) {
1122+
} else if (NameRef.starts_with("u_")) {
11231123
addUnsignedArg(-1);
11241124
NameRef = NameRef.drop_front(2);
11251125
} else if (NameRef.equals("fclamp")) {
@@ -1170,12 +1170,12 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
11701170
} else if (NameRef.equals("enqueue_marker")) {
11711171
setArgAttr(2, SPIR::ATTR_CONST);
11721172
addUnsignedArg(1);
1173-
} else if (NameRef.startswith("vload")) {
1173+
} else if (NameRef.starts_with("vload")) {
11741174
addUnsignedArg(0);
11751175
setArgAttr(1, SPIR::ATTR_CONST);
1176-
} else if (NameRef.startswith("vstore")) {
1176+
} else if (NameRef.starts_with("vstore")) {
11771177
addUnsignedArg(1);
1178-
} else if (NameRef.startswith("ndrange_")) {
1178+
} else if (NameRef.starts_with("ndrange_")) {
11791179
addUnsignedArgs(0, 2);
11801180
if (NameRef[8] == '2' || NameRef[8] == '3') {
11811181
setArgAttr(0, SPIR::ATTR_CONST);
@@ -1190,7 +1190,7 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
11901190
EraseSymbol(NameRef.find("umin"));
11911191
} else if (NameRef.contains("broadcast")) {
11921192
addUnsignedArg(-1);
1193-
} else if (NameRef.startswith(kOCLBuiltinName::SampledReadImage)) {
1193+
} else if (NameRef.starts_with(kOCLBuiltinName::SampledReadImage)) {
11941194
if (!NameRef.consume_front(kOCLBuiltinName::Sampled))
11951195
report_fatal_error(llvm::Twine("Builtin name illformed"));
11961196
addSamplerArg(1);
@@ -1282,12 +1282,12 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
12821282
else if (NameRef.contains("chroma_mode_cost_function"))
12831283
addUnsignedArg(0);
12841284
}
1285-
} else if (NameRef.startswith("intel_sub_group_shuffle")) {
1286-
if (NameRef.endswith("_down") || NameRef.endswith("_up"))
1285+
} else if (NameRef.starts_with("intel_sub_group_shuffle")) {
1286+
if (NameRef.ends_with("_down") || NameRef.ends_with("_up"))
12871287
addUnsignedArg(2);
12881288
else
12891289
addUnsignedArg(1);
1290-
} else if (NameRef.startswith("intel_sub_group_block_write")) {
1290+
} else if (NameRef.starts_with("intel_sub_group_block_write")) {
12911291
// distinguish write to image and other data types based on number of
12921292
// arguments--images have one more argument.
12931293
if (F->getFunctionType()->getNumParams() == 2) {
@@ -1296,16 +1296,16 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
12961296
} else {
12971297
addUnsignedArg(2);
12981298
}
1299-
} else if (NameRef.startswith("intel_sub_group_block_read")) {
1299+
} else if (NameRef.starts_with("intel_sub_group_block_read")) {
13001300
// distinguish read from image and other data types based on number of
13011301
// arguments--images have one more argument.
13021302
if (F->getFunctionType()->getNumParams() == 1) {
13031303
setArgAttr(0, SPIR::ATTR_CONST);
13041304
addUnsignedArg(0);
13051305
}
1306-
} else if (NameRef.startswith("intel_sub_group_media_block_write")) {
1306+
} else if (NameRef.starts_with("intel_sub_group_media_block_write")) {
13071307
addUnsignedArg(3);
1308-
} else if (NameRef.startswith(kOCLBuiltinName::SubGroupPrefix)) {
1308+
} else if (NameRef.starts_with(kOCLBuiltinName::SubGroupPrefix)) {
13091309
if (NameRef.contains("ballot")) {
13101310
if (NameRef.contains("inverse") || NameRef.contains("bit_count") ||
13111311
NameRef.contains("inclusive_scan") ||
@@ -1315,14 +1315,14 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
13151315
else if (NameRef.contains("bit_extract")) {
13161316
addUnsignedArgs(0, 1);
13171317
}
1318-
} else if (NameRef.startswith("sub_group_clustered_rotate")) {
1318+
} else if (NameRef.starts_with("sub_group_clustered_rotate")) {
13191319
addUnsignedArg(2);
13201320
} else if (NameRef.contains("shuffle") || NameRef.contains("clustered"))
13211321
addUnsignedArg(1);
1322-
} else if (NameRef.startswith("bitfield_insert")) {
1322+
} else if (NameRef.starts_with("bitfield_insert")) {
13231323
addUnsignedArgs(2, 3);
1324-
} else if (NameRef.startswith("bitfield_extract_signed") ||
1325-
NameRef.startswith("bitfield_extract_unsigned")) {
1324+
} else if (NameRef.starts_with("bitfield_extract_signed") ||
1325+
NameRef.starts_with("bitfield_extract_unsigned")) {
13261326
addUnsignedArgs(1, 2);
13271327
}
13281328

lib/SPIRV/SPIRVBuiltinHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ void BuiltinCallHelper::initialize(llvm::Module &M) {
365365
if (!Ty->isOpaque() || !Ty->hasName())
366366
continue;
367367
StringRef Name = Ty->getName();
368-
if (Name.startswith("opencl.") || Name.startswith("spirv.")) {
368+
if (Name.starts_with("opencl.") || Name.starts_with("spirv.")) {
369369
UseTargetTypes = false;
370370
}
371371
}

lib/SPIRV/SPIRVLowerSaddWithOverflow.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ void SPIRVLowerSaddWithOverflowBase::visitIntrinsicInst(CallInst &I) {
6767
assert(IntrinsicFunc && "Missing function");
6868
StringRef IntrinsicName = IntrinsicFunc->getName();
6969
std::string FuncName = "llvm_sadd_with_overflow_i";
70-
if (IntrinsicName.endswith(".i16"))
70+
if (IntrinsicName.ends_with(".i16"))
7171
FuncName += "16";
72-
else if (IntrinsicName.endswith(".i32"))
72+
else if (IntrinsicName.ends_with(".i32"))
7373
FuncName += "32";
74-
else if (IntrinsicName.endswith(".i64"))
74+
else if (IntrinsicName.ends_with(".i64"))
7575
FuncName += "64";
7676
else {
7777
assert(false &&

0 commit comments

Comments
 (0)