From 6690389c8802205a2a90912b3fb0520733e8c122 Mon Sep 17 00:00:00 2001 From: Jessica Del Date: Fri, 22 Dec 2023 18:23:54 +0100 Subject: [PATCH] [lgc/llpc][NFC] - Use `starts_with` and `ends_with` `StringRef::startswith` and `StringRef::endswith` are deprecated. --- lgc/builder/BuilderRecorder.cpp | 4 +-- lgc/builder/BuilderReplayer.cpp | 6 ++-- lgc/disassembler/Disassembler.cpp | 2 +- lgc/elfLinker/FetchShader.cpp | 2 +- lgc/patch/CombineCooperativeMatrix.cpp | 36 +++++++++---------- lgc/patch/FragColorExport.cpp | 4 +-- lgc/patch/LowerCooperativeMatrix.cpp | 22 ++++++------ lgc/patch/NggPrimShader.cpp | 18 +++++----- lgc/patch/PatchCopyShader.cpp | 2 +- lgc/patch/PatchEntryPointMutate.cpp | 10 +++--- lgc/patch/PatchImageDerivatives.cpp | 2 +- lgc/patch/PatchImageOpCollect.cpp | 2 +- lgc/patch/PatchInOutImportExport.cpp | 18 +++++----- lgc/patch/PatchInvariantLoads.cpp | 6 ++-- lgc/patch/PatchLoopMetadata.cpp | 6 ++-- lgc/patch/PatchResourceCollect.cpp | 16 ++++----- lgc/patch/PatchWorkarounds.cpp | 4 +-- lgc/patch/ShaderInputs.cpp | 2 +- lgc/patch/ShaderMerger.cpp | 2 +- lgc/patch/TcsPassthroughShader.cpp | 4 +-- lgc/state/PalMetadata.cpp | 8 ++--- lgc/tool/lgc/lgc.cpp | 6 ++-- llpc/context/llpcCompiler.cpp | 6 ++-- llpc/lower/LowerGLCompatibility.cpp | 2 +- llpc/lower/llpcSpirvLowerCfgMerges.cpp | 2 +- .../lower/llpcSpirvLowerCooperativeMatrix.cpp | 2 +- llpc/lower/llpcSpirvLowerGlobal.cpp | 34 +++++++++--------- llpc/lower/llpcSpirvLowerInstMetaRemove.cpp | 4 +-- llpc/lower/llpcSpirvLowerMath.cpp | 4 +-- .../llpcSpirvLowerRayQueryPostInline.cpp | 2 +- llpc/lower/llpcSpirvLowerRayTracing.cpp | 2 +- llpc/lower/llpcSpirvLowerUtil.cpp | 2 +- llpc/lower/llpcSpirvProcessGpuRtLibrary.cpp | 14 ++++---- llpc/tool/amdllpc.cpp | 8 ++--- llpc/tool/llpcInputUtils.cpp | 10 +++--- llpc/tool/llpcShaderCacheWrap.cpp | 4 +-- llpc/translator/lib/SPIRV/SPIRVReader.cpp | 8 ++--- .../lib/SPIRV/libSPIRV/SPIRVModule.cpp | 2 +- llpc/util/llpcDebug.cpp | 2 +- 39 files changed, 145 insertions(+), 145 deletions(-) diff --git a/lgc/builder/BuilderRecorder.cpp b/lgc/builder/BuilderRecorder.cpp index 2908eef1d3..07687f4e48 100644 --- a/lgc/builder/BuilderRecorder.cpp +++ b/lgc/builder/BuilderRecorder.cpp @@ -2161,13 +2161,13 @@ Instruction *Builder::record(BuilderOpcode opcode, Type *resultTy, ArrayRef(opcode)); - if (name.startswith(opcodeName)) { + if (name.starts_with(opcodeName)) { if (opcodeName.size() > bestLength) { bestLength = opcodeName.size(); bestOpcode = opcode; diff --git a/lgc/builder/BuilderReplayer.cpp b/lgc/builder/BuilderReplayer.cpp index e06b6ac2cf..6ced88a1d2 100644 --- a/lgc/builder/BuilderReplayer.cpp +++ b/lgc/builder/BuilderReplayer.cpp @@ -95,13 +95,13 @@ bool BuilderReplayer::runImpl(Module &module, PipelineState *pipelineState) { if (const MDNode *funcMeta = func.getMetadata(opcodeMetaKindId)) { const ConstantAsMetadata *metaConst = cast(funcMeta->getOperand(0)); opcode = cast(metaConst->getValue())->getZExtValue(); - assert(func.getName().startswith(BuilderCallPrefix)); + assert(func.getName().starts_with(BuilderCallPrefix)); assert(func.getName() .slice(strlen(BuilderCallPrefix), StringRef::npos) - .startswith(BuilderRecorder::getCallName(static_cast(opcode))) && + .starts_with(BuilderRecorder::getCallName(static_cast(opcode))) && "lgc.create.* mismatch!"); } else { - if (!func.getName().startswith(BuilderCallPrefix)) + if (!func.getName().starts_with(BuilderCallPrefix)) continue; // Not lgc.create.* call opcode = BuilderRecorder::getOpcodeFromName(func.getName()); } diff --git a/lgc/disassembler/Disassembler.cpp b/lgc/disassembler/Disassembler.cpp index aa92894f6a..dafd63ca15 100644 --- a/lgc/disassembler/Disassembler.cpp +++ b/lgc/disassembler/Disassembler.cpp @@ -603,7 +603,7 @@ static InstOp parseInstOp(StringRef op) { return res; } - if (op.startswith("s")) { + if (op.starts_with("s")) { StringRef s = op.drop_front(1); s.consume_front("["); unsigned n; diff --git a/lgc/elfLinker/FetchShader.cpp b/lgc/elfLinker/FetchShader.cpp index 9da79b455e..e81f1858ba 100644 --- a/lgc/elfLinker/FetchShader.cpp +++ b/lgc/elfLinker/FetchShader.cpp @@ -151,7 +151,7 @@ void FetchShader::replaceShaderInputBuiltInFunctions(Function *fetchFunc) const for (Function &func : *fetchFunc->getParent()) { if (!func.isDeclaration()) continue; - if (func.getName().startswith(lgcName::SpecialUserData) || func.getName().startswith(lgcName::ShaderInput)) { + if (func.getName().starts_with(lgcName::SpecialUserData) || func.getName().starts_with(lgcName::ShaderInput)) { while (!func.use_empty()) { auto call = cast(func.use_begin()->getUser()); Value *replacement = nullptr; diff --git a/lgc/patch/CombineCooperativeMatrix.cpp b/lgc/patch/CombineCooperativeMatrix.cpp index fbf3588677..801730cd35 100644 --- a/lgc/patch/CombineCooperativeMatrix.cpp +++ b/lgc/patch/CombineCooperativeMatrix.cpp @@ -99,14 +99,14 @@ bool CooperativeMatrixCombiner::run() { if (!fn.isDeclaration()) continue; - if (fn.getName().startswith(lgcName::CooperativeMatrixTranspose)) { + if (fn.getName().starts_with(lgcName::CooperativeMatrixTranspose)) { for (User *user : fn.users()) { if (auto *call = dyn_cast(user)) { if (call->getFunction() == &m_function) ops.push_back(call); } } - } else if (fn.getName().startswith(lgcName::CooperativeMatrixConvert)) { + } else if (fn.getName().starts_with(lgcName::CooperativeMatrixConvert)) { for (User *user : fn.users()) { if (auto *call = dyn_cast(user)) { if (call->getFunction() == &m_function) @@ -174,11 +174,11 @@ void CooperativeMatrixCombiner::foldTo(Value *from, Value *to) { bool CooperativeMatrixCombiner::tryFold(CallInst *op) { Value *src; bool isConvert = false; - if (op->getCalledFunction()->getName().startswith(lgcName::CooperativeMatrixConvert)) { + if (op->getCalledFunction()->getName().starts_with(lgcName::CooperativeMatrixConvert)) { src = op->getArgOperand(1); isConvert = true; } else { - assert(op->getCalledFunction()->getName().startswith(lgcName::CooperativeMatrixTranspose)); + assert(op->getCalledFunction()->getName().starts_with(lgcName::CooperativeMatrixTranspose)); src = op->getArgOperand(0); } @@ -320,14 +320,14 @@ bool CooperativeMatrixCombiner::tryFoldComponentContaining(Value *start) { if (auto *call = dyn_cast(input)) { if (auto *callee = call->getCalledFunction()) { - if (callee->getName().startswith(lgcName::CooperativeMatrixLoad)) + if (callee->getName().starts_with(lgcName::CooperativeMatrixLoad)) continue; // loads can be adjusted at zero cost - if (callee->getName().startswith(lgcName::CooperativeMatrixTranspose)) { + if (callee->getName().starts_with(lgcName::CooperativeMatrixTranspose)) { foundComponentShape(getShapeOfTranspose(call)); ++numTransposeInputs; continue; } - if (callee->getName().startswith(lgcName::CooperativeMatrixConvert)) { + if (callee->getName().starts_with(lgcName::CooperativeMatrixConvert)) { auto srcElemType = (Builder::CooperativeMatrixElementType)cast(call->getArgOperand(2))->getZExtValue(); auto dstElemType = @@ -357,14 +357,14 @@ bool CooperativeMatrixCombiner::tryFoldComponentContaining(Value *start) { for (Use *use : component.outputs) { if (auto *call = dyn_cast(use->getUser())) { if (auto *callee = call->getCalledFunction()) { - if (callee->getName().startswith(lgcName::CooperativeMatrixStore)) + if (callee->getName().starts_with(lgcName::CooperativeMatrixStore)) continue; // stores can be adapted at zero cost - if (callee->getName().startswith(lgcName::CooperativeMatrixTranspose)) { + if (callee->getName().starts_with(lgcName::CooperativeMatrixTranspose)) { foundComponentShape(getShapeOfTranspose(call)); transposeOutputs.insert(use->get()); continue; } - if (callee->getName().startswith(lgcName::CooperativeMatrixConvert)) { + if (callee->getName().starts_with(lgcName::CooperativeMatrixConvert)) { auto srcElemType = (Builder::CooperativeMatrixElementType)cast(call->getArgOperand(2))->getZExtValue(); auto dstElemType = @@ -403,7 +403,7 @@ bool CooperativeMatrixCombiner::tryFoldComponentContaining(Value *start) { // Handle inputs that can be folded away / absorbed. if (auto *call = dyn_cast(input)) { if (auto *callee = call->getCalledFunction()) { - if (callee->getName().startswith(lgcName::CooperativeMatrixTranspose)) { + if (callee->getName().starts_with(lgcName::CooperativeMatrixTranspose)) { Value *src = call->getArgOperand(0); foldTo(input, src); @@ -411,7 +411,7 @@ bool CooperativeMatrixCombiner::tryFoldComponentContaining(Value *start) { outTransposed.try_emplace(src, input); continue; } - if (callee->getName().startswith(lgcName::CooperativeMatrixLoad)) { + if (callee->getName().starts_with(lgcName::CooperativeMatrixLoad)) { bool colMajor = cast(call->getArgOperand(2))->getZExtValue(); call->setArgOperand(2, b.getInt1(!colMajor)); continue; @@ -437,11 +437,11 @@ bool CooperativeMatrixCombiner::tryFoldComponentContaining(Value *start) { // Handle outputs that can be folded away / absorbed. if (auto *call = dyn_cast(use->getUser())) { if (auto *callee = call->getCalledFunction()) { - if (callee->getName().startswith(lgcName::CooperativeMatrixTranspose)) { + if (callee->getName().starts_with(lgcName::CooperativeMatrixTranspose)) { foldTo(call, use->get()); continue; } - if (callee->getName().startswith(lgcName::CooperativeMatrixStore)) { + if (callee->getName().starts_with(lgcName::CooperativeMatrixStore)) { bool colMajor = cast(call->getArgOperand(2))->getZExtValue(); call->setArgOperand(2, b.getInt1(!colMajor)); continue; @@ -505,7 +505,7 @@ bool CooperativeMatrixCombiner::tryFoldComponentContaining(Value *start) { // Handle inputs for which the relayout can be folded or absorbed. if (auto *call = dyn_cast(input)) { if (auto *callee = call->getCalledFunction()) { - if (callee->getName().startswith(lgcName::CooperativeMatrixConvert)) { + if (callee->getName().starts_with(lgcName::CooperativeMatrixConvert)) { unsigned srcElemType = cast(call->getArgOperand(2))->getZExtValue(); unsigned dstElemType = cast(call->getArgOperand(3))->getZExtValue(); @@ -527,7 +527,7 @@ bool CooperativeMatrixCombiner::tryFoldComponentContaining(Value *start) { call->setArgOperand(5, b.getInt32((unsigned)*otherLayout)); continue; } - if (callee->getName().startswith(lgcName::CooperativeMatrixLoad)) { + if (callee->getName().starts_with(lgcName::CooperativeMatrixLoad)) { call->setArgOperand(4, b.getInt32((unsigned)*otherLayout)); continue; } @@ -553,7 +553,7 @@ bool CooperativeMatrixCombiner::tryFoldComponentContaining(Value *start) { // Handle outputs for which the relayout can be folded or absorbed. if (auto *call = dyn_cast(use->getUser())) { if (auto *callee = call->getCalledFunction()) { - if (callee->getName().startswith(lgcName::CooperativeMatrixConvert)) { + if (callee->getName().starts_with(lgcName::CooperativeMatrixConvert)) { unsigned srcElemType = cast(call->getArgOperand(2))->getZExtValue(); unsigned dstElemType = cast(call->getArgOperand(3))->getZExtValue(); @@ -567,7 +567,7 @@ bool CooperativeMatrixCombiner::tryFoldComponentContaining(Value *start) { continue; } } - if (callee->getName().startswith(lgcName::CooperativeMatrixStore)) { + if (callee->getName().starts_with(lgcName::CooperativeMatrixStore)) { call->setArgOperand(4, b.getInt32((unsigned)*otherLayout)); continue; } diff --git a/lgc/patch/FragColorExport.cpp b/lgc/patch/FragColorExport.cpp index 40ae489eab..1ae032da3f 100644 --- a/lgc/patch/FragColorExport.cpp +++ b/lgc/patch/FragColorExport.cpp @@ -526,7 +526,7 @@ void LowerFragColorExport::collectExportInfoForGenericOutputs(Function *fragEntr // Collect all of the exports in the fragment shader for (auto &func : *fragEntryPoint->getParent()) { - if (!func.isDeclaration() || !func.getName().startswith(lgcName::OutputExportGeneric)) + if (!func.isDeclaration() || !func.getName().starts_with(lgcName::OutputExportGeneric)) continue; for (auto user : func.users()) { auto callInst = cast(user); @@ -652,7 +652,7 @@ void LowerFragColorExport::collectExportInfoForBuiltinOutput(Function *module, B Value *m_fragStencilRef = nullptr; Value *m_sampleMask = nullptr; for (auto &func : *module->getParent()) { - if (!func.isDeclaration() || !func.getName().startswith(lgcName::OutputExportBuiltIn)) + if (!func.isDeclaration() || !func.getName().starts_with(lgcName::OutputExportBuiltIn)) continue; for (auto user : func.users()) { auto callInst = cast(user); diff --git a/lgc/patch/LowerCooperativeMatrix.cpp b/lgc/patch/LowerCooperativeMatrix.cpp index 4582205f70..fa3ac8b260 100644 --- a/lgc/patch/LowerCooperativeMatrix.cpp +++ b/lgc/patch/LowerCooperativeMatrix.cpp @@ -82,7 +82,7 @@ bool LowerCooperativeMatrix::runImpl(Module &module, PipelineShadersResult &pipe SmallVector lowerCoopMatrixCallees; for (auto &func : module) { auto name = func.getName(); - if (name.startswith(lgcName::CooperativeMatrix)) + if (name.starts_with(lgcName::CooperativeMatrix)) lowerCoopMatrixCallees.push_back(&func); } if (lowerCoopMatrixCallees.empty()) @@ -127,11 +127,11 @@ void LowerCooperativeMatrix::visitCallInst(CallInst &callInst) { builder.SetInsertPoint(&callInst); auto mangledName = callee->getName(); - if (mangledName.startswith(lgcName::CooperativeMatrixLength)) { + if (mangledName.starts_with(lgcName::CooperativeMatrixLength)) { auto layout = static_cast(cast(callInst.getOperand(1))->getZExtValue()); callInst.replaceAllUsesWith(builder.getInt32(getLength(layout))); - } else if (mangledName.startswith(lgcName::CooperativeMatrixExtract)) { + } else if (mangledName.starts_with(lgcName::CooperativeMatrixExtract)) { Value *matrix = callInst.getOperand(0); Value *index = callInst.getOperand(1); auto elemType = @@ -141,7 +141,7 @@ void LowerCooperativeMatrix::visitCallInst(CallInst &callInst) { Value *result = cooperativeMatrixExtract(builder, matrix, index, elemType, layout); result->takeName(&callInst); callInst.replaceAllUsesWith(result); - } else if (mangledName.startswith(lgcName::CooperativeMatrixInsert)) { + } else if (mangledName.starts_with(lgcName::CooperativeMatrixInsert)) { Value *matrix = callInst.getOperand(0); Value *value = callInst.getOperand(1); Value *index = callInst.getOperand(2); @@ -152,7 +152,7 @@ void LowerCooperativeMatrix::visitCallInst(CallInst &callInst) { Value *result = cooperativeMatrixInsert(builder, matrix, value, index, elemType, layout); result->takeName(&callInst); callInst.replaceAllUsesWith(result); - } else if (mangledName.startswith(lgcName::CooperativeMatrixLoad)) { + } else if (mangledName.starts_with(lgcName::CooperativeMatrixLoad)) { Value *dataPtr = callInst.getOperand(0); Value *stride = callInst.getOperand(1); bool colMajor = cast(callInst.getOperand(2))->getZExtValue(); @@ -166,7 +166,7 @@ void LowerCooperativeMatrix::visitCallInst(CallInst &callInst) { callInst.getName(), &callInst); callInst.replaceAllUsesWith(loadVal); - } else if (mangledName.startswith(lgcName::CooperativeMatrixStore)) { + } else if (mangledName.starts_with(lgcName::CooperativeMatrixStore)) { Value *dataPtr = callInst.getOperand(0); Value *stride = callInst.getOperand(1); bool colMajor = cast(callInst.getOperand(2))->getZExtValue(); @@ -180,7 +180,7 @@ void LowerCooperativeMatrix::visitCallInst(CallInst &callInst) { cooperativeMatrixStoreInternal(dataPtr, stride, colMajor, elemType, layout, memoryAccess, vecVal, callInst.getName(), &callInst); - } else if (mangledName.startswith(lgcName::CooperativeMatrixConvert)) { + } else if (mangledName.starts_with(lgcName::CooperativeMatrixConvert)) { CastInst::CastOps castOp = static_cast(cast(callInst.getOperand(0))->getZExtValue()); Value *source = callInst.getOperand(1); @@ -204,7 +204,7 @@ void LowerCooperativeMatrix::visitCallInst(CallInst &callInst) { } callInst.replaceAllUsesWith(resultVal); - } else if (mangledName.startswith(lgcName::CooperativeMatrixTranspose)) { + } else if (mangledName.starts_with(lgcName::CooperativeMatrixTranspose)) { Value *matrix = callInst.getOperand(0); Builder::CooperativeMatrixElementType elemType = static_cast(cast(callInst.getOperand(1))->getZExtValue()); @@ -214,7 +214,7 @@ void LowerCooperativeMatrix::visitCallInst(CallInst &callInst) { Value *resultVal = cooperativeMatrixTranspose(matrix, elemType, srcLayout, callInst.getName(), &callInst); callInst.replaceAllUsesWith(resultVal); - } else if (mangledName.startswith(lgcName::CooperativeMatrixBinOp)) { + } else if (mangledName.starts_with(lgcName::CooperativeMatrixBinOp)) { Builder::CooperativeMatrixArithOp coopMatArithOp = static_cast(cast(callInst.getOperand(0))->getZExtValue()); Value *lhs = callInst.getOperand(1); @@ -228,7 +228,7 @@ void LowerCooperativeMatrix::visitCallInst(CallInst &callInst) { cooperativeMatrixBinaryOp(coopMatArithOp, lhs, rhs, elemType, srcLayout, callInst.getName(), &callInst); callInst.replaceAllUsesWith(resultVal); - } else if (mangledName.startswith(lgcName::CooperativeMatrixTimesScalar)) { + } else if (mangledName.starts_with(lgcName::CooperativeMatrixTimesScalar)) { Value *matrix = callInst.getOperand(0); Value *scalar = callInst.getOperand(1); Builder::CooperativeMatrixElementType elemType = @@ -239,7 +239,7 @@ void LowerCooperativeMatrix::visitCallInst(CallInst &callInst) { Value *resultVal = coopMatrixTimesScalar(matrix, scalar, elemType, srcLayout, callInst.getName(), &callInst); callInst.replaceAllUsesWith(resultVal); - } else if (mangledName.startswith(lgcName::CooperativeMatrixMulAdd)) { + } else if (mangledName.starts_with(lgcName::CooperativeMatrixMulAdd)) { Value *matrixA = callInst.getOperand(0); Value *matrixB = callInst.getOperand(1); Value *matrixC = callInst.getOperand(2); diff --git a/lgc/patch/NggPrimShader.cpp b/lgc/patch/NggPrimShader.cpp index dd03afe840..6368ae3e01 100644 --- a/lgc/patch/NggPrimShader.cpp +++ b/lgc/patch/NggPrimShader.cpp @@ -3369,7 +3369,7 @@ void NggPrimShader::splitEs() { if (func.isIntrinsic() && func.getIntrinsicID() == Intrinsic::amdgcn_exp) expFuncs.push_back(&func); else if (m_gfxIp.major >= 11) { - if (func.getName().startswith(lgcName::NggAttribExport) || func.getName().startswith(lgcName::NggXfbExport)) + if (func.getName().starts_with(lgcName::NggAttribExport) || func.getName().starts_with(lgcName::NggXfbExport)) expFuncs.push_back(&func); } } @@ -3685,7 +3685,7 @@ void NggPrimShader::mutateGs() { // Handle GS message and GS output export for (auto &func : m_gsHandlers.main->getParent()->functions()) { - if (func.getName().startswith(lgcName::NggWriteGsOutput)) { + if (func.getName().starts_with(lgcName::NggWriteGsOutput)) { // Export GS outputs to GS-VS ring for (auto user : func.users()) { CallInst *const call = cast(user); @@ -3835,7 +3835,7 @@ void NggPrimShader::mutateCopyShader() { SmallVector removedCalls; for (auto &func : m_gsHandlers.copyShader->getParent()->functions()) { - if (func.getName().startswith(lgcName::NggReadGsOutput)) { + if (func.getName().starts_with(lgcName::NggReadGsOutput)) { // Import GS outputs from GS-VS ring for (auto user : func.users()) { CallInst *const call = cast(user); @@ -6101,7 +6101,7 @@ void NggPrimShader::processVertexAttribExport(Function *&target) { SmallVector removedCalls; for (auto &func : target->getParent()->functions()) { - if (func.getName().startswith(lgcName::NggAttribExport)) { + if (func.getName().starts_with(lgcName::NggAttribExport)) { for (auto user : func.users()) { CallInst *const call = dyn_cast(user); assert(call); @@ -7265,11 +7265,11 @@ Value *NggPrimShader::fetchXfbOutput(Function *target, ArrayRef args SmallVector expFuncs; for (auto &func : target->getParent()->functions()) { if (dontClone) { - if (func.getName().startswith(lgcName::NggXfbExport)) + if (func.getName().starts_with(lgcName::NggXfbExport)) expFuncs.push_back(&func); } else { if ((func.isIntrinsic() && func.getIntrinsicID() == Intrinsic::amdgcn_exp) || - func.getName().startswith(lgcName::NggAttribExport) || func.getName().startswith(lgcName::NggXfbExport)) + func.getName().starts_with(lgcName::NggAttribExport) || func.getName().starts_with(lgcName::NggXfbExport)) expFuncs.push_back(&func); } } @@ -7338,7 +7338,7 @@ Value *NggPrimShader::fetchXfbOutput(Function *target, ArrayRef args if (!dontClone) { // Remove transform feedback export calls from the target function. No need of doing this if we // just mutate it without cloning. - if (call->getFunction() == target && func->getName().startswith(lgcName::NggXfbExport)) { + if (call->getFunction() == target && func->getName().starts_with(lgcName::NggXfbExport)) { removedCalls.push_back(call); continue; } @@ -7349,7 +7349,7 @@ Value *NggPrimShader::fetchXfbOutput(Function *target, ArrayRef args assert(call->getParent() == retBlock); // Must in return block - if (func->getName().startswith(lgcName::NggXfbExport)) { + if (func->getName().starts_with(lgcName::NggXfbExport)) { // Lower transform feedback export calls auto xfbBuffer = cast(call->getArgOperand(0))->getZExtValue(); auto xfbOffset = cast(call->getArgOperand(1))->getZExtValue(); @@ -7367,7 +7367,7 @@ Value *NggPrimShader::fetchXfbOutput(Function *target, ArrayRef args if (m_hasGs) { // NOTE: For GS, the output value must be loaded by GS read output call. This is generated by copy shader. CallInst *readCall = dyn_cast(outputValue); - assert(readCall && readCall->getCalledFunction()->getName().startswith(lgcName::NggReadGsOutput)); + assert(readCall && readCall->getCalledFunction()->getName().starts_with(lgcName::NggReadGsOutput)); streamId = cast(call->getArgOperand(2))->getZExtValue(); assert(streamId == cast(readCall->getArgOperand(2))->getZExtValue()); // Stream ID must match location = cast(readCall->getArgOperand(0))->getZExtValue(); diff --git a/lgc/patch/PatchCopyShader.cpp b/lgc/patch/PatchCopyShader.cpp index d109a44c62..495405ae7a 100644 --- a/lgc/patch/PatchCopyShader.cpp +++ b/lgc/patch/PatchCopyShader.cpp @@ -319,7 +319,7 @@ void PatchCopyShader::collectGsGenericOutputInfo(Function *gsEntryPoint) { // Collect the byte sizes of the output value at each mapped location for (auto &func : *gsEntryPoint->getParent()) { - if (func.getName().startswith(lgcName::OutputExportGeneric)) { + if (func.getName().starts_with(lgcName::OutputExportGeneric)) { for (auto user : func.users()) { auto callInst = dyn_cast(user); if (!callInst || callInst->getParent()->getParent() != gsEntryPoint) diff --git a/lgc/patch/PatchEntryPointMutate.cpp b/lgc/patch/PatchEntryPointMutate.cpp index 70a594750f..8f11ebb439 100644 --- a/lgc/patch/PatchEntryPointMutate.cpp +++ b/lgc/patch/PatchEntryPointMutate.cpp @@ -864,7 +864,7 @@ void PatchEntryPointMutate::setupComputeWithCalls(Module *module) { // functions and intrinsics). for (Function &func : *module) { if (func.isDeclaration() && func.getIntrinsicID() == Intrinsic::not_intrinsic && - !func.getName().startswith(lgcName::InternalCallPrefix) && !func.user_empty()) { + !func.getName().starts_with(lgcName::InternalCallPrefix) && !func.user_empty()) { m_computeWithCalls = true; return; } @@ -972,7 +972,7 @@ void PatchEntryPointMutate::gatherUserDataUsage(Module *module) { if (!func.isDeclaration()) continue; - if (func.getName().startswith(lgcName::SpecialUserData)) { + if (func.getName().starts_with(lgcName::SpecialUserData)) { for (User *user : func.users()) { CallInst *call = cast(user); ShaderStage stage = getShaderStage(call->getFunction()); @@ -986,7 +986,7 @@ void PatchEntryPointMutate::gatherUserDataUsage(Module *module) { continue; } - if ((func.getName().startswith(lgcName::OutputExportXfb) && !func.use_empty()) || m_pipelineState->enableSwXfb()) { + if ((func.getName().starts_with(lgcName::OutputExportXfb) && !func.use_empty()) || m_pipelineState->enableSwXfb()) { // NOTE: For GFX11+, SW emulated stream-out will always use stream-out buffer descriptors and stream-out buffer // offsets to calculate numbers of written primitives/dwords and update the counters. auto lastVertexStage = auto lastVertexStage = m_pipelineState->getLastVertexProcessingStage(); @@ -1205,7 +1205,7 @@ void PatchEntryPointMutate::processComputeFuncs(ShaderInputs *shaderInputs, Modu SmallVector origFuncs; for (Function &func : module) { if (func.isDeclaration()) { - if (!func.isIntrinsic() && !func.getName().startswith(lgcName::InternalCallPrefix)) { + if (!func.isIntrinsic() && !func.getName().starts_with(lgcName::InternalCallPrefix)) { // This is the declaration of a callable function that is defined in a different module. func.setCallingConv(CallingConv::AMDGPU_Gfx); } @@ -1280,7 +1280,7 @@ void PatchEntryPointMutate::processCalls(Function &func, SmallVectorImpl Value *calledVal = call->getCalledOperand(); Function *calledFunc = dyn_cast(calledVal); if (calledFunc) { - if (calledFunc->isIntrinsic() || calledFunc->getName().startswith(lgcName::InternalCallPrefix)) + if (calledFunc->isIntrinsic() || calledFunc->getName().starts_with(lgcName::InternalCallPrefix)) continue; } else if (call->isInlineAsm()) { continue; diff --git a/lgc/patch/PatchImageDerivatives.cpp b/lgc/patch/PatchImageDerivatives.cpp index ef56e1508a..39c95ad39f 100644 --- a/lgc/patch/PatchImageDerivatives.cpp +++ b/lgc/patch/PatchImageDerivatives.cpp @@ -58,7 +58,7 @@ PreservedAnalyses PatchImageDerivatives::run(Module &module, ModuleAnalysisManag } static bool usesImplicitDerivatives(StringRef name) { - if (!(name.startswith("llvm.amdgcn.image.sample") || name.startswith("llvm.amdgcn.image.gather"))) + if (!(name.starts_with("llvm.amdgcn.image.sample") || name.starts_with("llvm.amdgcn.image.gather"))) return false; if (name.find(".l.") != std::string::npos || name.find(".d.") != std::string::npos) return false; diff --git a/lgc/patch/PatchImageOpCollect.cpp b/lgc/patch/PatchImageOpCollect.cpp index 52eabd9de0..582ad47ddc 100644 --- a/lgc/patch/PatchImageOpCollect.cpp +++ b/lgc/patch/PatchImageOpCollect.cpp @@ -66,7 +66,7 @@ bool PatchImageOpCollect::runImpl(llvm::Module &module, PipelineState *pipelineS for (Function &func : module) { if (!func.isIntrinsic()) continue; - if (func.getName().startswith("llvm.amdgcn.image")) { + if (func.getName().starts_with("llvm.amdgcn.image")) { for (User *user : func.users()) { CallInst *call = cast(user); ShaderStage stage = getShaderStage(call->getFunction()); diff --git a/lgc/patch/PatchInOutImportExport.cpp b/lgc/patch/PatchInOutImportExport.cpp index 89b011e6f8..804a08c471 100644 --- a/lgc/patch/PatchInOutImportExport.cpp +++ b/lgc/patch/PatchInOutImportExport.cpp @@ -118,9 +118,9 @@ bool PatchInOutImportExport::runImpl(Module &module, PipelineShadersResult &pipe SmallVector inputCallees, otherCallees; for (auto &func : module.functions()) { auto name = func.getName(); - if (name.startswith("lgc.input")) + if (name.starts_with("lgc.input")) inputCallees.push_back(&func); - else if (name.startswith("lgc.output") || name == "llvm.amdgcn.s.sendmsg") + else if (name.starts_with("lgc.output") || name == "llvm.amdgcn.s.sendmsg") otherCallees.push_back(&func); } @@ -474,7 +474,7 @@ void PatchInOutImportExport::processShader() { // Different with above, this will force the threadID swizzle which will rearrange thread ID within a group into // blocks of 8*4, not to reconfig workgroup automatically and will support to be swizzled in 8*4 block // split. - if (func.isDeclaration() && func.getName().startswith(lgcName::ReconfigureLocalInvocationId)) { + if (func.isDeclaration() && func.getName().starts_with(lgcName::ReconfigureLocalInvocationId)) { unsigned workgroupSizeX = mode.workgroupSizeX; unsigned workgroupSizeY = mode.workgroupSizeY; unsigned workgroupSizeZ = mode.workgroupSizeZ; @@ -494,7 +494,7 @@ void PatchInOutImportExport::processShader() { } } - if (func.isDeclaration() && func.getName().startswith(lgcName::SwizzleWorkgroupId)) { + if (func.isDeclaration() && func.getName().starts_with(lgcName::SwizzleWorkgroupId)) { createSwizzleThreadGroupFunction(); } } @@ -544,10 +544,10 @@ void PatchInOutImportExport::visitCallInst(CallInst &callInst) { auto importBuiltInOutput = lgcName::OutputImportBuiltIn; const bool isGenericInputImport = isa(callInst); - const bool isBuiltInInputImport = mangledName.startswith(importBuiltInInput); + const bool isBuiltInInputImport = mangledName.starts_with(importBuiltInInput); const bool isInterpolatedInputImport = isa(callInst); const bool isGenericOutputImport = isa(callInst); - const bool isBuiltInOutputImport = mangledName.startswith(importBuiltInOutput); + const bool isBuiltInOutputImport = mangledName.starts_with(importBuiltInOutput); const bool isImport = (isGenericInputImport || isBuiltInInputImport || isInterpolatedInputImport || isGenericOutputImport || isBuiltInOutputImport); @@ -556,9 +556,9 @@ void PatchInOutImportExport::visitCallInst(CallInst &callInst) { auto exportBuiltInOutput = lgcName::OutputExportBuiltIn; auto exportXfbOutput = lgcName::OutputExportXfb; - const bool isGenericOutputExport = mangledName.startswith(exportGenericOutput); - const bool isBuiltInOutputExport = mangledName.startswith(exportBuiltInOutput); - const bool isXfbOutputExport = mangledName.startswith(exportXfbOutput); + const bool isGenericOutputExport = mangledName.starts_with(exportGenericOutput); + const bool isBuiltInOutputExport = mangledName.starts_with(exportBuiltInOutput); + const bool isXfbOutputExport = mangledName.starts_with(exportXfbOutput); const bool isExport = (isGenericOutputExport || isBuiltInOutputExport || isXfbOutputExport); diff --git a/lgc/patch/PatchInvariantLoads.cpp b/lgc/patch/PatchInvariantLoads.cpp index 950f9b26a1..378043bfd5 100644 --- a/lgc/patch/PatchInvariantLoads.cpp +++ b/lgc/patch/PatchInvariantLoads.cpp @@ -83,8 +83,8 @@ static unsigned findAddressSpaceAccess(const Instruction *inst) { auto func = ci->getCalledFunction(); if (func) { // Treat these as buffer address space as they do not overlap with private. - if (func->getName().startswith("llvm.amdgcn.image") || func->getName().startswith("llvm.amdgcn.raw") || - func->getName().startswith("llvm.amdgcn.struct")) + if (func->getName().starts_with("llvm.amdgcn.image") || func->getName().starts_with("llvm.amdgcn.raw") || + func->getName().starts_with("llvm.amdgcn.struct")) return ADDR_SPACE_BUFFER_FAT_POINTER; } } @@ -179,7 +179,7 @@ bool PatchInvariantLoads::runImpl(Function &function, PipelineState *pipelineSta } } else if (CallInst *ci = dyn_cast(&inst)) { auto func = ci->getCalledFunction(); - if (func && func->getName().startswith("lgc.ngg.")) + if (func && func->getName().starts_with("lgc.ngg.")) continue; } unsigned addrSpace = findAddressSpaceAccess(&inst); diff --git a/lgc/patch/PatchLoopMetadata.cpp b/lgc/patch/PatchLoopMetadata.cpp index ca4eda2669..23dfc3f45e 100644 --- a/lgc/patch/PatchLoopMetadata.cpp +++ b/lgc/patch/PatchLoopMetadata.cpp @@ -66,7 +66,7 @@ MDNode *PatchLoopMetadata::updateMetadata(MDNode *loopId, ArrayRef pr if (MDNode *mdNode = dyn_cast(op)) { if (const MDString *mdString = dyn_cast(mdNode->getOperand(0))) { if (any_of(prefixesToRemove, - [mdString](StringRef prefix) -> bool { return mdString->getString().startswith(prefix); })) + [mdString](StringRef prefix) -> bool { return mdString->getString().starts_with(prefix); })) found = true; else mds.push_back(op); @@ -169,7 +169,7 @@ bool PatchLoopMetadata::runImpl(Loop &loop, PipelineState *pipelineState) { Metadata *op = loopMetaNode->getOperand(i); if (MDNode *mdNode = dyn_cast(op)) { if (const MDString *mdString = dyn_cast(mdNode->getOperand(0))) { - if (m_dontUnrollHintThreshold > 0 && mdString->getString().startswith("llvm.loop.unroll.disable")) { + if (m_dontUnrollHintThreshold > 0 && mdString->getString().starts_with("llvm.loop.unroll.disable")) { LLVM_DEBUG(dbgs() << " relaxing llvm.loop.unroll.disable to amdgpu.loop.unroll.threshold " << m_dontUnrollHintThreshold << "\n"); Metadata *thresholdMeta[] = { @@ -181,7 +181,7 @@ bool PatchLoopMetadata::runImpl(Loop &loop, PipelineState *pipelineState) { changed = true; break; } - if (m_unrollHintThreshold > 0 && mdString->getString().startswith("llvm.loop.unroll.full")) { + if (m_unrollHintThreshold > 0 && mdString->getString().starts_with("llvm.loop.unroll.full")) { LLVM_DEBUG(dbgs() << " relaxing llvm.loop.unroll.full to amdgpu.loop.unroll.threshold " << m_unrollHintThreshold << "\n"); Metadata *thresholdMeta[] = { diff --git a/lgc/patch/PatchResourceCollect.cpp b/lgc/patch/PatchResourceCollect.cpp index fba5c03eb8..7f640e20d6 100644 --- a/lgc/patch/PatchResourceCollect.cpp +++ b/lgc/patch/PatchResourceCollect.cpp @@ -383,7 +383,7 @@ bool PatchResourceCollect::canUseNggCulling(Module *module) { CallInst *posCall = nullptr; for (Function &func : *module) { - if (func.getName().startswith(posCallName)) { + if (func.getName().starts_with(posCallName)) { for (User *user : func.users()) { auto call = cast(user); if (m_pipelineShaders->getShaderStage(call->getFunction()) == callStage) { @@ -1169,7 +1169,7 @@ void PatchResourceCollect::visitCallInst(CallInst &callInst) { m_deadCalls.push_back(&callInst); else m_inputCalls.push_back(cast(&callInst)); - } else if (mangledName.startswith(lgcName::InputImportBuiltIn)) { + } else if (mangledName.starts_with(lgcName::InputImportBuiltIn)) { // Built-in input import if (isDeadCall) m_deadCalls.push_back(&callInst); @@ -1184,14 +1184,14 @@ void PatchResourceCollect::visitCallInst(CallInst &callInst) { assert(outputTy->isSingleValueType()); (void)(outputTy); m_importedOutputCalls.push_back(outputImport); - } else if (mangledName.startswith(lgcName::OutputImportBuiltIn)) { + } else if (mangledName.starts_with(lgcName::OutputImportBuiltIn)) { // Built-in output import assert(m_shaderStage == ShaderStageTessControl); unsigned builtInId = cast(callInst.getOperand(0))->getZExtValue(); m_importedOutputBuiltIns.insert(builtInId); - } else if (mangledName.startswith(lgcName::OutputExportGeneric)) { + } else if (mangledName.starts_with(lgcName::OutputExportGeneric)) { m_outputCalls.push_back(&callInst); - } else if (mangledName.startswith(lgcName::OutputExportBuiltIn)) { + } else if (mangledName.starts_with(lgcName::OutputExportBuiltIn)) { // NOTE: If an output value is unspecified, we can safely drop it and remove the output export call. // Currently, do this for geometry shader. if (m_shaderStage == ShaderStageGeometry) { @@ -1203,7 +1203,7 @@ void PatchResourceCollect::visitCallInst(CallInst &callInst) { m_activeOutputBuiltIns.insert(builtInId); } } - } else if (mangledName.startswith(lgcName::OutputExportXfb)) { + } else if (mangledName.starts_with(lgcName::OutputExportXfb)) { auto outputValue = callInst.getArgOperand(callInst.arg_size() - 1); if (isa(outputValue) || isa(outputValue)) { // NOTE: If an output value is unspecified, we can safely drop it and remove the transform feedback export call. @@ -3373,7 +3373,7 @@ void PatchResourceCollect::scalarizeForInOutPacking(Module *module) { visitor.visit(payload, *module); for (Function &func : *module) { - if (func.getName().startswith(lgcName::OutputExportGeneric)) { + if (func.getName().starts_with(lgcName::OutputExportGeneric)) { // This is a generic output. Find its uses in VS/TES/GS. for (User *user : func.users()) { auto call = cast(user); @@ -3763,7 +3763,7 @@ void InOutLocationInfoMapManager::addSpan(CallInst *call, ShaderStage shaderStag elemIdx = cast(call->getOperand(compIdxArgIdx))->getZExtValue(); if (shaderStage == ShaderStageGeometry && - call->getCalledFunction()->getName().startswith(lgcName::OutputExportGeneric)) { + call->getCalledFunction()->getName().starts_with(lgcName::OutputExportGeneric)) { // Set streamId and output bitWidth of a GS output export for copy shader use streamId = cast(call->getOperand(2))->getZExtValue(); bitWidth = call->getOperand(3)->getType()->getScalarSizeInBits(); diff --git a/lgc/patch/PatchWorkarounds.cpp b/lgc/patch/PatchWorkarounds.cpp index 5c4ebb049b..0c4ef82bf2 100644 --- a/lgc/patch/PatchWorkarounds.cpp +++ b/lgc/patch/PatchWorkarounds.cpp @@ -103,7 +103,7 @@ void PatchWorkarounds::applyImageDescWorkaround(void) { SmallVector useWorkListImage; for (const Function &func : m_module->getFunctionList()) { - bool isImage = func.getName().startswith("llvm.amdgcn.image"); + bool isImage = func.getName().starts_with("llvm.amdgcn.image"); #if !defined(LLVM_HAVE_BRANCH_AMD_GFX) bool isLastUse = false; #else @@ -166,7 +166,7 @@ void PatchWorkarounds::processImageDescWorkaround(CallInst &callInst, bool isLas bool requiresWorkaround = false; for (auto &use : callInst.uses()) { if (auto *useCallInst = dyn_cast(use.getUser())) { - if (useCallInst->getCalledFunction()->getName().startswith("llvm.amdgcn.image")) { + if (useCallInst->getCalledFunction()->getName().starts_with("llvm.amdgcn.image")) { // We need to process this intrinsic requiresWorkaround = true; break; diff --git a/lgc/patch/ShaderInputs.cpp b/lgc/patch/ShaderInputs.cpp index 4b411a3ce4..3515aefff5 100644 --- a/lgc/patch/ShaderInputs.cpp +++ b/lgc/patch/ShaderInputs.cpp @@ -309,7 +309,7 @@ const char *ShaderInputs::getInputName(ShaderInput inputKind) { // @param module : IR module void ShaderInputs::gatherUsage(Module &module) { for (auto &func : module) { - if (!func.isDeclaration() || !func.getName().startswith(lgcName::ShaderInput)) + if (!func.isDeclaration() || !func.getName().starts_with(lgcName::ShaderInput)) continue; for (User *user : func.users()) { CallInst *call = cast(user); diff --git a/lgc/patch/ShaderMerger.cpp b/lgc/patch/ShaderMerger.cpp index 6313848ae4..91e390a59f 100644 --- a/lgc/patch/ShaderMerger.cpp +++ b/lgc/patch/ShaderMerger.cpp @@ -178,7 +178,7 @@ void ShaderMerger::gatherTuningAttributes(AttrBuilder &tuningAttrs, const Functi continue; auto attrKind = srcAttr.getKindAsString(); - if (!(attrKind.startswith("amdgpu") || attrKind.startswith("disable"))) + if (!(attrKind.starts_with("amdgpu") || attrKind.starts_with("disable"))) continue; // Note: this doesn't mean attribute values match diff --git a/lgc/patch/TcsPassthroughShader.cpp b/lgc/patch/TcsPassthroughShader.cpp index 8ca65d5c8a..c7f9ae56ad 100644 --- a/lgc/patch/TcsPassthroughShader.cpp +++ b/lgc/patch/TcsPassthroughShader.cpp @@ -189,7 +189,7 @@ void TcsPassthroughShader::generateTcsPassthroughShaderBody(Module &module, Pipe // copy vs generic output and built-in output to tcs output Function *vsEntryPoint = pipelineShaders.getEntryPoint(ShaderStageVertex); for (Function &func : *vsEntryPoint->getParent()) { - if (func.getName().startswith(lgcName::OutputExportGeneric)) { + if (func.getName().starts_with(lgcName::OutputExportGeneric)) { for (auto user : func.users()) { CallInst *callInst = dyn_cast(user); if (!callInst || callInst->getParent()->getParent() != vsEntryPoint) @@ -228,7 +228,7 @@ void TcsPassthroughShader::generateTcsPassthroughShaderBody(Module &module, Pipe tcsInputLocInfoMap[origLocInfo].setData(InvalidValue); tcsOutputLocInfoMap[origLocInfo].setData(InvalidValue); } - } else if (func.getName().startswith(lgcName::OutputExportBuiltIn)) { + } else if (func.getName().starts_with(lgcName::OutputExportBuiltIn)) { for (auto user : func.users()) { CallInst *callInst = dyn_cast(user); if (!callInst || callInst->getParent()->getParent() != vsEntryPoint) diff --git a/lgc/state/PalMetadata.cpp b/lgc/state/PalMetadata.cpp index edcf8624d0..64b70a9056 100644 --- a/lgc/state/PalMetadata.cpp +++ b/lgc/state/PalMetadata.cpp @@ -213,9 +213,9 @@ void PalMetadata::mergeFromBlob(llvm::StringRef blob, bool isGlueCode) { if (destNode->isString() && srcNode.isString()) { if (destNode->getString() == srcNode.getString()) return 0; - if (srcNode.getString().endswith("_fetchless")) + if (srcNode.getString().ends_with("_fetchless")) return 0; - if (destNode->getString().endswith("_fetchless")) { + if (destNode->getString().ends_with("_fetchless")) { *destNode = srcNode; return 0; } @@ -307,9 +307,9 @@ void PalMetadata::mergeFromBlob(llvm::StringRef blob, bool isGlueCode) { if (destNode->isString() && srcNode.isString()) { if (destNode->getString() == srcNode.getString()) return 0; - if (srcNode.getString().endswith("_fetchless")) + if (srcNode.getString().ends_with("_fetchless")) return 0; - if (destNode->getString().endswith("_fetchless")) { + if (destNode->getString().ends_with("_fetchless")) { *destNode = srcNode; return 0; } diff --git a/lgc/tool/lgc/lgc.cpp b/lgc/tool/lgc/lgc.cpp index 41b0f8f77b..9f78f90b5e 100644 --- a/lgc/tool/lgc/lgc.cpp +++ b/lgc/tool/lgc/lgc.cpp @@ -127,7 +127,7 @@ static bool isIsaText(StringRef data) { // This is called by the lgc standalone tool to help distinguish between its three output types of ELF binary, // LLVM IR assembler and ISA assembler. Here we use the fact that ISA assembler is the only one that starts // with a tab character. - return data.startswith("\t"); + return data.starts_with("\t"); } // ===================================================================================================================== @@ -325,8 +325,8 @@ int main(int argc, char **argv) { if (notSpacePos != StringRef::npos) { if (remaining[notSpacePos] == '!') hadMetadata = true; - else if (hadMetadata && (remaining.drop_front(notSpacePos).startswith("target") || - remaining.drop_front(notSpacePos).startswith("define"))) { + else if (hadMetadata && (remaining.drop_front(notSpacePos).starts_with("target") || + remaining.drop_front(notSpacePos).starts_with("define"))) { // End the current split module and go on to the next one. separatedAsms.back() = separatedAsms.back().slice(0, remaining.data() - separatedAsms.back().data()); separatedAsms.push_back(remaining); diff --git a/llpc/context/llpcCompiler.cpp b/llpc/context/llpcCompiler.cpp index d21c447006..fcaaa0c907 100644 --- a/llpc/context/llpcCompiler.cpp +++ b/llpc/context/llpcCompiler.cpp @@ -2087,7 +2087,7 @@ Result Compiler::buildGraphicsPipelineWithPartPipelines(Context *context, // If the "ELF" does not look like ELF, then it must be textual output from -emit-lgc, -emit-llvm, -filetype=asm. // We can't link that, so just concatenate it on to the output. - if (partPipelineElf.size() < 4 || !partPipelineElf.startswith("\177ELF")) { + if (partPipelineElf.size() < 4 || !partPipelineElf.starts_with("\177ELF")) { const unsigned char magic[] = {'B', 'C', 0xC0, 0xDE}; if (partPipelineElf.size() > 4 && memcmp(partPipelineElf.data(), magic, sizeof(magic)) == 0) report_fatal_error("Cannot emit llvm bitcode with part pipeline compilation."); @@ -2951,7 +2951,7 @@ Result Compiler::buildRayTracingPipelineInternal(RayTracingContext &rtContext, for (auto funcIt = gpurtShaderLibrary->begin(), funcEnd = gpurtShaderLibrary->end(); funcIt != funcEnd;) { Function *func = &*funcIt++; if (func->getLinkage() == GlobalValue::ExternalLinkage && !func->empty()) { - if (!func->getName().startswith(traceRayFuncName) && !func->getName().startswith(fetchTrianglePosFunc)) { + if (!func->getName().starts_with(traceRayFuncName) && !func->getName().starts_with(fetchTrianglePosFunc)) { func->dropAllReferences(); func->eraseFromParent(); } @@ -3160,7 +3160,7 @@ MetroHash::Hash Compiler::generateHashForCompileOptions(unsigned optionCount, co StringRef option = options[i] + 1; // Skip '-' in options bool ignore = false; for (unsigned j = 0; j < sizeof(IgnoredOptions) / sizeof(IgnoredOptions[0]); ++j) { - if (option.startswith(IgnoredOptions[j])) { + if (option.starts_with(IgnoredOptions[j])) { ignore = true; break; } diff --git a/llpc/lower/LowerGLCompatibility.cpp b/llpc/lower/LowerGLCompatibility.cpp index badffab8d9..70793974ee 100644 --- a/llpc/lower/LowerGLCompatibility.cpp +++ b/llpc/lower/LowerGLCompatibility.cpp @@ -166,7 +166,7 @@ void LowerGLCompatibility::collectEmitInst() { auto mangledName = function.getName(); // We get all users before iterating because the iterator can be invalidated // by interpolateInputElement - if (mangledName.startswith(gSPIRVName::EmitVertex) || mangledName.startswith(gSPIRVName::EmitStreamVertex)) { + if (mangledName.starts_with(gSPIRVName::EmitVertex) || mangledName.starts_with(gSPIRVName::EmitStreamVertex)) { SmallVector users(function.users()); for (User *user : users) { assert(isa(user) && "We should only have CallInst instructions here."); diff --git a/llpc/lower/llpcSpirvLowerCfgMerges.cpp b/llpc/lower/llpcSpirvLowerCfgMerges.cpp index dd32838b27..c2a04972c1 100644 --- a/llpc/lower/llpcSpirvLowerCfgMerges.cpp +++ b/llpc/lower/llpcSpirvLowerCfgMerges.cpp @@ -286,7 +286,7 @@ void SpirvLowerCfgMerges::mapConvergentValues(Module &module) { Function *func = worklist.pop_back_val(); if (visited.count(func)) continue; - if (func->getName().startswith("spirv.loop.")) + if (func->getName().starts_with("spirv.loop.")) continue; // Record each convergent call block and function diff --git a/llpc/lower/llpcSpirvLowerCooperativeMatrix.cpp b/llpc/lower/llpcSpirvLowerCooperativeMatrix.cpp index 6280a79364..1c27cff125 100644 --- a/llpc/lower/llpcSpirvLowerCooperativeMatrix.cpp +++ b/llpc/lower/llpcSpirvLowerCooperativeMatrix.cpp @@ -71,7 +71,7 @@ PreservedAnalyses LowerCooperativeMatrix::run() { bool changed = false; for (Function &function : m_module.functions()) { - if (function.isDeclaration() && function.getName().startswith(LlpcName::SpirvCooperativeMatrixProxy)) { + if (function.isDeclaration() && function.getName().starts_with(LlpcName::SpirvCooperativeMatrixProxy)) { for (User *user : function.users()) { if (auto *call = dyn_cast(user)) { assert(call->getCalledOperand() == &function); diff --git a/llpc/lower/llpcSpirvLowerGlobal.cpp b/llpc/lower/llpcSpirvLowerGlobal.cpp index 5a6ace802b..cbcec4c8fa 100644 --- a/llpc/lower/llpcSpirvLowerGlobal.cpp +++ b/llpc/lower/llpcSpirvLowerGlobal.cpp @@ -341,30 +341,30 @@ void SpirvLowerGlobal::handleCallInst(bool checkEmitCall, bool checkInterpCall) assert(isa(user) && "We should only have CallInst instructions here."); CallInst *callInst = cast(user); if (checkEmitCall) { - if (mangledName.startswith(gSPIRVName::EmitVertex) || mangledName.startswith(gSPIRVName::EmitStreamVertex)) + if (mangledName.starts_with(gSPIRVName::EmitVertex) || mangledName.starts_with(gSPIRVName::EmitStreamVertex)) m_emitCalls.insert(callInst); } else { assert(checkInterpCall); - if (mangledName.startswith(gSPIRVName::InterpolateAtCentroid) || - mangledName.startswith(gSPIRVName::InterpolateAtSample) || - mangledName.startswith(gSPIRVName::InterpolateAtOffset) || - mangledName.startswith(gSPIRVName::InterpolateAtVertexAMD)) { + if (mangledName.starts_with(gSPIRVName::InterpolateAtCentroid) || + mangledName.starts_with(gSPIRVName::InterpolateAtSample) || + mangledName.starts_with(gSPIRVName::InterpolateAtOffset) || + mangledName.starts_with(gSPIRVName::InterpolateAtVertexAMD)) { // Translate interpolation functions to LLPC intrinsic calls auto loadSrc = callInst->getArgOperand(0); unsigned interpLoc = InterpLocUnknown; Value *auxInterpValue = nullptr; - if (mangledName.startswith(gSPIRVName::InterpolateAtCentroid)) + if (mangledName.starts_with(gSPIRVName::InterpolateAtCentroid)) interpLoc = InterpLocCentroid; - else if (mangledName.startswith(gSPIRVName::InterpolateAtSample)) { + else if (mangledName.starts_with(gSPIRVName::InterpolateAtSample)) { interpLoc = InterpLocSample; auxInterpValue = callInst->getArgOperand(1); // Sample ID - } else if (mangledName.startswith(gSPIRVName::InterpolateAtOffset)) { + } else if (mangledName.starts_with(gSPIRVName::InterpolateAtOffset)) { interpLoc = InterpLocCenter; auxInterpValue = callInst->getArgOperand(1); // Offset from pixel center } else { - assert(mangledName.startswith(gSPIRVName::InterpolateAtVertexAMD)); + assert(mangledName.starts_with(gSPIRVName::InterpolateAtVertexAMD)); interpLoc = InterpLocCustom; auxInterpValue = callInst->getArgOperand(1); // Vertex no. } @@ -594,13 +594,13 @@ void SpirvLowerGlobal::mapGlobalVariableToProxy(GlobalVariable *globalVar) { assert(m_entryPoint); removeConstantExpr(m_context, globalVar); // Handle special globals, regular allocas will be removed by SROA pass. - if (globalVar->getName().startswith(RtName::HitAttribute)) { + if (globalVar->getName().starts_with(RtName::HitAttribute)) { proxy = m_entryPoint->getArg(1); globalVar->replaceAllUsesWith(proxy); - } else if (globalVar->getName().startswith(RtName::IncomingRayPayLoad)) { + } else if (globalVar->getName().starts_with(RtName::IncomingRayPayLoad)) { proxy = m_entryPoint->getArg(0); globalVar->replaceAllUsesWith(proxy); - } else if (globalVar->getName().startswith(RtName::IncomingCallableData)) { + } else if (globalVar->getName().starts_with(RtName::IncomingCallableData)) { proxy = m_entryPoint->getArg(0); globalVar->replaceAllUsesWith(proxy); } else { @@ -846,10 +846,10 @@ void SpirvLowerGlobal::lowerOutput() { m_builder->SetInsertPoint(emitCall); auto mangledName = emitCall->getCalledFunction()->getName(); - if (mangledName.startswith(gSPIRVName::EmitStreamVertex)) + if (mangledName.starts_with(gSPIRVName::EmitStreamVertex)) emitStreamId = cast(emitCall->getOperand(0))->getZExtValue(); else - assert(mangledName.startswith(gSPIRVName::EmitVertex)); + assert(mangledName.starts_with(gSPIRVName::EmitVertex)); Value *outputValue = m_builder->CreateLoad(proxyTy, proxy); addCallInstForOutputExport(outputValue, meta, nullptr, 0, 0, 0, nullptr, nullptr, emitStreamId); @@ -1958,7 +1958,7 @@ void SpirvLowerGlobal::lowerBufferBlock() { if (!callee) continue; // If the call is our non uniform decoration, record we are non uniform. - isNonUniform = callee->getName().startswith(gSPIRVName::NonUniform); + isNonUniform = callee->getName().starts_with(gSPIRVName::NonUniform); break; } } @@ -1972,7 +1972,7 @@ void SpirvLowerGlobal::lowerBufferBlock() { continue; // If the call is our non uniform decoration, record we are non uniform. auto callee = call->getCalledFunction(); - if (callee && callee->getName().startswith(gSPIRVName::NonUniform)) { + if (callee && callee->getName().starts_with(gSPIRVName::NonUniform)) { isNonUniform = true; break; } @@ -2515,7 +2515,7 @@ void SpirvLowerGlobal::lowerShaderRecordBuffer() { static const char *ShaderRecordBuffer = "ShaderRecordBuffer"; for (GlobalVariable &global : m_module->globals()) { - if (!global.getName().startswith(ShaderRecordBuffer)) + if (!global.getName().starts_with(ShaderRecordBuffer)) continue; removeConstantExpr(m_context, &global); diff --git a/llpc/lower/llpcSpirvLowerInstMetaRemove.cpp b/llpc/lower/llpcSpirvLowerInstMetaRemove.cpp index 2a1be0eb0b..94caae7bfd 100644 --- a/llpc/lower/llpcSpirvLowerInstMetaRemove.cpp +++ b/llpc/lower/llpcSpirvLowerInstMetaRemove.cpp @@ -70,7 +70,7 @@ bool SpirvLowerInstMetaRemove::runImpl(Module &module) { // Remove calls to functions whose names start with "spirv.NonUniform". SmallVector callsToRemove; for (auto &func : *m_module) { - if (func.getName().startswith(gSPIRVName::NonUniform)) { + if (func.getName().starts_with(gSPIRVName::NonUniform)) { for (auto &use : func.uses()) { if (auto *callInst = dyn_cast(use.getUser())) { if (callInst->isCallee(&use)) @@ -88,7 +88,7 @@ bool SpirvLowerInstMetaRemove::runImpl(Module &module) { // Remove any named metadata in the module that starts "spirv.". SmallVector nodesToRemove; for (auto &namedMdNode : m_module->named_metadata()) { - if (namedMdNode.getName().startswith(gSPIRVMD::Prefix)) + if (namedMdNode.getName().starts_with(gSPIRVMD::Prefix)) nodesToRemove.push_back(&namedMdNode); } for (NamedMDNode *namedMdNode : nodesToRemove) { diff --git a/llpc/lower/llpcSpirvLowerMath.cpp b/llpc/lower/llpcSpirvLowerMath.cpp index d56a9f7561..88cfe7196c 100644 --- a/llpc/lower/llpcSpirvLowerMath.cpp +++ b/llpc/lower/llpcSpirvLowerMath.cpp @@ -284,9 +284,9 @@ bool SpirvLowerMathPrecision::adjustExports(Module &module) { // We need to find a neater way to do it. auto funcName = func.getName(); bool isExport; - if (funcName.startswith("lgc.output.export.builtin.")) + if (funcName.starts_with("lgc.output.export.builtin.")) isExport = true; - else if (funcName.startswith("lgc.create.write.builtin")) + else if (funcName.starts_with("lgc.create.write.builtin")) isExport = false; else continue; diff --git a/llpc/lower/llpcSpirvLowerRayQueryPostInline.cpp b/llpc/lower/llpcSpirvLowerRayQueryPostInline.cpp index 335ea532e3..7d1d848daa 100644 --- a/llpc/lower/llpcSpirvLowerRayQueryPostInline.cpp +++ b/llpc/lower/llpcSpirvLowerRayQueryPostInline.cpp @@ -72,7 +72,7 @@ bool SpirvLowerRayQueryPostInline::runImpl(Module &module) { for (auto funcIt = module.begin(), funcEnd = module.end(); funcIt != funcEnd;) { Function *func = &*funcIt++; if (func->getLinkage() == GlobalValue::ExternalLinkage && !func->empty()) { - if (!func->getName().startswith(m_entryPoint->getName())) { + if (!func->getName().starts_with(m_entryPoint->getName())) { func->dropAllReferences(); func->eraseFromParent(); } diff --git a/llpc/lower/llpcSpirvLowerRayTracing.cpp b/llpc/lower/llpcSpirvLowerRayTracing.cpp index 4c70f17c97..8a5a58f041 100644 --- a/llpc/lower/llpcSpirvLowerRayTracing.cpp +++ b/llpc/lower/llpcSpirvLowerRayTracing.cpp @@ -658,7 +658,7 @@ PreservedAnalyses SpirvLowerRayTracing::run(Module &module, ModuleAnalysisManage for (auto funcIt = module.begin(), funcEnd = module.end(); funcIt != funcEnd;) { Function *func = &*funcIt++; if (func->getLinkage() == GlobalValue::ExternalLinkage && !func->empty()) { - if (!func->getName().startswith(module.getName())) { + if (!func->getName().starts_with(module.getName())) { func->setLinkage(GlobalValue::InternalLinkage); } } diff --git a/llpc/lower/llpcSpirvLowerUtil.cpp b/llpc/lower/llpcSpirvLowerUtil.cpp index 05261490ad..46df7666f7 100644 --- a/llpc/lower/llpcSpirvLowerUtil.cpp +++ b/llpc/lower/llpcSpirvLowerUtil.cpp @@ -110,7 +110,7 @@ void clearNonEntryFunctions(Module *module, StringRef entryName) { for (auto funcIt = module->begin(), funcEnd = module->end(); funcIt != funcEnd;) { Function *func = &*funcIt++; if (func->getLinkage() == GlobalValue::ExternalLinkage && !func->empty()) { - if (!func->getName().startswith(entryName)) { + if (!func->getName().starts_with(entryName)) { func->dropAllReferences(); func->eraseFromParent(); } diff --git a/llpc/lower/llpcSpirvProcessGpuRtLibrary.cpp b/llpc/lower/llpcSpirvProcessGpuRtLibrary.cpp index b792e51f78..6c94e25d65 100644 --- a/llpc/lower/llpcSpirvProcessGpuRtLibrary.cpp +++ b/llpc/lower/llpcSpirvProcessGpuRtLibrary.cpp @@ -139,17 +139,17 @@ void SpirvProcessGpuRtLibrary::processLibraryFunction(Function *&func) { assert(!fetchTrianglePositionFromRayQueryFuncName.empty()); // Set external linkage for library entry functions - if (funcName.startswith(traceRayFuncName) || funcName.startswith(rayQueryInitializeFuncName) || - funcName.startswith(rayQueryProceedFuncName) || - funcName.startswith(fetchTrianglePositionFromNodePointerFuncName) || - funcName.startswith(fetchTrianglePositionFromRayQueryFuncName)) { + if (funcName.starts_with(traceRayFuncName) || funcName.starts_with(rayQueryInitializeFuncName) || + funcName.starts_with(rayQueryProceedFuncName) || + funcName.starts_with(fetchTrianglePositionFromNodePointerFuncName) || + funcName.starts_with(fetchTrianglePositionFromRayQueryFuncName)) { func->setLinkage(GlobalValue::ExternalLinkage); return; } // Drop dummy entry function. static const char *LibraryEntryFuncName = "libraryEntry"; - if (funcName.startswith(LibraryEntryFuncName)) { + if (funcName.starts_with(LibraryEntryFuncName)) { func->dropAllReferences(); func->eraseFromParent(); func = nullptr; @@ -157,11 +157,11 @@ void SpirvProcessGpuRtLibrary::processLibraryFunction(Function *&func) { } // Special handling for _AmdContStackStore* and _AmdContStackLoad* to accept arbitrary type - if (funcName.startswith("_AmdContStackStore")) { + if (funcName.starts_with("_AmdContStackStore")) { m_builder->SetInsertPoint(clearBlock(func)); createContStackStore(func); return; - } else if (funcName.startswith("_AmdContStackLoad")) { + } else if (funcName.starts_with("_AmdContStackLoad")) { m_builder->SetInsertPoint(clearBlock(func)); createContStackLoad(func); return; diff --git a/llpc/tool/amdllpc.cpp b/llpc/tool/amdllpc.cpp index 4fa506079d..97365e5702 100644 --- a/llpc/tool/amdllpc.cpp +++ b/llpc/tool/amdllpc.cpp @@ -428,9 +428,9 @@ static Result init(int argc, char *argv[], ICompiler *&compiler, ShaderCacheWrap // Before we get to LLVM command-line option parsing, we need to find the -gfxip option value. for (int i = 1; i != argc; ++i) { StringRef arg = argv[i]; - if (arg.startswith("--gfxip")) + if (arg.starts_with("--gfxip")) arg = arg.drop_front(1); - if (!arg.startswith("-gfxip")) + if (!arg.starts_with("-gfxip")) continue; StringRef gfxipStr; arg = arg.slice(strlen("-gfxip"), StringRef::npos); @@ -443,9 +443,9 @@ static Result init(int argc, char *argv[], ICompiler *&compiler, ShaderCacheWrap if (!gfxipStr.consumeInteger(10, ParsedGfxIp.major)) { ParsedGfxIp.minor = 0; ParsedGfxIp.stepping = 0; - if (gfxipStr.startswith(".")) { + if (gfxipStr.starts_with(".")) { gfxipStr = gfxipStr.slice(1, StringRef::npos); - if (!gfxipStr.consumeInteger(10, ParsedGfxIp.minor) && gfxipStr.startswith(".")) { + if (!gfxipStr.consumeInteger(10, ParsedGfxIp.minor) && gfxipStr.starts_with(".")) { gfxipStr = gfxipStr.slice(1, StringRef::npos); gfxipStr.consumeInteger(10, ParsedGfxIp.stepping); } diff --git a/llpc/tool/llpcInputUtils.cpp b/llpc/tool/llpcInputUtils.cpp index 22ae3d4abe..df13d3c29f 100644 --- a/llpc/tool/llpcInputUtils.cpp +++ b/llpc/tool/llpcInputUtils.cpp @@ -219,7 +219,7 @@ bool isIsaText(const void *data, size_t dataSize) { // @param fileName : File path to check // @returns : true when fileName is a SPIR-V text file bool isSpirvTextFile(StringRef fileName) { - return fileName.endswith(Ext::SpirvText); + return fileName.ends_with(Ext::SpirvText); } // ===================================================================================================================== @@ -228,7 +228,7 @@ bool isSpirvTextFile(StringRef fileName) { // @param fileName : File path to check // @returns : true when fileName is a SPIR-V binary file bool isSpirvBinaryFile(StringRef fileName) { - return fileName.endswith(Ext::SpirvBin); + return fileName.ends_with(Ext::SpirvBin); } // ===================================================================================================================== @@ -237,7 +237,7 @@ bool isSpirvBinaryFile(StringRef fileName) { // @param fileName : File path to check // @returns : true when fileName is an LLVM IR file bool isGlslShaderTextFile(llvm::StringRef fileName) { - return any_of(Ext::GlslShaders, [fileName](StringLiteral extension) { return fileName.endswith(extension); }); + return any_of(Ext::GlslShaders, [fileName](StringLiteral extension) { return fileName.ends_with(extension); }); } // ===================================================================================================================== @@ -246,7 +246,7 @@ bool isGlslShaderTextFile(llvm::StringRef fileName) { // @param fileName : File path to check // @returns : true when fileName is an LLVM IR file bool isLlvmIrFile(StringRef fileName) { - return fileName.endswith(Ext::LlvmIr); + return fileName.ends_with(Ext::LlvmIr); } // ===================================================================================================================== @@ -255,7 +255,7 @@ bool isLlvmIrFile(StringRef fileName) { // @param fileName : File path to check // @returns : true when `fileName` is a pipeline info file bool isPipelineInfoFile(StringRef fileName) { - return fileName.endswith(Ext::PipelineInfo); + return fileName.ends_with(Ext::PipelineInfo); } // ===================================================================================================================== diff --git a/llpc/tool/llpcShaderCacheWrap.cpp b/llpc/tool/llpcShaderCacheWrap.cpp index ae977561a5..88e1205de0 100644 --- a/llpc/tool/llpcShaderCacheWrap.cpp +++ b/llpc/tool/llpcShaderCacheWrap.cpp @@ -81,8 +81,8 @@ ShaderCacheWrap *ShaderCacheWrap::Create(unsigned optionCount, const char *const StringRef option = options[i] + 1; // Skip '-' in options - if (option.startswith(cl::ShaderCacheMode.ArgStr) || option.startswith(cl::ShaderCacheFileDir.ArgStr) || - option.startswith(cl::ExecutableName.ArgStr)) { + if (option.starts_with(cl::ShaderCacheMode.ArgStr) || option.starts_with(cl::ShaderCacheFileDir.ArgStr) || + option.starts_with(cl::ExecutableName.ArgStr)) { createDummyCompiler = true; break; } diff --git a/llpc/translator/lib/SPIRV/SPIRVReader.cpp b/llpc/translator/lib/SPIRV/SPIRVReader.cpp index 100c863725..da97608e65 100644 --- a/llpc/translator/lib/SPIRV/SPIRVReader.cpp +++ b/llpc/translator/lib/SPIRV/SPIRVReader.cpp @@ -295,7 +295,7 @@ Value *SPIRVToLLVM::mapValue(SPIRVValue *bv, Value *v) { return v; auto ld = dyn_cast(loc->second); auto placeholder = cast(ld->getPointerOperand()); - assert(ld && placeholder->getName().startswith(KPlaceholderPrefix) && "A value is translated twice"); + assert(ld && placeholder->getName().starts_with(KPlaceholderPrefix) && "A value is translated twice"); // Replaces placeholders for PHI nodes ld->replaceAllUsesWith(v); ld->eraseFromParent(); @@ -1429,7 +1429,7 @@ bool SPIRVToLLVM::postProcessRowMajorMatrix() { SmallVector functionsToRemove; for (Function &func : m_m->functions()) { - if (!func.getName().startswith(SpirvLaunderRowMajor)) + if (!func.getName().starts_with(SpirvLaunderRowMajor)) continue; // Remember to remove the function later. @@ -1644,7 +1644,7 @@ bool SPIRVToLLVM::postProcessRowMajorMatrix() { // don't add users to worklist continue; } else if (auto *const callInst = dyn_cast(inst)) { - if (callInst->getCalledFunction()->getName().startswith(gSPIRVMD::NonUniform)) { + if (callInst->getCalledFunction()->getName().starts_with(gSPIRVMD::NonUniform)) { // don't add users to worklist continue; } @@ -6526,7 +6526,7 @@ Function *SPIRVToLLVM::transFunction(SPIRVFunction *bf) { m_blockPredecessorToCount.clear(); // Special handling for GPURT intrinsic function _AmdContStackStore* to rescue the stored pointee type - if (f->getName().startswith("_AmdContStackStore")) { + if (f->getName().starts_with("_AmdContStackStore")) { assert(f->arg_size() == 2); Type *pointeeType = getPointeeType(bf->getArgument(1)); Metadata *MD = ConstantAsMetadata::get(PoisonValue::get(pointeeType)); diff --git a/llpc/translator/lib/SPIRV/libSPIRV/SPIRVModule.cpp b/llpc/translator/lib/SPIRV/libSPIRV/SPIRVModule.cpp index 062feca63e..2531347b91 100644 --- a/llpc/translator/lib/SPIRV/libSPIRV/SPIRVModule.cpp +++ b/llpc/translator/lib/SPIRV/libSPIRV/SPIRVModule.cpp @@ -558,7 +558,7 @@ bool SPIRVModuleImpl::importBuiltinSet(const std::string &BuiltinSetName, SPIRVI } bool SPIRVModuleImpl::isNonSemanticInfoInstSet(llvm::StringRef setName) const { - return setName.startswith("NonSemantic."); + return setName.starts_with("NonSemantic."); } bool SPIRVModuleImpl::importBuiltinSetWithId(const std::string &BuiltinSetName, SPIRVId BuiltinSetId) { diff --git a/llpc/util/llpcDebug.cpp b/llpc/util/llpcDebug.cpp index 0677f76521..8aaa7993b7 100644 --- a/llpc/util/llpcDebug.cpp +++ b/llpc/util/llpcDebug.cpp @@ -121,7 +121,7 @@ void redirectLogOutput(bool restoreToDefault, unsigned optionCount, const char * bool needDebugOut = ::llvm::DebugFlag; for (unsigned i = 1; !needDebugOut && i < optionCount; ++i) { StringRef option = options[i]; - if (option.startswith("-debug") || option.startswith("-print")) + if (option.starts_with("-debug") || option.starts_with("-print")) needDebugOut = true; }