Skip to content

Commit 73abcef

Browse files
svenvhsys-ce-bb
authored andcommitted
Update for StringRef::{starts,ends}with deprecation (#2272)
Replace with the {starts,ends}_with variants, after LLVM commit 5ac1295 ("[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' Original commit: KhronosGroup/SPIRV-LLVM-Translator@adf1f52
1 parent 9bc30c6 commit 73abcef

12 files changed

+127
-127
lines changed

llvm-spirv/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;

llvm-spirv/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) {

llvm-spirv/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);

llvm-spirv/lib/SPIRV/OCLUtil.cpp

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

670670
size_t getAtomicBuiltinNumMemoryOrderArgs(StringRef Name) {
671-
if (Name.startswith("atomic_compare_exchange"))
671+
if (Name.starts_with("atomic_compare_exchange"))
672672
return 2;
673673
return 1;
674674
}
@@ -683,8 +683,8 @@ size_t getSPIRVAtomicBuiltinNumMemoryOrderArgs(Op OC) {
683683
// max]_explicit functions declared in clang headers should be translated
684684
// to corresponding FP-typed Atomic Instructions
685685
bool isComputeAtomicOCLBuiltin(StringRef DemangledName) {
686-
if (!DemangledName.startswith(kOCLBuiltinName::AtomicPrefix) &&
687-
!DemangledName.startswith(kOCLBuiltinName::AtomPrefix))
686+
if (!DemangledName.starts_with(kOCLBuiltinName::AtomicPrefix) &&
687+
!DemangledName.starts_with(kOCLBuiltinName::AtomPrefix))
688688
return false;
689689

690690
return llvm::StringSwitch<bool>(DemangledName)
@@ -1019,12 +1019,12 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
10191019
NameRef = StringRef(TempStorage);
10201020
};
10211021

1022-
if (NameRef.startswith("async_work_group")) {
1022+
if (NameRef.starts_with("async_work_group")) {
10231023
addUnsignedArg(-1);
10241024
setArgAttr(1, SPIR::ATTR_CONST);
1025-
} else if (NameRef.startswith("printf"))
1025+
} else if (NameRef.starts_with("printf"))
10261026
setVarArg(1);
1027-
else if (NameRef.startswith("write_imageui"))
1027+
else if (NameRef.starts_with("write_imageui"))
10281028
addUnsignedArg(2);
10291029
else if (NameRef.equals("prefetch")) {
10301030
addUnsignedArg(1);
@@ -1037,13 +1037,13 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
10371037
FunctionType *InvokeTy = getBlockInvokeTy(F, BlockArgIdx);
10381038
if (InvokeTy->getNumParams() > 1)
10391039
setLocalArgBlock(BlockArgIdx);
1040-
} else if (NameRef.startswith("__enqueue_kernel")) {
1040+
} else if (NameRef.starts_with("__enqueue_kernel")) {
10411041
// clang doesn't mangle enqueue_kernel builtins
10421042
setAsDontMangle();
1043-
} else if (NameRef.startswith("get_") || NameRef.equals("nan") ||
1044-
NameRef.equals("mem_fence") || NameRef.startswith("shuffle")) {
1043+
} else if (NameRef.starts_with("get_") || NameRef.equals("nan") ||
1044+
NameRef.equals("mem_fence") || NameRef.starts_with("shuffle")) {
10451045
addUnsignedArg(-1);
1046-
if (NameRef.startswith(kOCLBuiltinName::GetFence)) {
1046+
if (NameRef.starts_with(kOCLBuiltinName::GetFence)) {
10471047
setArgAttr(0, SPIR::ATTR_CONST);
10481048
addVoidPtrArg(0);
10491049
}
@@ -1054,18 +1054,18 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
10541054
NameRef.equals("intel_work_group_barrier_arrive") ||
10551055
NameRef.equals("intel_work_group_barrier_wait"))
10561056
setEnumArg(1, SPIR::PRIMITIVE_MEMORY_SCOPE);
1057-
} else if (NameRef.startswith("atomic_work_item_fence")) {
1057+
} else if (NameRef.starts_with("atomic_work_item_fence")) {
10581058
addUnsignedArg(0);
10591059
setEnumArg(1, SPIR::PRIMITIVE_MEMORY_ORDER);
10601060
setEnumArg(2, SPIR::PRIMITIVE_MEMORY_SCOPE);
1061-
} else if (NameRef.startswith("atom_")) {
1061+
} else if (NameRef.starts_with("atom_")) {
10621062
setArgAttr(0, SPIR::ATTR_VOLATILE);
1063-
if (NameRef.endswith("_umax") || NameRef.endswith("_umin")) {
1063+
if (NameRef.ends_with("_umax") || NameRef.ends_with("_umin")) {
10641064
addUnsignedArg(-1);
10651065
// We need to remove u to match OpenCL C built-in function name
10661066
EraseSymbol(5);
10671067
}
1068-
} else if (NameRef.startswith("atomic")) {
1068+
} else if (NameRef.starts_with("atomic")) {
10691069
setArgAttr(0, SPIR::ATTR_VOLATILE);
10701070
if (NameRef.contains("_umax") || NameRef.contains("_umin")) {
10711071
addUnsignedArg(-1);
@@ -1077,41 +1077,41 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
10771077
}
10781078
if (NameRef.contains("store_explicit") ||
10791079
NameRef.contains("exchange_explicit") ||
1080-
(NameRef.startswith("atomic_fetch") &&
1080+
(NameRef.starts_with("atomic_fetch") &&
10811081
NameRef.contains("explicit"))) {
10821082
setEnumArg(2, SPIR::PRIMITIVE_MEMORY_ORDER);
10831083
setEnumArg(3, SPIR::PRIMITIVE_MEMORY_SCOPE);
10841084
} else if (NameRef.contains("load_explicit") ||
1085-
(NameRef.startswith("atomic_flag") &&
1085+
(NameRef.starts_with("atomic_flag") &&
10861086
NameRef.contains("explicit"))) {
10871087
setEnumArg(1, SPIR::PRIMITIVE_MEMORY_ORDER);
10881088
setEnumArg(2, SPIR::PRIMITIVE_MEMORY_SCOPE);
1089-
} else if (NameRef.endswith("compare_exchange_strong_explicit") ||
1090-
NameRef.endswith("compare_exchange_weak_explicit")) {
1089+
} else if (NameRef.ends_with("compare_exchange_strong_explicit") ||
1090+
NameRef.ends_with("compare_exchange_weak_explicit")) {
10911091
setEnumArg(3, SPIR::PRIMITIVE_MEMORY_ORDER);
10921092
setEnumArg(4, SPIR::PRIMITIVE_MEMORY_ORDER);
10931093
setEnumArg(5, SPIR::PRIMITIVE_MEMORY_SCOPE);
10941094
}
10951095
// Don't set atomic property to the first argument of 1.2 atomic
10961096
// built-ins.
1097-
if (!NameRef.endswith("xchg") && // covers _cmpxchg too
1097+
if (!NameRef.ends_with("xchg") && // covers _cmpxchg too
10981098
(NameRef.contains("fetch") ||
1099-
!(NameRef.endswith("_add") || NameRef.endswith("_sub") ||
1100-
NameRef.endswith("_inc") || NameRef.endswith("_dec") ||
1101-
NameRef.endswith("_min") || NameRef.endswith("_max") ||
1102-
NameRef.endswith("_and") || NameRef.endswith("_or") ||
1103-
NameRef.endswith("_xor")))) {
1099+
!(NameRef.ends_with("_add") || NameRef.ends_with("_sub") ||
1100+
NameRef.ends_with("_inc") || NameRef.ends_with("_dec") ||
1101+
NameRef.ends_with("_min") || NameRef.ends_with("_max") ||
1102+
NameRef.ends_with("_and") || NameRef.ends_with("_or") ||
1103+
NameRef.ends_with("_xor")))) {
11041104
addAtomicArg(0);
11051105
}
1106-
} else if (NameRef.startswith("uconvert_")) {
1106+
} else if (NameRef.starts_with("uconvert_")) {
11071107
addUnsignedArg(0);
11081108
NameRef = NameRef.drop_front(1);
11091109
UnmangledName.erase(0, 1);
1110-
} else if (NameRef.startswith("s_")) {
1110+
} else if (NameRef.starts_with("s_")) {
11111111
if (NameRef.equals("s_upsample"))
11121112
addUnsignedArg(1);
11131113
NameRef = NameRef.drop_front(2);
1114-
} else if (NameRef.startswith("u_")) {
1114+
} else if (NameRef.starts_with("u_")) {
11151115
addUnsignedArg(-1);
11161116
NameRef = NameRef.drop_front(2);
11171117
} else if (NameRef.equals("fclamp")) {
@@ -1162,12 +1162,12 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
11621162
} else if (NameRef.equals("enqueue_marker")) {
11631163
setArgAttr(2, SPIR::ATTR_CONST);
11641164
addUnsignedArg(1);
1165-
} else if (NameRef.startswith("vload")) {
1165+
} else if (NameRef.starts_with("vload")) {
11661166
addUnsignedArg(0);
11671167
setArgAttr(1, SPIR::ATTR_CONST);
1168-
} else if (NameRef.startswith("vstore")) {
1168+
} else if (NameRef.starts_with("vstore")) {
11691169
addUnsignedArg(1);
1170-
} else if (NameRef.startswith("ndrange_")) {
1170+
} else if (NameRef.starts_with("ndrange_")) {
11711171
addUnsignedArgs(0, 2);
11721172
if (NameRef[8] == '2' || NameRef[8] == '3') {
11731173
setArgAttr(0, SPIR::ATTR_CONST);
@@ -1182,7 +1182,7 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
11821182
EraseSymbol(NameRef.find("umin"));
11831183
} else if (NameRef.contains("broadcast")) {
11841184
addUnsignedArg(-1);
1185-
} else if (NameRef.startswith(kOCLBuiltinName::SampledReadImage)) {
1185+
} else if (NameRef.starts_with(kOCLBuiltinName::SampledReadImage)) {
11861186
if (!NameRef.consume_front(kOCLBuiltinName::Sampled))
11871187
report_fatal_error(llvm::Twine("Builtin name illformed"));
11881188
addSamplerArg(1);
@@ -1274,12 +1274,12 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
12741274
else if (NameRef.contains("chroma_mode_cost_function"))
12751275
addUnsignedArg(0);
12761276
}
1277-
} else if (NameRef.startswith("intel_sub_group_shuffle")) {
1278-
if (NameRef.endswith("_down") || NameRef.endswith("_up"))
1277+
} else if (NameRef.starts_with("intel_sub_group_shuffle")) {
1278+
if (NameRef.ends_with("_down") || NameRef.ends_with("_up"))
12791279
addUnsignedArg(2);
12801280
else
12811281
addUnsignedArg(1);
1282-
} else if (NameRef.startswith("intel_sub_group_block_write")) {
1282+
} else if (NameRef.starts_with("intel_sub_group_block_write")) {
12831283
// distinguish write to image and other data types based on number of
12841284
// arguments--images have one more argument.
12851285
if (F->getFunctionType()->getNumParams() == 2) {
@@ -1288,16 +1288,16 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
12881288
} else {
12891289
addUnsignedArg(2);
12901290
}
1291-
} else if (NameRef.startswith("intel_sub_group_block_read")) {
1291+
} else if (NameRef.starts_with("intel_sub_group_block_read")) {
12921292
// distinguish read from image and other data types based on number of
12931293
// arguments--images have one more argument.
12941294
if (F->getFunctionType()->getNumParams() == 1) {
12951295
setArgAttr(0, SPIR::ATTR_CONST);
12961296
addUnsignedArg(0);
12971297
}
1298-
} else if (NameRef.startswith("intel_sub_group_media_block_write")) {
1298+
} else if (NameRef.starts_with("intel_sub_group_media_block_write")) {
12991299
addUnsignedArg(3);
1300-
} else if (NameRef.startswith(kOCLBuiltinName::SubGroupPrefix)) {
1300+
} else if (NameRef.starts_with(kOCLBuiltinName::SubGroupPrefix)) {
13011301
if (NameRef.contains("ballot")) {
13021302
if (NameRef.contains("inverse") || NameRef.contains("bit_count") ||
13031303
NameRef.contains("inclusive_scan") ||
@@ -1307,14 +1307,14 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
13071307
else if (NameRef.contains("bit_extract")) {
13081308
addUnsignedArgs(0, 1);
13091309
}
1310-
} else if (NameRef.startswith("sub_group_clustered_rotate")) {
1310+
} else if (NameRef.starts_with("sub_group_clustered_rotate")) {
13111311
addUnsignedArg(2);
13121312
} else if (NameRef.contains("shuffle") || NameRef.contains("clustered"))
13131313
addUnsignedArg(1);
1314-
} else if (NameRef.startswith("bitfield_insert")) {
1314+
} else if (NameRef.starts_with("bitfield_insert")) {
13151315
addUnsignedArgs(2, 3);
1316-
} else if (NameRef.startswith("bitfield_extract_signed") ||
1317-
NameRef.startswith("bitfield_extract_unsigned")) {
1316+
} else if (NameRef.starts_with("bitfield_extract_signed") ||
1317+
NameRef.starts_with("bitfield_extract_unsigned")) {
13181318
addUnsignedArgs(1, 2);
13191319
}
13201320

llvm-spirv/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
}

llvm-spirv/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)