diff --git a/dev-libs/intel-vc-intrinsics/intel-vc-intrinsics-0.25.0.ebuild b/dev-libs/intel-vc-intrinsics/intel-vc-intrinsics-0.25.0-r1.ebuild similarity index 80% rename from dev-libs/intel-vc-intrinsics/intel-vc-intrinsics-0.25.0.ebuild rename to dev-libs/intel-vc-intrinsics/intel-vc-intrinsics-0.25.0-r1.ebuild index 880dec0..57ef125 100644 --- a/dev-libs/intel-vc-intrinsics/intel-vc-intrinsics-0.25.0.ebuild +++ b/dev-libs/intel-vc-intrinsics/intel-vc-intrinsics-0.25.0-r1.ebuild @@ -4,7 +4,7 @@ EAPI=8 CMAKE_BUILD_TYPE="Release" -LLVM_COMPAT=( {15..22} ) +LLVM_COMPAT=( 21 ) MY_PN="${PN/intel-/}" MY_P="${MY_PN}-${PV}" PYTHON_COMPAT=( python3_{11..14} ) @@ -17,8 +17,9 @@ SRC_URI="https://github.com/intel/${MY_PN}/archive/refs/tags/v${PV}.tar.gz -> ${ S="${WORKDIR}/${MY_P}" LICENSE="MIT" -SLOT="0" +SLOT="21" KEYWORDS="amd64" +IUSE="shared-libs" DEPEND=" dev-libs/libxml2:2= @@ -32,8 +33,14 @@ BDEPEND="${PYTHON_DEPS}" src_configure() { local mycmakeargs=( + -DBUILD_SHARED_LIBS=$(usex shared-libs) + -DCMAKE_INSTALL_PREFIX="/opt/intel/llvm/${LLVM_SLOT}" -DLLVM_DIR="$(get_llvm_prefix)" ) cmake_src_configure } + +src_install() { + cmake_src_install +} diff --git a/dev-util/intel-graphics-compiler/files/intel-graphics-compiler-2.32.7-r2-llvm22.patch b/dev-util/intel-graphics-compiler/files/intel-graphics-compiler-2.32.7-r2-llvm22.patch new file mode 100644 index 0000000..f320c8d --- /dev/null +++ b/dev-util/intel-graphics-compiler/files/intel-graphics-compiler-2.32.7-r2-llvm22.patch @@ -0,0 +1,10035 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5b04555..809b5c5 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -21,3 +21,14 @@ list(APPEND IGC__IGC_TARGETS "opencl-clang-lib") + set(IGC__IGC_TARGETS "${IGC__IGC_TARGETS}" PARENT_SCOPE) + set(IGC_LIBRARY_NAME "${IGC_LIBRARY_NAME}" PARENT_SCOPE) + set(FCL_LIBRARY_NAME "${FCL_LIBRARY_NAME}" PARENT_SCOPE) ++ ++message(STATUS "<<< Gentoo configuration >>> ++Build type ${CMAKE_BUILD_TYPE} ++Install path ${CMAKE_INSTALL_PREFIX} ++Compiler flags: ++C ${CMAKE_C_FLAGS} ++C++ ${CMAKE_CXX_FLAGS} ++Linker flags: ++Executable ${CMAKE_EXE_LINKER_FLAGS} ++Module ${CMAKE_MODULE_LINKER_FLAGS} ++Shared ${CMAKE_SHARED_LINKER_FLAGS}\n") +diff --git a/IGC/AdaptorCommon/LivenessUtils/MergeAllocas.cpp b/IGC/AdaptorCommon/LivenessUtils/MergeAllocas.cpp +index 6f96a2f..39bb3b2 100644 +--- a/IGC/AdaptorCommon/LivenessUtils/MergeAllocas.cpp ++++ b/IGC/AdaptorCommon/LivenessUtils/MergeAllocas.cpp +@@ -152,7 +152,7 @@ static void ReplaceAllocas(const MergeAllocas::AllocaInfo &MergableAlloca, Funct + // We can re-use same bitcast + if (topAllocaBitcast == nullptr) { + topAllocaBitcast = cast( +- Builder.CreateBitCast(topAlloca, Builder.getInt8PtrTy(topAlloca->getType()->getPointerAddressSpace()))); ++ Builder.CreateBitCast(topAlloca, PointerType::get(Builder.getInt8Ty(), topAlloca->getType()->getPointerAddressSpace()))); + } + auto *Offset = Builder.getInt32(subAlloca->offset); + auto *GEP = Builder.CreateGEP(Builder.getInt8Ty(), topAllocaBitcast, Offset); +diff --git a/IGC/AdaptorCommon/ProcessFuncAttributes.cpp b/IGC/AdaptorCommon/ProcessFuncAttributes.cpp +index 32c9caf..cac6681 100644 +--- a/IGC/AdaptorCommon/ProcessFuncAttributes.cpp ++++ b/IGC/AdaptorCommon/ProcessFuncAttributes.cpp +@@ -292,7 +292,7 @@ static bool deduceIfUsesImageParams(Function *F, ModuleMetaData *ModMD) { + // is not possible with opaque pointers and in this case the parameter types must be deduced based on the mangled + // function name. + auto IsSyclImageAccessor = [](StringRef Name) { +- return Name.startswith("_Z") && Name.contains("sycl") && Name.contains("accessor") && Name.contains("image"); ++ return Name.starts_with("_Z") && Name.contains("sycl") && Name.contains("accessor") && Name.contains("image"); + }; + + if (IsSyclImageAccessor(F->getName())) +@@ -519,9 +519,9 @@ bool ProcessFuncAttributes::runOnModule(Module &M) { + // Check all "ExternalLinkage" functions. Func declarations = Import, Func definition = Export + if (F->hasExternalLinkage() && F->getCallingConv() == CallingConv::SPIR_FUNC) { + // builtins should not be externally linked, they will always be resolved by IGC +- return !(F->hasFnAttribute("OclBuiltin") || F->getName().startswith("__builtin_") || +- F->getName().startswith("__igcbuiltin_") || F->getName().startswith("llvm.") || +- F->getName().equals("printf") || Regex("^_Z[0-9]+__builtin_bf16").match(F->getName()) || ++ return !(F->hasFnAttribute("OclBuiltin") || F->getName().starts_with("__builtin_") || ++ F->getName().starts_with("__igcbuiltin_") || F->getName().starts_with("llvm.") || ++ F->getName() == "printf" || Regex("^_Z[0-9]+__builtin_bf16").match(F->getName()) || + Regex("^_Z[0-9]+__spirv_").match(F->getName()) || Regex("^_Z[0-9]+__builtin_spirv").match(F->getName())); + } + return false; +@@ -529,7 +529,7 @@ bool ProcessFuncAttributes::runOnModule(Module &M) { + + // If a builtin func is a FP64 one with the given prefix, return true. + auto IsBuiltinFP64WithPrefix = [](Function *F, const std::string &Prefix) { +- if (F->getName().startswith(Prefix)) { ++ if (F->getName().starts_with(Prefix)) { + if (F->getReturnType()->isDoubleTy() || + (F->getReturnType()->isVectorTy() && F->getReturnType()->getContainedType(0)->isDoubleTy())) { + auto functionName = F->getName(); +@@ -710,7 +710,7 @@ bool ProcessFuncAttributes::runOnModule(Module &M) { + bool defaultStackCall = IGC_IS_FLAG_ENABLED(EnableStackCallFuncCall); + + // Add always attribute if function is a builtin +- if (F->hasFnAttribute("OclBuiltin") || F->getName().startswith("__builtin_spirv_")) { ++ if (F->hasFnAttribute("OclBuiltin") || F->getName().starts_with("__builtin_spirv_")) { + // OptNone builtins are special versions of builtins assuring that all + // theirs parameters are constant values. + if (isOptNoneBuiltin(F->getName())) { +@@ -910,18 +910,18 @@ bool ProcessFuncAttributes::runOnModule(Module &M) { + StringRef sline(line); + + // Ignore empty, whitespace lines, or is comment +- if (sline.trim().empty() || sline.startswith("//")) ++ if (sline.trim().empty() || sline.starts_with("//")) + continue; + +- if (sline.equals("FLAG_FCALL_DEFAULT:")) ++ if (sline == "FLAG_FCALL_DEFAULT:") + FunctionControlMode = FLAG_FCALL_DEFAULT; +- else if (sline.equals("FLAG_FCALL_FORCE_INLINE:")) ++ else if (sline == "FLAG_FCALL_FORCE_INLINE:") + FunctionControlMode = FLAG_FCALL_FORCE_INLINE; +- else if (sline.equals("FLAG_FCALL_FORCE_SUBROUTINE:")) ++ else if (sline == "FLAG_FCALL_FORCE_SUBROUTINE:") + FunctionControlMode = FLAG_FCALL_FORCE_SUBROUTINE; +- else if (sline.equals("FLAG_FCALL_FORCE_STACKCALL:")) ++ else if (sline == "FLAG_FCALL_FORCE_STACKCALL:") + FunctionControlMode = FLAG_FCALL_FORCE_STACKCALL; +- else if (sline.equals("FLAG_FCALL_FORCE_INDIRECTCALL:")) ++ else if (sline == "FLAG_FCALL_FORCE_INDIRECTCALL:") + FunctionControlMode = FLAG_FCALL_FORCE_INDIRECTCALL; + + else if (Function *F = M.getFunction(line)) { +diff --git a/IGC/AdaptorCommon/RayTracing/NewTraceRayInlineLoweringPass.cpp b/IGC/AdaptorCommon/RayTracing/NewTraceRayInlineLoweringPass.cpp +index 1986148..26136b7 100644 +--- a/IGC/AdaptorCommon/RayTracing/NewTraceRayInlineLoweringPass.cpp ++++ b/IGC/AdaptorCommon/RayTracing/NewTraceRayInlineLoweringPass.cpp +@@ -88,7 +88,7 @@ bool InlineRaytracing::LowerAllocations(Function &F) { + auto *getRQHandleFromRQObjectFn = m_Functions[GET_RQ_HANDLE_FROM_RQ_OJECT] = Function::Create( + getRQHandleFromRQObjectFnTy, GlobalValue::PrivateLinkage, VALUE_NAME("getRQHandleFromRQObjectFn"), F.getParent()); + +- getStackPointerFn->addParamAttr(0, llvm::Attribute::NoCapture); ++ getStackPointerFn->addParamAttr(0, llvm::Attribute::Captures); + + // allocate rayquery instructions return i32 handle + // we want all rayqueries to be represent via our struct +@@ -505,7 +505,7 @@ void InlineRaytracing::LowerIntrinsics(Function &F) { + CallInst *traceRay = IRB.createSyncTraceRay(bvhLevel, traceRayCtrl, globalBufferPtr); + + // add this for liveness analysis +- traceRay->addParamAttr(0, llvm::Attribute::NoCapture); ++ traceRay->addParamAttr(0, llvm::Attribute::Captures); + + IRB.createReadSyncTraceRay(traceRay); + +diff --git a/IGC/AdaptorCommon/RayTracing/RTBuilder.cpp b/IGC/AdaptorCommon/RayTracing/RTBuilder.cpp +index 73417bb..c4340b7 100644 +--- a/IGC/AdaptorCommon/RayTracing/RTBuilder.cpp ++++ b/IGC/AdaptorCommon/RayTracing/RTBuilder.cpp +@@ -1545,7 +1545,7 @@ Value *RTBuilder::getGlobalBufferPtrForSlot(IGC::ADDRESS_SPACE Addrspace, Value + + auto *offset = CreateMul(slot, getInt32(IGC::Align(sizeof(RayDispatchGlobalData), IGC::RTGlobalsAlign))); + +- auto *globalBufferPtr = CreateBitCast(mainGlobalBufferPtr, getInt8PtrTy(ADDRESS_SPACE_CONSTANT)); ++ auto *globalBufferPtr = CreateBitCast(mainGlobalBufferPtr, PointerType::get(getInt8Ty(), ADDRESS_SPACE_CONSTANT)); + globalBufferPtr = CreateInBoundsGEP(getInt8Ty(), globalBufferPtr, offset); + globalBufferPtr = CreateBitCast(globalBufferPtr, mainGlobalBufferPtr->getType(), VALUE_NAME("globalBuffer[]")); + +@@ -1619,7 +1619,7 @@ enum class RaytracingType { + // will later be updated to null values with the actual types. + NamedMDNode *initTypeMD(Module &M, uint32_t NumEntries) { + auto *TypesMD = M.getOrInsertNamedMetadata(RaytracingTypesMDName); +- auto *Val = UndefValue::get(Type::getInt8PtrTy(M.getContext())); ++ auto *Val = UndefValue::get(PointerType::get(Type::getInt8Ty(M.getContext()), 0)); + auto *Node = MDNode::get(M.getContext(), ConstantAsMetadata::get(Val)); + + for (uint32_t i = 0; i < NumEntries; i++) +@@ -1792,9 +1792,9 @@ Instruction *RTBuilder::getEntryFirstInsertionPointInBlock(BasicBlock &block, + return curInsertPoint; + } + +-Type *RTBuilder::getInt64PtrTy(unsigned int AddrSpace) const { return Type::getInt64PtrTy(this->Context, AddrSpace); } ++Type *RTBuilder::getInt64PtrTy(unsigned int AddrSpace) const { return PointerType::get(Type::getInt64Ty(this->Context), AddrSpace); } + +-Type *RTBuilder::getInt32PtrTy(unsigned int AddrSpace) const { return Type::getInt32PtrTy(this->Context, AddrSpace); } ++Type *RTBuilder::getInt32PtrTy(unsigned int AddrSpace) const { return PointerType::get(Type::getInt32Ty(this->Context), AddrSpace); } + + IGC::RTMemoryStyle RTBuilder::getMemoryStyle() const { return Ctx.getModuleMetaData()->rtInfo.MemStyle; } + +@@ -1836,12 +1836,12 @@ GenIntrinsicInst *RTBuilder::createDummyInstID(Value *pSrcVal) { + } + + CallInst *RTBuilder::ctlz(Value *V) { +- auto *Ctlz = Intrinsic::getDeclaration(GetInsertBlock()->getModule(), Intrinsic::ctlz, V->getType()); ++ auto *Ctlz = Intrinsic::getOrInsertDeclaration(GetInsertBlock()->getModule(), Intrinsic::ctlz, V->getType()); + return CreateCall2(Ctlz, V, getFalse(), VALUE_NAME("lzd")); + } + + CallInst *RTBuilder::cttz(Value *V) { +- auto *Cttz = Intrinsic::getDeclaration(GetInsertBlock()->getModule(), Intrinsic::cttz, V->getType()); ++ auto *Cttz = Intrinsic::getOrInsertDeclaration(GetInsertBlock()->getModule(), Intrinsic::cttz, V->getType()); + return CreateCall2(Cttz, V, getFalse(), VALUE_NAME("cttz")); + } + +diff --git a/IGC/AdaptorCommon/RayTracing/TraceRayInlineLoweringPass.cpp b/IGC/AdaptorCommon/RayTracing/TraceRayInlineLoweringPass.cpp +index fb1566b..f38d704 100644 +--- a/IGC/AdaptorCommon/RayTracing/TraceRayInlineLoweringPass.cpp ++++ b/IGC/AdaptorCommon/RayTracing/TraceRayInlineLoweringPass.cpp +@@ -823,7 +823,7 @@ bool RTGlobalsPointerLoweringPass::runOnFunction(Function &F) { + uint32_t Addrspace = rtGlobalsPtr->getType()->getPointerAddressSpace(); + auto *LaneId = builder.get32BitLaneID(); + auto *Cond = builder.CreateICmpULT(LaneId, builder.getInt32(numLanes(SIMDMode::SIMD16))); +- auto *Ptr = builder.CreateBitCast(rtGlobalsPtr, builder.getInt8PtrTy(Addrspace)); ++ auto *Ptr = builder.CreateBitCast(rtGlobalsPtr, PointerType::get(builder.getInt8Ty(), Addrspace)); + // UMD will allocate back-to-back RTGlobals if requested. The upper + // 16 lanes will get the pointer to the second one. + // We need at least 64-byte alignment. Let's just align both +diff --git a/IGC/AdaptorOCL/ResolveConstExprCalls.cpp b/IGC/AdaptorOCL/ResolveConstExprCalls.cpp +index 8948bf2..74a50fb 100644 +--- a/IGC/AdaptorOCL/ResolveConstExprCalls.cpp ++++ b/IGC/AdaptorOCL/ResolveConstExprCalls.cpp +@@ -101,7 +101,7 @@ bool transformConstExprCastCall(CallInst &Call) { + return false; // Cannot transform this parameter value. + + AttrBuilder AB(FT->getContext(), CallerPAL.getParamAttrs(i)); +- if (AB.overlaps(AttributeFuncs::typeIncompatible(ParamTy))) ++ if (AB.overlaps(AttributeFuncs::typeIncompatible(ParamTy, CallerPAL.getParamAttrs(i)))) + return false; // Attribute not compatible with transformed value. + + if (Call.isInAllocaArgument(i)) +@@ -150,7 +150,7 @@ bool transformConstExprCastCall(CallInst &Call) { + AttrBuilder RAttrs(FT->getContext(), CallerPAL.getRetAttrs()); + // If the return value is not being used, the type may not be compatible + // with the existing attributes. Wipe out any problematic attributes. +- RAttrs.remove(AttributeFuncs::typeIncompatible(NewRetTy)); ++ RAttrs.remove(AttributeFuncs::typeIncompatible(NewRetTy, CallerPAL.getRetAttrs())); + + LLVMContext &Ctx = Call.getContext(); + AI = Call.arg_begin(); +diff --git a/IGC/AdaptorOCL/UnifyIROCL.cpp b/IGC/AdaptorOCL/UnifyIROCL.cpp +index 76e5f77..2f46128 100644 +--- a/IGC/AdaptorOCL/UnifyIROCL.cpp ++++ b/IGC/AdaptorOCL/UnifyIROCL.cpp +@@ -160,7 +160,7 @@ int getOCLMajorVersion(const SPIRMD::SpirMetaDataUtils &spirMDUtils) { + // check compiler options + for (auto i = spirMDUtils.getCompilerOptionsItem(0)->begin(), e = spirMDUtils.getCompilerOptionsItem(0)->end(); + i != e; ++i) { +- if (StringRef(*i).startswith("-cl-std=CL") && i->length() >= 13) { ++ if (StringRef(*i).starts_with("-cl-std=CL") && i->length() >= 13) { + oclMajor = i->at(10) - '0'; + oclMinor = i->at(12) - '0'; + break; +@@ -297,7 +297,7 @@ static void CommonOCLBasedPasses(OpenCLProgramContext *pContext) { + + // right now we don't support any standard function in the code gen + // maybe we want to support some at some point to take advantage of LLVM optimizations +- TargetLibraryInfoImpl TLI; ++ TargetLibraryInfoImpl TLI(Triple(pContext->getModule()->getTargetTriple())); + TLI.disableAllFunctions(); + + mpm.add(new llvm::TargetLibraryInfoWrapperPass(TLI)); +diff --git a/IGC/AdaptorOCL/Utils/IGCCSPIRVSupportTblGen/IGCCSPIRVSupportTblGen.cpp b/IGC/AdaptorOCL/Utils/IGCCSPIRVSupportTblGen/IGCCSPIRVSupportTblGen.cpp +index 704afd4..3d408b9 100644 +--- a/IGC/AdaptorOCL/Utils/IGCCSPIRVSupportTblGen/IGCCSPIRVSupportTblGen.cpp ++++ b/IGC/AdaptorOCL/Utils/IGCCSPIRVSupportTblGen/IGCCSPIRVSupportTblGen.cpp +@@ -580,7 +580,7 @@ cl::opt Action( + "Generate IGCCompute SPIR-V extension support query header (structures + query functions)"))); + } // namespace + +-static bool OptionsAndDocsTblgenMain(raw_ostream &OS, RecordKeeper &Records) { ++static bool OptionsAndDocsTblgenMain(raw_ostream &OS, const RecordKeeper &Records) { + switch (Action) { + case EmitSPIRVDocs: + emitSPIRVDocs(Records, OS); +diff --git a/IGC/AdaptorOCL/dllInterfaceCompute.cpp b/IGC/AdaptorOCL/dllInterfaceCompute.cpp +index e52712f..c9e9c09 100644 +--- a/IGC/AdaptorOCL/dllInterfaceCompute.cpp ++++ b/IGC/AdaptorOCL/dllInterfaceCompute.cpp +@@ -658,12 +658,12 @@ bool ProcessElfInput(STB_TranslateInputArgs &InputArgs, STB_TranslateOutputArgs + } + + Context.getLLVMContext()->setDiagnosticHandlerCallBack( +- [](const llvm::DiagnosticInfo &DI, void *Ptr) { +- if (DI.getSeverity() == llvm::DS_Error) { ++ [](const llvm::DiagnosticInfo *DI, void *Ptr) { ++ if (DI->getSeverity() == llvm::DS_Error) { + auto *S = static_cast(Ptr); + llvm::raw_string_ostream OS(*S); + llvm::DiagnosticPrinterRawOStream DP(OS); +- DI.print(DP); ++ DI->print(DP); + OS << '\n'; + } + }, +@@ -811,7 +811,7 @@ bool ParseInput(llvm::Module *&pKernelModule, const STB_TranslateInputArgs *pInp + + // IGC does not handle legacy ocl binary for now (legacy ocl binary + // is the binary that contains text LLVM IR (2.7 or 3.0). +- if (!strInput.startswith("BC")) { ++ if (!strInput.starts_with("BC")) { + bool isLLVM27IR = false, isLLVM30IR = false; + + if (strInput.find("triple = \"GHAL3D") != llvm::StringRef::npos) { +@@ -1002,7 +1002,7 @@ bool TranslateBuildSPMD(const STB_TranslateInputArgs *pInputArgs, STB_TranslateO + llvm::StringRef unrollMaxUpperBoundFlag = "-unroll-max-upperbound=16"; + auto unrollMaxUpperBoundSwitch = optionsMap.find(unrollMaxUpperBoundFlag.trim("-=16")); + if (unrollMaxUpperBoundSwitch != optionsMap.end()) { +- if (unrollMaxUpperBoundSwitch->getValue()->getNumOccurrences() == 0) { ++ if (unrollMaxUpperBoundSwitch->second->getNumOccurrences() == 0) { + args.push_back(unrollMaxUpperBoundFlag.data()); + } + } +@@ -1014,7 +1014,7 @@ bool TranslateBuildSPMD(const STB_TranslateInputArgs *pInputArgs, STB_TranslateO + llvm::StringRef instCombineFlag = "-instcombine-code-sinking=0"; + auto instCombineSinkingSwitch = optionsMap.find(instCombineFlag.trim("-=0")); + if (instCombineSinkingSwitch != optionsMap.end()) { +- if (instCombineSinkingSwitch->getValue()->getNumOccurrences() == 0) { ++ if (instCombineSinkingSwitch->second->getNumOccurrences() == 0) { + args.push_back(instCombineFlag.data()); + } + } +@@ -1026,7 +1026,7 @@ bool TranslateBuildSPMD(const STB_TranslateInputArgs *pInputArgs, STB_TranslateO + llvm::StringRef licmMSSAPromotionFlag = "-licm-mssa-max-acc-promotion=500"; + auto licmMSSAPromotionSwitch = optionsMap.find(licmMSSAPromotionFlag.trim("-=500")); + if (licmMSSAPromotionSwitch != optionsMap.end()) { +- if (licmMSSAPromotionSwitch->getValue()->getNumOccurrences() == 0) { ++ if (licmMSSAPromotionSwitch->second->getNumOccurrences() == 0) { + args.push_back(licmMSSAPromotionFlag.data()); + } + } +@@ -1035,7 +1035,7 @@ bool TranslateBuildSPMD(const STB_TranslateInputArgs *pInputArgs, STB_TranslateO + llvm::StringRef aaQueryDepthFlag = "-basic-aa-max-query-depth=192"; + auto aaQueryDepthSwitch = optionsMap.find(aaQueryDepthFlag.trim("-=192")); + if (aaQueryDepthSwitch != optionsMap.end()) { +- if (aaQueryDepthSwitch->getValue()->getNumOccurrences() == 0) { ++ if (aaQueryDepthSwitch->second->getNumOccurrences() == 0) { + args.push_back(aaQueryDepthFlag.data()); + } + } +@@ -1043,7 +1043,7 @@ bool TranslateBuildSPMD(const STB_TranslateInputArgs *pInputArgs, STB_TranslateO + llvm::StringRef dsePartialOverwriteTrackingFlag = "-enable-dse-partial-overwrite-tracking=1"; + auto dsePartialOverwriteTrackingSwitch = optionsMap.find(dsePartialOverwriteTrackingFlag.trim("-=1")); + if (dsePartialOverwriteTrackingSwitch != optionsMap.end()) { +- if (dsePartialOverwriteTrackingSwitch->getValue()->getNumOccurrences() == 0) { ++ if (dsePartialOverwriteTrackingSwitch->second->getNumOccurrences() == 0) { + args.push_back(dsePartialOverwriteTrackingFlag.data()); + } + } +@@ -1051,7 +1051,7 @@ bool TranslateBuildSPMD(const STB_TranslateInputArgs *pInputArgs, STB_TranslateO + llvm::StringRef dseMSSAStepLimitFlag = "-dse-memoryssa-walklimit=150"; + auto dseMSSAStepLimitSwitch = optionsMap.find(dseMSSAStepLimitFlag.trim("-=150")); + if (dseMSSAStepLimitSwitch != optionsMap.end()) { +- if (dseMSSAStepLimitSwitch->getValue()->getNumOccurrences() == 0) { ++ if (dseMSSAStepLimitSwitch->second->getNumOccurrences() == 0) { + args.push_back(dseMSSAStepLimitFlag.data()); + } + } +@@ -1063,7 +1063,7 @@ bool TranslateBuildSPMD(const STB_TranslateInputArgs *pInputArgs, STB_TranslateO + for (const auto indVarSimplifyFlag : indVarSimplifyFlags) { + auto indVarSimplifySwitch = optionsMap.find(indVarSimplifyFlag.drop_front(1).split("=").first); + if (indVarSimplifySwitch != optionsMap.end()) { +- if (indVarSimplifySwitch->getValue()->getNumOccurrences() == 0) { ++ if (indVarSimplifySwitch->second->getNumOccurrences() == 0) { + args.push_back(indVarSimplifyFlag.data()); + } + } +@@ -1257,7 +1257,7 @@ bool TranslateBuildSPMD(const STB_TranslateInputArgs *pInputArgs, STB_TranslateO + oclContext.getModuleMetaData()->csInfo.forcedSIMDSize |= IGC_GET_FLAG_VALUE(ForceOCLSIMDWidth); + + try { +- if (llvm::StringRef(oclContext.getModule()->getTargetTriple()).startswith("spir")) { ++ if (oclContext.getModule()->getTargetTriple().getTriple().starts_with("spir")) { + IGC::UnifyIRSPIR(&oclContext); + } else // not SPIR + { +diff --git a/IGC/AdaptorOCL/ocl_igc_interface/impl/fcl_ocl_translation_ctx_impl.cpp b/IGC/AdaptorOCL/ocl_igc_interface/impl/fcl_ocl_translation_ctx_impl.cpp +index b7210f0..4e3842c 100644 +--- a/IGC/AdaptorOCL/ocl_igc_interface/impl/fcl_ocl_translation_ctx_impl.cpp ++++ b/IGC/AdaptorOCL/ocl_igc_interface/impl/fcl_ocl_translation_ctx_impl.cpp +@@ -318,7 +318,7 @@ static bool processCmSrcOptions(llvm::SmallVectorImpl &userArgs, s + optname += "="; + toErase = std::find_if(userArgs.begin(), userArgs.end(), [&optname](const auto &Item) { + llvm::StringRef S = Item; +- return S.startswith(optname); ++ return S.starts_with(optname); + }); + if (toErase != userArgs.end()) { + inputFile = *toErase; +diff --git a/IGC/AdaptorOCL/preprocess_spvir/HandleSPIRVDecorations/HandleSpirvDecorationMetadata.cpp b/IGC/AdaptorOCL/preprocess_spvir/HandleSPIRVDecorations/HandleSpirvDecorationMetadata.cpp +index a84ae58..0912c70 100644 +--- a/IGC/AdaptorOCL/preprocess_spvir/HandleSPIRVDecorations/HandleSpirvDecorationMetadata.cpp ++++ b/IGC/AdaptorOCL/preprocess_spvir/HandleSPIRVDecorations/HandleSpirvDecorationMetadata.cpp +@@ -556,7 +556,7 @@ void HandleSpirvDecorationMetadata::handleCacheControlINTELFor1DBlockIO(CallInst + void HandleSpirvDecorationMetadata::handleCacheControlINTELForOCL1DBlockPrefetch(CallInst &I, + SmallPtrSetImpl &MDNodes, + SmallVectorImpl &Matches) { +- IGC_ASSERT(Matches[1].startswith("intel_sub_group_block_prefetch")); ++ IGC_ASSERT(Matches[1].starts_with("intel_sub_group_block_prefetch")); + + CacheControlFromMDNodes cacheControl = resolveCacheControlFromMDNodes(m_pCtx, MDNodes); + if (cacheControl.isEmpty) +@@ -575,13 +575,13 @@ void HandleSpirvDecorationMetadata::handleCacheControlINTELForOCL1DBlockPrefetch + numElementsToPrefetch == 8 || numElementsToPrefetch == 16); + + uint32_t typeSizeInBytes = 0; +- if (Matches[2].equals("uc")) ++ if (Matches[2] == "uc") + typeSizeInBytes = 1; +- else if (Matches[2].equals("us")) ++ else if (Matches[2] == "us") + typeSizeInBytes = 2; +- else if (Matches[2].equals("ui")) ++ else if (Matches[2] == "ui") + typeSizeInBytes = 4; +- else if (Matches[2].equals("ul")) ++ else if (Matches[2] == "ul") + typeSizeInBytes = 8; + else + IGC_ASSERT(0 && "Unsupported type prefetch!"); +diff --git a/IGC/AdaptorOCL/preprocess_spvir/PreprocessSPVIR.cpp b/IGC/AdaptorOCL/preprocess_spvir/PreprocessSPVIR.cpp +index 891376f..28b74f4 100644 +--- a/IGC/AdaptorOCL/preprocess_spvir/PreprocessSPVIR.cpp ++++ b/IGC/AdaptorOCL/preprocess_spvir/PreprocessSPVIR.cpp +@@ -67,7 +67,7 @@ void PreprocessSPVIR::createCallAndReplace(CallInst &oldCallInst, StringRef newF + // IGC supports clang-consistent representation of printf (which is unmangled, + // variadic function), all printf calls must get replaced. + void PreprocessSPVIR::visitOpenCLEISPrintf(llvm::CallInst &CI) { +- FunctionType *FT = FunctionType::get(CI.getType(), Type::getInt8PtrTy(m_Module->getContext(), 2), true); ++ FunctionType *FT = FunctionType::get(CI.getType(), PointerType::get(Type::getInt8Ty(m_Module->getContext()), 2), true); + Function *newPrintf = cast(m_Module->getOrInsertFunction("printf", FT)); + CI.setCalledFunction(newPrintf); + +@@ -194,7 +194,7 @@ void PreprocessSPVIR::removePointerAnnotations(Module &M) { + if (!CI) + continue; + auto *Callee = CI->getCalledFunction(); +- if (!Callee || !Callee->getName().startswith("llvm.ptr.annotation.")) ++ if (!Callee || !Callee->getName().starts_with("llvm.ptr.annotation.")) + continue; + + // @llvm.ptr.annotation returns its first operand (the annotated pointer) +@@ -248,7 +248,7 @@ static void fixKernelArgBaseTypes(Module &M) { + StringRef Ty = TyStr->getString(); + StringRef Base = BaseStr->getString(); + +- if (Ty.endswith("_t") && Ty != Base) { ++ if (Ty.ends_with("_t") && Ty != Base) { + NeedPatch = true; + NewBase.push_back(MDString::get(Ctx, Ty)); + } else { +diff --git a/IGC/AdaptorOCL/preprocess_spvir/PromoteSubByte.cpp b/IGC/AdaptorOCL/preprocess_spvir/PromoteSubByte.cpp +index 94284a2..269cb05 100644 +--- a/IGC/AdaptorOCL/preprocess_spvir/PromoteSubByte.cpp ++++ b/IGC/AdaptorOCL/preprocess_spvir/PromoteSubByte.cpp +@@ -520,7 +520,7 @@ Function *PromoteSubByte::promoteFunction(Function *function) { + } + + #if !defined(WDDM_ANDROID_IGC) +- if (BiFManager::BiFManagerHandler::IsBiF(function) || function->getName().startswith("__builtin_IB_") || ++ if (BiFManager::BiFManagerHandler::IsBiF(function) || function->getName().starts_with("__builtin_IB_") || + function->getName() == "intel_sub_group_ballot" || + function->getName().contains("intel_is_device_barrier_valid")) { + return function; +diff --git a/IGC/BiFManager/BiFManagerHandler.cpp b/IGC/BiFManager/BiFManagerHandler.cpp +index f1e5704..a1c7335 100644 +--- a/IGC/BiFManager/BiFManagerHandler.cpp ++++ b/IGC/BiFManager/BiFManagerHandler.cpp +@@ -244,7 +244,7 @@ void BiFManagerHandler::preapareBiFSections(llvm::Module &pMainModule, TFunction + if (T == "") { + bifGenericSection.setTargetTriple(builtinSizeModule()->getTargetTriple()); + } else { +- bifGenericSection.setTargetTriple(T); ++ bifGenericSection.setTargetTriple(llvm::Triple(T)); + } + } + if (DL == nullptr) { +diff --git a/IGC/BiFManager/CMakeLists.txt b/IGC/BiFManager/CMakeLists.txt +index 6b91831..868fa69 100644 +--- a/IGC/BiFManager/CMakeLists.txt ++++ b/IGC/BiFManager/CMakeLists.txt +@@ -24,7 +24,7 @@ set(IGC_BUILD__PROJ__BiFManager_EXE "${IGC_BUILD__PROJ__BiFManager_EXE}" PAREN + set(IGC_BUILD__PROJ__BiFManager "${IGC_BUILD__PROJ__BiFManager}" PARENT_SCOPE) + set(IGC_BUILD__PROJ_LABEL__BiFManager "${IGC_BUILD__PROJ__BiFManager}") + +-add_library("${IGC_BUILD__PROJ__BiFManager}" ++add_library("${IGC_BUILD__PROJ__BiFManager}" STATIC + "${CMAKE_CURRENT_SOURCE_DIR}/BiFManagerHandler.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/BiFManagerCommon.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/BiFManagerHandler.hpp" +diff --git a/IGC/BiFModule/cmake/BiFBuildBitcode.cmake b/IGC/BiFModule/cmake/BiFBuildBitcode.cmake +index e92c6d3..abc26f2 100644 +--- a/IGC/BiFModule/cmake/BiFBuildBitcode.cmake ++++ b/IGC/BiFModule/cmake/BiFBuildBitcode.cmake +@@ -190,7 +190,7 @@ function(igc_bif_build_bc) + # forcibly included headers or change of additional dependencies. + execute_process( + COMMAND "${CMAKE_COMMAND}" -E make_directory "${_outBcFileDir}" +- COMMAND ${clang-tool} -cc1 ${IGC_BUILD__OPAQUE_POINTERS_DEFAULT_ARG_CLANG} -x cl -fblocks -fpreserve-vec3-type -opencl-builtins "-triple=${_archTriple}" -w -emit-llvm-bc -discard-value-names -o "${_bcTempFilePath}" ${_pchFlags} ${_incFileFlags} ${_includeDirsFlags} ${_defineFlags} ${_options_DEFAULT} ${_options_CL} "${_srcFilePath}" ++ COMMAND ${clang-tool} -cc1 ${IGC_BUILD__OPAQUE_POINTERS_DEFAULT_ARG_CLANG} -x cl -fblocks -Wno-error=incompatible-pointer-types -Wno-error=incompatible-function-pointer-types -opencl-builtins "-triple=${_archTriple}" -w -emit-llvm-bc -discard-value-names -o "${_bcTempFilePath}" ${_pchFlags} ${_incFileFlags} ${_includeDirsFlags} ${_defineFlags} ${_options_DEFAULT} ${_options_CL} "${_srcFilePath}" + COMMAND_ECHO STDOUT + ) + execute_process( +diff --git a/IGC/CMakeLists.txt b/IGC/CMakeLists.txt +index 295e13b..f4d6d68 100644 +--- a/IGC/CMakeLists.txt ++++ b/IGC/CMakeLists.txt +@@ -120,7 +120,7 @@ else() + set(_buildType "Release") + message(WARNING "CMAKE_BUILD_TYPE: No build configuration specified. The following configurations are available: ${IGC_CMAKE_CONFIGURATION_TYPES}.\nThe \"${_buildType}\" configuration will be used.\nThis value has meaning only for single-configuration generators (like Make). It will be ignored for MSVC/XCode.") + endif() +- set(CMAKE_BUILD_TYPE "${_buildType}") ++#_cmake_modify_IGNORE set(CMAKE_BUILD_TYPE "${_buildType}") + unset(_buildType) + endif() + +@@ -820,7 +820,7 @@ foreach(_compilerFlagName IN ITEMS "CMAKE_CXX_FLAGS" "CMAKE_C_FLAGS") + ExceptionsEnabled + MultiProcessorCompilation + DeadCodeEliminate +- TreatWarnAsErrorEnabled ++ TreatWarnAsErrorDisabled + ) + + if(IGC_OPTION__UNIVERSAL_DRIVER) +@@ -1053,7 +1053,6 @@ foreach(_compilerFlagName IN ITEMS "CMAKE_CXX_FLAGS" "CMAKE_C_FLAGS") + string(FIND ${CMAKE_CXX_FLAGS} "-D_FORTIFY_SOURCE=3" __FORTIFY_SOURCE_3_SET) + set(flags -fstack-protector) + if(${__FORTIFY_SOURCE_3_SET} EQUAL -1) +- list(APPEND flags -D_FORTIFY_SOURCE=2) + endif() + igc_config_flag_apply_settings( + CompilerOptions +diff --git a/IGC/Compiler/Builtins/BIFFlagCtrl/BIFFlagCtrlResolution.cpp b/IGC/Compiler/Builtins/BIFFlagCtrl/BIFFlagCtrlResolution.cpp +index d97defe..cdcff0f 100644 +--- a/IGC/Compiler/Builtins/BIFFlagCtrl/BIFFlagCtrlResolution.cpp ++++ b/IGC/Compiler/Builtins/BIFFlagCtrl/BIFFlagCtrlResolution.cpp +@@ -56,7 +56,7 @@ void BIFFlagCtrlResolution::FillFlagCtrl() { + BIF_FLAG_CTRL_SET(UseBfn, IGC_IS_FLAG_ENABLED(EnableBfn) && PtrCGC->platform.supportBfnInstruction()); + BIF_FLAG_CTRL_SET(hasHWLocalThreadID, PtrCGC->platform.hasHWLocalThreadID()); + BIF_FLAG_CTRL_SET(CRMacros, PtrCGC->platform.hasCorrectlyRoundedMacros()); +- BIF_FLAG_CTRL_SET(APIRS, !(StringRef(PtrCGC->getModule()->getTargetTriple()).size() > 0)); ++ BIF_FLAG_CTRL_SET(APIRS, !(PtrCGC->getModule()->getTargetTriple().empty() == false)); + + if (PtrCGC->type == ShaderType::OPENCL_SHADER) { + BIF_FLAG_CTRL_SET(IsSPIRV, static_cast(PtrCGC)->isSPIRV()); +diff --git a/IGC/Compiler/CISACodeGen/AdvCodeMotion.cpp b/IGC/Compiler/CISACodeGen/AdvCodeMotion.cpp +index f2fa188..eca4466 100644 +--- a/IGC/Compiler/CISACodeGen/AdvCodeMotion.cpp ++++ b/IGC/Compiler/CISACodeGen/AdvCodeMotion.cpp +@@ -202,7 +202,8 @@ void WorkItemSetting::collect(Function *F) { + Value *X = nullptr; + ICmpInst::Predicate Pred; + if (match(Inst, +- m_Select(m_ICmp(Pred, m_Specific(GlobalSize1.X), m_Zero()), m_Value(X), m_Specific(GlobalSize1.X))) && ++ m_Select(m_ICmp(m_Specific(GlobalSize1.X), m_Zero()), m_Value(X), m_Specific(GlobalSize1.X))) && ++ (Pred = cast(cast(Inst)->getCondition())->getPredicate(), true) && + Pred == ICmpInst::ICMP_EQ) { + GlobalSize.X = Inst; + } +@@ -776,9 +777,9 @@ static bool sliceCandidateRun(BasicBlock *BB, ArrayRef Run) { + + DenseMap Leaders; + for (auto I = ECs.begin(), E = ECs.end(); I != E; ++I) { +- if (!I->isLeader()) ++ if (!(*I)->isLeader()) + continue; +- Instruction *Leader = I->getData(); ++ Instruction *Leader = (*I)->getData(); + Leaders.insert(std::make_pair(Leader, nullptr)); + } + +@@ -857,13 +858,13 @@ bool MadLoopSlice::sliceLoop(Loop *L) const { + } + DenseMap Leaders; + for (auto I = ECs.begin(), E = ECs.end(); I != E; ++I) { +- if (!I->isLeader()) ++ if (!(*I)->isLeader()) + continue; +- Instruction *Leader = I->getData(); ++ Instruction *Leader = (*I)->getData(); + // Skip EC with the loop condition. + if (ECs.isEquivalent(Leader, BI)) + continue; +- for (auto MI = ECs.member_begin(I), ME = ECs.member_end(); MI != ME; ++MI) { ++ for (auto MI = ECs.member_begin(**I), ME = ECs.member_end(); MI != ME; ++MI) { + // Skip the slicing if there is non-MAD instructions. + if (!isa(*MI) && !isCandidateMAD(*MI, CGC)) + return false; +diff --git a/IGC/Compiler/CISACodeGen/AtomicOptPass.cpp b/IGC/Compiler/CISACodeGen/AtomicOptPass.cpp +index a0aeeef..085666e 100644 +--- a/IGC/Compiler/CISACodeGen/AtomicOptPass.cpp ++++ b/IGC/Compiler/CISACodeGen/AtomicOptPass.cpp +@@ -12,6 +12,7 @@ SPDX-License-Identifier: MIT + + #include "Compiler/IGCPassSupport.h" + #include "GenISAIntrinsics/GenIntrinsicInst.h" ++#include "common/LLVMUtils.h" + + #include "common/LLVMWarningsPush.hpp" + #include "common/LLVMWarningsPop.hpp" +@@ -71,19 +72,19 @@ bool AtomicOptPass::checkFloatAtomicEmulation(Instruction *Inst, size_t &Operand + if (BbWithAtomic->hasNPredecessorsOrMore(3)) + return false; + +- BitCastInst *FirstBitcastInstr = dyn_cast(GInst->getNextNonDebugInstruction()); ++ BitCastInst *FirstBitcastInstr = dyn_cast(IGC::getNextNonDbgInstruction(GInst)); + if (!FirstBitcastInstr) + return false; + +- Instruction *OpInstr = FirstBitcastInstr->getNextNonDebugInstruction(); ++ Instruction *OpInstr = IGC::getNextNonDbgInstruction(FirstBitcastInstr); + if (!OpInstr || !OpInstr->isFast()) + return false; + +- BitCastInst *SecondBitcastInstr = dyn_cast(OpInstr->getNextNonDebugInstruction()); ++ BitCastInst *SecondBitcastInstr = dyn_cast(IGC::getNextNonDbgInstruction(OpInstr)); + if (!SecondBitcastInstr) + return false; + +- GenIntrinsicInst *AtomicFinishInstr = dyn_cast(SecondBitcastInstr->getNextNonDebugInstruction()); ++ GenIntrinsicInst *AtomicFinishInstr = dyn_cast(IGC::getNextNonDbgInstruction(SecondBitcastInstr)); + + if (!AtomicFinishInstr) + return false; +@@ -91,7 +92,7 @@ bool AtomicOptPass::checkFloatAtomicEmulation(Instruction *Inst, size_t &Operand + if (AtomicFinishInstr->getIntrinsicID() != GenISAIntrinsic::GenISA_icmpxchgatomicrawA64) + return false; + +- CmpInst *CmpInstr = dyn_cast(AtomicFinishInstr->getNextNonDebugInstruction()); ++ CmpInst *CmpInstr = dyn_cast(IGC::getNextNonDbgInstruction(AtomicFinishInstr)); + if (!CmpInstr) + return false; + +@@ -104,9 +105,8 @@ bool AtomicOptPass::checkFloatAtomicEmulation(Instruction *Inst, size_t &Operand + else + return false; + +- CmpInst::Predicate Pred = CmpInst::Predicate::ICMP_EQ; + Instruction *FinishInstr = cast(AtomicFinishInstr); +- auto CmpPattern = m_Cmp(Pred, m_Instruction(Inst), m_Instruction(FinishInstr)); ++ auto CmpPattern = m_Cmp(m_Instruction(Inst), m_Instruction(FinishInstr)); + + if (!match(cast(CmpInstr), CmpPattern)) + return false; +@@ -151,8 +151,8 @@ bool AtomicOptPass::runOnFunction(Function &F) { + size_t OperandPos = 0; + // Here we check if this is an atomic instruction emulation or not. + if (checkFloatAtomicEmulation(&I, OperandPos)) { +- Instruction *FirstBitcastInstr = I.getNextNonDebugInstruction(); +- Instruction *MainInstr = FirstBitcastInstr->getNextNonDebugInstruction(); ++ Instruction *FirstBitcastInstr = IGC::getNextNonDbgInstruction(&I); ++ Instruction *MainInstr = IGC::getNextNonDbgInstruction(FirstBitcastInstr); + + BasicBlock *BbWithAtomic = I.getParent(); + BasicBlock *BackBb = nullptr; +diff --git a/IGC/Compiler/CISACodeGen/BlockMemOpAddrScalarizationPass.cpp b/IGC/Compiler/CISACodeGen/BlockMemOpAddrScalarizationPass.cpp +index 6f1a6fe..39a8e70 100644 +--- a/IGC/Compiler/CISACodeGen/BlockMemOpAddrScalarizationPass.cpp ++++ b/IGC/Compiler/CISACodeGen/BlockMemOpAddrScalarizationPass.cpp +@@ -10,6 +10,7 @@ SPDX-License-Identifier: MIT + #include + + #include "Compiler/IGCPassSupport.h" ++#include "common/LLVMUtils.h" + + #include "common/LLVMWarningsPush.hpp" + #include "common/LLVMWarningsPop.hpp" +@@ -193,7 +194,7 @@ Value *BlockMemOpAddrScalarizationPass::insertBroadcast(Instruction *InstForBroa + if (isa(InstForBroadcast)) + PlaceForInsert = InstForBroadcast->getParent()->getFirstNonPHI(); + else +- PlaceForInsert = InstForBroadcast->getNextNonDebugInstruction(); ++ PlaceForInsert = IGC::getNextNonDbgInstruction(InstForBroadcast); + + IRBuilder<> Builder(PlaceForInsert); + +diff --git a/IGC/Compiler/CISACodeGen/CodeSchedulingOptionsDef.h b/IGC/Compiler/CISACodeGen/CodeSchedulingOptionsDef.h +index 66baa86..26f1d9a 100644 +--- a/IGC/Compiler/CISACodeGen/CodeSchedulingOptionsDef.h ++++ b/IGC/Compiler/CISACodeGen/CodeSchedulingOptionsDef.h +@@ -13,7 +13,7 @@ SPDX-License-Identifier: MIT + + // Generate default options line: + // clang-format off +-// python3 -c "print('IGC_CodeSchedulingConfig=\"' + ';'.join([line.split(',')[1].strip() for line in open('CodeSchedulingOptionsDef.h') if line.strip().startswith('DECLARE_SCHEDULING_OPTION')]) + '\"')" ++// python3 -c "print('IGC_CodeSchedulingConfig=\"' + ';'.join([line.split(',')[1].strip() for line in open('CodeSchedulingOptionsDef.h') if line.strip().starts_with('DECLARE_SCHEDULING_OPTION')]) + '\"')" + // clang-format on + + // Edge weights +diff --git a/IGC/Compiler/CISACodeGen/CodeSinking.cpp b/IGC/Compiler/CISACodeGen/CodeSinking.cpp +index f8c8e5c..3f5e954 100644 +--- a/IGC/Compiler/CISACodeGen/CodeSinking.cpp ++++ b/IGC/Compiler/CISACodeGen/CodeSinking.cpp +@@ -16,6 +16,7 @@ See LICENSE.TXT for details. + #include + #include "common/debug/Debug.hpp" + #include "common/debug/Dump.hpp" ++#include "common/LLVMUtils.h" + #include "common/Stats.hpp" + #include "common/LLVMUtils.h" + #include "common/LLVMWarningsPush.hpp" +@@ -64,7 +65,7 @@ static void ProcessDbgValueInst(BasicBlock &blk, DominatorTree *DT) { + PositionMap[inst] = &*def->getParent()->getFirstInsertionPt(); + } else { + // Otherwise, insert the new instruction after the defining instruction. +- PositionMap[inst] = def->getNextNonDebugInstruction(); ++ PositionMap[inst] = IGC::getNextNonDbgInstruction(def); + IGC_ASSERT(!isa(def)); + } + } +diff --git a/IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp b/IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp +index f95de91..d0d8af8 100644 +--- a/IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp ++++ b/IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp +@@ -826,7 +826,7 @@ void ConstantCoalescing::SetAlignmentFromOffset(Instruction *load) { + } + IGC_ASSERT(offset != nullptr); + const DominatorTree &DT = getAnalysis().getDomTree(); +- KnownBits kb = computeKnownBits(offset, *dataLayout, 0 /*current depth*/, nullptr /*AssumptionCache*/, load, &DT); ++ KnownBits kb = computeKnownBits(offset, *dataLayout, nullptr /*AssumptionCache*/, load, &DT, true, 0 /*current depth*/); + uint32_t numTrailZeros = std::min(kb.countMinTrailingZeros(), Value::MaxAlignmentExponent); + alignment_t alignment = (1ull << std::min(kb.getBitWidth() - 1, numTrailZeros)); + alignment = std::max(alignment, m_ChunkMinAlignment); +diff --git a/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp b/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp +index 08ec898..7b721eb 100644 +--- a/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp ++++ b/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp +@@ -24,6 +24,7 @@ SPDX-License-Identifier: MIT + #include "ShaderCodeGen.hpp" + #include "MemOpt.h" // helper functions related struct value. + #include "common/debug/Dump.hpp" ++#include "common/LLVMUtils.h" + #include "common/debug/Dump.hpp" + #include "common/igc_regkeys.hpp" + #include "common/Stats.hpp" +@@ -1004,7 +1005,7 @@ bool EmitPass::runOnFunction(llvm::Function &F) { + unsigned int curLineNumber = llvmInst->getDebugLoc().getLine(); + auto &&srcFile = llvmInst->getDebugLoc()->getScope()->getFilename(); + auto &&srcDir = llvmInst->getDebugLoc()->getScope()->getDirectory(); +- if (!curSrcFile.equals(srcFile) || !curSrcDir.equals(srcDir)) { ++ if (!(curSrcFile == srcFile) || !(curSrcDir == srcDir)) { + curSrcFile = srcFile; + curSrcDir = srcDir; + m_pDebugEmitter->BeginEncodingMark(); +@@ -2722,7 +2723,7 @@ void EmitPass::EmitInsertValueToStruct(InsertValueInst *inst) { + for (const auto &II : toBeCopied) { + // skip one that will be written by this inst + auto theIdx = inst->getIndices(); +- if (theIdx.equals(II)) { ++ if ((llvm::ArrayRef(theIdx) == llvm::ArrayRef(II))) { + continue; + } + +@@ -9677,16 +9678,16 @@ bool EmitPass::validateInlineAsmConstraints(llvm::CallInst *inst, SmallVectorIsImmediate(); +- } else if (str.equals("rw.u")) { ++ } else if ((str == "rw.u")) { + return cv && cv->IsUniform(); + } else { + IGC_ASSERT_MESSAGE(0, "Unsupported constraint type!"); +@@ -9704,7 +9705,7 @@ bool EmitPass::validateInlineAsmConstraints(llvm::CallInst *inst, SmallVectorGetVISABuilder()->GetAsmTextStream(); + InlineAsm *IA = cast(IGCLLVM::getCalledValue(inst)); +- string asmStr = IA->getAsmString(); ++ string asmStr = IA->getAsmString().str(); + smallvector opnds; + SmallVector constraints; + DenseMap DstOpndMap; +@@ -9801,12 +9802,12 @@ void EmitPass::EmitInlineAsm(llvm::CallInst *inst) { + + // All uniform variables must be broadcasted if 'rw' constraint was + // specified +- if (opVar->IsUniform() && constraint.equals("rw")) { ++ if (opVar->IsUniform() && (constraint == "rw")) { + opnds[i] = BroadcastIfUniform(opVar); + } + // Special handling if LLVM replaces a variable with an immediate, we need + // to insert an extra move +- else if (opVar->IsImmediate() && !constraint.equals("i") && !constraint.equals("P")) { ++ else if (opVar->IsImmediate() && !(constraint == "i") && !(constraint == "P")) { + CVariable *tempMov = m_currShader->GetNewVariable(1, opVar->GetType(), EALIGN_GRF, true, opVar->getName()); + m_encoder->Copy(tempMov, opVar); + m_encoder->Push(); +@@ -9873,7 +9874,7 @@ void EmitPass::EmitInlineAsm(llvm::CallInst *inst) { + return; + } + string varName; +- if (constraints[val].equals("P")) ++ if (constraints[val] == "P") + varName = std::to_string(opnds[val]->GetImmediateValue()); + else if (opnds[val]) + varName = m_encoder->GetVariableName(opnds[val]); +@@ -16301,8 +16302,8 @@ void EmitPass::ResetRoundingMode(Instruction *inst) { + // next explicit-RM setting instruction (genintrinsic). + bool nextImplicitFPCvtInt = false; + bool nextImplicitFP = false; +- for (auto nextInst = inst->getNextNonDebugInstruction(); nextInst != nullptr; +- nextInst = nextInst->getNextNonDebugInstruction()) { ++ for (auto nextInst = IGC::getNextNonDbgInstruction(inst); nextInst != nullptr; ++ nextInst = IGC::getNextNonDbgInstruction(nextInst)) { + if (ignoresRoundingMode(nextInst)) { + continue; + } +@@ -23891,14 +23892,14 @@ void EmitPass::emitLSCFence(llvm::GenIntrinsicInst *inst) { + unsigned short getLSCAtomicBitWidth(llvm::GenIntrinsicInst *inst) { + llvm::StringRef name = inst->getCalledFunction()->getName(); + unsigned short bitwidth = 0; +- if (name.startswith("llvm.genx.GenISA.LSCAtomicInts.i64") || name.startswith("llvm.genx.GenISA.LSCAtomicInts.u64") || +- name.startswith("llvm.genx.GenISA.LSCAtomicFP64")) ++ if (name.starts_with("llvm.genx.GenISA.LSCAtomicInts.i64") || name.starts_with("llvm.genx.GenISA.LSCAtomicInts.u64") || ++ name.starts_with("llvm.genx.GenISA.LSCAtomicFP64")) + bitwidth = 64; +- else if (name.startswith("llvm.genx.GenISA.LSCAtomicInts.i32") || +- name.startswith("llvm.genx.GenISA.LSCAtomicInts.u32") || name.startswith("llvm.genx.GenISA.LSCAtomicFP32")) ++ else if (name.starts_with("llvm.genx.GenISA.LSCAtomicInts.i32") || ++ name.starts_with("llvm.genx.GenISA.LSCAtomicInts.u32") || name.starts_with("llvm.genx.GenISA.LSCAtomicFP32")) + bitwidth = 32; +- else if (name.startswith("llvm.genx.GenISA.LSCAtomicInts.i16") || +- name.startswith("llvm.genx.GenISA.LSCAtomicInts.u16") || (name.startswith("llvm.genx.GenISA.LSCAtomicBF16"))) ++ else if (name.starts_with("llvm.genx.GenISA.LSCAtomicInts.i16") || ++ name.starts_with("llvm.genx.GenISA.LSCAtomicInts.u16") || (name.starts_with("llvm.genx.GenISA.LSCAtomicBF16"))) + bitwidth = 16; + else + IGC_ASSERT_MESSAGE(0, "Intrinsic support is not implemented."); +@@ -25340,7 +25341,7 @@ Function *EmitPass::findStackOverflowDetectionFunction(Function *ParentFunction, + auto FG = m_FGA->getGroup(ParentFunction); + // Function subgroup can contain clones of the subroutine. + for (auto F : *FG) { +- if (F->getName().startswith(FunctionName) && m_FGA->getSubGroupMap(ParentFunction) == m_FGA->getSubGroupMap(F)) { ++ if (F->getName().starts_with(FunctionName) && m_FGA->getSubGroupMap(ParentFunction) == m_FGA->getSubGroupMap(F)) { + StackOverflowFunction = F; + break; + } +diff --git a/IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp b/IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp +index 03d3650..d0da89f 100644 +--- a/IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp ++++ b/IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp +@@ -1352,9 +1352,9 @@ bool InstExpander::visitFPToUI(FPToUIInst &F2U) { + } + + IID = Intrinsic::trunc; +- Function *Trunc = Intrinsic::getDeclaration(Emu->getModule(), IID, SrcTy); ++ Function *Trunc = Intrinsic::getOrInsertDeclaration(Emu->getModule(), IID, SrcTy); + IID = Intrinsic::fma; +- Function *Fma = Intrinsic::getDeclaration(Emu->getModule(), IID, SrcTy); ++ Function *Fma = Intrinsic::getOrInsertDeclaration(Emu->getModule(), IID, SrcTy); + + Value *FC0 = ConstantFP::get(SrcTy, ldexp(1., -32)); + Value *FC1 = ConstantFP::get(SrcTy, ldexp(-1., 32)); +@@ -1407,11 +1407,11 @@ bool InstExpander::visitFPToSI(FPToSIInst &F2S) { + Sign = IRB->CreateAShr(Sign, 31); + + IID = Intrinsic::fabs; +- Function *FAbs = Intrinsic::getDeclaration(Emu->getModule(), IID, SrcTy); ++ Function *FAbs = Intrinsic::getOrInsertDeclaration(Emu->getModule(), IID, SrcTy); + IID = Intrinsic::trunc; +- Function *Trunc = Intrinsic::getDeclaration(Emu->getModule(), IID, SrcTy); ++ Function *Trunc = Intrinsic::getOrInsertDeclaration(Emu->getModule(), IID, SrcTy); + IID = Intrinsic::fma; +- Function *Fma = Intrinsic::getDeclaration(Emu->getModule(), IID, SrcTy); ++ Function *Fma = Intrinsic::getOrInsertDeclaration(Emu->getModule(), IID, SrcTy); + + Value *FC0 = ConstantFP::get(SrcTy, ldexp(1., -32)); + Value *FC1 = ConstantFP::get(SrcTy, ldexp(-1., 32)); +@@ -1450,7 +1450,7 @@ Value *InstExpander::convertUIToFP32(Type *DstTy, Value *Lo, Value *Hi, Instruct + + IGCLLVM::Intrinsic IID; + IID = Intrinsic::ctlz; +- Function *Lzd = Intrinsic::getDeclaration(Emu->getModule(), IID, Lo->getType()); ++ Function *Lzd = Intrinsic::getOrInsertDeclaration(Emu->getModule(), IID, Lo->getType()); + + Value *ShAmt = IRB->CreateCall2(Lzd, Hi, IRB->getFalse()); + // Check ShAmt == 32 +@@ -1572,7 +1572,7 @@ bool InstExpander::visitUIToFP(UIToFPInst &U2F) { + + if (DstTy->isDoubleTy()) { + IGCLLVM::Intrinsic IID = Intrinsic::fma; +- Function *Fma = Intrinsic::getDeclaration(Emu->getModule(), IID, DstTy); ++ Function *Fma = Intrinsic::getOrInsertDeclaration(Emu->getModule(), IID, DstTy); + Value *FC0 = ConstantFP::get(DstTy, ldexp(1., 32)); + Value *LoF = IRB->CreateUIToFP(Lo, DstTy); + Value *HiF = IRB->CreateUIToFP(Hi, DstTy); +@@ -1619,7 +1619,7 @@ bool InstExpander::visitSIToFP(SIToFPInst &S2F) { + + if (DstTy->isDoubleTy()) { + IGCLLVM::Intrinsic IID = Intrinsic::fma; +- Function *Fma = Intrinsic::getDeclaration(Emu->getModule(), IID, DstTy); ++ Function *Fma = Intrinsic::getOrInsertDeclaration(Emu->getModule(), IID, DstTy); + Value *FC0 = ConstantFP::get(DstTy, ldexp(1., 32)); + Value *LoF = IRB->CreateUIToFP(Lo, DstTy); + Value *HiF = IRB->CreateSIToFP(Hi, DstTy); +diff --git a/IGC/Compiler/CISACodeGen/EstimateFunctionSize.cpp b/IGC/Compiler/CISACodeGen/EstimateFunctionSize.cpp +index e9f29f7..7fdb05b 100644 +--- a/IGC/Compiler/CISACodeGen/EstimateFunctionSize.cpp ++++ b/IGC/Compiler/CISACodeGen/EstimateFunctionSize.cpp +@@ -551,37 +551,37 @@ void EstimateFunctionSize::clear() { + bool EstimateFunctionSize::matchImplicitArg(CallInst &CI) { + bool matched = false; + StringRef funcName = CI.getCalledFunction()->getName(); +- if (funcName.equals(GET_LOCAL_ID_X) || funcName.equals(GET_LOCAL_ID_Y) || funcName.equals(GET_LOCAL_ID_Z)) { ++ if ((funcName == GET_LOCAL_ID_X) || (funcName == GET_LOCAL_ID_Y) || (funcName == GET_LOCAL_ID_Z)) { + matched = true; +- } else if (funcName.equals(GET_GROUP_ID)) { ++ } else if ((funcName == GET_GROUP_ID)) { + matched = true; +- } else if (funcName.equals(GET_LOCAL_THREAD_ID)) { ++ } else if ((funcName == GET_LOCAL_THREAD_ID)) { + matched = true; +- } else if (funcName.equals(GET_GLOBAL_OFFSET)) { ++ } else if ((funcName == GET_GLOBAL_OFFSET)) { + matched = true; +- } else if (funcName.equals(GET_GLOBAL_SIZE)) { ++ } else if ((funcName == GET_GLOBAL_SIZE)) { + matched = true; +- } else if (funcName.equals(GET_LOCAL_SIZE)) { ++ } else if ((funcName == GET_LOCAL_SIZE)) { + matched = true; +- } else if (funcName.equals(GET_WORK_DIM)) { ++ } else if ((funcName == GET_WORK_DIM)) { + matched = true; +- } else if (funcName.equals(GET_NUM_GROUPS)) { ++ } else if ((funcName == GET_NUM_GROUPS)) { + matched = true; +- } else if (funcName.equals(GET_ENQUEUED_LOCAL_SIZE)) { ++ } else if ((funcName == GET_ENQUEUED_LOCAL_SIZE)) { + matched = true; +- } else if (funcName.equals(GET_STAGE_IN_GRID_ORIGIN)) { ++ } else if ((funcName == GET_STAGE_IN_GRID_ORIGIN)) { + matched = true; +- } else if (funcName.equals(GET_STAGE_IN_GRID_SIZE)) { ++ } else if ((funcName == GET_STAGE_IN_GRID_SIZE)) { + matched = true; +- } else if (funcName.equals(GET_SYNC_BUFFER)) { ++ } else if ((funcName == GET_SYNC_BUFFER)) { + matched = true; +- } else if (funcName.equals(GET_ASSERT_BUFFER)) { ++ } else if ((funcName == GET_ASSERT_BUFFER)) { + matched = true; +- } else if (funcName.equals(GET_REGION_GROUP_SIZE)) { ++ } else if ((funcName == GET_REGION_GROUP_SIZE)) { + matched = true; +- } else if (funcName.equals(GET_REGION_GROUP_WG_COUNT)) { ++ } else if ((funcName == GET_REGION_GROUP_WG_COUNT)) { + matched = true; +- } else if (funcName.equals(GET_REGION_GROUP_BARRIER_BUFFER)) { ++ } else if ((funcName == GET_REGION_GROUP_BARRIER_BUFFER)) { + matched = true; + } + +@@ -678,7 +678,7 @@ void EstimateFunctionSize::runStaticAnalysis() { + continue; + auto &BFI = getAnalysis(F).getBFI(); + FunctionNode *Node = get(&F); +- Node->setEntryFrequency(BFI.getEntryFreq(), 0); ++ Node->setEntryFrequency(BFI.getEntryFreq().getFrequency(), 0); + + for (auto &B : F) + Node->blockFreqs[&B] = Scaled64(BFI.getBlockFreq(&B).getFrequency(), 0); +diff --git a/IGC/Compiler/CISACodeGen/FPRoundingModeCoalescing.cpp b/IGC/Compiler/CISACodeGen/FPRoundingModeCoalescing.cpp +index 00f72f7..a38c9b8 100644 +--- a/IGC/Compiler/CISACodeGen/FPRoundingModeCoalescing.cpp ++++ b/IGC/Compiler/CISACodeGen/FPRoundingModeCoalescing.cpp +@@ -16,6 +16,13 @@ SPDX-License-Identifier: MIT + #include "Compiler/CodeGenPublic.h" + #include "Compiler/IGCPassSupport.h" + #include "Compiler/MetaDataUtilsWrapper.h" ++#include "common/LLVMUtils.h" ++ ++namespace IGC { ++static llvm::Instruction *getNextNonDbgInstructionLocal(llvm::Instruction *I) { return getNextNonDbgInstruction(I); } ++static llvm::Instruction *getPrevNonDbgInstructionLocal(llvm::Instruction *I) { return getPrevNonDbgInstruction(I); } ++} ++ + #include "common/igc_regkeys.hpp" + + using namespace llvm; +@@ -210,8 +217,8 @@ bool FPRoundingModeCoalescingImpl::setsRoundingMode(Instruction &ToMove) { + + bool FPRoundingModeCoalescingImpl::checkMoveThreshold(Instruction &ToMove, Instruction *InsertPoint) { + unsigned Dist = 1; +- for (Instruction *I = ToMove.getNextNonDebugInstruction(); I != InsertPoint; +- I = I->getNextNonDebugInstruction(), ++Dist) { ++ for (Instruction *I = IGC::getNextNonDbgInstructionLocal(&ToMove); I != InsertPoint; ++ I = IGC::getNextNonDbgInstructionLocal(I), ++Dist) { + if (Dist >= IGC_GET_FLAG_VALUE(FPRoundingModeCoalescingMaxDistance)) + return false; + } +@@ -277,8 +284,8 @@ bool FPRoundingModeCoalescingImpl::tryMove(Instruction &ToMove, FPRoundingModeGr + // Next, find first instruction before group switching RM that is NOT an user + // of instruction to move. This will be an insert point. + Instruction *InsertPoint = nullptr; +- for (Instruction *I = Group.getHead()->getPrevNonDebugInstruction(); I != &ToMove; +- I = I->getPrevNonDebugInstruction()) { ++ for (Instruction *I = IGC::getPrevNonDbgInstructionLocal(Group.getHead()); I != &ToMove; ++ I = IGC::getPrevNonDbgInstructionLocal(I)) { + if (!ignoresRoundingMode(I) && Users.count(I) == 0) { + InsertPoint = I; + break; +diff --git a/IGC/Compiler/CISACodeGen/FoldKnownWorkGroupSizes.cpp b/IGC/Compiler/CISACodeGen/FoldKnownWorkGroupSizes.cpp +index 45f18b4..5630b82 100644 +--- a/IGC/Compiler/CISACodeGen/FoldKnownWorkGroupSizes.cpp ++++ b/IGC/Compiler/CISACodeGen/FoldKnownWorkGroupSizes.cpp +@@ -63,7 +63,7 @@ void FoldKnownWorkGroupSizes::visitCallInst(llvm::CallInst &I) { + } + StringRef funcName = calledFunction->getName(); + +- if (funcName.equals(WIFuncsAnalysis::GET_GLOBAL_OFFSET) && ++ if ((funcName == WIFuncsAnalysis::GET_GLOBAL_OFFSET) && + ctx->getModuleMetaData()->compOpt.replaceGlobalOffsetsByZero) { + if (calledFunction->getReturnType() == Type::getInt32Ty(module->getContext())) { + ConstantInt *IntZero = ConstantInt::get(Type::getInt32Ty(module->getContext()), 0); +@@ -72,7 +72,7 @@ void FoldKnownWorkGroupSizes::visitCallInst(llvm::CallInst &I) { + I.eraseFromParent(); + m_changed = true; + } +- } else if (funcName.equals(WIFuncsAnalysis::GET_ENQUEUED_LOCAL_SIZE)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_ENQUEUED_LOCAL_SIZE)) { + auto Dims = IGCMetaDataHelper::getThreadGroupDims(*ctx->getMetaDataUtils(), I.getFunction()); + + if (!Dims) +diff --git a/IGC/Compiler/CISACodeGen/GenCodeGenModule.cpp b/IGC/Compiler/CISACodeGen/GenCodeGenModule.cpp +index 02690f6..7d6ccdf 100644 +--- a/IGC/Compiler/CISACodeGen/GenCodeGenModule.cpp ++++ b/IGC/Compiler/CISACodeGen/GenCodeGenModule.cpp +@@ -133,7 +133,7 @@ void GenXCodeGenModule::detectUnpromotableFunctions(Module *pM) { + // Find functions that have uses of "localSLM" globals + for (auto gi = pM->global_begin(), ge = pM->global_end(); gi != ge; gi++) { + GlobalVariable *GV = dyn_cast(gi); +- if (GV && GV->hasSection() && GV->getSection().equals("localSLM")) { ++ if (GV && GV->hasSection() && GV->getSection() == "localSLM") { + for (auto user : GV->users()) { + if (Instruction *U = dyn_cast(user)) { + Function *pF = U->getParent()->getParent(); +@@ -186,7 +186,7 @@ void GenXCodeGenModule::processFunction(Function &F) { + + std::vector Callers; + if (IGC_IS_FLAG_ENABLED(StackOverflowDetection)) { +- if (F.getName().equals("__stackoverflow_detection")) { ++ if (F.getName() == "__stackoverflow_detection") { + // Mark all stack calls as users of this detection function. + // It will be used as a subroutine, so it needs to be cloned for + // each of stack call functions. +@@ -1311,13 +1311,7 @@ void SubroutineInliner::verifyAddrSpaceMismatch(CallGraphSCC &SCC) { + bool SubroutineInliner::runOnSCC(CallGraphSCC &SCC) { + FSA = &getAnalysis(); + MDUW = &getAnalysis(); +-#if LLVM_VERSION_MAJOR >= 16 +- if (skipSCC(SCC)) +- return false; +- bool changed = inlineCalls(SCC); +-#else +- bool changed = LegacyInlinerBase::runOnSCC(SCC); +-#endif ++bool changed = inlineCalls(SCC); + if (changed) + verifyAddrSpaceMismatch(SCC); + +diff --git a/IGC/Compiler/CISACodeGen/GenCodeGenModule.h b/IGC/Compiler/CISACodeGen/GenCodeGenModule.h +index 57a4aa9..b7e99fe 100644 +--- a/IGC/Compiler/CISACodeGen/GenCodeGenModule.h ++++ b/IGC/Compiler/CISACodeGen/GenCodeGenModule.h +@@ -129,7 +129,7 @@ public: + /// \brief Only one function in this group ignoring stack overflow detection methods + bool isSingleIgnoringStackOverflowDetection() const { + auto isNotStackOverflowDetection = [](const llvm::Function *F) { +- return !F->getName().startswith("__stackoverflow_detection") && !F->getName().startswith("__stackoverflow_init"); ++ return !F->getName().starts_with("__stackoverflow_detection") && !F->getName().starts_with("__stackoverflow_init"); + }; + return (Functions.size() == 1 && + std::count_if(Functions.front()->begin(), Functions.front()->end(), isNotStackOverflowDetection) == 1); +diff --git a/IGC/Compiler/CISACodeGen/GenIRLowering.cpp b/IGC/Compiler/CISACodeGen/GenIRLowering.cpp +index 01afdd2..e289d9f 100644 +--- a/IGC/Compiler/CISACodeGen/GenIRLowering.cpp ++++ b/IGC/Compiler/CISACodeGen/GenIRLowering.cpp +@@ -100,7 +100,7 @@ template struct FMaxMinCast_ma + return false; + } + +- template bool match(OpTy *V) { ++ template bool match(OpTy *V) const { + SelectInst *SI = dyn_cast(V); + if (!SI) + return false; +@@ -163,7 +163,7 @@ template struct ClampWithConstants_match { + + ClampWithConstants_match(const Op_t &OpMatch, ConstPtrTy &Min, ConstPtrTy &Max) : Op(OpMatch), CMin(Min), CMax(Max) {} + +- template bool match(OpTy *V) { ++ template bool match(OpTy *V) const { + CallInst *GII = dyn_cast(V); + if (!GII) + return false; +@@ -501,7 +501,7 @@ bool GEPLowering::simplifyGEP(BasicBlock &BB) { + for (auto PI = B.second.rbegin(), PE = B.second.rend(); PI != PE; ++PI) { + auto &P = *PI; + if (P.Offset) { +- SCEVExpander E(*SE, *DL, "gep-simplification"); ++ SCEVExpander E(*SE, "gep-simplification"); + Value *V = E.expandCodeFor(P.Offset, P.Idx->getType(), P.GEP); + Builder->SetInsertPoint(P.GEP); + auto *NewGEP = Builder->CreateInBoundsGEP(P.Base->getResultElementType(), P.Base, +@@ -1128,7 +1128,7 @@ bool GenIRLowering::combineSelectInst(SelectInst *Sel, BasicBlock::iterator &BBI + } + + IGCLLVM::Intrinsic IID = IsMax ? Intrinsic::maxnum : Intrinsic::minnum; +- Function *IFunc = Intrinsic::getDeclaration(Sel->getParent()->getParent()->getParent(), IID, LHS->getType()); ++ Function *IFunc = Intrinsic::getOrInsertDeclaration(Sel->getParent()->getParent()->getParent(), IID, LHS->getType()); + + Instruction *I = Builder->CreateCall2(IFunc, LHS, RHS); + BBI = BasicBlock::iterator(I); // Don't move to the next one. We still need combine for saturation. +diff --git a/IGC/Compiler/CISACodeGen/GenerateFrequencyData.cpp b/IGC/Compiler/CISACodeGen/GenerateFrequencyData.cpp +index f4ef79e..2fcfdae 100644 +--- a/IGC/Compiler/CISACodeGen/GenerateFrequencyData.cpp ++++ b/IGC/Compiler/CISACodeGen/GenerateFrequencyData.cpp +@@ -99,7 +99,7 @@ void GenerateFrequencyData::runStaticAnalysis() { + if (F.empty() || F_freqs.find(&F) == F_freqs.end()) + continue; + auto &BFI = getAnalysis(F).getBFI(); +- Scaled64 EntryFreq(BFI.getEntryFreq(), 0); ++ Scaled64 EntryFreq(BFI.getEntryFreq().getFrequency(), 0); + + if ((IGC_GET_FLAG_VALUE(PrintStaticProfileGuidedSpillCostAnalysis) & PGSS_IGC_DUMP_BLK) != 0) + dbgs() << "Function frequency of " << F.getName().str() << ": " << F_freqs[&F].toString() << "\n"; +@@ -143,7 +143,7 @@ void GenerateFrequencyData::updateStaticFuncFreq(DenseMap(F).getBFI(); +- entryFreqs[&F] = Scaled64(BFI.getEntryFreq(), 0); ++ entryFreqs[&F] = Scaled64(BFI.getEntryFreq().getFrequency(), 0); + for (auto &B : F) + blockFreqs[&B] = Scaled64(BFI.getBlockFreq(&B).getFrequency(), 0); + } +diff --git a/IGC/Compiler/CISACodeGen/HalfPromotion.cpp b/IGC/Compiler/CISACodeGen/HalfPromotion.cpp +index cfe23a5..d3bb062 100644 +--- a/IGC/Compiler/CISACodeGen/HalfPromotion.cpp ++++ b/IGC/Compiler/CISACodeGen/HalfPromotion.cpp +@@ -60,7 +60,7 @@ void IGC::HalfPromotion::handleLLVMIntrinsic(llvm::IntrinsicInst &I) { + llvm::IGCIRBuilder<> builder(&I); + std::vector arguments; + +- Function *pNewFunc = Intrinsic::getDeclaration(M, I.getIntrinsicID(), builder.getFloatTy()); ++ Function *pNewFunc = Intrinsic::getOrInsertDeclaration(M, I.getIntrinsicID(), builder.getFloatTy()); + + for (unsigned i = 0; i < IGCLLVM::getNumArgOperands(&I); ++i) { + if (I.getOperand(i)->getType()->isHalfTy()) { +diff --git a/IGC/Compiler/CISACodeGen/IGCVectorizer.cpp b/IGC/Compiler/CISACodeGen/IGCVectorizer.cpp +index bebfba8..993c4ce 100644 +--- a/IGC/Compiler/CISACodeGen/IGCVectorizer.cpp ++++ b/IGC/Compiler/CISACodeGen/IGCVectorizer.cpp +@@ -426,7 +426,7 @@ bool IGCVectorizer::handlePHI(VecArr &Slice) { + Instruction *InsertPoint = getInsertPointForVector(ForVector); + if (!InsertPoint) + return false; +- auto CreatedVec = createVector(ForVector, InsertPoint->getNextNonDebugInstruction()); ++ auto CreatedVec = createVector(ForVector, IGC::getNextNonDbgInstruction(InsertPoint)); + PRINT_INST_NL(CreatedVec); + Operands.push_back(CreatedVec); + } else { +@@ -493,7 +493,7 @@ Instruction *IGCVectorizer::getInsertPointForVector(VecArr &Arr) { + if (llvm::isa(InsertPoint)) + InsertPoint = InsertPoint->getParent()->getFirstNonPHI(); + if (InsertPoint->isTerminator()) +- InsertPoint = InsertPoint->getPrevNonDebugInstruction(); ++ InsertPoint = IGC::getPrevNonDbgInstruction(InsertPoint); + + return InsertPoint; + } +@@ -513,7 +513,7 @@ Instruction *IGCVectorizer::getInsertPointForCreatedInstruction(VecVal &Operands + + Instruction *InsertPoint = Slice.front()->getParent()->getFirstNonPHI(); + if (InstOperands.size() != 0) { +- InsertPoint = getMaxPoint(InstOperands)->getNextNonDebugInstruction(); ++ InsertPoint = IGC::getNextNonDbgInstruction(getMaxPoint(InstOperands)); + // if insert point is PHI, shift it to the first nonPHI to be safe + if (llvm::isa(InsertPoint)) + InsertPoint = InsertPoint->getParent()->getFirstNonPHI(); +@@ -587,7 +587,7 @@ void IGCVectorizer::replaceSliceInstructionsWithExtract(VecArr &Slice, Instructi + PRINT_INST_NL(CreatedInst); + + Instruction *InsertPoint = (llvm::isa(Slice.front())) ? CreatedInst->getParent()->getFirstNonPHI() +- : CreatedInst->getNextNonDebugInstruction(); ++ : IGC::getNextNonDbgInstruction(CreatedInst); + + for (size_t i = 0; i < Slice.size(); i++) { + +@@ -1028,7 +1028,7 @@ bool IGCVectorizer::handleIntrinsic(VecArr &Slice) { + llvm::VectorType *VectorType = llvm::FixedVectorType::get(First->getType(), Slice.size()); + + auto IntrinsicID = llvm::cast(First)->getIntrinsicID(); +- auto *Decl = Intrinsic::getDeclaration(M, IntrinsicID, {VectorType}); ++ auto *Decl = Intrinsic::getOrInsertDeclaration(M, IntrinsicID, {VectorType}); + PRINT_DECL_NL(Decl); + + auto *CreatedInst = llvm::CallInst::Create(Decl, Operands); +@@ -1285,7 +1285,7 @@ Value *IGCVectorizer::vectorizeSlice(VecArr &Slice, unsigned int OperNum) { + PRINT_LOG_NL("Couldn't find insert point"); + return nullptr; + } +- NewVector = createVector(NotVectorizedInstruction, InsertPoint->getNextNonDebugInstruction()); ++ NewVector = createVector(NotVectorizedInstruction, IGC::getNextNonDbgInstruction(InsertPoint)); + PRINT_LOG("New vector created: "); + PRINT_INST_NL(NewVector); + } +@@ -1411,7 +1411,7 @@ bool IGCVectorizerCommon::checkDependencyAndTryToEliminate(VecArr &Slice, unsign + Instruction *SearchPoint = MinPoint; + SliceScope.push_back(SearchPoint); + while (SearchPoint != MaxPoint) { +- SearchPoint = SearchPoint->getNextNonDebugInstruction(); ++ SearchPoint = IGC::getNextNonDbgInstruction(SearchPoint); + SliceScope.push_back(SearchPoint); + } + +@@ -1457,7 +1457,7 @@ bool IGCVectorizerCommon::checkDependencyAndTryToEliminate(VecArr &Slice, unsign + } + } + +- Instruction *AfterInsertPoint = MaxPoint->getNextNonDebugInstruction(); ++ Instruction *AfterInsertPoint = IGC::getNextNonDbgInstruction(MaxPoint); + // scheduling part + // everything that doesn't depend on slice values goes before + // everything that DEPENDS on slice-value goes after +@@ -1803,7 +1803,7 @@ void IGCVectorCoalescer::mergeHorizontalSliceIntrinsic(VecArr &Slice) { + + ShuffleIn(Slice, 0, Slice.front()->getNumOperands() - 1, Operands); + auto IntrinsicID = llvm::cast(Slice.front())->getIntrinsicID(); +- auto *Decl = Intrinsic::getDeclaration(M, IntrinsicID, {vectorType}); ++ auto *Decl = Intrinsic::getOrInsertDeclaration(M, IntrinsicID, {vectorType}); + auto *CreatedInst = llvm::CallInst::Create(Decl, Operands); + + CreatedInst->setName("coalesced_intrinsic"); +diff --git a/IGC/Compiler/CISACodeGen/LSCCacheOptimizationPass.cpp b/IGC/Compiler/CISACodeGen/LSCCacheOptimizationPass.cpp +index 0a1aa6a..cc8d757 100644 +--- a/IGC/Compiler/CISACodeGen/LSCCacheOptimizationPass.cpp ++++ b/IGC/Compiler/CISACodeGen/LSCCacheOptimizationPass.cpp +@@ -294,7 +294,7 @@ void LSCCacheOptimizationPass::visitStoreInst(StoreInst &storeInst) { + + /* First do the GGRR 32 wide store */ + // %0 = bitcast <>* %baseAddress to i8* +- auto *bitcast1 = builder.CreateBitCast(initial_pointer, builder.getInt8PtrTy(addrspace)); ++ auto *bitcast1 = builder.CreateBitCast(initial_pointer, PointerType::get(builder.getInt8Ty(), addrspace)); + // %1 = getelementptr i8, i8* %0, i64 -offset + auto *left_green_address = builder.CreateGEP(builder.getInt8Ty(), bitcast1, builder.getInt64(-1 * offset)); + // %2 = bitcast i8* %1 to * +@@ -369,7 +369,7 @@ void LSCCacheOptimizationPass::visitStoreInst(StoreInst &storeInst) { + uint64_t num_blue_blocks = data_size / element_size; + + // %0 = bitcast <>* %baseAddress to i8* +- auto *bitcast1 = builder.CreateBitCast(initial_pointer, builder.getInt8PtrTy(addrspace)); ++ auto *bitcast1 = builder.CreateBitCast(initial_pointer, PointerType::get(builder.getInt8Ty(), addrspace)); + // %1 = getelementptr i8, i8* %0, i64 data_size + auto *green_address = builder.CreateGEP(builder.getInt8Ty(), bitcast1, builder.getInt64(data_size)); + // %2 = bitcast i8* %1 to * +@@ -407,7 +407,7 @@ void LSCCacheOptimizationPass::visitStoreInst(StoreInst &storeInst) { + uint64_t num_blue_blocks = data_size / element_size; + + // %0 = bitcast <>* %baseAddress to i8* +- auto *bitcast1 = builder.CreateBitCast(initial_pointer, builder.getInt8PtrTy(addrspace)); ++ auto *bitcast1 = builder.CreateBitCast(initial_pointer, PointerType::get(builder.getInt8Ty(), addrspace)); + // %1 = getelementptr i8, i8* %0, i64 -offset + auto *green_address = builder.CreateGEP(builder.getInt8Ty(), bitcast1, builder.getInt64(-1 * offset)); + // %2 = bitcast i8* %1 to * +@@ -443,7 +443,7 @@ void LSCCacheOptimizationPass::visitStoreInst(StoreInst &storeInst) { + uint64_t num_total_blocks = right_boundary / element_size; + + // %0 = bitcast <>* %baseAddress to i8* +- auto *bitcast1 = builder.CreateBitCast(initial_pointer, builder.getInt8PtrTy(addrspace)); ++ auto *bitcast1 = builder.CreateBitCast(initial_pointer, PointerType::get(builder.getInt8Ty(), addrspace)); + // %1 = getelementptr i8, i8* %0, i64 -offset + auto *starting_address = builder.CreateGEP(builder.getInt8Ty(), bitcast1, builder.getInt64(-1 * offset)); + // %2 = bitcast i8* %1 to * +@@ -493,7 +493,7 @@ bool LSCCacheOptimizationPass::create_48_wide_store(Function& function) + uint64_t num_red_blocks = 8; // in dwords + Type* element_type = builder.getInt32Ty(); + // %0 = bitcast <>* %baseAddress to i8* +- auto* bitcast1 = builder.CreateBitCast(intrinsic_call, builder.getInt8PtrTy(addrspace)); ++ auto* bitcast1 = builder.CreateBitCast(intrinsic_call, PointerType::get(builder.getInt8Ty(), addrspace)); + // %1 = getelementptr i8, i8* %0, i64 offset + auto* red_address = builder.CreateGEP(builder.getInt8Ty(), bitcast1, builder.getInt64(offset)); + // %2 = bitcast i8* %1 to * +diff --git a/IGC/Compiler/CISACodeGen/LiveVars.cpp b/IGC/Compiler/CISACodeGen/LiveVars.cpp +index 29938df..673bfaa 100644 +--- a/IGC/Compiler/CISACodeGen/LiveVars.cpp ++++ b/IGC/Compiler/CISACodeGen/LiveVars.cpp +@@ -108,9 +108,9 @@ void LiveVars::preAllocMemory(Function &F) { + uint32_t mapCap1 = int_cast((size_t)(nVals * 1.40f)); + // For PHIVarInfo, increase 10% only. + uint32_t mapCap2 = int_cast((size_t)(F.size() * 1.10f)); +- DistanceMap.grow(mapCap1); +- VirtRegInfo.grow(mapCap1); +- PHIVarInfo.grow(mapCap2); ++ DistanceMap.reserve(mapCap1); ++ VirtRegInfo.reserve(mapCap1); ++ PHIVarInfo.reserve(mapCap2); + } + + void LiveVars::dump() const { print(ods()); } +@@ -631,11 +631,11 @@ bool LiveVars::hasInterference(llvm::Value *V0, llvm::Value *V1) { + + if (!I0) { + // V0 must be argument. Use the first inst in Entry +- I0 = MF->getEntryBlock().getFirstNonPHIOrDbg(); ++ I0 = &*MF->getEntryBlock().getFirstNonPHIOrDbg(); + } + if (!I1) { + // V1 must be argument. Use the first inst in Entry +- I1 = MF->getEntryBlock().getFirstNonPHIOrDbg(); ++ I1 = &*MF->getEntryBlock().getFirstNonPHIOrDbg(); + } + + if (isLiveAt(V0, I1) || isLiveAt(V1, I0)) { +diff --git a/IGC/Compiler/CISACodeGen/LivenessAnalysis.cpp b/IGC/Compiler/CISACodeGen/LivenessAnalysis.cpp +index 2e57878..086fa59 100644 +--- a/IGC/Compiler/CISACodeGen/LivenessAnalysis.cpp ++++ b/IGC/Compiler/CISACodeGen/LivenessAnalysis.cpp +@@ -71,7 +71,7 @@ bool LivenessAnalysis::runOnFunction(Function &F) { + // allocate even more to avoid such automatic resizing. + uint32_t mapCap1 = int_cast((size_t)(nVals * 1.40f)); + uint32_t vecCap1 = int_cast((size_t)(nVals * 1.10f)); +- ValueIds.grow(mapCap1); ++ ValueIds.reserve(mapCap1); + IdValues.reserve(vecCap1); + + initValueIds(); +@@ -178,8 +178,8 @@ void LivenessAnalysis::calculate(Function *F) { + // allocate even more to avoid such automatic resizing. + uint32_t mapCap1 = int_cast((size_t)(nVals * 1.40f)); + uint32_t mapCap2 = int_cast((size_t)(m_F->size() * 1.40f)); +- BBLiveIns.grow(mapCap2); +- KillInsts.grow(mapCap1); ++ BBLiveIns.reserve(mapCap2); ++ KillInsts.reserve(mapCap1); + + for (LiveVars::iterator LVI = m_LV->begin(), LVE = m_LV->end(); LVI != LVE; ++LVI) { + Value *V = LVI->first; +diff --git a/IGC/Compiler/CISACodeGen/MemOpt.cpp b/IGC/Compiler/CISACodeGen/MemOpt.cpp +index eadfaa9..b5c21a9 100644 +--- a/IGC/Compiler/CISACodeGen/MemOpt.cpp ++++ b/IGC/Compiler/CISACodeGen/MemOpt.cpp +@@ -38,6 +38,7 @@ SPDX-License-Identifier: MIT + #include "Compiler/InitializePasses.h" + #include "Compiler/CISACodeGen/MemOpt.h" + #include "Probe/Assertion.h" ++#include "common/LLVMUtils.h" + #include + #include "MemOptUtils.h" + +@@ -667,7 +668,7 @@ bool MemOpt::removeRedBlockRead(GenIntrinsicInst *LeadingBlockRead, MemRefListTy + aMI->first = BlockReadToOptimize; + } + +- Builder.SetInsertPoint(BlockReadToOptimize->getNextNonDebugInstruction()); ++ Builder.SetInsertPoint(IGC::getNextNonDbgInstruction(BlockReadToOptimize)); + Value *subgroupLocalInvocationId = nullptr; + + // Go through the collected blockreads to replace them with shuffles +@@ -693,7 +694,7 @@ bool MemOpt::removeRedBlockRead(GenIntrinsicInst *LeadingBlockRead, MemRefListTy + + std::get<1>(ITuple)->first = nullptr; + I->eraseFromParent(); +- Builder.SetInsertPoint(BlockReadToOptimize->getNextNonDebugInstruction()); ++ Builder.SetInsertPoint(IGC::getNextNonDbgInstruction(BlockReadToOptimize)); + } + } + aMI->first = BlockReadToOptimize; +@@ -2882,7 +2883,7 @@ bool LdStCombine::hasAlias(AliasSetTracker &AST, MemoryLocation &MemLoc) { + for (auto &AS : AST) { + if (AS.isForwardingAliasSet()) + continue; +- AliasResult aresult = AS.aliasesPointer(MemLoc.Ptr, MemLoc.Size, MemLoc.AATags, AST.getAliasAnalysis()); ++ AliasResult aresult = AS.aliasesMemoryLocation(MemLoc, AST.getAliasAnalysis()); + if (aresult != AliasResult::NoAlias) { + return true; + } +@@ -4881,14 +4882,14 @@ bool isLayoutStructType(const StructType *StTy) { + if (!StTy || StTy->isLiteral() || !StTy->hasName() || !StTy->isPacked()) + return false; + StringRef stId = StTy->getName(); +- return (stId.startswith(getStructNameForSOALayout()) || stId.startswith(getStructNameForAOSLayout())); ++ return (stId.starts_with(getStructNameForSOALayout()) || stId.starts_with(getStructNameForAOSLayout())); + } + + bool isLayoutStructTypeAOS(const StructType *StTy) { + if (!StTy || StTy->isLiteral() || !StTy->hasName() || !StTy->isPacked()) + return false; + StringRef stId = StTy->getName(); +- return stId.startswith(getStructNameForAOSLayout()); ++ return stId.starts_with(getStructNameForAOSLayout()); + } + + bool isLayoutStructTypeSOA(const StructType *StTy) { return isLayoutStructType(StTy) && !isLayoutStructTypeAOS(StTy); } +diff --git a/IGC/Compiler/CISACodeGen/PartialEmuI64OpsPass.cpp b/IGC/Compiler/CISACodeGen/PartialEmuI64OpsPass.cpp +index 2a7d8f9..6e611d7 100644 +--- a/IGC/Compiler/CISACodeGen/PartialEmuI64OpsPass.cpp ++++ b/IGC/Compiler/CISACodeGen/PartialEmuI64OpsPass.cpp +@@ -12,6 +12,8 @@ SPDX-License-Identifier: MIT + #include "llvm/ADT/PostOrderIterator.h" + #include "llvm/ADT/SmallPtrSet.h" + #include "llvm/Analysis/ValueTracking.h" ++#include "llvm/Analysis/WithCache.h" ++#include "llvm/Analysis/SimplifyQuery.h" + #include "llvm/IR/DataLayout.h" + #include "llvm/IR/Dominators.h" + #include "llvm/IR/Function.h" +@@ -282,7 +284,7 @@ public: + auto *RHS = BO->getOperand(1); + + if (Emu->CGC->platform.hasInt64Add() && +- haveNoCommonBitsSet(LHS, RHS, F.getParent()->getDataLayout(), nullptr, nullptr, Emu->DT)) { ++ haveNoCommonBitsSet(WithCache(LHS), WithCache(RHS), SimplifyQuery(F.getParent()->getDataLayout(), Emu->DT))) { + IRB->SetInsertPoint(BO); + auto *NewAdd = IRB->CreateAdd(LHS, RHS); + BO->replaceAllUsesWith(NewAdd); +diff --git a/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp b/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp +index f97ed11..1bfa1cd 100644 +--- a/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp ++++ b/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp +@@ -482,7 +482,7 @@ template struct ClampWithConstants_match { + + ClampWithConstants_match(const Op_t &OpMatch, ConstPtrTy &Min, ConstPtrTy &Max) : Op(OpMatch), CMin(Min), CMax(Max) {} + +- template bool match(OpTy *V) { ++ template bool match(OpTy *V) const { + CallInst *GII = dyn_cast(V); + if (!GII) + return false; +@@ -537,7 +537,7 @@ template struct IsNaN_match { + + IsNaN_match(const Op_t &OpMatch) : Op(OpMatch) {} + +- template bool match(OpTy *V) { ++ template bool match(OpTy *V) const { + using namespace llvm::PatternMatch; + + FCmpInst *FCI = dyn_cast(V); +@@ -673,23 +673,28 @@ CodeGenPatternMatch::isFPToUnsignedIntSatWithInexactConstant(llvm::SelectInst *S + if (!CMax || !CMin || !CMax->isMaxValue(false) || !CMin->isMinValue(false)) + return std::make_tuple(nullptr, 0, ISA_TYPE_F); + +- Constant *FMin = ConstantExpr::getUIToFP(CMin, Ty); +- Constant *FMax = ConstantExpr::getUIToFP(CMax, Ty); ++ Constant *FMin = ConstantExpr::getCast(Instruction::UIToFP, CMin, Ty); ++ Constant *FMax = ConstantExpr::getCast(Instruction::UIToFP, CMax, Ty); + + FCmpInst::Predicate Pred = FCmpInst::FCMP_FALSE; +- if (!match(Cond2, m_FCmp(Pred, m_Specific(X), m_Specific(FMax)))) ++ if (!match(Cond2, m_FCmp(m_Specific(X), m_Specific(FMax)))) + return std::make_tuple(nullptr, 0, ISA_TYPE_F); ++ Pred = cast(Cond2)->getPredicate(); + if (Pred != FCmpInst::FCMP_OGT) // FIXME: We should use OGE instead of OGT. + return std::make_tuple(nullptr, 0, ISA_TYPE_F); + + FCmpInst::Predicate Pred2 = FCmpInst::FCMP_FALSE; +- if (!match(Cond, m_Or(m_FCmp(Pred, m_Specific(X), m_Specific(FMin)), m_FCmp(Pred2, m_Specific(X), m_Specific(X))))) { +- if (!match(Cond, m_Or(m_FCmp(Pred, m_Specific(X), m_Specific(FMin)), m_Zero()))) { ++ if (!match(Cond, m_Or(m_FCmp(m_Specific(X), m_Specific(FMin)), m_FCmp(m_Specific(X), m_Specific(X))))) { ++ auto *Or0 = cast(Cond); ++ Pred = cast(Or0->getOperand(0))->getPredicate(); ++ Pred2 = cast(Or0->getOperand(1))->getPredicate(); ++ if (!match(Cond, m_Or(m_FCmp(m_Specific(X), m_Specific(FMin)), m_Zero()))) { + return std::make_tuple(nullptr, 0, ISA_TYPE_F); + } + // Special case where the staturatured result is bitcasted into float + // again (due to typedwrite only accepts `float`. So the isNaN(X) is + // reduced to `false`. ++ Pred = cast(cast(Cond)->getOperand(0))->getPredicate(); + Pred2 = FCmpInst::FCMP_UNE; + } + if (Pred != FCmpInst::FCMP_OLT || Pred2 != FCmpInst::FCMP_UNE) +@@ -3063,7 +3068,7 @@ bool CodeGenPatternMatch::MatchLoadStoreAtomicsStatelessUniformBase(llvm::Instru + auto ScaleImm = 1ll << Scale->getSExtValue(); + if (DataSizeInBytes == ScaleImm) { + Offset = NotScaledOffset; +- Scale = ConstantInt::get(Scale->getType(), ScaleImm); ++ Scale = cast(ConstantInt::get(Scale->getType(), ScaleImm)); + } else { + Scale = nullptr; + } +@@ -3273,7 +3278,7 @@ bool CodeGenPatternMatch::MatchLoadStoreAtomicsStatefulEff64(GenIntrinsicInst *I + int64_t ScaleImm = 1ll << Scale->getSExtValue(); + if (DataSizeInBytes == ScaleImm) { + VarOffset = NotScaledOffset; +- Scale = ConstantInt::get(Scale->getType(), ScaleImm); ++ Scale = cast(ConstantInt::get(Scale->getType(), ScaleImm)); + } else { + Scale = nullptr; + } +@@ -6081,8 +6086,9 @@ static bool isIntegerAbs(SelectInst *SI, e_modifier &mod, Value *&source) { + Value *LHS = nullptr; + Value *RHS = nullptr; + +- if (!match(Cond, m_ICmp(IPred, m_Value(LHS), m_Value(RHS)))) ++ if (!match(Cond, m_ICmp(m_Value(LHS), m_Value(RHS)))) + return false; ++ IPred = cast(Cond)->getPredicate(); + + if (!ICmpInst::isSigned(IPred)) + return false; +diff --git a/IGC/Compiler/CISACodeGen/RayTracingShaderLowering.cpp b/IGC/Compiler/CISACodeGen/RayTracingShaderLowering.cpp +index c14b5e4..769e720 100644 +--- a/IGC/Compiler/CISACodeGen/RayTracingShaderLowering.cpp ++++ b/IGC/Compiler/CISACodeGen/RayTracingShaderLowering.cpp +@@ -69,7 +69,7 @@ static Instruction::CastOps isEliminableCastPair(const CastInst *CI1, const Cast + Type *MidIntPtrTy = MidTy->isPtrOrPtrVectorTy() ? DL.getIntPtrType(MidTy) : nullptr; + Type *DstIntPtrTy = DstTy->isPtrOrPtrVectorTy() ? DL.getIntPtrType(DstTy) : nullptr; + unsigned Res = +- CastInst::isEliminableCastPair(firstOp, secondOp, SrcTy, MidTy, DstTy, SrcIntPtrTy, MidIntPtrTy, DstIntPtrTy); ++ CastInst::isEliminableCastPair(firstOp, secondOp, SrcTy, MidTy, DstTy, &DL); + + // We don't want to form an inttoptr or ptrtoint that converts to an integer + // type that differs from the pointer size. +diff --git a/IGC/Compiler/CISACodeGen/RayTracingStatefulPass.cpp b/IGC/Compiler/CISACodeGen/RayTracingStatefulPass.cpp +index 287720d..cec9f51 100644 +--- a/IGC/Compiler/CISACodeGen/RayTracingStatefulPass.cpp ++++ b/IGC/Compiler/CISACodeGen/RayTracingStatefulPass.cpp +@@ -50,7 +50,7 @@ static LoadInst *legalizeLoad(LoadInst *LI) { + + PointerType *ptrTy = cast(LI->getPointerOperand()->getType()); + unsigned addressSpace = ptrTy->getAddressSpace(); +- PointerType *I8PtrTy = IRB.getInt8PtrTy(addressSpace); ++ PointerType *I8PtrTy = PointerType::get(IRB.getInt8Ty(), addressSpace); + Value *I8PtrOp = IRB.CreateBitCast(LI->getPointerOperand(), I8PtrTy); + + LoadInst *pNewLoadInst = IGC::cloneLoad(LI, IRB.getInt8Ty(), I8PtrOp); +@@ -71,7 +71,7 @@ static StoreInst *legalizeStore(StoreInst *SI) { + + PointerType *ptrTy = cast(SI->getPointerOperand()->getType()); + unsigned addressSpace = ptrTy->getAddressSpace(); +- PointerType *I8PtrTy = IRB.getInt8PtrTy(addressSpace); ++ PointerType *I8PtrTy = PointerType::get(IRB.getInt8Ty(), addressSpace); + Value *I8PtrOp = IRB.CreateBitCast(SI->getPointerOperand(), I8PtrTy); + + auto *NewSI = IGC::cloneStore(SI, newVal, I8PtrOp); +@@ -146,7 +146,7 @@ bool RaytracingStatefulPass::runOnFunction(Function &F) { + auto *ResourceOffset = RTB.CreateAdd(BaseSSHOffset, RTB.getIntN(BitWidth, BaseOffset)); + + auto *Offset = RTB.CreatePtrToInt(PointerOp, RTB.getInt32Ty()); +- auto *ResourcePtr = RTB.CreateIntToPtr(ResourceOffset, RTB.getInt8PtrTy(Addrspace)); ++ auto *ResourcePtr = RTB.CreateIntToPtr(ResourceOffset, PointerType::get(RTB.getInt8Ty(), Addrspace)); + + if (auto *LI = dyn_cast(I)) { + LI = legalizeLoad(LI); +diff --git a/IGC/Compiler/CISACodeGen/RegisterEstimator.cpp b/IGC/Compiler/CISACodeGen/RegisterEstimator.cpp +index aa41126..b5720c8 100644 +--- a/IGC/Compiler/CISACodeGen/RegisterEstimator.cpp ++++ b/IGC/Compiler/CISACodeGen/RegisterEstimator.cpp +@@ -421,7 +421,7 @@ RegPressureTracker::RegPressureTracker(RegisterEstimator *RPE) : m_BB(nullptr), + // Pre-allocate DenseMap + size_t nVals = m_pRPE->getNumValues(); + uint32_t mapCap = int_cast((size_t)(nVals * 1.40f)); +- m_DeadValueNumUses.grow(mapCap); ++ m_DeadValueNumUses.reserve(mapCap); + } + + void RegPressureTracker::init(BasicBlock *BB, bool doMaxRegInBB) { +diff --git a/IGC/Compiler/CISACodeGen/RematAddressArithmetic.cpp b/IGC/Compiler/CISACodeGen/RematAddressArithmetic.cpp +index a5683d4..ce8c257 100644 +--- a/IGC/Compiler/CISACodeGen/RematAddressArithmetic.cpp ++++ b/IGC/Compiler/CISACodeGen/RematAddressArithmetic.cpp +@@ -833,7 +833,7 @@ bool RematAddressArithmetic::rematerializePhiMemoryAddressCalculation(Function & + Instruction *newIntToPtr = intToPtr->clone(); + newIntToPtr->setOperand(0, newAdd); + // and insert in after the phi +- Instruction *insertPoint = BB->getFirstNonPHIOrDbgOrLifetime(); ++ Instruction *insertPoint = &*BB->getFirstNonPHIOrDbgOrLifetime(); + newAdd->insertBefore(insertPoint); + newIntToPtr->insertBefore(insertPoint); + phi->replaceAllUsesWith(newIntToPtr); +diff --git a/IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp b/IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp +index 73751e2..3c19a51 100644 +--- a/IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp ++++ b/IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp +@@ -507,7 +507,7 @@ void AddLegalizationPasses(CodeGenContext &ctx, IGCPassManager &mpm, PSSignature + IGC_IS_FLAG_ENABLED(ForcePrivateMemoryToSLMOnBuffers)) { + TargetIRAnalysis GenTTgetIIRAnalysis([&](const Function &F) { + GenIntrinsicsTTIImpl GTTI(&ctx); +- return TargetTransformInfo(GTTI); ++ return TargetTransformInfo(std::make_unique(std::move(GTTI))); + }); + mpm.add(new TargetTransformInfoWrapperPass(std::move(GenTTgetIIRAnalysis))); + } +@@ -515,9 +515,9 @@ void AddLegalizationPasses(CodeGenContext &ctx, IGCPassManager &mpm, PSSignature + // Disable all target library functions. + // right now we don't support any standard function in the code gen + // maybe we want to support some at some point to take advantage of LLVM optimizations +- TargetLibraryInfoImpl TLI; ++ TargetLibraryInfoImpl TLI(Triple(ctx.getModule()->getTargetTriple())); + TLI.disableAllFunctions(); +- mpm.add(new llvm::TargetLibraryInfoWrapperPass(TLI)); ++ mpm.add(new llvm::TargetLibraryInfoWrapperPass(std::move(TLI))); + + // Add Metadata API immutable pass + mpm.add(new MetaDataUtilsWrapper(pMdUtils, ctx.getModuleMetaData())); +@@ -543,9 +543,7 @@ void AddLegalizationPasses(CodeGenContext &ctx, IGCPassManager &mpm, PSSignature + if (ctx.m_threadCombiningOptDone) { + mpm.add(createLoopCanonicalization()); + mpm.add(IGCLLVM::createLegacyWrappedLoopDeletionPass()); +- mpm.add(llvm::createBreakCriticalEdgesPass()); +- mpm.add(llvm::createLoopRotatePass(LOOP_ROTATION_HEADER_INST_THRESHOLD)); +- mpm.add(llvm::createLowerSwitchPass()); ++ mpm.add(llvm::createBreakCriticalEdgesPass()); mpm.add(llvm::createLowerSwitchPass()); + + int LoopUnrollThreshold = ctx.m_DriverInfo.GetLoopUnrollThreshold(); + +@@ -1259,7 +1257,7 @@ void OptimizeIR(CodeGenContext *const pContext) { + + // right now we don't support any standard function in the code gen + // maybe we want to support some at some point to take advantage of LLVM optimizations +- TargetLibraryInfoImpl TLI; ++ TargetLibraryInfoImpl TLI(Triple(pContext->getModule()->getTargetTriple())); + TLI.disableAllFunctions(); + + mpm.add(new MetaDataUtilsWrapper(pMdUtils, pContext->getModuleMetaData())); +@@ -1267,7 +1265,7 @@ void OptimizeIR(CodeGenContext *const pContext) { + mpm.add(new CodeGenContextWrapper(pContext)); + TargetIRAnalysis GenTTgetIIRAnalysis([&](const Function &F) { + GenIntrinsicsTTIImpl GTTI(pContext); +- return TargetTransformInfo(GTTI); ++ return TargetTransformInfo(std::make_unique(std::move(GTTI))); + }); + + mpm.add(new TargetTransformInfoWrapperPass(GenTTgetIIRAnalysis)); +@@ -1275,7 +1273,7 @@ void OptimizeIR(CodeGenContext *const pContext) { + // IGC IR Verification pass checks that we get a correct IR after the Unification. + mpm.add(new VerificationPass()); + #endif +- mpm.add(new llvm::TargetLibraryInfoWrapperPass(TLI)); ++ mpm.add(new llvm::TargetLibraryInfoWrapperPass(std::move(TLI))); + initializeWIAnalysisPass(*PassRegistry::getPassRegistry()); + + if (IGC_IS_FLAG_ENABLED(EnableSinkPointerConstAdd)) { +@@ -1409,9 +1407,7 @@ void OptimizeIR(CodeGenContext *const pContext) { + mpm.add(createLoopDeadCodeEliminationPass()); + mpm.add(createLoopCanonicalization()); + mpm.add(IGCLLVM::createLegacyWrappedLoopDeletionPass()); +- mpm.add(llvm::createBreakCriticalEdgesPass()); +- mpm.add(llvm::createLoopRotatePass(LOOP_ROTATION_HEADER_INST_THRESHOLD)); +- mpm.add(llvm::createLCSSAPass()); ++ mpm.add(llvm::createBreakCriticalEdgesPass()); mpm.add(llvm::createLCSSAPass()); + mpm.add(llvm::createLoopSimplifyPass()); + } + } +@@ -1657,8 +1653,6 @@ void OptimizeIR(CodeGenContext *const pContext) { + assert(disableGOPT); + // disable loop unroll for excessive large shaders + if (pContext->m_instrTypes.numOfLoop) { +- mpm.add(llvm::createLoopRotatePass(LOOP_ROTATION_HEADER_INST_THRESHOLD)); +- + + int LoopUnrollThreshold = pContext->m_DriverInfo.GetLoopUnrollThreshold(); + +diff --git a/IGC/Compiler/CISACodeGen/SinkCommonOffsetFromGEP.cpp b/IGC/Compiler/CISACodeGen/SinkCommonOffsetFromGEP.cpp +index 3695748..94675ce 100644 +--- a/IGC/Compiler/CISACodeGen/SinkCommonOffsetFromGEP.cpp ++++ b/IGC/Compiler/CISACodeGen/SinkCommonOffsetFromGEP.cpp +@@ -7,6 +7,7 @@ SPDX-License-Identifier: MIT + ============================= end_copyright_notice ===========================*/ + + #include "Compiler/CodeGenPublic.h" ++#include "common/LLVMUtils.h" + #include "Compiler/CISACodeGen/SinkCommonOffsetFromGEP.h" + #include "Compiler/CISACodeGen/ShaderCodeGen.hpp" + #include "Compiler/IGCPassSupport.h" +@@ -405,7 +406,7 @@ static bool sinkCommonOffsetForGroup(const CommonBaseGroup &Group) { + Indices.push_back(ConstantInt::get(Offset->getType(), 0)); + Indices.push_back(Offset); + +- auto OffsetGEP = GetElementPtrInst::Create(PhiElType, BasePhi, Indices, "", BasePhi->getNextNonDebugInstruction()); ++ auto OffsetGEP = GetElementPtrInst::Create(PhiElType, BasePhi, Indices, "", IGC::getNextNonDbgInstruction(BasePhi)); + + bool isInBounds = false; + for (const auto &Gep : Geps) +diff --git a/IGC/Compiler/CISACodeGen/helper.cpp b/IGC/Compiler/CISACodeGen/helper.cpp +index 86e91a7..e84db87 100644 +--- a/IGC/Compiler/CISACodeGen/helper.cpp ++++ b/IGC/Compiler/CISACodeGen/helper.cpp +@@ -2259,7 +2259,7 @@ bool isNoOpInst(Instruction *I, CodeGenContext *Ctx) { + // + // + bool valueIsPositive(Value *V, const DataLayout *DL, llvm::AssumptionCache *AC, llvm::Instruction *CxtI) { +- return computeKnownBits(V, *DL, 0, AC, CxtI).isNonNegative(); ++ return computeKnownBits(V, *DL, AC, CxtI, nullptr, true, 0).isNonNegative(); + } + + void appendToUsed(llvm::Module &M, ArrayRef Values) { +@@ -2279,7 +2279,7 @@ void appendToUsed(llvm::Module &M, ArrayRef Values) { + GV->eraseFromParent(); + } + +- Type *Int8PtrTy = llvm::Type::getInt8PtrTy(M.getContext()); ++ Type *Int8PtrTy = llvm::PointerType::get(llvm::Type::getInt8Ty(M.getContext()), 0); + for (auto *V : Values) { + Constant *C = V; + // llvm will complain if members of llvm.uses doesn't have a name +@@ -2571,7 +2571,7 @@ std::tuple ParseVectorVariantFunctionString( + auto strEnd = varStr.end(); + + // Starts with _ZGV +- IGC_ASSERT(varStr.startswith("_ZGV")); ++ IGC_ASSERT(varStr.starts_with("_ZGV")); + outStr << "_ZGV"; + pos += 4; + // ISA class target processor type +diff --git a/IGC/Compiler/CISACodeGen/helper.h b/IGC/Compiler/CISACodeGen/helper.h +index 0a46902..75fa562 100644 +--- a/IGC/Compiler/CISACodeGen/helper.h ++++ b/IGC/Compiler/CISACodeGen/helper.h +@@ -259,7 +259,7 @@ inline llvm::Function *getIntelSymbolTableVoidProgram(llvm::Module *pM, int Simd + // Note, the module can contain multiple dummy kernels to support SIMD variants. + // This function returns true if the current function is any of those variant kernels. + inline bool isIntelSymbolTableVoidProgram(llvm::Function *pF) { +- return (pF && pF->getName().startswith(INTEL_SYMBOL_TABLE_VOID_PROGRAM)); ++ return (pF && pF->getName().starts_with(INTEL_SYMBOL_TABLE_VOID_PROGRAM)); + } + + int getFunctionControl(const CodeGenContext *pContext); +diff --git a/IGC/Compiler/CodeGenContext.cpp b/IGC/Compiler/CodeGenContext.cpp +index 8cf03ac..5e7a7d5 100644 +--- a/IGC/Compiler/CodeGenContext.cpp ++++ b/IGC/Compiler/CodeGenContext.cpp +@@ -969,7 +969,7 @@ void CodeGenContext::initializeRemarkEmitter(const ShaderHash &hash) { + // setting up optimization remark emitter + if (IGC_IS_FLAG_ENABLED(EnableRemarks)) { + std::string remark_file_name = IGC::Debug::DumpName("Remark_").Type(this->type).Hash(hash).Extension("yaml").str(); +- llvm::Expected> RemarksFileOrErr = ++ llvm::Expected RemarksFileOrErr = + setupLLVMOptimizationRemarks(*this->getLLVMContext(), remark_file_name, "", "yaml", false, 0); + this->RemarksFile = std::move(*RemarksFileOrErr); + this->RemarksFile->keep(); +diff --git a/IGC/Compiler/CodeGenPublic.h b/IGC/Compiler/CodeGenPublic.h +index a2f0817..d80bfeb 100644 +--- a/IGC/Compiler/CodeGenPublic.h ++++ b/IGC/Compiler/CodeGenPublic.h +@@ -1018,7 +1018,7 @@ private: + std::stringstream oclErrorMessage; + // For storing warning message + std::stringstream oclWarningMessage; +- std::unique_ptr RemarksFile; ++ llvm::LLVMRemarkFileHandle RemarksFile; + + protected: + // Objects pointed to by these pointers are owned by this class. +diff --git a/IGC/Compiler/CustomLoopOpt.cpp b/IGC/Compiler/CustomLoopOpt.cpp +index 7e59b35..922b373 100644 +--- a/IGC/Compiler/CustomLoopOpt.cpp ++++ b/IGC/Compiler/CustomLoopOpt.cpp +@@ -140,8 +140,8 @@ bool CustomLoopVersioning::detectLoop(Loop *loop, Value *&var_range_x, Value *&v + BasicBlock *header = loop->getHeader(); + BasicBlock *body = loop->getLoopLatch(); + +- Instruction *i0 = body->getFirstNonPHIOrDbg(); +- Instruction *i1 = i0->getNextNonDebugInstruction(); ++ Instruction *i0 = IGC::getFirstNonPHIOrDbgInst(body); ++ Instruction *i1 = IGC::getNextNonDbgInstruction(i0); + + CallInst *imax = dyn_cast(i0); + CallInst *imin = i1 ? dyn_cast(i1) : nullptr; +@@ -252,8 +252,8 @@ void CustomLoopVersioning::rewriteLoopSeg1(Loop *loop, Value *interval_x, Value + + fcmp->setOperand(1, interval_x); + +- Instruction *i0 = body->getFirstNonPHIOrDbg(); +- Instruction *i1 = i0->getNextNonDebugInstruction(); ++ Instruction *i0 = IGC::getFirstNonPHIOrDbgInst(body); ++ Instruction *i1 = IGC::getNextNonDbgInstruction(i0); + + IntrinsicInst *imax = cast(i0); + IntrinsicInst *imin = cast(i1); +@@ -309,13 +309,13 @@ void CustomLoopVersioning::hoistSeg2Invariant(Loop *loop, Instruction *fmul, Val + if (fmul_log2 && fmul_log2->getParent() == body) { + IntrinsicInst *intrin = dyn_cast(*fmul_log2->users().begin()); + if (intrin && intrin->getIntrinsicID() == Intrinsic::exp2) { +- IRBuilder<> irb(preHdr->getFirstNonPHIOrDbg()); ++ IRBuilder<> irb(IGC::getFirstNonPHIOrDbgInst(preHdr)); + irb.setFastMathFlags(fmul_log2->getFastMathFlags()); + + Function *flog = +- Intrinsic::getDeclaration(m_function->getParent(), llvm::Intrinsic::log2, intrin_log2->getType()); ++ Intrinsic::getOrInsertDeclaration(m_function->getParent(), llvm::Intrinsic::log2, intrin_log2->getType()); + Function *fexp = +- Intrinsic::getDeclaration(m_function->getParent(), llvm::Intrinsic::exp2, intrin_log2->getType()); ++ Intrinsic::getOrInsertDeclaration(m_function->getParent(), llvm::Intrinsic::exp2, intrin_log2->getType()); + Value *v = irb.CreateCall(flog, cbLoad); + v = irb.CreateFMul(fmul_log2_opnd, v); + v = irb.CreateCall(fexp, v); +@@ -348,8 +348,8 @@ void CustomLoopVersioning::rewriteLoopSeg2(Loop *loop, Value *interval_y, Value + v->setFast(true); + fcmp->setOperand(1, v); + +- Instruction *i0 = body->getFirstNonPHIOrDbg(); +- Instruction *i1 = i0->getNextNonDebugInstruction(); ++ Instruction *i0 = IGC::getFirstNonPHIOrDbgInst(body); ++ Instruction *i1 = IGC::getNextNonDbgInstruction(i0); + + IntrinsicInst *imax = cast(i0); + IntrinsicInst *imin = cast(i1); +@@ -390,8 +390,8 @@ void CustomLoopVersioning::rewriteLoopSeg2(Loop *loop, Value *interval_y, Value + // float val0 = t; + // float val1 = loop_range_y; + void CustomLoopVersioning::rewriteLoopSeg3(BasicBlock *bb, Value *interval_y) { +- Instruction *i0 = bb->getFirstNonPHIOrDbg(); +- Instruction *i1 = i0->getNextNonDebugInstruction(); ++ Instruction *i0 = IGC::getFirstNonPHIOrDbgInst(bb); ++ Instruction *i1 = IGC::getNextNonDbgInstruction(i0); + + IntrinsicInst *imax = cast(i0); + IntrinsicInst *imin = cast(i1); +@@ -921,7 +921,7 @@ bool LoopHoistConstant::runOnLoop(Loop *L, LPPassManager &LPM) { + + // Match the minnum comparison between the induction var and the loop size + // Should appear right after the post-incremented induction variable +- MinInst = dyn_cast(InductionPostInc->getNextNonDebugInstruction()); ++ MinInst = dyn_cast(IGC::getNextNonDbgInstruction(InductionPostInc)); + if (MinInst && MinInst->getIntrinsicID() == llvm::Intrinsic::minnum) { + Value *min1 = MinInst->getOperand(0); + Value *min2 = MinInst->getOperand(1); +diff --git a/IGC/Compiler/CustomSafeOptPass.cpp b/IGC/Compiler/CustomSafeOptPass.cpp +index 4b7f967..5b2ed4c 100644 +--- a/IGC/Compiler/CustomSafeOptPass.cpp ++++ b/IGC/Compiler/CustomSafeOptPass.cpp +@@ -62,6 +62,7 @@ cmp+sel to avoid expensive VxH mov. + #include "GenISAIntrinsics/GenIntrinsics.h" + #include "GenISAIntrinsics/GenIntrinsicInst.h" + #include "common/IGCConstantFolder.h" ++#include "common/LLVMUtils.h" + #include "common/LLVMWarningsPush.hpp" + #include + #include +@@ -158,10 +159,14 @@ void CustomSafeOptPass::visitXor(Instruction &XorInstr) { + using namespace llvm::PatternMatch; + + CmpInst::Predicate Pred = CmpInst::Predicate::FCMP_FALSE; +- auto XorPattern = m_c_Xor(m_ICmp(Pred, m_Value(), m_Value()), m_SpecificInt(1)); ++ auto XorPattern = m_c_Xor(m_ICmp(m_Value(), m_Value()), m_SpecificInt(1)); + if (!match(&XorInstr, XorPattern)) { + return; + } ++ Pred = cast(isa(XorInstr.getOperand(0)) ? XorInstr.getOperand(0) : XorInstr.getOperand(1))->getPredicate(); ++ if (false) { ++ return; ++ } + + Value *XorOp0 = XorInstr.getOperand(0); + Value *XorOp1 = XorInstr.getOperand(1); +@@ -210,8 +215,8 @@ void CustomSafeOptPass::visitXor(Instruction &XorInstr) { + if (Instruction *NewCmpInst = dyn_cast(NewCmp)) { + NewCmpInst->setDebugLoc(DL); + auto *Val = static_cast(ICmpInstr); +- SmallVector DbgValues; +- llvm::findDbgValues(DbgValues, Val); ++ SmallVector DbgValues; ++ llvm::findDbgValues(Val, DbgValues); + for (auto DV : DbgValues) { + DIExpression *OldExpr = DV->getExpression(); + DIExpression *NewExpr = +@@ -250,9 +255,10 @@ void CustomSafeOptPass::visitAnd(BinaryOperator &I) { + + Value *XorArgValue = nullptr; + CmpInst::Predicate Pred = CmpInst::Predicate::FCMP_FALSE; +- auto AndPattern = m_c_And(m_c_Xor(m_Value(XorArgValue), m_SpecificInt(1)), m_ICmp(Pred, m_Value(), m_Value())); ++ auto AndPattern = m_c_And(m_c_Xor(m_Value(XorArgValue), m_SpecificInt(1)), m_ICmp(m_Value(), m_Value())); + if (!match(&I, AndPattern)) + return; ++ Pred = cast(isa(I.getOperand(0)) ? I.getOperand(0) : I.getOperand(1))->getPredicate(); + + IRBuilder<> builder(&I); + auto CompareInst = cast(isa(I.getOperand(0)) ? I.getOperand(0) : I.getOperand(1)); +@@ -270,8 +276,8 @@ void CustomSafeOptPass::visitAnd(BinaryOperator &I) { + if (Instruction *NewOrInst = dyn_cast(OrInst)) { + NewOrInst->setDebugLoc(DL); + auto *Val = static_cast(&I); +- SmallVector DbgValues; +- llvm::findDbgValues(DbgValues, Val); ++ SmallVector DbgValues; ++ llvm::findDbgValues(Val, DbgValues); + for (auto DV : DbgValues) { + DIExpression *OldExpr = DV->getExpression(); + DIExpression *NewExpr = +@@ -893,7 +899,7 @@ void CustomSafeOptPass::visitAllocaInst(AllocaInst &I) { + + // A debug line info is moved so the alloca has corresponding dbg.declare call + // with DIExpression DW_OP_LLVM_fragment specifying fragment. +- TinyPtrVector Dbgs = llvm::FindDbgDeclareUses(&I); ++ TinyPtrVector Dbgs = llvm::findDVRDeclares(&I); + unsigned typeSize = (unsigned)pType->getArrayElementType()->getPrimitiveSizeInBits(); + if (!Dbgs.empty()) { + const DebugLoc DL = I.getDebugLoc(); +@@ -3299,9 +3305,9 @@ void GenSpecificPattern::visitCmpInst(CmpInst &I) { + CmpInst::Predicate Pred = CmpInst::Predicate::BAD_ICMP_PREDICATE; + Value *Val1 = nullptr; + uint64_t const_int1 = 0, const_int2 = 0; +- auto cmp_pattern = m_Cmp(Pred, m_And(m_Value(Val1), m_ConstantInt(const_int1)), m_ConstantInt(const_int2)); ++ auto cmp_pattern = m_Cmp(m_And(m_Value(Val1), m_ConstantInt(const_int1)), m_ConstantInt(const_int2)); + +- if (match(&I, cmp_pattern) && (const_int1 << 32) == 0 && (const_int2 << 32) == 0 && ++ if (match(&I, cmp_pattern) && (Pred = I.getPredicate(), true) && (const_int1 << 32) == 0 && (const_int2 << 32) == 0 && + Val1->getType()->isIntegerTy(64)) { + llvm::IRBuilder<> builder(&I); + VectorType *vec2 = IGCLLVM::FixedVectorType::get(builder.getInt32Ty(), 2); +@@ -3565,7 +3571,7 @@ void GenSpecificPattern::visitCastInst(CastInst &I) { + if (isa(srcVal) && srcVal->isFast()) { + IRBuilder<> builder(&I); + Function *func = +- Intrinsic::getDeclaration(I.getParent()->getParent()->getParent(), Intrinsic::trunc, I.getType()); ++ Intrinsic::getOrInsertDeclaration(I.getParent()->getParent()->getParent(), Intrinsic::trunc, I.getType()); + Value *newVal = builder.CreateCall(func, srcVal); + I.replaceAllUsesWith(newVal); + I.eraseFromParent(); +@@ -3708,7 +3714,7 @@ void GenSpecificPattern::visitZExtInst(ZExtInst &ZEI) { + * %zext.0 = extractelement <2 x i32> %call, i32 0 --> result + * %zext.1 = extractelement <2 x i32> %call, i32 1 --> carry + */ +- auto addcPattern1 = m_Cmp(pred, m_Instruction(I1), m_ConstantInt(C2)); ++ auto addcPattern1 = m_Cmp(m_Instruction(I1), m_ConstantInt(C2)); + auto addcPattern2 = m_Add(m_Instruction(I2), m_ConstantInt(C1)); + + /* +@@ -3721,9 +3727,9 @@ void GenSpecificPattern::visitZExtInst(ZExtInst &ZEI) { + * %zext.2 = extractelement <2 x i32> %call.1, i32 0 --> result + * %zext.3 = extractelement <2 x i32> %call.1, i32 1 --> carry + */ +- auto addcPattern3 = m_Cmp(pred, m_Add(m_Instruction(I1), m_Instruction(I2)), m_Instruction(I3)); ++ auto addcPattern3 = m_Cmp(m_Add(m_Instruction(I1), m_Instruction(I2)), m_Instruction(I3)); + +- if (match(Cmp, addcPattern1) && pred == CmpInst::Predicate::ICMP_EQ && C2->isMinusOne()) { ++ if (match(Cmp, addcPattern1) && (pred = cast(Cmp)->getPredicate(), true) && pred == CmpInst::Predicate::ICMP_EQ && C2->isMinusOne()) { + IGC_ASSERT(I1); + for (auto U : I1->users()) { + Instruction *inst = dyn_cast(U); +@@ -3733,7 +3739,7 @@ void GenSpecificPattern::visitZExtInst(ZExtInst &ZEI) { + return; + } + } +- } else if (match(Cmp, addcPattern3) && pred == CmpInst::Predicate::ICMP_ULT && (I1 == I3 || I2 == I3) && ++ } else if (match(Cmp, addcPattern3) && (pred = cast(Cmp)->getPredicate(), true) && pred == CmpInst::Predicate::ICMP_ULT && (I1 == I3 || I2 == I3) && + ZEI.getType() == I3->getType() && I3->getType()->isIntegerTy(32)) { + Instruction *inst = dyn_cast(Cmp->getOperand(0)); + if (isActualAddInstr(inst)) { +@@ -6035,7 +6041,7 @@ void LogicalAndToBranch::convertAndToBranch(Instruction *opAnd, Instruction *con + BasicBlock *bb = opAnd->getParent(); + BasicBlock *bbThen, *bbElse, *bbEnd; + +- Instruction *splitBefore = cond0->getNextNonDebugInstruction(); ++ Instruction *splitBefore = IGC::getNextNonDbgInstruction(cond0); + bbThen = bb->splitBasicBlock(splitBefore->getIterator(), "if.then"); + bbElse = bbThen->splitBasicBlock(opAnd, "if.else"); + bbEnd = bbElse->splitBasicBlock(opAnd, "if.end"); +diff --git a/IGC/Compiler/CustomUnsafeOptPass.cpp b/IGC/Compiler/CustomUnsafeOptPass.cpp +index 1efbbd9..0c22e64 100644 +--- a/IGC/Compiler/CustomUnsafeOptPass.cpp ++++ b/IGC/Compiler/CustomUnsafeOptPass.cpp +@@ -338,10 +338,10 @@ bool CustomUnsafeOptPass::visitBinaryOperatorFmulFaddPropagation(BinaryOperator + return false; + } + +- instBase[1] = instBase[0]->getNextNonDebugInstruction(); ++ instBase[1] = IGC::getNextNonDbgInstruction(instBase[0]); + + if (instBase[1] && instBase[1]->getOpcode() != opcode) { +- instBase[1] = instBase[1]->getNextNonDebugInstruction(); ++ instBase[1] = IGC::getNextNonDbgInstruction(instBase[1]); + } + + if (instBase[1] == nullptr || instBase[1]->getOpcode() != opcode || +@@ -359,10 +359,10 @@ bool CustomUnsafeOptPass::visitBinaryOperatorFmulFaddPropagation(BinaryOperator + matchPattern1 = true; + } + for (int i = 2; i < 4; i++) { +- instBase[i] = instBase[i - 1]->getNextNonDebugInstruction(); ++ instBase[i] = IGC::getNextNonDbgInstruction(instBase[i - 1]); + + if (instBase[i] && instBase[i - 1]->getOpcode() != instBase[i]->getOpcode()) { +- instBase[i] = instBase[i]->getNextNonDebugInstruction(); ++ instBase[i] = IGC::getNextNonDbgInstruction(instBase[i]); + } + + if (!instBase[i] || instBase[i]->getOpcode() != opcode || +@@ -1047,8 +1047,8 @@ bool CustomUnsafeOptPass::visitBinaryOperatorNegateMultiply(BinaryOperator &I) { + const DebugLoc &DL = NewfmulInst->getDebugLoc(); + fsubInstr->setDebugLoc(DL); + auto *Val = static_cast(fmulInst); +- SmallVector DbgValues; +- llvm::findDbgValues(DbgValues, Val); ++ SmallVector DbgValues; ++ llvm::findDbgValues(Val, DbgValues); + for (auto DV : DbgValues) { + DIExpression *OldExpr = DV->getExpression(); + DIExpression *NewExpr = +@@ -1219,7 +1219,7 @@ bool CustomUnsafeOptPass::visitBinaryOperatorDivRsq(BinaryOperator &I) { + if (ConstantFP *fp0 = dyn_cast(I.getOperand(0))) { + llvm::IRBuilder<> builder(I.getContext()); + llvm::CallInst *sqrt_call = llvm::IntrinsicInst::Create( +- llvm::Intrinsic::getDeclaration(m_ctx->getModule(), Intrinsic::sqrt, builder.getFloatTy()), ++ llvm::Intrinsic::getOrInsertDeclaration(m_ctx->getModule(), Intrinsic::sqrt, builder.getFloatTy()), + genIntr->getOperand(0), "", &I); + + if (fp0->isExactlyValue(1.0)) { +@@ -2069,7 +2069,7 @@ void CustomUnsafeOptPass::strengthReducePowOrExpLog(IntrinsicInst *intrin, Value + irb.setFastMathFlags(intrin->getFastMathFlags()); + if (exponent == ConstantFP::get(exponent->getType(), 0.5)) { + // pow(x, 0.5) -> sqrt(x) +- llvm::Function *sqrtIntr = llvm::Intrinsic::getDeclaration(m_ctx->getModule(), Intrinsic::sqrt, base->getType()); ++ llvm::Function *sqrtIntr = llvm::Intrinsic::getOrInsertDeclaration(m_ctx->getModule(), Intrinsic::sqrt, base->getType()); + llvm::CallInst *sqrt = irb.CreateCall(sqrtIntr, base); + intrin->replaceAllUsesWith(sqrt); + collectForErase(*intrin); +@@ -2116,8 +2116,8 @@ void CustomUnsafeOptPass::strengthReducePowOrExpLog(IntrinsicInst *intrin, Value + collectForErase(*intrin); + } else if (isPow && IGC_IS_FLAG_ENABLED(EnablePowToLogMulExp)) { + // pow(x, y) -> exp2(log2(x) * y) +- Function *logf = Intrinsic::getDeclaration(m_ctx->getModule(), Intrinsic::log2, base->getType()); +- Function *expf = Intrinsic::getDeclaration(m_ctx->getModule(), Intrinsic::exp2, base->getType()); ++ Function *logf = Intrinsic::getOrInsertDeclaration(m_ctx->getModule(), Intrinsic::log2, base->getType()); ++ Function *expf = Intrinsic::getOrInsertDeclaration(m_ctx->getModule(), Intrinsic::exp2, base->getType()); + CallInst *logv = irb.CreateCall(logf, base); + Value *mulv = irb.CreateFMul(logv, exponent); + CallInst *expv = irb.CreateCall(expf, mulv); +diff --git a/IGC/Compiler/DebugInfo/Utils.cpp b/IGC/Compiler/DebugInfo/Utils.cpp +index 889ec05..56ac2d7 100644 +--- a/IGC/Compiler/DebugInfo/Utils.cpp ++++ b/IGC/Compiler/DebugInfo/Utils.cpp +@@ -90,7 +90,7 @@ llvm::Instruction *UpdateGlobalVarDebugInfo(llvm::GlobalVariable *pGlobalVar, ll + + if (isIndirect) + return Builder.insertDeclare(pNewVal, llvm::cast(Var), Builder.createExpression(), +- locToUse, pEntryPoint); ++ locToUse, pEntryPoint).template dyn_cast(); + + return Builder.insertDbgValueIntrinsic(pNewVal, 0, llvm::cast(Var), + Builder.createExpression(), locToUse, pEntryPoint); +diff --git a/IGC/Compiler/GenTTI.cpp b/IGC/Compiler/GenTTI.cpp +index d69ac0b..ddb2902 100644 +--- a/IGC/Compiler/GenTTI.cpp ++++ b/IGC/Compiler/GenTTI.cpp +@@ -35,7 +35,7 @@ using namespace IGC; + + namespace llvm { + +-bool GenIntrinsicsTTIImpl::isLoweredToCall(const Function *F) { ++bool GenIntrinsicsTTIImpl::isLoweredToCall(const Function *F) const { + if (GenISAIntrinsic::isIntrinsic(F)) + return false; + return BaseT::isLoweredToCall(F); +@@ -45,7 +45,7 @@ bool GenIntrinsicsTTIImpl::isLoweredToCall(const Function *F) { + // instructions. Set this to false unless IGC legalization can fix them. + bool GenIntrinsicsTTIImpl::shouldBuildLookupTables() { return false; } + +-bool GenIntrinsicsTTIImpl::enablePromoteLoopUnrollwithAlloca() { ++bool GenIntrinsicsTTIImpl::enablePromoteLoopUnrollwithAlloca() const { + const IGC::TriboolFlag RK_PromoteLoopUnrollwithAlloca = + static_cast(IGC_GET_FLAG_VALUE(ForcePromoteLoopUnrollwithAlloca)); + switch (RK_PromoteLoopUnrollwithAlloca) { +@@ -303,7 +303,8 @@ void GenIntrinsicsTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE, + } + + if (UnrollLoopForCodeSizeOnly) { +- UP.Threshold = getLoopSize(L, *this) + 1; ++ const TargetTransformInfo TTI(ctx->getModule()->getDataLayout()); ++ UP.Threshold = getLoopSize(L, TTI) + 1; + UP.MaxPercentThresholdBoost = 100; + UP.Partial = false; + } +@@ -427,7 +428,8 @@ void GenIntrinsicsTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE, + + SmallPtrSet EphValues; + CodeMetrics Metrics; +- Metrics.analyzeBasicBlock(BB, *this, EphValues); ++ const TargetTransformInfo TTI(ctx->getModule()->getDataLayout()); ++ Metrics.analyzeBasicBlock(BB, TTI, EphValues); + if (Metrics.NumInsts < 50) { + for (auto I = BB->begin(), E = BB->end(); I != E; ++I) { + CallInst *Call = dyn_cast(I); +@@ -631,7 +633,7 @@ void GenIntrinsicsTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE, + for (unsigned i = 0; i < LoopID->getNumOperands(); ++i) { + if (MDNode *MD = llvm::dyn_cast(LoopID->getOperand(i))) { + if (MDString *S = llvm::dyn_cast(MD->getOperand(0))) { +- if (maxIterMetadataNames.equals(S->getString())) { ++ if (maxIterMetadataNames == S->getString()) { + UP.MaxCount = static_cast(mdconst::extract(MD->getOperand(1))->getZExtValue()); + } + } +@@ -651,7 +653,7 @@ void GenIntrinsicsTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE, + for (unsigned i = 0; i < LoopID->getNumOperands(); ++i) { + if (MDNode *MD = llvm::dyn_cast(LoopID->getOperand(i))) { + if (MDString *S = llvm::dyn_cast(MD->getOperand(0))) { +- if (peelCountMetadataNames.equals(S->getString())) { ++ if (peelCountMetadataNames == S->getString()) { + PP.AllowPeeling = true; + PP.PeelCount = static_cast(mdconst::extract(MD->getOperand(1))->getZExtValue()); + } +@@ -678,13 +680,13 @@ llvm::InstructionCost GenIntrinsicsTTIImpl::getUserCost(const User *U, ArrayRef< + + #if LLVM_VERSION_MAJOR >= 16 + llvm::InstructionCost GenIntrinsicsTTIImpl::getInstructionCost(const User *U, ArrayRef Operands, +- TTI::TargetCostKind CostKind) { ++ TTI::TargetCostKind CostKind) const { + return GenIntrinsicsTTIImpl::internalCalculateCost(U, Operands, CostKind); + } + #endif + + llvm::InstructionCost GenIntrinsicsTTIImpl::internalCalculateCost(const User *U, ArrayRef Operands, +- TTI::TargetCostKind CostKind) { ++ TTI::TargetCostKind CostKind) const { + // The extra cost of speculative execution for math intrinsics + if (auto *II = dyn_cast_or_null(U)) { + if (Intrinsic::ID IID = II->getIntrinsicID()) { +@@ -746,7 +748,7 @@ unsigned getLoopSize(const Loop *L, const TargetTransformInfo &TTI) { + LoopSize = Metrics.NumInsts; + + LoopSize = (LoopSize > 3 /*BEInsns + 1*/) ? LoopSize : 3; +- return *LoopSize.getValue(); ++ return LoopSize.getValue(); + } + + } // namespace llvm +diff --git a/IGC/Compiler/GenTTI.h b/IGC/Compiler/GenTTI.h +index 643450c..60be777 100644 +--- a/IGC/Compiler/GenTTI.h ++++ b/IGC/Compiler/GenTTI.h +@@ -32,9 +32,9 @@ public: + DenseMap isGEPLoopInduction; + + bool shouldBuildLookupTables(); +- bool enablePromoteLoopUnrollwithAlloca(); ++ bool enablePromoteLoopUnrollwithAlloca() const; + +- bool isLoweredToCall(const Function *F); ++ bool isLoweredToCall(const Function *F) const; + + void *getAdjustedAnalysisPointer(const void *ID); + +@@ -55,11 +55,11 @@ public: + llvm::InstructionCost getUserCost(const User *U, ArrayRef Operands, TTI::TargetCostKind CostKind); + + llvm::InstructionCost getInstructionCost(const User *U, ArrayRef Operands, +- TTI::TargetCostKind CostKind); ++ TTI::TargetCostKind CostKind) const; + + private: + llvm::InstructionCost internalCalculateCost(const User *U, ArrayRef Operands, +- TTI::TargetCostKind CostKind); ++ TTI::TargetCostKind CostKind) const; + }; + + unsigned getLoopSize(const Loop *L, const TargetTransformInfo &TTI); +diff --git a/IGC/Compiler/GenUpdateCB.cpp b/IGC/Compiler/GenUpdateCB.cpp +index 53ec408..dc535c2 100644 +--- a/IGC/Compiler/GenUpdateCB.cpp ++++ b/IGC/Compiler/GenUpdateCB.cpp +@@ -203,58 +203,58 @@ void GenUpdateCB::InsertInstTree(Instruction *inst, Instruction *pos) { + if (CallInst *callI = dyn_cast(Clone)) { + switch (GetOpCode(callI)) { + case llvm_log: +- pfunc = llvm::Intrinsic::getDeclaration( ++ pfunc = llvm::Intrinsic::getOrInsertDeclaration( + m_ConstantBufferReplaceShaderPatterns, Intrinsic::log2, + llvm::ArrayRef(Type::getFloatTy(m_ConstantBufferReplaceShaderPatterns->getContext()))); + break; + case llvm_sqrt: +- pfunc = llvm::Intrinsic::getDeclaration( ++ pfunc = llvm::Intrinsic::getOrInsertDeclaration( + m_ConstantBufferReplaceShaderPatterns, Intrinsic::sqrt, + llvm::ArrayRef(Type::getFloatTy(m_ConstantBufferReplaceShaderPatterns->getContext()))); + break; + case llvm_pow: +- pfunc = llvm::Intrinsic::getDeclaration( ++ pfunc = llvm::Intrinsic::getOrInsertDeclaration( + m_ConstantBufferReplaceShaderPatterns, Intrinsic::pow, + llvm::ArrayRef(Type::getFloatTy(m_ConstantBufferReplaceShaderPatterns->getContext()))); + break; + case llvm_cos: +- pfunc = llvm::Intrinsic::getDeclaration( ++ pfunc = llvm::Intrinsic::getOrInsertDeclaration( + m_ConstantBufferReplaceShaderPatterns, Intrinsic::cos, + llvm::ArrayRef(Type::getFloatTy(m_ConstantBufferReplaceShaderPatterns->getContext()))); + break; + case llvm_sin: +- pfunc = llvm::Intrinsic::getDeclaration( ++ pfunc = llvm::Intrinsic::getOrInsertDeclaration( + m_ConstantBufferReplaceShaderPatterns, Intrinsic::sin, + llvm::ArrayRef(Type::getFloatTy(m_ConstantBufferReplaceShaderPatterns->getContext()))); + break; + case llvm_exp: +- pfunc = llvm::Intrinsic::getDeclaration( ++ pfunc = llvm::Intrinsic::getOrInsertDeclaration( + m_ConstantBufferReplaceShaderPatterns, Intrinsic::exp2, + llvm::ArrayRef(Type::getFloatTy(m_ConstantBufferReplaceShaderPatterns->getContext()))); + break; + + case llvm_floor: +- pfunc = llvm::Intrinsic::getDeclaration( ++ pfunc = llvm::Intrinsic::getOrInsertDeclaration( + m_ConstantBufferReplaceShaderPatterns, Intrinsic::floor, + llvm::ArrayRef(Type::getFloatTy(m_ConstantBufferReplaceShaderPatterns->getContext()))); + break; + case llvm_ceil: +- pfunc = llvm::Intrinsic::getDeclaration( ++ pfunc = llvm::Intrinsic::getOrInsertDeclaration( + m_ConstantBufferReplaceShaderPatterns, Intrinsic::ceil, + llvm::ArrayRef(Type::getFloatTy(m_ConstantBufferReplaceShaderPatterns->getContext()))); + break; + case llvm_fabs: +- pfunc = llvm::Intrinsic::getDeclaration( ++ pfunc = llvm::Intrinsic::getOrInsertDeclaration( + m_ConstantBufferReplaceShaderPatterns, Intrinsic::fabs, + llvm::ArrayRef(Type::getFloatTy(m_ConstantBufferReplaceShaderPatterns->getContext()))); + break; + case llvm_max: +- pfunc = llvm::Intrinsic::getDeclaration( ++ pfunc = llvm::Intrinsic::getOrInsertDeclaration( + m_ConstantBufferReplaceShaderPatterns, Intrinsic::maxnum, + llvm::ArrayRef(Type::getFloatTy(m_ConstantBufferReplaceShaderPatterns->getContext()))); + break; + case llvm_min: +- pfunc = llvm::Intrinsic::getDeclaration( ++ pfunc = llvm::Intrinsic::getOrInsertDeclaration( + m_ConstantBufferReplaceShaderPatterns, Intrinsic::minnum, + llvm::ArrayRef(Type::getFloatTy(m_ConstantBufferReplaceShaderPatterns->getContext()))); + break; +diff --git a/IGC/Compiler/IGCPassSupport.h b/IGC/Compiler/IGCPassSupport.h +index 107b395..1fde96b 100644 +--- a/IGC/Compiler/IGCPassSupport.h ++++ b/IGC/Compiler/IGCPassSupport.h +@@ -20,6 +20,7 @@ See LICENSE.TXT for details. + #include "Compiler/InitializePasses.h" + + #include "common/LLVMWarningsPush.hpp" ++#include "llvm/Config/llvm-config.h" + #include "llvm/InitializePasses.h" + #include + #include "llvm/Support/Threading.h" +@@ -45,6 +46,17 @@ See LICENSE.TXT for details. + + #define IGC_INITIALIZE_AG_DEPENDENCY(depName) INITIALIZE_AG_DEPENDENCY(depName) + ++#if LLVM_VERSION_MAJOR >= 22 ++#define IGC_INITIALIZE_PASS_END(passName, arg, name, cfg, analysis) \ ++ PassInfo *PI = \ ++ new PassInfo(name, arg, &passName ::ID, PassInfo::NormalCtor_t(callDefaultCtor), cfg, analysis); \ ++ Registry.registerPass(*PI, true); \ ++ } \ ++ static llvm::once_flag Initialize##passName##PassFlag; \ ++ void initialize##passName##Pass(PassRegistry &Registry) { \ ++ llvm::call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, std::ref(Registry)); \ ++ } ++#else + #define IGC_INITIALIZE_PASS_END(passName, arg, name, cfg, analysis) \ + PassInfo *PI = \ + new PassInfo(name, arg, &passName ::ID, PassInfo::NormalCtor_t(callDefaultCtor), cfg, analysis); \ +@@ -55,6 +67,11 @@ See LICENSE.TXT for details. + void initialize##passName##Pass(PassRegistry &Registry) { \ + llvm::call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, std::ref(Registry)); \ + } ++#endif \ ++ static llvm::once_flag Initialize##passName##PassFlag; \ ++ void initialize##passName##Pass(PassRegistry &Registry) { \ ++ llvm::call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, std::ref(Registry)); \ ++ } + + #define IGC_INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \ + static void *initialize##passName##PassOnce(PassRegistry &Registry) { \ +diff --git a/IGC/Compiler/LegalizationPass.cpp b/IGC/Compiler/LegalizationPass.cpp +index 6e0ccae..3d595a5 100644 +--- a/IGC/Compiler/LegalizationPass.cpp ++++ b/IGC/Compiler/LegalizationPass.cpp +@@ -259,7 +259,7 @@ void Legalization::visitBinaryOperator(llvm::BinaryOperator &I) { + if (I.getOpcode() == Instruction::FRem && (I.getType()->isFloatTy() || I.getType()->isHalfTy())) { + bool hasFP16Floor = !m_ctx->platform.supportFP16Rounding(); + Type *floorType = hasFP16Floor ? I.getType() : m_builder->getFloatTy(); +- Function *floorFunc = Intrinsic::getDeclaration(m_ctx->getModule(), Intrinsic::floor, floorType); ++ Function *floorFunc = Intrinsic::getOrInsertDeclaration(m_ctx->getModule(), Intrinsic::floor, floorType); + m_builder->SetInsertPoint(&I); + Value *a = I.getOperand(0); + Value *b = I.getOperand(1); +@@ -1213,7 +1213,7 @@ void Legalization::visitStoreInst(StoreInst &I) { + + PointerType *ptrTy = cast(I.getPointerOperand()->getType()); + unsigned addressSpace = ptrTy->getAddressSpace(); +- PointerType *I8PtrTy = m_builder->getInt8PtrTy(addressSpace); ++ PointerType *I8PtrTy = PointerType::get(m_builder->getInt8Ty(), addressSpace); + Value *I8PtrOp = m_builder->CreateBitCast(I.getPointerOperand(), I8PtrTy); + + IGC::cloneStore(&I, newVal, I8PtrOp); +@@ -1276,7 +1276,7 @@ void Legalization::visitLoadInst(LoadInst &I) { + m_builder->SetInsertPoint(&I); + PointerType *ptrTy = cast(I.getPointerOperand()->getType()); + unsigned addressSpace = ptrTy->getAddressSpace(); +- PointerType *I8PtrTy = m_builder->getInt8PtrTy(addressSpace); ++ PointerType *I8PtrTy = PointerType::get(m_builder->getInt8Ty(), addressSpace); + Value *I8PtrOp = m_builder->CreateBitCast(I.getPointerOperand(), I8PtrTy); + + LoadInst *pNewLoadInst = IGC::cloneLoad(&I, m_builder->getInt8Ty(), I8PtrOp); +@@ -1847,7 +1847,7 @@ void Legalization::visitIntrinsicInst(llvm::IntrinsicInst &I) { + // demote back. + Value *Val = Builder.CreateFPExt(I.getOperand(0), Builder.getFloatTy()); + Value *Callee = +- Intrinsic::getDeclaration(I.getParent()->getParent()->getParent(), intrinsicID, Builder.getFloatTy()); ++ Intrinsic::getOrInsertDeclaration(I.getParent()->getParent()->getParent(), intrinsicID, Builder.getFloatTy()); + Val = Builder.CreateCall(Callee, ArrayRef(Val)); + Val = Builder.CreateFPTrunc(Val, I.getType()); + I.replaceAllUsesWith(Val); +diff --git a/IGC/Compiler/Legalizer/InstPromoter.cpp b/IGC/Compiler/Legalizer/InstPromoter.cpp +index 82ee857..4155393 100644 +--- a/IGC/Compiler/Legalizer/InstPromoter.cpp ++++ b/IGC/Compiler/Legalizer/InstPromoter.cpp +@@ -232,7 +232,7 @@ bool InstPromoter::visitLoadInst(LoadInst &I) { + + Type *PromotedTy = TySeq->front(); + +- Value *NewBasePtr = IRB->CreatePointerCast(OldPtr, IRB->getInt8PtrTy(AS), Twine(OldPtr->getName(), ".ptrcast")); ++ Value *NewBasePtr = IRB->CreatePointerCast(OldPtr, PointerType::get(IRB->getInt8Ty(), AS), Twine(OldPtr->getName(), ".ptrcast")); + + // Different from promotion of regular instructions, such as 'add', promotion + // of load is required to split the original load into small ones and +@@ -307,7 +307,7 @@ bool InstPromoter::visitStoreInst(StoreInst &I) { + + Value *PromotedVal = ValSeq->front(); + +- Value *NewBasePtr = IRB->CreatePointerCast(OldPtr, IRB->getInt8PtrTy(AS), Twine(OldPtr->getName(), ".ptrcast")); ++ Value *NewBasePtr = IRB->CreatePointerCast(OldPtr, PointerType::get(IRB->getInt8Ty(), AS), Twine(OldPtr->getName(), ".ptrcast")); + + unsigned Off = 0; + for (unsigned TotalStoreBits = TL->getTypeStoreSizeInBits(OrigTy), ActualStoreBits = 0; TotalStoreBits != 0; +@@ -639,7 +639,7 @@ std::pair InstPromoter::preparePromotedIntrinsicInst(IntrinsicI + IGC_ASSERT(PromotedBitWidth == ValBitWidth); + } + +- Function *Func = Intrinsic::getDeclaration(I.getModule(), I.getIntrinsicID(), PromotedTy); ++ Function *Func = Intrinsic::getOrInsertDeclaration(I.getModule(), I.getIntrinsicID(), PromotedTy); + return {IRB->CreateCall(Func, PromotedArgs), PromotedTy}; + } + +diff --git a/IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp b/IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp +index 81ffbd7..6418ca3 100644 +--- a/IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp ++++ b/IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp +@@ -611,7 +611,7 @@ void PeepholeTypeLegalizer::legalizeUnaryInstruction(Instruction &I) { + I.eraseFromParent(); + } else { + Value *newUpBitCast = m_builder->CreateBitCast( +- I.getOperand(0), Type::getIntNPtrTy(I.getContext(), promoteToInt, I.getType()->getPointerAddressSpace())); ++ I.getOperand(0), PointerType::get(Type::getIntNTy(I.getContext(), promoteToInt), I.getType()->getPointerAddressSpace())); + Value *newDownBitCast = m_builder->CreateBitCast(newUpBitCast, I.getType()); + + I.replaceAllUsesWith(newDownBitCast); +@@ -1033,7 +1033,7 @@ void PeepholeTypeLegalizer::cleanupZExtInst(Instruction &I) { + auto Load = cast(prevInst); + unsigned zext_size = I.getType()->getScalarSizeInBits(); + auto max_srcSize = APInt::getMaxValue(srcSize).getZExtValue(); +- auto ptrTy = Type::getIntNPtrTy(I.getContext(), zext_size, Load->getPointerAddressSpace()); ++ auto ptrTy = PointerType::get(Type::getIntNTy(I.getContext(), zext_size), Load->getPointerAddressSpace()); + auto ldTy = Type::getIntNTy(I.getContext(), zext_size); + + auto newBitcast = m_builder->CreateBitCast(prevInst->getOperand(0), ptrTy); +diff --git a/IGC/Compiler/Legalizer/TypeLegalizer.cpp b/IGC/Compiler/Legalizer/TypeLegalizer.cpp +index d75fb79..d7c1b32 100644 +--- a/IGC/Compiler/Legalizer/TypeLegalizer.cpp ++++ b/IGC/Compiler/Legalizer/TypeLegalizer.cpp +@@ -420,7 +420,7 @@ void TypeLegalizer::promoteConstant(ValueSeq *ValSeq, TypeSeq *TySeq, Constant * + + Type *PromotedTy = TySeq->front(); + +- auto *ExtValue = isSigned ? ConstantExpr::getSExt(C, PromotedTy) : ConstantExpr::getZExt(C, PromotedTy); ++ auto *ExtValue = isSigned ? ConstantExpr::getCast(Instruction::SExt, C, PromotedTy) : ConstantExpr::getCast(Instruction::ZExt, C, PromotedTy); + + ValSeq->push_back(ExtValue); + } +diff --git a/IGC/Compiler/LowPrecisionOptPass.cpp b/IGC/Compiler/LowPrecisionOptPass.cpp +index 72a7e11..fe3e9a9 100644 +--- a/IGC/Compiler/LowPrecisionOptPass.cpp ++++ b/IGC/Compiler/LowPrecisionOptPass.cpp +@@ -322,7 +322,7 @@ void LowPrecisionOpt::visitIntrinsicInst(llvm::IntrinsicInst &I) { + + if (!func_llvm_floor_f32) + func_llvm_floor_f32 = +- llvm::Intrinsic::getDeclaration(m_currFunction->getParent(), Intrinsic::floor, m_builder->getFloatTy()); ++ llvm::Intrinsic::getOrInsertDeclaration(m_currFunction->getParent(), Intrinsic::floor, m_builder->getFloatTy()); + + auto floor32 = m_builder->CreateCall(func_llvm_floor_f32, src); + #if VALUE_NAME_ENABLE +diff --git a/IGC/Compiler/Optimizer/BuiltInFuncImport.cpp b/IGC/Compiler/Optimizer/BuiltInFuncImport.cpp +index 38450bc..223ebef 100644 +--- a/IGC/Compiler/Optimizer/BuiltInFuncImport.cpp ++++ b/IGC/Compiler/Optimizer/BuiltInFuncImport.cpp +@@ -188,7 +188,7 @@ static bool isMangledImageFn(StringRef FName, const MangleSubstTy &MangleSubst) + bool UpdateMangle = std::any_of(MangleSubst.begin(), MangleSubst.end(), + [=](PairTy Pair) { return FName.find(Pair.first) != StringRef::npos; }); + +- return (FName.startswith("_Z") && UpdateMangle); ++ return (FName.starts_with("_Z") && UpdateMangle); + } + + static std::string updatedMangleName(const std::string &FuncName, const std::string &Mangle) { +@@ -427,8 +427,8 @@ void BIImport::fixSPIRFunctionsReturnType(Module &M) { + if (F.isDeclaration()) { + auto FuncName = F.getName(); + +- if (FuncName.equals("intel_is_traversal_done") || FuncName.equals("intel_get_hit_front_face") || +- FuncName.equals("intel_has_committed_hit")) { ++ if (FuncName == "intel_is_traversal_done" || FuncName == "intel_get_hit_front_face" || ++ FuncName == "intel_has_committed_hit") { + if (!F.getReturnType()->isIntegerTy(8)) + continue; + +@@ -479,7 +479,7 @@ void BIImport::fixSPIRFunctionsReturnType(Module &M) { + // bitcast must be replaced with bitcast + addrspacecast. + void BIImport::fixInvalidBitcasts(llvm::Module &M) { + for (auto &F : M) { +- if (!F.getName().startswith("__builtin")) ++ if (!F.getName().starts_with("__builtin")) + continue; + + // Collect invalid bitcasts with address space change. +@@ -642,14 +642,14 @@ bool BIImport::runOnModule(Module &M) { + // temporary work around for sampler types and pipes + for (auto &func : M) { + auto funcName = func.getName(); +- if (funcName.startswith("__builtin_IB_convert_sampler_to_int") || +- funcName.startswith("__builtin_IB_convert_pipe_ro_to_intel_pipe") || +- funcName.startswith("__builtin_IB_convert_pipe_wo_to_intel_pipe")) { ++ if (funcName.starts_with("__builtin_IB_convert_sampler_to_int") || ++ funcName.starts_with("__builtin_IB_convert_pipe_ro_to_intel_pipe") || ++ funcName.starts_with("__builtin_IB_convert_pipe_wo_to_intel_pipe")) { + for (auto Users : func.users()) { + if (auto CI = dyn_cast(Users)) { + IRBuilder<> builder(CI); + Value *newV; +- if (funcName.startswith("__builtin_IB_convert_sampler_to_int")) { ++ if (funcName.starts_with("__builtin_IB_convert_sampler_to_int")) { + newV = builder.CreatePtrToInt(CI->getOperand(0), CI->getType()); + } else + newV = builder.CreateBitOrPointerCast(CI->getOperand(0), CI->getType()); +@@ -665,7 +665,7 @@ bool BIImport::runOnModule(Module &M) { + auto funcName = F.getName(); + // Builtin for OCL support for function pointers + // Gets the function address +- if (funcName.startswith("__builtin_IB_get_function_pointer")) { ++ if (funcName.starts_with("__builtin_IB_get_function_pointer")) { + for (auto user : F.users()) { + if (CallInst *CI = dyn_cast(&*user)) { + // Strip if CI->getArgOperand(0) is ConstExpr bitcast which happens when +@@ -695,7 +695,7 @@ bool BIImport::runOnModule(Module &M) { + } + // Builtin for OCL support for function pointers + // Calls a function address +- else if (funcName.startswith("__builtin_IB_call_function_pointer")) { ++ else if (funcName.starts_with("__builtin_IB_call_function_pointer")) { + for (auto user : F.users()) { + if (CallInst *CI = dyn_cast(&*user)) { + IGCLLVM::IRBuilder<> builder(CI); +@@ -713,7 +713,7 @@ bool BIImport::runOnModule(Module &M) { + } + + // Handles the function pointer SIMD variant functions +- else if (funcName.startswith("__intel_create_simd_variant")) { ++ else if (funcName.starts_with("__intel_create_simd_variant")) { + // If we encounter this call, we need to enable this flag to indicate we need to compile multiple SIMD + auto pCtx = getAnalysis().getCodeGenContext(); + pCtx->m_enableSimdVariantCompilation = true; +@@ -752,7 +752,7 @@ bool BIImport::runOnModule(Module &M) { + // FIXME: This is a temp solution, eventually if we support argument variants etc, it's unlikely + // we will have all the information for the variant index in this pass, and will have to move it + // to later passes. For now, since we only require subgroup size, this should suffice. +- else if (funcName.startswith("__intel_indirect_call")) { ++ else if (funcName.starts_with("__intel_indirect_call")) { + MetaDataUtils *pMdUtils = getAnalysis().getMetaDataUtils(); + for (auto user : F.users()) { + if (CallInst *CI = dyn_cast(&*user)) { +@@ -1158,8 +1158,8 @@ bool PreBIImportAnalysis::runOnModule(Module &M) { + for (; instUse != instEnd; ++instUse) { + if (CallInst *useInst = dyn_cast(instUse->getUser())) { + StringRef funcName = useInst->getCalledFunction()->getName(); +- if (!funcName.startswith(cosBuiltinName) && !funcName.startswith(sinBuiltinName) && +- !funcName.startswith(sinPiBuiltinName) && !funcName.startswith(cosPiBuiltinName)) { ++ if (!funcName.starts_with(cosBuiltinName) && !funcName.starts_with(sinBuiltinName) && ++ !funcName.starts_with(sinPiBuiltinName) && !funcName.starts_with(cosPiBuiltinName)) { + return true; + } + } else +@@ -1171,7 +1171,7 @@ bool PreBIImportAnalysis::runOnModule(Module &M) { + + auto modMD = getAnalysis().getModuleMetaData(); + if ((modMD->compOpt.MatchSinCosPi) && !(modMD->compOpt.FastRelaxedMath) && +- (funcName.startswith(cosBuiltinName) || funcName.startswith(sinBuiltinName))) { ++ (funcName.starts_with(cosBuiltinName) || funcName.starts_with(sinBuiltinName))) { + for (auto Users : pFunc->users()) { + if (auto CI = dyn_cast(Users)) { + IRBuilder<> builder(CI); +@@ -1234,9 +1234,9 @@ bool PreBIImportAnalysis::runOnModule(Module &M) { + InstToModify.push_back(std::make_tuple(fmulInst, intValue, srcPos)); + + std::string newName; +- if (funcName.startswith(cosBuiltinName)) { ++ if (funcName.starts_with(cosBuiltinName)) { + newName = cosPiBuiltinName; +- } else if (funcName.startswith(sinBuiltinName)) { ++ } else if (funcName.starts_with(sinBuiltinName)) { + newName = sinPiBuiltinName; + } + +diff --git a/IGC/Compiler/Optimizer/CodeAssumption.cpp b/IGC/Compiler/Optimizer/CodeAssumption.cpp +index 31f4340..bbf6026 100644 +--- a/IGC/Compiler/Optimizer/CodeAssumption.cpp ++++ b/IGC/Compiler/Optimizer/CodeAssumption.cpp +@@ -61,8 +61,8 @@ void CodeAssumption::uniformHelper(Module *M) { + StringRef FN = F->getName(); + + // sub_group_id +- if (!FN.equals("_Z25__spirv_BuiltInSubgroupIdv") && !FN.equals("__builtin_spirv_BuiltInSubgroupId") && +- !FN.equals("_Z16get_sub_group_idv")) ++ if (FN != "_Z25__spirv_BuiltInSubgroupIdv" && FN != "__builtin_spirv_BuiltInSubgroupId" && ++ FN != "_Z16get_sub_group_idv") + continue; + // find all the callees + for (auto ui = F->use_begin(), ue = F->use_end(); ui != ue; ++ui) { +diff --git a/IGC/Compiler/Optimizer/GatingSimilarSamples.cpp b/IGC/Compiler/Optimizer/GatingSimilarSamples.cpp +index a6b99e4..6f52e7c 100644 +--- a/IGC/Compiler/Optimizer/GatingSimilarSamples.cpp ++++ b/IGC/Compiler/Optimizer/GatingSimilarSamples.cpp +@@ -19,6 +19,7 @@ SPDX-License-Identifier: MIT + #include + #include + #include "Probe/Assertion.h" ++#include "common/LLVMUtils.h" + + using namespace llvm; + using namespace IGC; +@@ -30,13 +31,13 @@ static bool samplesAveragedEqually(const std::vector &similarSamp + unsigned totalSimilarSamples = similarToTexelSampleInstsCount + 1; // texel(sample2) + similar to texel(sample3,4,5) + const float cmpAveragingFactor = (float)1.0 / (float(totalSimilarSamples)); + for (auto sampleInst : similarSampleInsts) { +- Instruction *inst = sampleInst->getNextNonDebugInstruction(); ++ Instruction *inst = IGC::getNextNonDbgInstruction(sampleInst); + std::set texels; // for storing texel_x, texel_y, texel_z of this sampleInst + + for (int i = 0; i < 3; i++) { + if (inst->getOpcode() == Instruction::ExtractElement) { + texels.insert(inst); +- inst = inst->getNextNonDebugInstruction(); ++ inst = IGC::getNextNonDbgInstruction(inst); + } else { + return false; // Sample->followed by 3 EE == this pattern is not matching + } +@@ -59,7 +60,7 @@ static bool samplesAveragedEqually(const std::vector &similarSamp + } else { + return false; // 3 EE -> followed by 3 FMuls == this pattern is not matching + } +- inst = inst->getNextNonDebugInstruction(); ++ inst = IGC::getNextNonDbgInstruction(inst); + } + IGC_ASSERT_MESSAGE(texels.size() == 0, " All texels.x/y/z were not multiplied by same float"); + texels.clear(); +@@ -92,7 +93,7 @@ static bool detectSampleAveragePattern2(const std::vector &sample + Instruction *rgb[3] = {nullptr}; + + for (unsigned i = 0; i < nSampleInsts; i++) { +- Instruction *inst = sampleInsts[i]->getNextNonDebugInstruction(); ++ Instruction *inst = IGC::getNextNonDbgInstruction(sampleInsts[i]); + for (unsigned j = 0; j < 3; j++) { + ExtractElementInst *ei = dyn_cast(inst); + if (!ei) { +@@ -122,7 +123,7 @@ static bool detectSampleAveragePattern2(const std::vector &sample + } + rgb[idx] = fadd; + } +- inst = inst->getNextNonDebugInstruction(); ++ inst = IGC::getNextNonDbgInstruction(inst); + } + if (isa(inst)) { + return false; +@@ -342,13 +343,13 @@ bool GatingSimilarSamples::runOnFunction(llvm::Function &F) { + return false; + + // extract original texel.xyz and averaged color.xyz values for creating 3 PHI nodes +- Instruction *texel_x = texelSample->getNextNonDebugInstruction(); ++ Instruction *texel_x = IGC::getNextNonDbgInstruction(texelSample); + if (!dyn_cast(texel_x)) + return false; +- Instruction *texel_y = texel_x->getNextNonDebugInstruction(); ++ Instruction *texel_y = IGC::getNextNonDbgInstruction(texel_x); + if (!dyn_cast(texel_y)) + return false; +- Instruction *texel_z = texel_y->getNextNonDebugInstruction(); ++ Instruction *texel_z = IGC::getNextNonDbgInstruction(texel_y); + if (!dyn_cast(texel_z)) + return false; + +diff --git a/IGC/Compiler/Optimizer/IntDivRemIncrementReduction.cpp b/IGC/Compiler/Optimizer/IntDivRemIncrementReduction.cpp +index 8779dd1..c4818bd 100644 +--- a/IGC/Compiler/Optimizer/IntDivRemIncrementReduction.cpp ++++ b/IGC/Compiler/Optimizer/IntDivRemIncrementReduction.cpp +@@ -16,6 +16,8 @@ SPDX-License-Identifier: MIT + #include "llvm/ADT/SmallPtrSet.h" + #include "llvm/ADT/DenseMap.h" + #include "llvm/Analysis/ValueTracking.h" ++#include "llvm/Analysis/WithCache.h" ++#include "llvm/Analysis/SimplifyQuery.h" + #include "llvm/IR/Constants.h" + #include "llvm/IR/Dominators.h" + #include "llvm/IR/Function.h" +@@ -495,8 +497,7 @@ std::pair IntDivRemIncrementReductionImpl::getBaseAndOffset(Valu + // only one operand is a constant + if (I->getOpcode() == Instruction::Add || // ADD inst + (I->getOpcode() == Instruction::Or && // OR inst with no common bits set between both operands +- haveNoCommonBitsSet(I->getOperand(0), I->getOperand(1), I->getFunction()->getParent()->getDataLayout(), +- nullptr, I, DT))) { ++ haveNoCommonBitsSet(WithCache(I->getOperand(0)), WithCache(I->getOperand(1)), SimplifyQuery(I->getFunction()->getParent()->getDataLayout(), DT)))) { + if (c0) + return {I->getOperand(1), c0->getValue()}; + else +diff --git a/IGC/Compiler/Optimizer/OCLBIUtils.cpp b/IGC/Compiler/Optimizer/OCLBIUtils.cpp +index 07ea5ab..377784a 100644 +--- a/IGC/Compiler/Optimizer/OCLBIUtils.cpp ++++ b/IGC/Compiler/Optimizer/OCLBIUtils.cpp +@@ -48,7 +48,7 @@ Function *CCommand::getFunctionDeclaration(GenISAIntrinsic::ID id, ArrayRef Tys) { +- return Intrinsic::getDeclaration(m_pFunc->getParent(), id, Tys); ++ return Intrinsic::getOrInsertDeclaration(m_pFunc->getParent(), id, Tys); + } + + void CCommand::replaceCallInst(IGCLLVM::Intrinsic intrinsicName, ArrayRef Tys) { +@@ -118,8 +118,8 @@ void CImagesBI::prepareCoords(Dimension Dim, Value *Coord, Value *Zero) { + + void CImagesBI::CreateInlineSamplerAnnotations(Module *M, InlineSamplersMD &inlineSamplerMD, int samplerValue) { + inlineSamplerMD.m_Value = samplerValue; +- if (llvm::StringRef(M->getTargetTriple()).startswith("igil") || +- llvm::StringRef(M->getTargetTriple()).startswith("gpu_64")) { ++ if (M->getTargetTriple().getTriple().starts_with("igil") || ++ M->getTargetTriple().getTriple().starts_with("gpu_64")) { + inlineSamplerMD.addressMode = samplerValue & LEGACY_SAMPLER_ADDRESS_MASK; + switch (samplerValue & LEGACY_SAMPLER_ADDRESS_MASK) { + case LEGACY_CLK_ADDRESS_NONE: +@@ -181,7 +181,7 @@ void CImagesBI::CreateInlineSamplerAnnotations(Module *M, InlineSamplersMD &inli + inlineSamplerMD.BorderColorG = (0.0f); + inlineSamplerMD.BorderColorB = (0.0f); + inlineSamplerMD.BorderColorA = (0.0f); +- } else if (llvm::StringRef(M->getTargetTriple()).startswith("spir")) { ++ } else if (M->getTargetTriple().getTriple().starts_with("spir")) { + switch (samplerValue & SPIR_SAMPLER_ADDRESS_MASK) { + case SPIR_CLK_ADDRESS_NONE: + inlineSamplerMD.TCXAddressMode = (iOpenCL::SAMPLER_TEXTURE_ADDRESS_MODE_CLAMP); +@@ -1233,9 +1233,9 @@ public: + + IGCLLVM::IRBuilder<> IRB(m_pCallInst); + +- Value *pDsti8 = IRB.CreateBitCast(pDst, IRB.getInt8PtrTy(cast(pDst->getType())->getAddressSpace())); ++ Value *pDsti8 = IRB.CreateBitCast(pDst, PointerType::get(IRB.getInt8Ty(), cast(pDst->getType())->getAddressSpace())); + +- Value *pSrci8 = IRB.CreateBitCast(pSrc, IRB.getInt8PtrTy(cast(pSrc->getType())->getAddressSpace())); ++ Value *pSrci8 = IRB.CreateBitCast(pSrc, PointerType::get(IRB.getInt8Ty(), cast(pSrc->getType())->getAddressSpace())); + + CallInst *pCall = IRB.CreateMemCpy(pDsti8, pSrci8, pNumBytes, int_cast(Align)); + pCall->setDebugLoc(m_DL); +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.cpp +index 0b686d2..847864e 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.cpp +@@ -243,7 +243,7 @@ void ResolveAggregateArguments::storeArgument(const Argument *arg, AllocaInst *b + // associated with the explicit given argument. + Function::arg_iterator implicitArgToStore = std::next(m_pFunction->arg_begin(), baseImplicitArg + startArgNo); + +- Value *baseAsPtri8 = irBuilder.CreateBitCast(base, Type::getInt8PtrTy(base->getContext(), ADDRESS_SPACE_PRIVATE)); ++ Value *baseAsPtri8 = irBuilder.CreateBitCast(base, PointerType::get(Type::getInt8Ty(base->getContext()), ADDRESS_SPACE_PRIVATE)); + + // Iterate over all base type args of the structure and store them + // into the correct offset from the alloca. +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/AlignmentAnalysis/AlignmentAnalysis.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/AlignmentAnalysis/AlignmentAnalysis.cpp +index 8632b00..ce85e4d 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/AlignmentAnalysis/AlignmentAnalysis.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/AlignmentAnalysis/AlignmentAnalysis.cpp +@@ -77,7 +77,7 @@ void AlignmentAnalysis::setArgumentAlignmentBasedOnOptionalMetadata(Function &F) + continue; + } + +- if (!Op->getString().endswith("*")) { ++ if (!Op->getString().ends_with("*")) { + // If the metadata string does not end with '*', skip this argument. + // This can be e.g. a struct pointer passed byval. + // DPC++ does not add "*" in this case and we will not be able to +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/Atomics/ResolveOCLAtomics.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/Atomics/ResolveOCLAtomics.cpp +index a9185f9..0d42ea6 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/Atomics/ResolveOCLAtomics.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/Atomics/ResolveOCLAtomics.cpp +@@ -79,7 +79,7 @@ void ResolveOCLAtomics::visitCallInst(CallInst &callInst) { + processGetGlobalLock(callInst); + } + +- if (funcName.startswith("__builtin_IB_atomic")) { ++ if (funcName.starts_with("__builtin_IB_atomic")) { + IGC_ASSERT_MESSAGE(m_AtomicDescMap.count(funcName), "Unexpected IGC atomic function name."); + const OCLAtomicAttrs &attrs = m_AtomicDescMap[funcName]; + processOCLAtomic(callInst, attrs.op, attrs.bufType); +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/BIFTransforms/BIFTransforms.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/BIFTransforms/BIFTransforms.cpp +index 8a1cf0b..35d2e2c 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/BIFTransforms/BIFTransforms.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/BIFTransforms/BIFTransforms.cpp +@@ -72,17 +72,17 @@ bool BIFTransforms::replaceBIF(Function &F) { + + bool changed = false; + StringRef name = F.getName(); +- if (name.startswith("_Z6length")) { // length --> fast_length ++ if (name.starts_with("_Z6length")) { // length --> fast_length + std::string newName("_Z11fast_length"); + newName.append(name.data() + 9); + F.setName(newName); + changed = true; +- } else if (name.startswith("_Z9normalize")) { // normalize --> fast_normalize ++ } else if (name.starts_with("_Z9normalize")) { // normalize --> fast_normalize + std::string newName("_Z14fast_normalize"); + newName.append(name.data() + 12); + F.setName(newName); + changed = true; +- } else if (name.startswith("_Z8distance")) { // distance --> fast_distance ++ } else if (name.starts_with("_Z8distance")) { // distance --> fast_distance + std::string newName("_Z13fast_distance"); + newName.append(name.data() + 11); + F.setName(newName); +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/BfloatBuiltins/BfloatBuiltinsResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/BfloatBuiltins/BfloatBuiltinsResolution.cpp +index a9b8392..c6b55b5 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/BfloatBuiltins/BfloatBuiltinsResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/BfloatBuiltins/BfloatBuiltinsResolution.cpp +@@ -122,11 +122,11 @@ void BfloatBuiltinsResolution::visitCallInst(CallInst &CI) { + return; + } + ++std::string MangledNameForDemangling = MangledName.str(); + #if LLVM_VERSION_MAJOR < 20 + // Workaround for LLVM 16 demangler not supporting DF16b mangling (even though LLVM 16 supports bfloat type) + // Support was implemented in LLVM 20 + // (https://github.com/llvm/llvm-project/commit/a100fd8cbd3dad3846a6212d97279ca23db85c75) +- std::string MangledNameForDemangling = MangledName.str(); + if (MangledName.contains("DF16b")) { + MangledNameForDemangling = replaceAll(MangledName, "DF16b", "u6__bf16"); + } +@@ -145,7 +145,7 @@ void BfloatBuiltinsResolution::visitCallInst(CallInst &CI) { + StringRef DemangledNameRef = DemangledName; + bool IsSupported = false; + for (const auto &funcName : FuncNames) { +- if (DemangledNameRef.equals(funcName)) { ++ if (DemangledNameRef == funcName) { + IsSupported = true; + break; + } +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/BfloatFuncs/BfloatFuncsResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/BfloatFuncs/BfloatFuncsResolution.cpp +index 4605039..e4cdb4f 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/BfloatFuncs/BfloatFuncsResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/BfloatFuncs/BfloatFuncsResolution.cpp +@@ -63,7 +63,7 @@ void BfloatFuncsResolution::visitCallInst(CallInst &CI) { + std::string DNameStr = llvm::demangle(CI.getCalledFunction()->getName().str()); + StringRef DName(DNameStr); + +- if (!DName.startswith("__builtin_bf16")) ++ if (!DName.starts_with("__builtin_bf16")) + return; + + m_builder->SetInsertPoint(&CI); +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/CorrectlyRoundedDivSqrt/CorrectlyRoundedDivSqrt.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/CorrectlyRoundedDivSqrt/CorrectlyRoundedDivSqrt.cpp +index aa31479..f5c013f 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/CorrectlyRoundedDivSqrt/CorrectlyRoundedDivSqrt.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/CorrectlyRoundedDivSqrt/CorrectlyRoundedDivSqrt.cpp +@@ -68,13 +68,13 @@ bool CorrectlyRoundedDivSqrt::runOnModule(Module &M) { + + bool CorrectlyRoundedDivSqrt::processDeclaration(Function &F) { + StringRef name = F.getName(); +- if (name.startswith("_Z4sqrt")) { ++ if (name.starts_with("_Z4sqrt")) { + std::string newName = name.str(); + newName[2] = '7'; + newName.insert(7, "_cr"); + F.setName(newName); + return true; +- } else if (name.startswith("_Z16__spirv_ocl_sqrt")) { ++ } else if (name.starts_with("_Z16__spirv_ocl_sqrt")) { + std::string newName = name.str(); + newName[3] = '9'; + newName.insert(20, "_cr"); +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/Decompose2DBlockFuncsWithHoisting/Decompose2DBlockFuncsWithHoisting.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/Decompose2DBlockFuncsWithHoisting/Decompose2DBlockFuncsWithHoisting.cpp +index 042399e..976f0bc 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/Decompose2DBlockFuncsWithHoisting/Decompose2DBlockFuncsWithHoisting.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/Decompose2DBlockFuncsWithHoisting/Decompose2DBlockFuncsWithHoisting.cpp +@@ -249,7 +249,7 @@ bool Decompose2DBlockFuncsWithHoisting::runOnFunction(Function &F) { + DL = &F.getParent()->getDataLayout(); + LI = &getAnalysis().getLoopInfo(); + +- E = std::make_unique(*SE, *DL, "decompose-2d-block-funcs-with-hoisting"); ++ E = std::make_unique(*SE, "decompose-2d-block-funcs-with-hoisting"); + Platform = &CGC->platform; + + m_changed = false; +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/DpasFuncs/DpasFuncsResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/DpasFuncs/DpasFuncsResolution.cpp +index 3155ddb..8a2b02a 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/DpasFuncs/DpasFuncsResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/DpasFuncs/DpasFuncsResolution.cpp +@@ -307,26 +307,26 @@ void DpasFuncsResolution::visitCallInst(CallInst &CI) { + #endif + if (m_pCtx->platform.hasExecSize16DPAS()) { + // PVC +- if (funcName.startswith(DpasFuncsResolution::SG_PREFIX_IDPAS16)) { ++ if (funcName.starts_with(DpasFuncsResolution::SG_PREFIX_IDPAS16)) { + const int SG_PREFIX_LEN = DpasFuncsResolution::SG_PREFIX_IDPAS16.size(); + IsIDpas = true; + if (!demangleSuffix(funcName, SG_PREFIX_LEN, false, IsIDpas, DstTy, AccTy, PA, PB, SD, RC, nullptr)) + return; + iid = GenISAIntrinsic::GenISA_sub_group_dpas; +- } else if (funcName.startswith(DpasFuncsResolution::SG_PREFIX_IDPAS32N16)) { ++ } else if (funcName.starts_with(DpasFuncsResolution::SG_PREFIX_IDPAS32N16)) { + const int SG_PREFIX_LEN = DpasFuncsResolution::SG_PREFIX_IDPAS32N16.size(); + IsIDpas = true; + IsDoubleSubgroup = true; + if (!demangleSuffix(funcName, SG_PREFIX_LEN, false, IsIDpas, DstTy, AccTy, PA, PB, SD, RC, nullptr)) + return; + iid = GenISAIntrinsic::GenISA_sub_group_dpas; +- } else if (funcName.startswith(DpasFuncsResolution::SG_PREFIX_FDPAS16)) { ++ } else if (funcName.starts_with(DpasFuncsResolution::SG_PREFIX_FDPAS16)) { + const int SG_PREFIX_LEN = DpasFuncsResolution::SG_PREFIX_FDPAS16.size(); + IsIDpas = false; + if (!demangleSuffix(funcName, SG_PREFIX_LEN, true, IsIDpas, DstTy, AccTy, PA, PB, SD, RC, nullptr)) + return; + iid = GenISAIntrinsic::GenISA_sub_group_dpas; +- } else if (funcName.startswith(DpasFuncsResolution::SG_PREFIX_FDPAS32N16)) { ++ } else if (funcName.starts_with(DpasFuncsResolution::SG_PREFIX_FDPAS32N16)) { + const int SG_PREFIX_LEN = DpasFuncsResolution::SG_PREFIX_FDPAS32N16.size(); + IsIDpas = false; + IsDoubleSubgroup = true; +@@ -338,39 +338,39 @@ void DpasFuncsResolution::visitCallInst(CallInst &CI) { + return; + } + } else { +- if (funcName.startswith(DpasFuncsResolution::SG_PREFIX_IDPAS)) { ++ if (funcName.starts_with(DpasFuncsResolution::SG_PREFIX_IDPAS)) { + const int SG_PREFIX_LEN = DpasFuncsResolution::SG_PREFIX_IDPAS.size(); + IsIDpas = true; + if (!demangleSuffix(funcName, SG_PREFIX_LEN, false, IsIDpas, DstTy, AccTy, PA, PB, SD, RC, &IsDpasw)) + return; + iid = GenISAIntrinsic::GenISA_sub_group_dpas; +- } else if (funcName.startswith(DpasFuncsResolution::SG_PREFIX_FDPAS)) { ++ } else if (funcName.starts_with(DpasFuncsResolution::SG_PREFIX_FDPAS)) { + const int SG_PREFIX_LEN = DpasFuncsResolution::SG_PREFIX_FDPAS.size(); + IsIDpas = false; + if (!demangleSuffix(funcName, SG_PREFIX_LEN, false, IsIDpas, DstTy, AccTy, PA, PB, SD, RC, &IsDpasw)) + return; + iid = GenISAIntrinsic::GenISA_sub_group_dpas; +- } else if (funcName.startswith(DpasFuncsResolution::WI_PREFIX_IDPAS)) { ++ } else if (funcName.starts_with(DpasFuncsResolution::WI_PREFIX_IDPAS)) { + const int WI_PREFIX_LEN = DpasFuncsResolution::WI_PREFIX_IDPAS.size(); + IsIDpas = true; + if (!demangleSuffix(funcName, WI_PREFIX_LEN, false, IsIDpas, DstTy, AccTy, PA, PB, SD, RC, &IsDpasw)) + return; + iid = GenISAIntrinsic::GenISA_dpas; +- } else if (funcName.startswith(DpasFuncsResolution::WI_PREFIX_FDPAS)) { ++ } else if (funcName.starts_with(DpasFuncsResolution::WI_PREFIX_FDPAS)) { + const int WI_PREFIX_LEN = DpasFuncsResolution::WI_PREFIX_FDPAS.size(); + IsIDpas = false; + if (!demangleSuffix(funcName, WI_PREFIX_LEN, false, IsIDpas, DstTy, AccTy, PA, PB, SD, RC, &IsDpasw)) + return; + iid = GenISAIntrinsic::GenISA_dpas; +- } else if (funcName.startswith(DpasFuncsResolution::SG_PREFIX_HFDPAS) || +- funcName.startswith(DpasFuncsResolution::SG_PREFIX_BFDPAS)) { ++ } else if (funcName.starts_with(DpasFuncsResolution::SG_PREFIX_HFDPAS) || ++ funcName.starts_with(DpasFuncsResolution::SG_PREFIX_BFDPAS)) { + const int SG_PREFIX_HF_LEN = DpasFuncsResolution::SG_PREFIX_HFDPAS.size(); + IsIDpas = false; + if (!demangleSuffix(funcName, SG_PREFIX_HF_LEN, false, IsIDpas, DstTy, AccTy, PA, PB, SD, RC, &IsDpasw)) + return; + iid = GenISAIntrinsic::GenISA_sub_group_dpas; +- } else if (funcName.startswith(DpasFuncsResolution::WI_PREFIX_HFDPAS) || +- funcName.startswith(DpasFuncsResolution::WI_PREFIX_BFDPAS)) { ++ } else if (funcName.starts_with(DpasFuncsResolution::WI_PREFIX_HFDPAS) || ++ funcName.starts_with(DpasFuncsResolution::WI_PREFIX_BFDPAS)) { + const int WI_PREFIX_HF_LEN = DpasFuncsResolution::WI_PREFIX_HFDPAS.size(); + IsIDpas = false; + if (!demangleSuffix(funcName, WI_PREFIX_HF_LEN, false, IsIDpas, DstTy, AccTy, PA, PB, SD, RC, &IsDpasw)) +@@ -548,7 +548,7 @@ bool DpasFuncsResolution::processCvt(CallInst &CI) { + GenISAIntrinsic::ID iid; + Value *args[3]; + uint32_t argslen; +- if (funcName.startswith("__builtin_IB_ftobf_")) { ++ if (funcName.starts_with("__builtin_IB_ftobf_")) { + if (!demangleFCvtSuffix(funcName, (int)sizeof("__builtin_IB_ftobf_") - 1, &FP_RM, &VecLen, nullptr)) + return false; + +@@ -556,7 +556,7 @@ bool DpasFuncsResolution::processCvt(CallInst &CI) { + args[0] = CI.getArgOperand(0); // value to be converted + args[1] = ConstantInt::get(intTy, FP_RM); // rounding mode + argslen = 2; +- } else if (funcName.startswith("__builtin_IB_bftof_")) { ++ } else if (funcName.starts_with("__builtin_IB_bftof_")) { + // It is a precise conversion, no RM needed! + // Note that sizeof() includes the ending '\0', so need to do -1! + if (!demangleFCvtSuffix(funcName, (int)sizeof("__builtin_IB_bftof_") - 1, nullptr, &VecLen, nullptr)) +@@ -565,7 +565,7 @@ bool DpasFuncsResolution::processCvt(CallInst &CI) { + iid = GenISAIntrinsic::GenISA_bftof; + args[0] = CI.getArgOperand(0); + argslen = 1; +- } else if (funcName.startswith("__builtin_IB_2fto2bf_")) { ++ } else if (funcName.starts_with("__builtin_IB_2fto2bf_")) { + if (!demangleFCvtSuffix(funcName, (int)sizeof("__builtin_IB_2fto2bf_") - 1, &FP_RM, &VecLen, nullptr)) + return false; + +@@ -574,7 +574,7 @@ bool DpasFuncsResolution::processCvt(CallInst &CI) { + args[1] = CI.getArgOperand(1); // value to be converted + args[2] = ConstantInt::get(intTy, FP_RM); // rounding mode + argslen = 3; +- } else if (funcName.startswith("__builtin_IB_hftobf8_")) { ++ } else if (funcName.starts_with("__builtin_IB_hftobf8_")) { + int sz = (int)sizeof("__builtin_IB_hftobf8_"); + if (!demangleFCvtSuffix(funcName, sz - 1, nullptr, &VecLen, &isSat)) + return false; +@@ -584,7 +584,7 @@ bool DpasFuncsResolution::processCvt(CallInst &CI) { + args[1] = ConstantInt::get(intTy, FP_RM); // rounding mode + args[2] = ConstantInt::get(boolTy, isSat); // saturation + argslen = 3; +- } else if (funcName.startswith("__builtin_IB_bf8tohf_")) { ++ } else if (funcName.starts_with("__builtin_IB_bf8tohf_")) { + int sz = (int)sizeof("__builtin_IB_bf8tohf_"); + // It is a precise conversion, no RM needed! + // Note that sizeof() includes the ending '\0', so need to do -1! +@@ -594,7 +594,7 @@ bool DpasFuncsResolution::processCvt(CallInst &CI) { + iid = GenISAIntrinsic::GenISA_bf8tohf; + args[0] = CI.getArgOperand(0); + argslen = 1; +- } else if (funcName.startswith("__builtin_IB_hftohf8_")) { ++ } else if (funcName.starts_with("__builtin_IB_hftohf8_")) { + int sz = (int)sizeof("__builtin_IB_hftohf8_"); + if (!demangleFCvtSuffix(funcName, sz - 1, nullptr, &VecLen, &isSat)) + return false; +@@ -604,7 +604,7 @@ bool DpasFuncsResolution::processCvt(CallInst &CI) { + args[1] = ConstantInt::get(intTy, FP_RM); // rounding mode + args[2] = ConstantInt::get(boolTy, isSat); // saturation + argslen = 3; +- } else if (funcName.startswith("__builtin_IB_hf8tohf_")) { ++ } else if (funcName.starts_with("__builtin_IB_hf8tohf_")) { + int sz = (int)sizeof("__builtin_IB_hf8tohf_"); + // It is a precise conversion, no RM needed! + // Note that sizeof() includes the ending '\0', so need to do -1! +@@ -614,7 +614,7 @@ bool DpasFuncsResolution::processCvt(CallInst &CI) { + iid = GenISAIntrinsic::GenISA_hf8tohf; + args[0] = CI.getArgOperand(0); + argslen = 1; +- } else if (funcName.startswith("__builtin_IB_ftotf32_")) { ++ } else if (funcName.starts_with("__builtin_IB_ftotf32_")) { + if (!demangleFCvtSuffix(funcName, (int)sizeof("__builtin_IB_ftotf32_") - 1, nullptr, &VecLen, nullptr)) + return false; + +@@ -880,7 +880,7 @@ bool DpasFuncsResolution::processBdpas(CallInst &CI) { + Type *IntTy = Type::getInt32Ty(Ctx); + + int DstTy, AccTy, PA, PB, SD, RC; +- if (!m_pCtx->platform.hasExecSize16DPAS() || !FuncName.startswith(DpasFuncsResolution::SG_PREFIX_BDPAS16)) { ++ if (!m_pCtx->platform.hasExecSize16DPAS() || !FuncName.starts_with(DpasFuncsResolution::SG_PREFIX_BDPAS16)) { + return false; + } + +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/ExtensionFuncs/ExtensionArgAnalysis.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/ExtensionFuncs/ExtensionArgAnalysis.cpp +index 4471645..8626b69 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/ExtensionFuncs/ExtensionArgAnalysis.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/ExtensionFuncs/ExtensionArgAnalysis.cpp +@@ -139,7 +139,7 @@ void ExtensionArgAnalysis::visitCallInst(llvm::CallInst &CI) { + + StringRef name = F->getName(); + +- if (name.startswith("__builtin_IB_media_block_") || name == "__builtin_IB_media_block_rectangle_read") { ++ if (name.starts_with("__builtin_IB_media_block_") || name == "__builtin_IB_media_block_rectangle_read") { + SetExtension(0, ResourceExtensionTypeEnum::MediaResourceBlockType, m_MediaBlockArgs); + } else if (name == "__builtin_IB_vme_send_fbr" || name == "__builtin_IB_vme_send_ime") { + SetExtension(3, ResourceExtensionTypeEnum::MediaResourceType, m_MediaArgs); +@@ -150,7 +150,7 @@ void ExtensionArgAnalysis::visitCallInst(llvm::CallInst &CI) { + SetExtension(4, ResourceExtensionTypeEnum::MediaResourceType, m_MediaArgs); + SetExtension(5, ResourceExtensionTypeEnum::MediaResourceType, m_MediaArgs); + CheckandSetSIMD16(); +- } else if (name.startswith("__builtin_IB_vme_send_ime_new") || name == "__builtin_IB_vme_send_sic_new" || ++ } else if (name.starts_with("__builtin_IB_vme_send_ime_new") || name == "__builtin_IB_vme_send_sic_new" || + name == "__builtin_IB_vme_send_fbr_new") { + // Handle image args. + SetExtension(1, ResourceExtensionTypeEnum::MediaResourceType, m_MediaArgs); +@@ -183,7 +183,7 @@ bool ExtensionArgAnalysis::runOnFunction(Function &F) { + m_extensionType = ResourceExtensionTypeEnum::NonExtensionType; + + for (int func = VA_FUNCTION_ERODE; func < NUM_VA_FUNCTIONS; ++func) { +- if (funcName.equals(VA_FUNCTION_STRINGS[func])) { ++ if ((funcName == VA_FUNCTION_STRINGS[func])) { + // First function arg is the src image, second is the sampler, + // and third arg is output buffer (ignored by this analysis). + auto arg = F.arg_begin(); +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/ExtensionFuncs/ExtensionFuncResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/ExtensionFuncs/ExtensionFuncResolution.cpp +index b70eef4..2352b2e 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/ExtensionFuncs/ExtensionFuncResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/ExtensionFuncs/ExtensionFuncResolution.cpp +@@ -51,15 +51,15 @@ void ExtensionFuncsResolution::visitCallInst(CallInst &CI) { + Function &F = *(CI.getParent()->getParent()); + + ImplicitArg::ArgType argType; +- if (funcName.equals(ExtensionFuncsAnalysis::VME_MB_BLOCK_TYPE)) { ++ if ((funcName == ExtensionFuncsAnalysis::VME_MB_BLOCK_TYPE)) { + argType = ImplicitArg::VME_MB_BLOCK_TYPE; +- } else if (funcName.equals(ExtensionFuncsAnalysis::VME_SUBPIXEL_MODE)) { ++ } else if ((funcName == ExtensionFuncsAnalysis::VME_SUBPIXEL_MODE)) { + argType = ImplicitArg::VME_SUBPIXEL_MODE; +- } else if (funcName.equals(ExtensionFuncsAnalysis::VME_SAD_ADJUST_MODE)) { ++ } else if ((funcName == ExtensionFuncsAnalysis::VME_SAD_ADJUST_MODE)) { + argType = ImplicitArg::VME_SAD_ADJUST_MODE; +- } else if (funcName.equals(ExtensionFuncsAnalysis::VME_SEARCH_PATH_TYPE)) { ++ } else if ((funcName == ExtensionFuncsAnalysis::VME_SEARCH_PATH_TYPE)) { + argType = ImplicitArg::VME_SEARCH_PATH_TYPE; +- } else if (funcName.startswith(ExtensionFuncsAnalysis::VME_HELPER_GET_HANDLE)) { ++ } else if (funcName.starts_with(ExtensionFuncsAnalysis::VME_HELPER_GET_HANDLE)) { + // Load from the opaque vme pointer and return the a vector with values. + IGC_ASSERT(IGCLLVM::getNumArgOperands(&CI) == 1); + IGCLLVM::IRBuilder<> builder(&CI); +@@ -71,7 +71,7 @@ void ExtensionFuncsResolution::visitCallInst(CallInst &CI) { + CI.replaceAllUsesWith(ret); + CI.eraseFromParent(); + return; +- } else if (funcName.startswith(ExtensionFuncsAnalysis::VME_HELPER_GET_AS)) { ++ } else if (funcName.starts_with(ExtensionFuncsAnalysis::VME_HELPER_GET_AS)) { + // Store the VME values and return an opaque vme pointer. + IGC_ASSERT(IGCLLVM::getNumArgOperands(&CI) == 1); + IGCLLVM::IRBuilder<> builder(&*CI.getParent()->getParent()->begin()->getFirstInsertionPt()); +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/ExtensionFuncs/ExtensionFuncsAnalysis.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/ExtensionFuncs/ExtensionFuncsAnalysis.cpp +index ccd5845..c1cef18 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/ExtensionFuncs/ExtensionFuncsAnalysis.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/ExtensionFuncs/ExtensionFuncsAnalysis.cpp +@@ -84,9 +84,9 @@ void ExtensionFuncsAnalysis::visitCallInst(CallInst &CI) { + // Check for VME function calls + if (Function *F = CI.getCalledFunction()) { + StringRef funcName = F->getName(); +- if (funcName.equals(VME_MB_BLOCK_TYPE) || funcName.equals(VME_SUBPIXEL_MODE) || +- funcName.equals(VME_SAD_ADJUST_MODE) || funcName.equals(VME_SEARCH_PATH_TYPE) || +- funcName.startswith(VME_HELPER_GET_HANDLE) || funcName.startswith(VME_HELPER_GET_AS)) { ++ if ((funcName == VME_MB_BLOCK_TYPE) || (funcName == VME_SUBPIXEL_MODE) || ++ (funcName == VME_SAD_ADJUST_MODE) || (funcName == VME_SEARCH_PATH_TYPE) || ++ funcName.starts_with(VME_HELPER_GET_HANDLE) || funcName.starts_with(VME_HELPER_GET_AS)) { + m_hasVME = true; + } + } +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/GEPLoopStrengthReduction/GEPLoopStrengthReduction.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/GEPLoopStrengthReduction/GEPLoopStrengthReduction.cpp +index 78be6db..58e63ad 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/GEPLoopStrengthReduction/GEPLoopStrengthReduction.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/GEPLoopStrengthReduction/GEPLoopStrengthReduction.cpp +@@ -1146,7 +1146,7 @@ bool GEPLoopStrengthReduction::runOnFunction(llvm::Function &F) { + auto *WI = &FRPE.getWIAnalysis(&F); + + // Using one SCEV expander between all reductions reduces number of duplicated new instructions. +- auto E = SCEVExpander(SE, DL, "gep-loop-strength-reduction"); ++ auto E = SCEVExpander(SE, "gep-loop-strength-reduction"); + + SmallVector Candidates; + +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASPropagator.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASPropagator.cpp +index 193b52b..df49067 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASPropagator.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASPropagator.cpp +@@ -313,9 +313,9 @@ static bool handleMemTransferInst(MemTransferInst &I) { + IGC_ASSERT(nullptr != I.getParent()->getParent()); + Module *M = I.getParent()->getParent()->getParent(); + if (isa(I)) +- Fn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys); ++ Fn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::memcpy, Tys); + else if (isa(I)) +- Fn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys); ++ Fn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::memmove, Tys); + else + IGC_ASSERT_EXIT_MESSAGE(0, "unsupported memory intrinsic"); + +@@ -345,7 +345,7 @@ bool GASPropagator::visitMemSetInst(MemSetInst &I) { + Type *OrigDstTy = OrigDst->getType(); + + Type *Tys[] = {OrigDstTy, I.getArgOperand(2)->getType()}; +- Function *Fn = Intrinsic::getDeclaration(I.getParent()->getParent()->getParent(), Intrinsic::memset, Tys); ++ Function *Fn = Intrinsic::getOrInsertDeclaration(I.getParent()->getParent()->getParent(), Intrinsic::memset, Tys); + + I.setCalledFunction(Fn); + DstUse->set(OrigDst); +@@ -359,8 +359,8 @@ bool GASPropagator::visitCallInst(CallInst &I) { + return false; + + PointerType *SrcPtrTy = cast(TheVal->getType()); +- bool IsGAS2P = Callee->getName().equals("__builtin_IB_memcpy_generic_to_private"); +- bool IsP2GAS = Callee->getName().equals("__builtin_IB_memcpy_private_to_generic"); ++ bool IsGAS2P = (Callee->getName() == "__builtin_IB_memcpy_generic_to_private"); ++ bool IsP2GAS = (Callee->getName() == "__builtin_IB_memcpy_private_to_generic"); + if (IsGAS2P || IsP2GAS) { + Type *Tys[4]; + Tys[0] = IsGAS2P ? I.getArgOperand(0)->getType() : SrcPtrTy; +@@ -399,7 +399,7 @@ bool GASPropagator::visitCallInst(CallInst &I) { + } + } + +- if (Callee->getName().equals("__builtin_IB_to_local")) { ++ if ((Callee->getName() == "__builtin_IB_to_local")) { + Type *DstTy = I.getType(); + Value *NewPtr = Constant::getNullValue(DstTy); + if (SrcPtrTy->getAddressSpace() == ADDRESS_SPACE_LOCAL) { +@@ -413,7 +413,7 @@ bool GASPropagator::visitCallInst(CallInst &I) { + return true; + } + +- if (Callee->getName().equals("__builtin_IB_to_private")) { ++ if ((Callee->getName() == "__builtin_IB_to_private")) { + Type *DstTy = I.getType(); + Value *NewPtr = Constant::getNullValue(DstTy); + if (SrcPtrTy->getAddressSpace() == ADDRESS_SPACE_PRIVATE) { +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASRetValuePropagator.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASRetValuePropagator.cpp +index 418352f..e3d49dd 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASRetValuePropagator.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASRetValuePropagator.cpp +@@ -312,5 +312,5 @@ void GASRetValuePropagator::updateDwarfAddressSpace(Function *F) { + DIDerivedType *GASRetValuePropagator::getDIDerivedTypeWithDwarfAddrspace(DIDerivedType *type, unsigned dwarfTag) { + return DIDerivedType::get(type->getContext(), type->getTag(), type->getName(), type->getFile(), type->getLine(), + type->getScope(), type->getBaseType(), type->getSizeInBits(), type->getAlignInBits(), +- type->getOffsetInBits(), dwarfTag, type->getFlags(), type->getExtraData()); ++ type->getOffsetInBits(), dwarfTag, std::nullopt, type->getFlags(), type->getExtraData()); + } +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/HandleDevicelibAssert/HandleDevicelibAssert.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/HandleDevicelibAssert/HandleDevicelibAssert.cpp +index 4901baa..1f0869b 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/HandleDevicelibAssert/HandleDevicelibAssert.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/HandleDevicelibAssert/HandleDevicelibAssert.cpp +@@ -38,7 +38,7 @@ bool HandleDevicelibAssert::runOnModule(Module &M) { + bool changed = false; + for (Function &F : M) { + +- if (!F.getName().equals(ASSERT_FUNCTION_NAME)) ++ if (!(F.getName() == ASSERT_FUNCTION_NAME)) + continue; + + if (F.isDeclaration()) +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/ImageFuncs/ImageFuncResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/ImageFuncs/ImageFuncResolution.cpp +index 5425436..ef32f0b 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/ImageFuncs/ImageFuncResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/ImageFuncs/ImageFuncResolution.cpp +@@ -57,44 +57,44 @@ void ImageFuncResolution::visitCallInst(CallInst &CI) { + // Add appropriate sequence and image dimension func + StringRef funcName = CI.getCalledFunction()->getName(); + +- if (funcName.equals(ImageFuncsAnalysis::GET_IMAGE_HEIGHT)) { ++ if ((funcName == ImageFuncsAnalysis::GET_IMAGE_HEIGHT)) { + if (!isImplicitImageArgs) { + IGC_ASSERT_MESSAGE(false, "Getting Image Height from implicit args is supported only in bindful mode"); + return; + } + imageRes = getImageHeight(CI); +- } else if (funcName.equals(ImageFuncsAnalysis::GET_IMAGE_WIDTH)) { ++ } else if ((funcName == ImageFuncsAnalysis::GET_IMAGE_WIDTH)) { + if (!isImplicitImageArgs) { + IGC_ASSERT_MESSAGE(false, "Getting Image Width from implicit args is supported only in bindful mode"); + return; + } + imageRes = getImageWidth(CI); +- } else if (funcName.equals(ImageFuncsAnalysis::GET_IMAGE_DEPTH)) { ++ } else if ((funcName == ImageFuncsAnalysis::GET_IMAGE_DEPTH)) { + if (!isImplicitImageArgs) { + IGC_ASSERT_MESSAGE(false, "Getting Image Depth from implicit args is supported only in bindful mode"); + return; + } + imageRes = getImageDepth(CI); +- } else if (funcName.equals(ImageFuncsAnalysis::GET_IMAGE_NUM_MIP_LEVELS)) { ++ } else if ((funcName == ImageFuncsAnalysis::GET_IMAGE_NUM_MIP_LEVELS)) { + imageRes = getImageNumMipLevels(CI); +- } else if (funcName.equals(ImageFuncsAnalysis::GET_IMAGE_CHANNEL_DATA_TYPE)) { ++ } else if ((funcName == ImageFuncsAnalysis::GET_IMAGE_CHANNEL_DATA_TYPE)) { + imageRes = getImageChannelDataType(CI); +- } else if (funcName.equals(ImageFuncsAnalysis::GET_IMAGE_CHANNEL_ORDER)) { ++ } else if ((funcName == ImageFuncsAnalysis::GET_IMAGE_CHANNEL_ORDER)) { + imageRes = getImageChannelOrder(CI); +- } else if (funcName.equals(ImageFuncsAnalysis::GET_IMAGE1D_ARRAY_SIZE) || +- funcName.equals(ImageFuncsAnalysis::GET_IMAGE2D_ARRAY_SIZE)) { ++ } else if ((funcName == ImageFuncsAnalysis::GET_IMAGE1D_ARRAY_SIZE) || ++ (funcName == ImageFuncsAnalysis::GET_IMAGE2D_ARRAY_SIZE)) { + if (!isImplicitImageArgs) { + IGC_ASSERT_MESSAGE(false, "Getting Image Array Size from implicit args is supported only in bindful mode"); + return; + } + imageRes = getImageArraySize(CI); +- } else if (funcName.equals(ImageFuncsAnalysis::GET_IMAGE_NUM_SAMPLES)) { ++ } else if ((funcName == ImageFuncsAnalysis::GET_IMAGE_NUM_SAMPLES)) { + imageRes = getImageNumSamples(CI); +- } else if (funcName.equals(ImageFuncsAnalysis::GET_SAMPLER_ADDRESS_MODE)) { ++ } else if ((funcName == ImageFuncsAnalysis::GET_SAMPLER_ADDRESS_MODE)) { + imageRes = getSamplerAddressMode(CI); +- } else if (funcName.equals(ImageFuncsAnalysis::GET_SAMPLER_NORMALIZED_COORDS)) { ++ } else if ((funcName == ImageFuncsAnalysis::GET_SAMPLER_NORMALIZED_COORDS)) { + imageRes = getSamplerNormalizedCoords(CI); +- } else if (funcName.equals(ImageFuncsAnalysis::GET_SAMPLER_SNAP_WA_REQUIRED)) { ++ } else if ((funcName == ImageFuncsAnalysis::GET_SAMPLER_SNAP_WA_REQUIRED)) { + imageRes = getSamplerSnapWARequired(CI); + } else { + // Non image function, do nothing +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/ImageFuncs/ResolveSampledImageBuiltins.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/ImageFuncs/ResolveSampledImageBuiltins.cpp +index 8ff9b9e..7ae66ca 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/ImageFuncs/ResolveSampledImageBuiltins.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/ImageFuncs/ResolveSampledImageBuiltins.cpp +@@ -65,9 +65,9 @@ void ResolveSampledImageBuiltins::visitCallInst(CallInst &CI) { + Value *res = nullptr; + StringRef funcName = CI.getCalledFunction()->getName(); + +- if (funcName.equals(ResolveSampledImageBuiltins::GET_IMAGE)) { ++ if ((funcName == ResolveSampledImageBuiltins::GET_IMAGE)) { + res = lowerGetImage(CI); +- } else if (funcName.equals(ResolveSampledImageBuiltins::GET_SAMPLER)) { ++ } else if ((funcName == ResolveSampledImageBuiltins::GET_SAMPLER)) { + res = lowerGetSampler(CI); + } else { + return; +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/JointMatrixFuncsResolutionPass/JointMatrixFuncsResolutionPass.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/JointMatrixFuncsResolutionPass/JointMatrixFuncsResolutionPass.cpp +index 917e78c..291f87c 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/JointMatrixFuncsResolutionPass/JointMatrixFuncsResolutionPass.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/JointMatrixFuncsResolutionPass/JointMatrixFuncsResolutionPass.cpp +@@ -109,8 +109,8 @@ static bool isMatrixType(const Type *type) { + name = eltType->getStructName(); + } + +- if (name.startswith("intel.joint_matrix") || name.startswith("spirv.JointMatrixINTEL") || +- name.startswith("spirv.CooperativeMatrixKHR")) ++ if (name.starts_with("intel.joint_matrix") || name.starts_with("spirv.JointMatrixINTEL") || ++ name.starts_with("spirv.CooperativeMatrixKHR")) + return true; + + return false; +@@ -953,13 +953,13 @@ bool JointMatrixFuncsResolutionPass::parseMatrixTypeNameLegacy(const Type *opaqu + StringRef name = IGCLLVM::getNonOpaquePtrEltTy(ptrType)->getStructName(); + + unsigned offset = 0; +- if (name.startswith("intel.joint_matrix_packedA_")) { ++ if (name.starts_with("intel.joint_matrix_packedA_")) { + outDescription->layout = LayoutPackedA; + offset += sizeof "intel.joint_matrix_packedA_"; +- } else if (name.startswith("intel.joint_matrix_packedB_")) { ++ } else if (name.starts_with("intel.joint_matrix_packedB_")) { + outDescription->layout = LayoutPackedB; + offset += sizeof "intel.joint_matrix_packedB_"; +- } else if (name.startswith("intel.joint_matrix_acc_")) { ++ } else if (name.starts_with("intel.joint_matrix_acc_")) { + outDescription->layout = LayoutRowMajor; + offset += sizeof "intel.joint_matrix_acc_"; + } else { +@@ -1002,7 +1002,7 @@ bool JointMatrixFuncsResolutionPass::parseMatrixTypeNameLegacy(const Type *opaqu + bool JointMatrixFuncsResolutionPass::ParseMatrixTypeName(Type *opaqueType, JointMatrixTypeDescription *outDescription) { + StringRef name = GetMatrixTypeName(opaqueType); + +- if (name.startswith("intel.joint_matrix")) { ++ if (name.starts_with("intel.joint_matrix")) { + return parseMatrixTypeNameLegacy(opaqueType, outDescription); + } + +@@ -1577,7 +1577,7 @@ template Instruction *JointMatrixFuncsResol + * have a single set of store builtins for floats and integer */ + LLVMContext &ctx = CI->getContext(); + Type *retTy = Type::getVoidTy(ctx); +- Type *arrayTy = Type::getInt8PtrTy(ctx, ADDRESS_SPACE_PRIVATE); ++ Type *arrayTy = PointerType::get(Type::getInt8Ty(ctx), ADDRESS_SPACE_PRIVATE); + + Module *M = CI->getParent()->getModule(); + unsigned address_space = ptrVal->getType()->getPointerAddressSpace(); +@@ -1652,7 +1652,7 @@ template Instruction *JointMatrixFuncsResol + * have a single set of store builtins for floats and integers */ + + LLVMContext &ctx = CI->getContext(); +- Type *arrayTy = Type::getInt8PtrTy(ctx, ADDRESS_SPACE_PRIVATE); ++ Type *arrayTy = PointerType::get(Type::getInt8Ty(ctx), ADDRESS_SPACE_PRIVATE); + + Module *M = CI->getParent()->getModule(); + +@@ -1828,7 +1828,7 @@ static Function *getMADBuiltin(Module *Mod, unsigned M, unsigned N, unsigned K, + std::string funcName = getMADBuiltinName(M, N, K, PA, PB, cDesc, dDesc); + + Type *retTy = Type::getVoidTy(Mod->getContext()); +- Type *argTy = Type::getInt8PtrTy(Mod->getContext(), ADDRESS_SPACE_PRIVATE); ++ Type *argTy = PointerType::get(Type::getInt8Ty(Mod->getContext()), ADDRESS_SPACE_PRIVATE); + + FunctionType *funcType = FunctionType::get(retTy, {argTy, argTy, argTy, argTy}, false); + +@@ -1917,7 +1917,7 @@ Instruction *JointMatrixFuncsResolutionPass::ResolveMad(CallInst *CI, unsigned O + builder.CreateStore(cMat, sliceC); + + LLVMContext &ctx = CI->getContext(); +- Type *arrayTy = Type::getInt8PtrTy(ctx, ADDRESS_SPACE_PRIVATE); ++ Type *arrayTy = PointerType::get(Type::getInt8Ty(ctx), ADDRESS_SPACE_PRIVATE); + + Value *ptrA = builder.CreateBitCast(sliceA, arrayTy); + Value *ptrB = builder.CreateBitCast(sliceB, arrayTy); +@@ -2077,7 +2077,7 @@ Instruction *JointMatrixFuncsResolutionPass::ResolveFillChecked(CallInst *CI) { + Type *matTy = ResolveType(CI->getType(), &desc); + LLVMContext &ctx = CI->getContext(); + Type *retTy = Type::getVoidTy(ctx); +- Type *arrayTy = Type::getInt8PtrTy(ctx, ADDRESS_SPACE_PRIVATE); ++ Type *arrayTy = PointerType::get(Type::getInt8Ty(ctx), ADDRESS_SPACE_PRIVATE); + + Module *M = CI->getParent()->getModule(); + +@@ -2810,14 +2810,14 @@ void JointMatrixFuncsResolutionPass::visitCallInst(CallInst &CI) { + * future when returning and passing matrices by argument is + * supported also basic block terminators should be used as + * transformation starting point */ +- if (funcName.startswith(JointMatrixBIPrefix) || funcName.contains(JointMatrixBISuffix) || ++ if (funcName.starts_with(JointMatrixBIPrefix) || funcName.contains(JointMatrixBISuffix) || + funcName.contains(CooperativeMatrixBISuffix)) { + ResolveSIMDSize(CI.getParent()->getParent()); + ResolveCall(&CI); + return; + } + +- if (funcName.startswith("_Z") && ++ if (funcName.starts_with("_Z") && + (funcName.contains("__spirv_JointMatrix") || funcName.contains("__spirv_CooperativeMatrix") || + funcName.contains(JointMatrixFillPrefx))) { + ResolveSIMDSize(CI.getParent()->getParent()); +@@ -2887,7 +2887,7 @@ std::string getTypeName(Type *T) { + DIType *getOrCreateType(Type *T, Module *M) { + DIType *diType = nullptr; + DIBuilder Builder(*M, true); +- DataLayout Layout(M); ++ const DataLayout &Layout = M->getDataLayout(); + + if (T->isPointerTy()) { + +@@ -2935,7 +2935,7 @@ void JointMatrixFuncsResolutionPass::RecursiveSearchAndFixCanonicalizdGEPandLife + uint64_t pointerSize = DL.getPointerSizeInBits(GEP->getPointerAddressSpace()) / 8; + uint64_t offsetInElements = offset->getZExtValue() / pointerSize; + uint64_t correctOffset = offsetInElements * matrixTypeAllocSize; +- ConstantInt *newOffsetConstant = ConstantInt::get(offset->getType(), correctOffset); ++ ConstantInt *newOffsetConstant = cast(ConstantInt::get(offset->getType(), correctOffset)); + GEP->setOperand(1, newOffsetConstant); + LLVM_DEBUG(dbgs().indent(2) << "Fixed index: " << *GEP << "\n"); + } +@@ -2969,22 +2969,6 @@ void JointMatrixFuncsResolutionPass::visitAllocaInst(AllocaInst &I) { + + // update debug info + { +- TinyPtrVector DDIs = FindDbgDeclareUses(&I); +- +- for (DbgDeclareInst *ddi : DDIs) { +- auto loc = ddi->getDebugLoc(); +- auto var = ddi->getVariable(); +- auto file = var->getFile(); +- auto lineNo = var->getLine(); +- auto scope = var->getScope(); +- +- auto type = getOrCreateType(newInst->getType(), I.getModule()); +- +- DIBuilder builder(*(I.getModule())); +- auto created = builder.createAutoVariable(scope, var->getName(), file, lineNo, type); +- builder.insertDbgValueIntrinsic(newInst, created, builder.createExpression(), loc, ddi); +- ddi->eraseFromParent(); +- } + } + + // update GEPs and lifetime intrinsics +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs/KernelArgs.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs/KernelArgs.cpp +index 83c155a..4719427 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs/KernelArgs.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs/KernelArgs.cpp +@@ -142,7 +142,7 @@ KernelArg::ArgType KernelArg::calcArgType(const Argument *arg, const StringRef t + case ADDRESS_SPACE_PRIVATE: { + + Type *type = arg->getType(); +- if (typeStr.equals("queue_t") || typeStr.equals("spirv.Queue")) { ++ if ((typeStr == "queue_t") || (typeStr == "spirv.Queue")) { + return KernelArg::ArgType::PTR_DEVICE_QUEUE; + } else if (arg->hasByValAttr() && type->isPointerTy() && arg->getParamByValType()->isStructTy()) { + // Pass by value structs will show up as private pointer +@@ -339,13 +339,13 @@ KernelArg::ArgType KernelArg::calcArgType(const ImplicitArg &arg) const { + } + + KernelArg::AccessQual KernelArg::calcAccessQual(const Argument *arg, const StringRef qualStr) const { +- if (qualStr.equals("read_write")) ++ if ((qualStr == "read_write")) + return READ_WRITE; + +- if (qualStr.startswith("read")) ++ if (qualStr.starts_with("read")) + return READ_ONLY; + +- if (qualStr.startswith("write")) ++ if (qualStr.starts_with("write")) + return WRITE_ONLY; + + return NONE; +@@ -406,7 +406,7 @@ unsigned int KernelArg::getLocationCount() const { return m_locationCount; } + unsigned int KernelArg::getLocationIndex() const { return m_locationIndex; } + + bool KernelArg::isImage(const Argument *arg, const StringRef typeStr, ArgType &imageArgType) { +- if (!typeStr.startswith("image") && !typeStr.startswith("bindless")) ++ if (!typeStr.starts_with("image") && !typeStr.starts_with("bindless")) + return false; + + // Get the original OpenCL type from the metadata and check if it's an image +@@ -414,62 +414,62 @@ bool KernelArg::isImage(const Argument *arg, const StringRef typeStr, ArgType &i + // Accept those too. + std::vector accessQual{"_t", "_ro_t", "_wo_t", "_rw_t"}; + for (auto &postfix : accessQual) { +- if (typeStr.equals("image1d" + postfix)) { ++ if ((typeStr == "image1d" + postfix)) { + imageArgType = ArgType::IMAGE_1D; + return true; + } + +- if (typeStr.equals("image1d_buffer" + postfix)) { ++ if ((typeStr == "image1d_buffer" + postfix)) { + imageArgType = ArgType::IMAGE_1D_BUFFER; + return true; + } + +- if (typeStr.equals("image2d" + postfix)) { ++ if ((typeStr == "image2d" + postfix)) { + imageArgType = ArgType::IMAGE_2D; + return true; + } + +- if (typeStr.equals("image2d_depth" + postfix)) { ++ if ((typeStr == "image2d_depth" + postfix)) { + imageArgType = ArgType::IMAGE_2D_DEPTH; + return true; + } + +- if (typeStr.equals("image2d_msaa" + postfix)) { ++ if ((typeStr == "image2d_msaa" + postfix)) { + imageArgType = ArgType::IMAGE_2D_MSAA; + return true; + } + +- if (typeStr.equals("image2d_msaa_depth" + postfix)) { ++ if ((typeStr == "image2d_msaa_depth" + postfix)) { + imageArgType = ArgType::IMAGE_2D_MSAA_DEPTH; + return true; + } + +- if (typeStr.equals("image3d" + postfix)) { ++ if ((typeStr == "image3d" + postfix)) { + imageArgType = ArgType::IMAGE_3D; + return true; + } + +- if (typeStr.equals("image1d_array" + postfix)) { ++ if ((typeStr == "image1d_array" + postfix)) { + imageArgType = ArgType::IMAGE_1D_ARRAY; + return true; + } + +- if (typeStr.equals("image2d_array" + postfix)) { ++ if ((typeStr == "image2d_array" + postfix)) { + imageArgType = ArgType::IMAGE_2D_ARRAY; + return true; + } + +- if (typeStr.equals("image2d_array_depth" + postfix)) { ++ if ((typeStr == "image2d_array_depth" + postfix)) { + imageArgType = ArgType::IMAGE_2D_DEPTH_ARRAY; + return true; + } + +- if (typeStr.equals("image2d_array_msaa" + postfix)) { ++ if ((typeStr == "image2d_array_msaa" + postfix)) { + imageArgType = ArgType::IMAGE_2D_MSAA_ARRAY; + return true; + } + +- if (typeStr.equals("image2d_array_msaa_depth" + postfix)) { ++ if ((typeStr == "image2d_array_msaa_depth" + postfix)) { + imageArgType = ArgType::IMAGE_2D_MSAA_DEPTH_ARRAY; + return true; + } +@@ -477,82 +477,82 @@ bool KernelArg::isImage(const Argument *arg, const StringRef typeStr, ArgType &i + + // See if these are address space decoded args. + // Get the original OpenCL type from the metadata and check if it's an image +- if (typeStr.equals("bindless_image1d_t")) { ++ if ((typeStr == "bindless_image1d_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_1D; + return true; + } + +- if (typeStr.equals("bindless_image1d_buffer_t")) { ++ if ((typeStr == "bindless_image1d_buffer_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_1D_BUFFER; + return true; + } + +- if (typeStr.equals("bindless_image2d_t")) { ++ if ((typeStr == "bindless_image2d_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_2D; + return true; + } + +- if (typeStr.equals("bindless_image2d_depth_t")) { ++ if ((typeStr == "bindless_image2d_depth_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_2D_DEPTH; + return true; + } + +- if (typeStr.equals("bindless_image2d_msaa_t")) { ++ if ((typeStr == "bindless_image2d_msaa_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_2D_MSAA; + return true; + } + +- if (typeStr.equals("bindless_image2d_msaa_depth_t")) { ++ if ((typeStr == "bindless_image2d_msaa_depth_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_2D_MSAA_DEPTH; + return true; + } + +- if (typeStr.equals("bindless_image3d_t")) { ++ if ((typeStr == "bindless_image3d_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_3D; + return true; + } + +- if (typeStr.equals("bindless_image_cube_array_t")) { ++ if ((typeStr == "bindless_image_cube_array_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_CUBE_ARRAY; + return true; + } + +- if (typeStr.equals("bindless_image_cube_t")) { ++ if ((typeStr == "bindless_image_cube_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_CUBE; + return true; + } + +- if (typeStr.equals("bindless_image1d_array_t")) { ++ if ((typeStr == "bindless_image1d_array_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_1D_ARRAY; + return true; + } + +- if (typeStr.equals("bindless_image2d_array_t")) { ++ if ((typeStr == "bindless_image2d_array_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_2D_ARRAY; + return true; + } + +- if (typeStr.equals("bindless_image2d_array_depth_t")) { ++ if ((typeStr == "bindless_image2d_array_depth_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_2D_DEPTH_ARRAY; + return true; + } + +- if (typeStr.equals("bindless_image2d_array_msaa_t")) { ++ if ((typeStr == "bindless_image2d_array_msaa_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_2D_MSAA_ARRAY; + return true; + } + +- if (typeStr.equals("bindless_image2d_array_msaa_depth_t")) { ++ if ((typeStr == "bindless_image2d_array_msaa_depth_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_2D_MSAA_DEPTH_ARRAY; + return true; + } + +- if (typeStr.equals("bindless_image_cube_array_depth_t")) { ++ if ((typeStr == "bindless_image_cube_array_depth_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_CUBE_DEPTH_ARRAY; + return true; + } + +- if (typeStr.equals("bindless_image_cube_depth_t")) { ++ if ((typeStr == "bindless_image_cube_depth_t")) { + imageArgType = ArgType::BINDLESS_IMAGE_CUBE_DEPTH; + return true; + } +@@ -562,11 +562,11 @@ bool KernelArg::isImage(const Argument *arg, const StringRef typeStr, ArgType &i + + bool KernelArg::isSampler(const Argument *arg, const StringRef typeStr) { + // Get the original OpenCL type from the metadata and check if it's a sampler +- return (typeStr.equals("sampler_t")); ++ return ((typeStr == "sampler_t")); + } + + bool KernelArg::isBindlessSampler(const Argument *arg, const StringRef typeStr) { +- return (typeStr.equals("bindless_sampler_t")); ++ return ((typeStr == "bindless_sampler_t")); + } + + bool KernelArg::isArgPtrType() { +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/LSCFuncs/LSCFuncsResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/LSCFuncs/LSCFuncsResolution.cpp +index 0ab2cc8..0c5ca69 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/LSCFuncs/LSCFuncsResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/LSCFuncs/LSCFuncsResolution.cpp +@@ -291,35 +291,35 @@ void LSCFuncsResolution::visitCallInst(CallInst &CI) { + + ////////////// + // loads +- if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_LOAD_global)) { ++ if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_LOAD_global)) { + lscCall = CreateLSCLoadIntrinsicCallInst(GenISAIntrinsic::GenISA_LSCLoad, false); +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_LOAD_BLOCK_global)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_LOAD_BLOCK_global)) { + lscCall = CreateLSCLoadIntrinsicCallInst(GenISAIntrinsic::GenISA_LSCLoadBlock, false); +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_LOAD_local)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_LOAD_local)) { + lscCall = CreateLSCLoadIntrinsicCallInst(GenISAIntrinsic::GenISA_LSCLoad, true); +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_LOAD_CMASK_global)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_LOAD_CMASK_global)) { + lscCall = CreateLSCLoadCmaskIntrinsicCallInst(false); +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_LOAD_CMASK_local)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_LOAD_CMASK_local)) { + lscCall = CreateLSCLoadCmaskIntrinsicCallInst(true); + ////////////// + // prefetches + } else if (FN.consume_front(LSCFuncsResolution::PREFIX_LSC_SIMD_BLOCK_PREFETCH)) { + lscCall = CreateLSCSimdBlockPrefetchIntrinsicCallInst(FN); +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_LOAD_status)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_LOAD_status)) { + lscCall = CreateLSCLoadStatusPreftchIntrinsicCallInst(GenISAIntrinsic::GenISA_LSCLoadStatus); +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_PREFETCH)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_PREFETCH)) { + lscCall = CreateLSCLoadStatusPreftchIntrinsicCallInst(GenISAIntrinsic::GenISA_LSCPrefetch); + ////////////// + // stores +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_STORE_global)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_STORE_global)) { + lscCall = CreateLSCStoreIntrinsicCallInst(GenISAIntrinsic::GenISA_LSCStore, false); +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_STORE_BLOCK_global)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_STORE_BLOCK_global)) { + lscCall = CreateLSCStoreIntrinsicCallInst(GenISAIntrinsic::GenISA_LSCStoreBlock, false); +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_STORE_local)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_STORE_local)) { + lscCall = CreateLSCStoreIntrinsicCallInst(GenISAIntrinsic::GenISA_LSCStore, true); +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_STORE_CMASK_global)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_STORE_CMASK_global)) { + lscCall = CreateLSCStoreCmaskIntrinsicCallInst(false); +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_STORE_CMASK_local)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_STORE_CMASK_local)) { + lscCall = CreateLSCStoreCmaskIntrinsicCallInst(true); + ////////////// + // 2d block intrinsics +@@ -353,15 +353,15 @@ void LSCFuncsResolution::visitCallInst(CallInst &CI) { + lscCall = CreateSubGroup2DBlockOperation(CI, FN, false); + ////////////// + // atomics +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_ATOMIC)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_ATOMIC)) { + bool isLocalMem = FN.find("_local_") != StringRef::npos; + lscCall = CreateLSCAtomicIntrinsicCallInst(isLocalMem); + ////////////// + // misc stuff +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_FENCE_EVICT_TO_MEMORY)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_FENCE_EVICT_TO_MEMORY)) { + // LSC fence + lscCall = CreateLSCFenceEvictToMemory(); +- } else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_FENCE)) { ++ } else if (FN.starts_with(LSCFuncsResolution::PREFIX_LSC_FENCE)) { + // LSC fence + lscCall = CreateLSCFenceIntrinsicCallInst(CI); + } else { +@@ -1193,13 +1193,13 @@ Instruction *LSCFuncsResolution::CreateLSCSimdBlockPrefetchIntrinsicCallInst(Str + + LscTypeInfo typeInfo{}; + +- if (elementTypeName.equals("uchar")) { ++ if ((elementTypeName == "uchar")) { + typeInfo.dataSize = LSC_DATA_SIZE_8b; +- } else if (elementTypeName.equals("ushort")) { ++ } else if ((elementTypeName == "ushort")) { + typeInfo.dataSize = LSC_DATA_SIZE_16b; +- } else if (elementTypeName.equals("uint")) { ++ } else if ((elementTypeName == "uint")) { + typeInfo.dataSize = LSC_DATA_SIZE_32b; +- } else if (elementTypeName.equals("ulong")) { ++ } else if ((elementTypeName == "ulong")) { + typeInfo.dataSize = LSC_DATA_SIZE_64b; + } + +@@ -1484,11 +1484,11 @@ LscTypeInfo LSCFuncsResolution::decodeTypeInfoFromName() { + // they don't return data + // everything else is suffixed by the type and maybe a vector integer + +- if ((FN.endswith("uchar_to_uint")) || (FN.endswith("uchar_from_uint"))) { ++ if ((FN.ends_with("uchar_to_uint")) || (FN.ends_with("uchar_from_uint"))) { + ti.dataSize = LSC_DATA_SIZE_8c32b; + ti.sizeOfType = 1; + return ti; +- } else if (FN.endswith("ushort_to_uint") || FN.endswith("ushort_from_uint")) { ++ } else if (FN.ends_with("ushort_to_uint") || FN.ends_with("ushort_from_uint")) { + ti.dataSize = LSC_DATA_SIZE_16c32b; + ti.sizeOfType = 2; + return ti; +@@ -1571,8 +1571,8 @@ LscTypeInfo LSCFuncsResolution::decodeTypeInfoFromName() { + // The legal prototypes provided in the builtin file constrain + // most mischief, but remember anyone can write a prototype. + if (ti.dataSize == LSC_DATA_SIZE_8b || ti.dataSize == LSC_DATA_SIZE_16b) { +- bool isPrefetchOrLoadStatus = FN.startswith(LSCFuncsResolution::PREFIX_LSC_LOAD_status) || +- FN.startswith(LSCFuncsResolution::PREFIX_LSC_PREFETCH); ++ bool isPrefetchOrLoadStatus = FN.starts_with(LSCFuncsResolution::PREFIX_LSC_LOAD_status) || ++ FN.starts_with(LSCFuncsResolution::PREFIX_LSC_PREFETCH); + if (!isPrefetchOrLoadStatus) { + // D8 and D16 aren't supported yet in normal (non-prefetch) + // loads and stores +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/LocalBuffers/InlineLocalsResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/LocalBuffers/InlineLocalsResolution.cpp +index a4fe81c..9a7e9b8 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/LocalBuffers/InlineLocalsResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/LocalBuffers/InlineLocalsResolution.cpp +@@ -308,7 +308,7 @@ void InlineLocalsResolution::collectInfoOnSharedLocalMem(Module &M) { + Instruction *inst = &(*I); + if (CallInst *CI = dyn_cast(inst)) { + Function *pFunc = CI->getCalledFunction(); +- if (pFunc && pFunc->getName().equals(BUILTIN_MEMPOOL)) { ++ if (pFunc && (pFunc->getName() == BUILTIN_MEMPOOL)) { + // should always be called with constant operands + IGC_ASSERT(isa(CI->getArgOperand(0))); + IGC_ASSERT(isa(CI->getArgOperand(1))); +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/ManageableBarriers/ManageableBarriersResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/ManageableBarriers/ManageableBarriersResolution.cpp +index 6543557..bed9cd4 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/ManageableBarriers/ManageableBarriersResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/ManageableBarriers/ManageableBarriersResolution.cpp +@@ -74,7 +74,7 @@ Value *ManageableBarriersResolution::allocBarriersDataPool(Function *pFunc) { + new GlobalVariable(*(pFunc->getParent()), manageBarrierDataPoolType, false, GlobalVariable::InternalLinkage, + nullptr, "", nullptr, GlobalVariable::NotThreadLocal, ADDRESS_SPACE_LOCAL, false); + +- Value *cast = BitCastInst::CreateBitOrPointerCast(SLMPool, builder.getInt8PtrTy(ADDRESS_SPACE_LOCAL), "", pFirstInst); ++ Value *cast = BitCastInst::CreateBitOrPointerCast(SLMPool, PointerType::get(builder.getInt8Ty(), ADDRESS_SPACE_LOCAL), "", pFirstInst); + + return cast; + } +@@ -88,7 +88,7 @@ Value *ManageableBarriersResolution::preparePointerToBarrierStruct(Value *ptrToB + + // Pick insterested us data/field from this selected barrier data + Value *barrierIdx2Field = builder.CreateAdd(ptrToBarrierSlotPtr2Int, builder.getInt32((int)FiledType * sizeof(int))); +- Value *slmPoolInt2Ptr = builder.CreateIntToPtr(barrierIdx2Field, builder.getInt8PtrTy(ADDRESS_SPACE_LOCAL)); ++ Value *slmPoolInt2Ptr = builder.CreateIntToPtr(barrierIdx2Field, PointerType::get(builder.getInt8Ty(), ADDRESS_SPACE_LOCAL)); + return slmPoolInt2Ptr; + } + +@@ -103,7 +103,7 @@ Value *ManageableBarriersResolution::getManageableBarrierstructDataPtr(CallInst + // We need to move to correct barrier slot + Value *barrierIdx = builder.CreateMul(barrierID, builder.getInt32((int)MBDynamicStructFields::Max * sizeof(int))); + Value *slmBarrierSlotPtr2Int = builder.CreateAdd(barrierIdx, slmPoolPtr2Int); +- Value *slmBarrierSlotPtr = builder.CreateIntToPtr(slmBarrierSlotPtr2Int, builder.getInt8PtrTy(ADDRESS_SPACE_LOCAL)); ++ Value *slmBarrierSlotPtr = builder.CreateIntToPtr(slmBarrierSlotPtr2Int, PointerType::get(builder.getInt8Ty(), ADDRESS_SPACE_LOCAL)); + + // Return ptr to the begining of the Barrier Data slot + return slmBarrierSlotPtr; +@@ -154,7 +154,7 @@ Value *ManageableBarriersResolution::getManageableBarrierstructDataFieldPtr(Valu + IGCIRBuilder<> builder(pInsertBefore); + Value *ptr8ty = preparePointerToBarrierStruct(ptrToBarrierSlot, DataType, pInsertBefore); + Value *ptr32ty = +- builder.CreatePointerCast(ptr8ty, Type::getInt32PtrTy(pInsertBefore->getContext(), ADDRESS_SPACE_LOCAL)); ++ builder.CreatePointerCast(ptr8ty, PointerType::get(Type::getInt32Ty(pInsertBefore->getContext()), ADDRESS_SPACE_LOCAL)); + + return ptr32ty; + } +@@ -175,7 +175,7 @@ Value *ManageableBarriersResolution::prepareBarrierIDPoolPtr(Instruction *pInser + Value *offset2IDPool = builder.CreateAdd( + ptr2int, builder.getInt32(getMaxNamedBarrierCount() * (int)MBDynamicStructFields::Max * sizeof(int))); + Value *pIDPool = builder.CreateIntToPtr(offset2IDPool, +- PointerType::getInt32PtrTy(pInsertBefore->getContext(), ADDRESS_SPACE_LOCAL)); ++ PointerType::get(Type::getInt32Ty(pInsertBefore->getContext()), ADDRESS_SPACE_LOCAL)); + + if (hasSimpleBarrier()) { + IGC_ASSERT_MESSAGE(mManageBarrierInstructionsInit.size() < 31, "There is no free ID for the barrier"); +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/NamedBarriers/NamedBarriersResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/NamedBarriers/NamedBarriersResolution.cpp +index d360b77..d994879 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/NamedBarriers/NamedBarriersResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/NamedBarriers/NamedBarriersResolution.cpp +@@ -91,10 +91,10 @@ bool NamedBarriersResolution::runOnModule(Module &M) { + + for (auto &func : M.getFunctionList()) { + StringRef funcName = func.getName(); +- if (funcName.equals(NamedBarriersResolution::NAMED_BARRIERS_INIT)) { ++ if ((funcName == NamedBarriersResolution::NAMED_BARRIERS_INIT)) { + nbarrierInitF = &func; +- } else if (funcName.equals(NamedBarriersResolution::NAMED_BARRIERS_BARRIER_ARG2) || +- funcName.equals(NamedBarriersResolution::NAMED_BARRIERS_BARRIER_ARG3)) { ++ } else if ((funcName == NamedBarriersResolution::NAMED_BARRIERS_BARRIER_ARG2) || ++ (funcName == NamedBarriersResolution::NAMED_BARRIERS_BARRIER_ARG3)) { + nbarrierBarrierF = &func; + } else { + visit(func); +@@ -271,12 +271,12 @@ int NamedBarriersResolution::AlignNBCnt2BarrierNumber(uint NBCnt) { + } + + bool NamedBarriersResolution::isNamedBarrierInit(StringRef &FunctionName) { +- return FunctionName.equals(NamedBarriersResolution::NAMED_BARRIERS_INIT); ++ return (FunctionName == NamedBarriersResolution::NAMED_BARRIERS_INIT); + } + + bool NamedBarriersResolution::isNamedBarrierSync(StringRef &FunctionName) { +- return FunctionName.equals(NamedBarriersResolution::NAMED_BARRIERS_BARRIER_ARG2) || +- FunctionName.equals(NamedBarriersResolution::NAMED_BARRIERS_BARRIER_ARG3); ++ return (FunctionName == NamedBarriersResolution::NAMED_BARRIERS_BARRIER_ARG2) || ++ (FunctionName == NamedBarriersResolution::NAMED_BARRIERS_BARRIER_ARG3); + } + + void NamedBarriersResolution::HandleNamedBarrierInitSW(CallInst &NBarrierInitCall) { +@@ -294,7 +294,7 @@ void NamedBarriersResolution::HandleNamedBarrierInitSW(CallInst &NBarrierInitCal + + auto newName = "__builtin_spirv_OpNamedBarrierInitialize_i32_p3__namedBarrier_p3i32"; + SmallVector ArgsTy{Type::getInt32Ty(context), m_NamedBarrierType->getPointerTo(SPIRAS_Local), +- Type::getInt32PtrTy(context, SPIRAS_Local)}; ++ PointerType::get(Type::getInt32Ty(context), SPIRAS_Local)}; + Type *BaseTy = m_NamedBarrierArray->getValueType(); + auto pointerNBarrier = GetElementPtrInst::Create(BaseTy, m_NamedBarrierArray, + {ConstantInt::get(Type::getInt64Ty(module->getContext()), 0, true), +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/NontemporalLoadsAndStoresInAssert/NontemporalLoadsAndStoresInAssert.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/NontemporalLoadsAndStoresInAssert/NontemporalLoadsAndStoresInAssert.cpp +index a410a3e..2453f88 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/NontemporalLoadsAndStoresInAssert/NontemporalLoadsAndStoresInAssert.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/NontemporalLoadsAndStoresInAssert/NontemporalLoadsAndStoresInAssert.cpp +@@ -40,7 +40,7 @@ bool NontemporalLoadsAndStoresInAssert::runOnModule(Module &M) { + bool changed = false; + for (Function &F : M) { + +- if (!F.getName().equals(ASSERT_FUNCTION_NAME)) ++ if (!(F.getName() == ASSERT_FUNCTION_NAME)) + continue; + + for (auto I = inst_begin(F); I != inst_end(F); ++I) { +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/OpenCLPrintf/OpenCLPrintfResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/OpenCLPrintf/OpenCLPrintfResolution.cpp +index 35890bb..c0c0504 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/OpenCLPrintf/OpenCLPrintfResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/OpenCLPrintf/OpenCLPrintfResolution.cpp +@@ -609,7 +609,7 @@ CallInst *OpenCLPrintfResolution::genAtomicAdd(Value *outputBufferPtr, Value *da + // %writeOffset = call i32 @__builtin_IB_atomic_add_global_i32(i32 addrspace(1)* , + // i32 ) + // +- Type *bufPtrType = Type::getInt32PtrTy(*m_context, ADDRESS_SPACE_GLOBAL); ++ Type *bufPtrType = PointerType::get(Type::getInt32Ty(*m_context), ADDRESS_SPACE_GLOBAL); + if (outputBufferPtr->getType() != bufPtrType) { + outputBufferPtr = + CastInst::Create(Instruction::CastOps::BitCast, outputBufferPtr, bufPtrType, "ptrBC", &printfCall); +@@ -746,7 +746,7 @@ Instruction *OpenCLPrintfResolution::generateCastToPtr(SPrintfArgDescriptor *arg + } + + case IGC::SHADER_PRINTF_STRING_LITERAL: { +- castedType = Type::getInt64PtrTy(*m_context, ADDRESS_SPACE_GLOBAL); ++ castedType = PointerType::get(Type::getInt64Ty(*m_context), ADDRESS_SPACE_GLOBAL); + break; + } + case IGC::SHADER_PRINTF_POINTER: +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp +index 84a336b..7d94f10 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp +@@ -1029,18 +1029,7 @@ bool PrivateMemoryResolution::resolveAllocaInstructions(bool privateOnStack, boo + + // Attaching this metadata is crucial to both properly interpret this locations as stack based ond to inline it. + // Because these are stack locations we can safely inline them even with optimizations disabled (O0). +- auto DbgDcls = llvm::FindDbgDeclareUses(pAI); +- for (auto DbgDcl : DbgDcls) { +- unsigned scalarBufferOffset = m_ModAllocaInfo->getBufferOffset(pAI); +- unsigned bufferSize = m_ModAllocaInfo->getBufferStride(pAI); +- +- // Attach metadata to instruction containing offset of storage +- auto OffsetMD = +- MDNode::get(builder.getContext(), ConstantAsMetadata::get(builder.getInt32(scalarBufferOffset))); +- DbgDcl->setMetadata("StorageOffset", OffsetMD); +- auto SizeMD = MDNode::get(builder.getContext(), ConstantAsMetadata::get(builder.getInt32(bufferSize))); +- DbgDcl->setMetadata("StorageSize", SizeMD); +- } ++ // + } + // Replace all uses of original alloca with the bitcast + pAI->replaceAllUsesWith(privateBuffer); +@@ -1219,11 +1208,11 @@ bool PrivateMemoryResolution::resolveAllocaInstructions(bool privateOnStack, boo + // because getImplicitArgValue() can move instructions, and it means that the insert point will be moved too. + Instruction *pointInstr = &*entryBuilder.GetInsertPoint(); + if (pointInstr->isDebugOrPseudoInst()) +- pointInstr = pointInstr->getNextNonDebugInstruction(); ++ pointInstr = IGC::getNextNonDbgInstruction(pointInstr); + if (GenIntrinsicInst *inst = dyn_cast_or_null(pointInstr)) { + if (inst->getIntrinsicID() == GenISAIntrinsic::GenISA_getR0 || + inst->getIntrinsicID() == GenISAIntrinsic::GenISA_getPrivateBase) +- pointInstr = inst->getNextNonDebugInstruction(); ++ pointInstr = IGC::getNextNonDbgInstruction(inst); + } + + // Find the implicit argument representing r0 and the private memory base. +@@ -1331,14 +1320,7 @@ bool PrivateMemoryResolution::resolveAllocaInstructions(bool privateOnStack, boo + // We can only safely inline such locations with optimizations disabled. + // On O2 we have no guarantee the offsets in registers are gonna be valid throughout the entire variable lifetime. + if (modMD->compOpt.OptDisable) { +- auto DbgDcls = llvm::FindDbgDeclareUses(pAI); +- for (auto DbgDcl : DbgDcls) { +- // Attach metadata to instruction containing offset of storage +- unsigned int scalarBufferOffset = m_ModAllocaInfo->getBufferOffset(pAI); +- auto OffsetMD = +- MDNode::get(builder.getContext(), ConstantAsMetadata::get(builder.getInt32(scalarBufferOffset))); +- DbgDcl->setMetadata("StorageOffset", OffsetMD); +- } ++ // + } + + // Replace all uses of original alloca with the bitcast +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryUsageAnalysis.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryUsageAnalysis.cpp +index c4f29e3..290a4e7 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryUsageAnalysis.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryUsageAnalysis.cpp +@@ -172,7 +172,7 @@ void PrivateMemoryUsageAnalysis::visitCallInst(llvm::CallInst &CI) { + // Check if a sqrtd builtin is called to enable privMem + if (m_hasDPDivSqrtEmu && CI.hasName()) { + Function *calledFunc = CI.getCalledFunction(); +- if (calledFunc && calledFunc->getName().startswith("__builtin_IB_native_sqrtd")) { ++ if (calledFunc && calledFunc->getName().starts_with("__builtin_IB_native_sqrtd")) { + m_hasPrivateMem = true; + } + } +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/ProcessBICodeAssumption/ProcessBICodeAssumption.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/ProcessBICodeAssumption/ProcessBICodeAssumption.cpp +index c4392e6..7584b65 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/ProcessBICodeAssumption/ProcessBICodeAssumption.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/ProcessBICodeAssumption/ProcessBICodeAssumption.cpp +@@ -83,7 +83,10 @@ void ProcessBICodeAssumption::visitCallInst(CallInst &CI) { + // Look for assume: + // %9 = icmp ult i64 %8, 2147483648 + // call void @llvm.assume(i1 %9) +- if (!match(&CI, m_Intrinsic(m_ICmp(Pred, m_Instruction(I), m_ConstantInt(Const))))) ++ if (!match(&CI, m_Intrinsic(m_ICmp(m_Instruction(I), m_ConstantInt(Const))))) ++ return; ++ ++ Pred = cast(CI.getArgOperand(0))->getPredicate(); + return; + + if (!matchCmp(Pred, Const)) +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/ReplaceUnsupportedIntrinsics/ReplaceUnsupportedIntrinsics.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/ReplaceUnsupportedIntrinsics/ReplaceUnsupportedIntrinsics.cpp +index 2636b6c..9ce62ff 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/ReplaceUnsupportedIntrinsics/ReplaceUnsupportedIntrinsics.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/ReplaceUnsupportedIntrinsics/ReplaceUnsupportedIntrinsics.cpp +@@ -169,7 +169,7 @@ MemCpyInst *ReplaceUnsupportedIntrinsics::MemMoveToMemCpy(MemMoveInst *MM) { + + Type *Tys[] = {Dst->getType(), Src->getType(), Size->getType()}; + auto *M = MM->getParent()->getParent()->getParent(); +- auto TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys); ++ auto TheFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::memcpy, Tys); + + return cast(MemCpyInst::Create(TheFn, args)); + } +@@ -471,8 +471,8 @@ void ReplaceUnsupportedIntrinsics::replaceMemcpy(IntrinsicInst *I) { + const uint32_t DstAS = MC->getDestAddressSpace(); + + LLVMContext &C = MC->getContext(); +- Type *TySrcPtrI8 = Type::getInt8PtrTy(C, SrcAS); +- Type *TyDstPtrI8 = Type::getInt8PtrTy(C, DstAS); ++ Type *TySrcPtrI8 = PointerType::get(Type::getInt8Ty(C), SrcAS); ++ Type *TyDstPtrI8 = PointerType::get(Type::getInt8Ty(C), DstAS); + + IGCLLVM::IRBuilder<> Builder(MC); + +@@ -602,8 +602,8 @@ void ReplaceUnsupportedIntrinsics::replaceMemMove(IntrinsicInst *I) { + } + + LLVMContext &C = MM->getContext(); +- Type *TySrcPtrI8 = Type::getInt8PtrTy(C, SrcAS); +- Type *TyDstPtrI8 = Type::getInt8PtrTy(C, DstAS); ++ Type *TySrcPtrI8 = PointerType::get(Type::getInt8Ty(C), SrcAS); ++ Type *TyDstPtrI8 = PointerType::get(Type::getInt8Ty(C), DstAS); + + auto *F = MM->getParent()->getParent(); + +@@ -758,7 +758,7 @@ void ReplaceUnsupportedIntrinsics::replaceMemset(IntrinsicInst *I) { + const uint32_t AS = MS->getDestAddressSpace(); + + LLVMContext &C = MS->getContext(); +- Type *TyPtrI8 = Type::getInt8PtrTy(C, AS); ++ Type *TyPtrI8 = PointerType::get(Type::getInt8Ty(C), AS); + + IGCLLVM::IRBuilder<> Builder(MS); + +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/SetFastMathFlags/SetFastMathFlags.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/SetFastMathFlags/SetFastMathFlags.cpp +index b79f4fe..fbb0d90 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/SetFastMathFlags/SetFastMathFlags.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/SetFastMathFlags/SetFastMathFlags.cpp +@@ -120,7 +120,7 @@ bool SetFastMathFlags::setFlags(Function &F, FastMathFlags fmfs) { + } + + StringRef DemangledNameRef = DemangledName; +- if (DemangledNameRef.equals(funcName)) { ++ if ((DemangledNameRef == funcName)) { + isUnoptimizedFunc = true; + break; + } +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/StackOverflowDetection/StackOverflowDetection.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/StackOverflowDetection/StackOverflowDetection.cpp +index fe4cc56..5d90e1c 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/StackOverflowDetection/StackOverflowDetection.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/StackOverflowDetection/StackOverflowDetection.cpp +@@ -46,8 +46,8 @@ bool StackOverflowDetectionPass::removeDummyCalls(Module &M) { + Function *callFunction = callI->getCalledFunction(); + if (callFunction) { + auto callFunctionName = callFunction->getName(); +- if (callFunctionName.startswith(STACK_OVERFLOW_INIT_BUILTIN_NAME) || +- callFunctionName.startswith(STACK_OVERFLOW_DETECTION_BUILTIN_NAME)) { ++ if (callFunctionName.starts_with(STACK_OVERFLOW_INIT_BUILTIN_NAME) || ++ callFunctionName.starts_with(STACK_OVERFLOW_DETECTION_BUILTIN_NAME)) { + ToDeleteInstructions.push_back(&I); + } + } +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/SubGroupFuncs/SubGroupFuncsResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/SubGroupFuncs/SubGroupFuncsResolution.cpp +index 022f653..9c3f530 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/SubGroupFuncs/SubGroupFuncsResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/SubGroupFuncs/SubGroupFuncsResolution.cpp +@@ -365,19 +365,19 @@ void SubGroupFuncsResolution::simdBlockRead(llvm::CallInst &CI, bool hasCacheCon + + switch (scalarSizeInBits) { + case 8: +- types[1] = Type::getInt8PtrTy(C, AS); ++ types[1] = PointerType::get(Type::getInt8Ty(C), AS); + break; + case 16: +- types[1] = Type::getInt16PtrTy(C, AS); ++ types[1] = PointerType::get(Type::getInt16Ty(C), AS); + break; + case 64: +- types[1] = (Type::getInt64PtrTy(C, AS)); ++ types[1] = (PointerType::get(Type::getInt64Ty(C), AS)); + break; + default: + IGC_ASSERT_MESSAGE(0, "unrecognized bit width!"); + // assertion failed but continue code failsafe using default 32 + case 32: +- types[1] = (Type::getInt32PtrTy(C, AS)); ++ types[1] = (PointerType::get(Type::getInt32Ty(C), AS)); + break; + } + +@@ -447,19 +447,19 @@ void SubGroupFuncsResolution::simdBlockWrite(llvm::CallInst &CI, bool hasCacheCo + + switch (dataArg->getType()->getScalarType()->getScalarSizeInBits()) { + case 8: +- types.push_back(Type::getInt8PtrTy(C, AS)); ++ types.push_back(PointerType::get(Type::getInt8Ty(C), AS)); + break; + case 16: +- types.push_back(Type::getInt16PtrTy(C, AS)); ++ types.push_back(PointerType::get(Type::getInt16Ty(C), AS)); + break; + case 64: +- types.push_back(Type::getInt64PtrTy(C, AS)); ++ types.push_back(PointerType::get(Type::getInt64Ty(C), AS)); + break; + default: + IGC_ASSERT_MESSAGE(0, "unrecognized bit width!"); + // assertion failed but continue code failsafe using default 32 + case 32: +- types.push_back(Type::getInt32PtrTy(C, AS)); ++ types.push_back(PointerType::get(Type::getInt32Ty(C), AS)); + break; + } + +@@ -565,7 +565,7 @@ void SubGroupFuncsResolution::visitCallInst(CallInst &CI) { + StringRef funcName = func->getName(); + LLVMContext &Ctx = CI.getCalledFunction()->getContext(); + +- if (funcName.equals(SubGroupFuncsResolution::GET_MAX_SUB_GROUP_SIZE)) { ++ if ((funcName == SubGroupFuncsResolution::GET_MAX_SUB_GROUP_SIZE)) { + int32_t simdSize = GetSIMDSize(CI.getParent()->getParent()); + if (simdSize == 8 || simdSize == 16 || simdSize == 32) { + auto *C = ConstantInt::get(Type::getInt32Ty(Ctx), simdSize); +@@ -579,7 +579,7 @@ void SubGroupFuncsResolution::visitCallInst(CallInst &CI) { + CI.replaceAllUsesWith(simdSize); + } + CI.eraseFromParent(); +- } else if (funcName.equals(SubGroupFuncsResolution::GET_SUB_GROUP_LOCAL_ID)) { ++ } else if ((funcName == SubGroupFuncsResolution::GET_SUB_GROUP_LOCAL_ID)) { + // Creates intrinsics that will be lowered in the CodeGen and will handle the sub_group_local_id + IntegerType *typeInt32 = Type::getInt32Ty(Ctx); + +@@ -591,13 +591,13 @@ void SubGroupFuncsResolution::visitCallInst(CallInst &CI) { + updateDebugLoc(&CI, simdLaneId); + CI.replaceAllUsesWith(simdLaneId); + CI.eraseFromParent(); +- } else if (funcName.equals(SubGroupFuncsResolution::SUB_GROUP_SHUFFLE) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_US) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_F) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_H) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_C) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_B) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_DF)) { ++ } else if ((funcName == SubGroupFuncsResolution::SUB_GROUP_SHUFFLE) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_US) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_F) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_H) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_C) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_B) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_DF)) { + // Creates intrinsics that will be lowered in the CodeGen and will handle the sub_group_shuffle function + IRBuilder<> IRB(&CI); + Value *args[3]; +@@ -611,13 +611,13 @@ void SubGroupFuncsResolution::visitCallInst(CallInst &CI) { + updateDebugLoc(&CI, simdShuffle); + CI.replaceAllUsesWith(simdShuffle); + CI.eraseFromParent(); +- } else if (funcName.equals(SubGroupFuncsResolution::SUB_GROUP_BROADCAST) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_BROADCAST_US) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_BROADCAST_F) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_BROADCAST_H) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_BROADCAST_C) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_BROADCAST_B) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_BROADCAST_DF)) { ++ } else if ((funcName == SubGroupFuncsResolution::SUB_GROUP_BROADCAST) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_BROADCAST_US) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_BROADCAST_F) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_BROADCAST_H) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_BROADCAST_C) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_BROADCAST_B) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_BROADCAST_DF)) { + // Creates intrinsics that will be lowered in the CodeGen and will handle the sub_group_broadcast function + IRBuilder<> IRB(&CI); + Value *args[3]; +@@ -631,13 +631,13 @@ void SubGroupFuncsResolution::visitCallInst(CallInst &CI) { + updateDebugLoc(&CI, simdBroadcast); + CI.replaceAllUsesWith(simdBroadcast); + CI.eraseFromParent(); +- } else if (funcName.equals(SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST_US) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST_F) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST_H) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST_C) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST_B) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST_DF)) { ++ } else if ((funcName == SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST_US) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST_F) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST_H) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST_C) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST_B) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_BROADCAST_DF)) { + // Creates intrinsics that will be lowered in the CodeGen and will handle the sub_group_clustered_broadcast function + IRBuilder<> IRB(&CI); + Value *args[4]; +@@ -662,9 +662,9 @@ void SubGroupFuncsResolution::visitCallInst(CallInst &CI) { + updateDebugLoc(&CI, simdClusteredBroadcast); + CI.replaceAllUsesWith(simdClusteredBroadcast); + CI.eraseFromParent(); +- } else if (funcName.equals(SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_DOWN) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_DOWN_US) || +- funcName.equals(SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_DOWN_UC)) { ++ } else if ((funcName == SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_DOWN) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_DOWN_US) || ++ (funcName == SubGroupFuncsResolution::SUB_GROUP_SHUFFLE_DOWN_UC)) { + // Creates intrinsics that will be lowered in the CodeGen and will handle the sub_group_shuffle_down function + Value *args[3]; + args[0] = CI.getArgOperand(0); +@@ -677,133 +677,133 @@ void SubGroupFuncsResolution::visitCallInst(CallInst &CI) { + updateDebugLoc(&CI, simdShuffleDown); + CI.replaceAllUsesWith(simdShuffleDown); + CI.eraseFromParent(); +- } else if (funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_1_GBL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_2_GBL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_4_GBL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_8_GBL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_1_GBL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_2_GBL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_4_GBL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_8_GBL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_16_GBL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_1_GBL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_2_GBL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_4_GBL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_8_GBL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_16_GBL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_1_GBL_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_2_GBL_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_4_GBL_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_8_GBL_L)) { ++ } else if ((funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_1_GBL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_2_GBL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_4_GBL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_8_GBL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_1_GBL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_2_GBL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_4_GBL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_8_GBL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_16_GBL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_1_GBL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_2_GBL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_4_GBL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_8_GBL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_16_GBL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_1_GBL_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_2_GBL_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_4_GBL_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_8_GBL_L)) { + CheckSIMDSize(CI, "Block reads not supported in SIMD32"); + simdBlockRead(CI); +- } else if (funcName.startswith("__builtin_IB_cache_controls_simd_block_read")) { ++ } else if (funcName.starts_with("__builtin_IB_cache_controls_simd_block_read")) { + CheckSIMDSize(CI, "Block reads not supported in SIMD32"); + simdBlockRead(CI, true); +- } else if (funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_GBL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_GBL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_GBL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_GBL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_GBL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_GBL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_GBL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_GBL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_16_GBL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_GBL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_GBL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_GBL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_GBL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_16_GBL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_GBL_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_GBL_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_GBL_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_GBL_L)) { ++ } else if ((funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_GBL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_GBL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_GBL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_GBL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_GBL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_GBL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_GBL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_GBL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_16_GBL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_GBL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_GBL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_GBL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_GBL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_16_GBL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_GBL_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_GBL_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_GBL_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_GBL_L)) { + CheckSIMDSize(CI, "Block writes not supported in SIMD32"); + simdBlockWrite(CI); +- } else if (funcName.startswith("__builtin_IB_cache_controls_simd_block_write")) { ++ } else if (funcName.starts_with("__builtin_IB_cache_controls_simd_block_write")) { + CheckSIMDSize(CI, "Block writes not supported in SIMD32"); + simdBlockWrite(CI, true); +- } else if (funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_1_LCL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_2_LCL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_4_LCL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_8_LCL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_1_LCL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_2_LCL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_4_LCL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_8_LCL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_16_LCL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_1_LCL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_2_LCL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_4_LCL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_8_LCL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_16_LCL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_1_LCL_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_2_LCL_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_4_LCL_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_READ_8_LCL_L)) { ++ } else if ((funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_1_LCL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_2_LCL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_4_LCL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_8_LCL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_1_LCL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_2_LCL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_4_LCL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_8_LCL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_16_LCL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_1_LCL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_2_LCL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_4_LCL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_8_LCL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_16_LCL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_1_LCL_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_2_LCL_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_4_LCL_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_READ_8_LCL_L)) { + CheckSIMDSize(CI, "Block reads not supported in SIMD32"); + simdBlockRead(CI); +- } else if (funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_LCL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_LCL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_LCL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_LCL) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_LCL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_LCL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_LCL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_LCL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_16_LCL_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_LCL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_LCL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_LCL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_LCL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_16_LCL_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_LCL_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_LCL_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_LCL_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_LCL_L)) { ++ } else if ((funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_LCL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_LCL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_LCL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_LCL) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_LCL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_LCL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_LCL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_LCL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_16_LCL_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_LCL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_LCL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_LCL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_LCL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_16_LCL_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_1_LCL_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_2_LCL_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_4_LCL_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_BLOCK_WRITE_8_LCL_L)) { + CheckSIMDSize(CI, "Block writes not supported in SIMD32"); + simdBlockWrite(CI); +- } else if (funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_1) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_2) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_4) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_8) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_1_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_2_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_4_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_8_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_16_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_1_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_2_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_4_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_8_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_16_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_1_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_2_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_4_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_8_L)) { ++ } else if ((funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_1) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_2) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_4) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_8) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_1_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_2_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_4_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_8_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_16_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_1_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_2_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_4_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_8_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_16_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_1_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_2_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_4_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_READ_8_L)) { + CheckSIMDSize(CI, "SIMD Media Block Read not supported in SIMD32"); + mediaBlockRead(CI); +- } else if (funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_1) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_2) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_4) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_8) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_1_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_2_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_4_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_8_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_16_B) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_1_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_2_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_4_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_8_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_16_H) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_1_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_2_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_4_L) || +- funcName.equals(SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_8_L)) { ++ } else if ((funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_1) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_2) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_4) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_8) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_1_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_2_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_4_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_8_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_16_B) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_1_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_2_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_4_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_8_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_16_H) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_1_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_2_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_4_L) || ++ (funcName == SubGroupFuncsResolution::SIMD_MEDIA_BLOCK_WRITE_8_L)) { + CheckSIMDSize(CI, "SIMD Media Block Write not supported in SIMD32"); + mediaBlockWrite(CI); +- } else if (funcName.startswith(SubGroupFuncsResolution::MEDIA_BLOCK_READ)) { ++ } else if (funcName.starts_with(SubGroupFuncsResolution::MEDIA_BLOCK_READ)) { + // Creates intrinsics that will be lowered in the CodeGen and will handle the media_block_read + + SmallVector args; +@@ -846,7 +846,7 @@ void SubGroupFuncsResolution::visitCallInst(CallInst &CI) { + + CI.replaceAllUsesWith(MediaBlockRead); + CI.eraseFromParent(); +- } else if (funcName.startswith(SubGroupFuncsResolution::MEDIA_BLOCK_WRITE)) { ++ } else if (funcName.starts_with(SubGroupFuncsResolution::MEDIA_BLOCK_WRITE)) { + // Creates intrinsics that will be lowered in the CodeGen and will handle the media_block_write + + SmallVector args; +@@ -890,7 +890,7 @@ void SubGroupFuncsResolution::visitCallInst(CallInst &CI) { + + CI.replaceAllUsesWith(MediaBlockWrite); + CI.eraseFromParent(); +- } else if (funcName.equals(SubGroupFuncsResolution::MEDIA_BLOCK_RECTANGLE_READ)) { ++ } else if ((funcName == SubGroupFuncsResolution::MEDIA_BLOCK_RECTANGLE_READ)) { + // Creates intrinsics that will be lowered in the CodeGen and will handle the simd_media_block_read_8 + SmallVector args; + pushMediaBlockArgs(args, CI); +@@ -905,7 +905,7 @@ void SubGroupFuncsResolution::visitCallInst(CallInst &CI) { + updateDebugLoc(&CI, MediaBlockRectangleRead); + CI.replaceAllUsesWith(MediaBlockRectangleRead); + CI.eraseFromParent(); +- } else if (funcName.equals(SubGroupFuncsResolution::GET_IMAGE_BTI)) { ++ } else if ((funcName == SubGroupFuncsResolution::GET_IMAGE_BTI)) { + if (m_argIndexMap.empty()) { + BTIHelper(CI); + } +@@ -915,15 +915,15 @@ void SubGroupFuncsResolution::visitCallInst(CallInst &CI) { + + CI.replaceAllUsesWith(imageIndex); + CI.eraseFromParent(); +- } else if (funcName.startswith(SubGroupFuncsResolution::SUB_GROUP_REDUCE)) { ++ } else if (funcName.starts_with(SubGroupFuncsResolution::SUB_GROUP_REDUCE)) { + return subGroupArithmetic(CI, GetWaveOp(funcName), GroupOperationReduce); +- } else if (funcName.startswith(SubGroupFuncsResolution::SUB_GROUP_SCAN)) { ++ } else if (funcName.starts_with(SubGroupFuncsResolution::SUB_GROUP_SCAN)) { + return subGroupArithmetic(CI, GetWaveOp(funcName), GroupOperationScan); +- } else if (funcName.startswith(SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_REDUCE)) { ++ } else if (funcName.starts_with(SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_REDUCE)) { + return subGroupArithmetic(CI, GetWaveOp(funcName), GroupOperationClusteredReduce); +- } else if (funcName.startswith(SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_SCAN)) { ++ } else if (funcName.starts_with(SubGroupFuncsResolution::SUB_GROUP_CLUSTERED_SCAN)) { + return subGroupArithmetic(CI, GetWaveOp(funcName), GroupOperationClusteredScan); +- } else if (funcName.startswith(SubGroupFuncsResolution::SUB_GROUP_BARRIER)) { ++ } else if (funcName.starts_with(SubGroupFuncsResolution::SUB_GROUP_BARRIER)) { + ModuleMetaData *modMD = getAnalysis().getModuleMetaData(); + + // Subgroup barrier is a no-op in HW. +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/TransformUnmaskedFunctionsPass/TransformUnmaskedFunctionsPass.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/TransformUnmaskedFunctionsPass/TransformUnmaskedFunctionsPass.cpp +index c98a2d2..7d8583e 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/TransformUnmaskedFunctionsPass/TransformUnmaskedFunctionsPass.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/TransformUnmaskedFunctionsPass/TransformUnmaskedFunctionsPass.cpp +@@ -13,6 +13,7 @@ SPDX-License-Identifier: MIT + #include "Compiler/Optimizer/OpenCLPasses/TransformUnmaskedFunctionsPass/TransformUnmaskedFunctionsPass.h" + #include "llvmWrapper/Transforms/Utils/Cloning.h" + #include "Probe/Assertion.h" ++#include "common/LLVMUtils.h" + + #include "common/LLVMWarningsPush.hpp" + #include "llvm/IR/Module.h" +@@ -52,7 +53,7 @@ static void annotateUnmaskedCallSite(CallInst *CI) { + Function *unmaskedEnd = GenISAIntrinsic::getDeclaration(M, GenISAIntrinsic::GenISA_UnmaskedRegionEnd); + + builder.CreateCall(unmaskedBegin); +- builder.SetInsertPoint(CI->getNextNonDebugInstruction()); ++ builder.SetInsertPoint(getNextNonDbgInstruction(CI)); + builder.CreateCall(unmaskedEnd); + } + +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/UndefinedReferences/UndefinedReferencesPass.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/UndefinedReferences/UndefinedReferencesPass.cpp +index a9c9530..8ae6ac9 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/UndefinedReferences/UndefinedReferencesPass.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/UndefinedReferences/UndefinedReferencesPass.cpp +@@ -82,10 +82,10 @@ static bool ExistUndefinedReferencesInModule(Module &module, CodeGenContext *CGC + for (auto &F : module) { + if (F.isDeclaration() && !F.isIntrinsic() && !GenISAIntrinsic::isIntrinsic(&F) && F.hasNUsesOrMore(1)) { + StringRef funcName = F.getName(); +- if (!funcName.startswith("__builtin_IB") && funcName != "printf" && +- !Regex("^_Z[0-9]+__builtin_bf16").match(funcName) && !funcName.startswith("__igcbuiltin_") && +- !funcName.startswith("__translate_sampler_initializer") && !funcName.startswith("_Z20__spirv_SampledImage") && +- !funcName.startswith("_Z21__spirv_VmeImageINTEL") && ++ if (!funcName.starts_with("__builtin_IB") && funcName != "printf" && ++ !Regex("^_Z[0-9]+__builtin_bf16").match(funcName) && !funcName.starts_with("__igcbuiltin_") && ++ !funcName.starts_with("__translate_sampler_initializer") && !funcName.starts_with("_Z20__spirv_SampledImage") && ++ !funcName.starts_with("_Z21__spirv_VmeImageINTEL") && + funcName != BufferBoundsCheckingPatcher::BUFFER_SIZE_PLACEHOLDER_FUNCTION_NAME && + !F.hasFnAttribute("referenced-indirectly")) { + ReportUndefinedReference(CGC, funcName, &F); +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/WGFuncs/WGFuncResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/WGFuncs/WGFuncResolution.cpp +index e3b0cf5..716ecae 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/WGFuncs/WGFuncResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/WGFuncs/WGFuncResolution.cpp +@@ -47,7 +47,7 @@ void WGFuncResolution::visitCallInst(CallInst &callInst) { + return; + } + StringRef funcName = pCalledFunc->getName(); +- if (funcName.startswith("__builtin_IB_work_group_any")) { ++ if (funcName.starts_with("__builtin_IB_work_group_any")) { + SmallVector args; + + args.push_back(callInst.getOperand(0)); +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp +index 5bb9cef..4f560f4 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp +@@ -107,41 +107,41 @@ void WIFuncResolution::visitCallInst(CallInst &CI) { + // Add appropriate sequence and handle out of range where needed + StringRef funcName = CI.getCalledFunction()->getName(); + +- if (funcName.equals(WIFuncsAnalysis::GET_LOCAL_ID_X)) { ++ if ((funcName == WIFuncsAnalysis::GET_LOCAL_ID_X)) { + wiRes = getLocalId(CI, ImplicitArg::LOCAL_ID_X); +- } else if (funcName.equals(WIFuncsAnalysis::GET_LOCAL_ID_Y)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_LOCAL_ID_Y)) { + wiRes = getLocalId(CI, ImplicitArg::LOCAL_ID_Y); +- } else if (funcName.equals(WIFuncsAnalysis::GET_LOCAL_ID_Z)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_LOCAL_ID_Z)) { + wiRes = getLocalId(CI, ImplicitArg::LOCAL_ID_Z); +- } else if (funcName.equals(WIFuncsAnalysis::GET_GROUP_ID)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_GROUP_ID)) { + wiRes = getGroupId(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_LOCAL_THREAD_ID)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_LOCAL_THREAD_ID)) { + wiRes = getLocalThreadId(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_GLOBAL_SIZE)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_GLOBAL_SIZE)) { + wiRes = getGlobalSize(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_LOCAL_SIZE)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_LOCAL_SIZE)) { + wiRes = getLocalSize(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_ENQUEUED_LOCAL_SIZE)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_ENQUEUED_LOCAL_SIZE)) { + wiRes = getEnqueuedLocalSize(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_GLOBAL_OFFSET)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_GLOBAL_OFFSET)) { + wiRes = getGlobalOffset(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_WORK_DIM)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_WORK_DIM)) { + wiRes = getWorkDim(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_NUM_GROUPS)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_NUM_GROUPS)) { + wiRes = getNumGroups(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_STAGE_IN_GRID_ORIGIN)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_STAGE_IN_GRID_ORIGIN)) { + wiRes = getStageInGridOrigin(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_STAGE_IN_GRID_SIZE)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_STAGE_IN_GRID_SIZE)) { + wiRes = getStageInGridSize(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_SYNC_BUFFER)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_SYNC_BUFFER)) { + wiRes = getSyncBufferPtr(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_ASSERT_BUFFER)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_ASSERT_BUFFER)) { + wiRes = getAssertBufferPtr(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_REGION_GROUP_SIZE)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_REGION_GROUP_SIZE)) { + wiRes = getRegionGroupSize(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_REGION_GROUP_WG_COUNT)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_REGION_GROUP_WG_COUNT)) { + wiRes = getRegionGroupWGCount(CI); +- } else if (funcName.equals(WIFuncsAnalysis::GET_REGION_GROUP_BARRIER_BUFFER)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_REGION_GROUP_BARRIER_BUFFER)) { + wiRes = getRegionGroupBarrierBufferPtr(CI); + } else { + // Non WI function, do nothing +@@ -884,7 +884,7 @@ void LowerImplicitArgIntrinsics::visitCallInst(CallInst &CI) { + } + + // Load data +- auto Int16Ptr = Type::getInt16PtrTy(F->getContext(), ADDRESS_SPACE_GLOBAL); ++ auto Int16Ptr = PointerType::get(Type::getInt16Ty(F->getContext()), ADDRESS_SPACE_GLOBAL); + auto Addr = Builder.CreateIntToPtr(Result, Int16Ptr); + auto LoadInst = Builder.CreateLoad(Builder.getInt16Ty(), Addr); + auto Trunc = Builder.CreateZExtOrBitCast(LoadInst, CI.getType()); +diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncsAnalysis.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncsAnalysis.cpp +index 5aba647..0e85462 100644 +--- a/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncsAnalysis.cpp ++++ b/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncsAnalysis.cpp +@@ -204,37 +204,37 @@ void WIFuncsAnalysis::visitCallInst(CallInst &CI) { + + // Check for OpenCL WI function calls + StringRef funcName = F->getName(); +- if (funcName.equals(GET_LOCAL_ID_X) || funcName.equals(GET_LOCAL_ID_Y) || funcName.equals(GET_LOCAL_ID_Z)) { ++ if ((funcName == GET_LOCAL_ID_X) || (funcName == GET_LOCAL_ID_Y) || (funcName == GET_LOCAL_ID_Z)) { + m_hasLocalID = true; +- } else if (funcName.equals(GET_GROUP_ID)) { ++ } else if ((funcName == GET_GROUP_ID)) { + m_hasGroupID = true; +- } else if (funcName.equals(GET_LOCAL_THREAD_ID)) { ++ } else if ((funcName == GET_LOCAL_THREAD_ID)) { + m_hasLocalThreadID = true; +- } else if (funcName.equals(WIFuncsAnalysis::GET_GLOBAL_OFFSET)) { ++ } else if ((funcName == WIFuncsAnalysis::GET_GLOBAL_OFFSET)) { + m_hasGlobalOffset = true; +- } else if (funcName.equals(GET_GLOBAL_SIZE)) { ++ } else if ((funcName == GET_GLOBAL_SIZE)) { + m_hasGlobalSize = true; +- } else if (funcName.equals(GET_LOCAL_SIZE)) { ++ } else if ((funcName == GET_LOCAL_SIZE)) { + m_hasLocalSize = true; +- } else if (funcName.equals(GET_WORK_DIM)) { ++ } else if ((funcName == GET_WORK_DIM)) { + m_hasWorkDim = true; +- } else if (funcName.equals(GET_NUM_GROUPS)) { ++ } else if ((funcName == GET_NUM_GROUPS)) { + m_hasNumGroups = true; +- } else if (funcName.equals(GET_ENQUEUED_LOCAL_SIZE)) { ++ } else if ((funcName == GET_ENQUEUED_LOCAL_SIZE)) { + m_hasEnqueuedLocalSize = true; +- } else if (funcName.equals(GET_STAGE_IN_GRID_ORIGIN)) { ++ } else if ((funcName == GET_STAGE_IN_GRID_ORIGIN)) { + m_hasStageInGridOrigin = true; +- } else if (funcName.equals(GET_STAGE_IN_GRID_SIZE)) { ++ } else if ((funcName == GET_STAGE_IN_GRID_SIZE)) { + m_hasStageInGridSize = true; +- } else if (funcName.equals(GET_SYNC_BUFFER)) { ++ } else if ((funcName == GET_SYNC_BUFFER)) { + m_hasSyncBuffer = true; +- } else if (funcName.equals(GET_ASSERT_BUFFER)) { ++ } else if ((funcName == GET_ASSERT_BUFFER)) { + m_hasAssertBuffer = true; +- } else if (funcName.equals(GET_REGION_GROUP_SIZE)) { ++ } else if ((funcName == GET_REGION_GROUP_SIZE)) { + m_hasRegionGroupSize = true; +- } else if (funcName.equals(GET_REGION_GROUP_WG_COUNT)) { ++ } else if ((funcName == GET_REGION_GROUP_WG_COUNT)) { + m_hasRegionGroupWGCount = true; +- } else if (funcName.equals(GET_REGION_GROUP_BARRIER_BUFFER)) { ++ } else if ((funcName == GET_REGION_GROUP_BARRIER_BUFFER)) { + m_hasRegionGroupBarrierBuffer = true; + } + } +diff --git a/IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp b/IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp +index 6b032b2..c0bffb2 100644 +--- a/IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp ++++ b/IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp +@@ -579,23 +579,23 @@ bool PreCompiledFuncImport::runOnModule(Module &M) { + for (auto &I : BB) { + if (CallInst *CI = dyn_cast(&I)) { + if (Function *calledFunc = CI->getCalledFunction()) { +- if (calledFunc->getName().startswith("GenISA_fma_rtz")) { ++ if (calledFunc->getName().starts_with("GenISA_fma_rtz")) { + createIntrinsicCall(CI, GenISAIntrinsic::GenISA_fma_rtz); +- } else if (calledFunc->getName().startswith("GenISA_fma_rtp")) { ++ } else if (calledFunc->getName().starts_with("GenISA_fma_rtp")) { + createIntrinsicCall(CI, GenISAIntrinsic::GenISA_fma_rtp); +- } else if (calledFunc->getName().startswith("GenISA_fma_rtn")) { ++ } else if (calledFunc->getName().starts_with("GenISA_fma_rtn")) { + createIntrinsicCall(CI, GenISAIntrinsic::GenISA_fma_rtn); +- } else if (calledFunc->getName().startswith("GenISA_add_rte")) { ++ } else if (calledFunc->getName().starts_with("GenISA_add_rte")) { + createIntrinsicCall(CI, GenISAIntrinsic::GenISA_add_rte); +- } else if (calledFunc->getName().startswith("GenISA_add_rtz")) { ++ } else if (calledFunc->getName().starts_with("GenISA_add_rtz")) { + createIntrinsicCall(CI, GenISAIntrinsic::GenISA_add_rtz); +- } else if (calledFunc->getName().startswith("GenISA_add_rtn")) { ++ } else if (calledFunc->getName().starts_with("GenISA_add_rtn")) { + createIntrinsicCall(CI, GenISAIntrinsic::GenISA_add_rtn); +- } else if (calledFunc->getName().startswith("GenISA_add_rtp")) { ++ } else if (calledFunc->getName().starts_with("GenISA_add_rtp")) { + createIntrinsicCall(CI, GenISAIntrinsic::GenISA_add_rtp); +- } else if (calledFunc->getName().startswith("GenISA_mul_rtz")) { ++ } else if (calledFunc->getName().starts_with("GenISA_mul_rtz")) { + createIntrinsicCall(CI, GenISAIntrinsic::GenISA_mul_rtz); +- } else if (calledFunc->getName().startswith("GenISA_uitof_rtz")) { ++ } else if (calledFunc->getName().starts_with("GenISA_uitof_rtz")) { + createIntrinsicCall(CI, GenISAIntrinsic::GenISA_uitof_rtz); + } + } +@@ -800,23 +800,23 @@ PreCompiledFuncImport::ImportedFunction::ImportedFunction(Function *F) + // Get type of imported function. + StringRef name = F->getName(); + +- if (name.equals("__igcbuiltin_dp_div_nomadm_ieee") || name.equals("__igcbuiltin_dp_div_nomadm_fast") || +- name.equals("__igcbuiltin_dp_sqrt_nomadm_ieee") || name.equals("__igcbuiltin_dp_sqrt_nomadm_fast")) { ++ if (name == "__igcbuiltin_dp_div_nomadm_ieee" || name == "__igcbuiltin_dp_div_nomadm_fast" || ++ name == "__igcbuiltin_dp_sqrt_nomadm_ieee" || name == "__igcbuiltin_dp_sqrt_nomadm_fast") { + type = EmuType::FASTDP; +- } else if (name.equals("__igcbuiltin_dp_add") || name.equals("__igcbuiltin_dp_sub") || +- name.equals("__igcbuiltin_dp_fma") || name.equals("__igcbuiltin_dp_mul") || +- name.equals("__igcbuiltin_dp_div") || name.equals("__igcbuiltin_dp_cmp") || +- name.equals("__igcbuiltin_dp_to_int32") || name.equals("__igcbuiltin_dp_to_uint32") || +- name.equals("__igcbuiltin_int32_to_dp") || name.equals("__igcbuiltin_uint32_to_dp") || +- name.equals("__igcbuiltin_dp_to_sp") || name.equals("__igcbuiltin_sp_to_dp") || +- name.equals("__igcbuiltin_dp_sqrt")) { ++ } else if (name == "__igcbuiltin_dp_add" || name == "__igcbuiltin_dp_sub" || ++ name == "__igcbuiltin_dp_fma" || name == "__igcbuiltin_dp_mul" || ++ name == "__igcbuiltin_dp_div" || name == "__igcbuiltin_dp_cmp" || ++ name == "__igcbuiltin_dp_to_int32" || name == "__igcbuiltin_dp_to_uint32" || ++ name == "__igcbuiltin_int32_to_dp" || name == "__igcbuiltin_uint32_to_dp" || ++ name == "__igcbuiltin_dp_to_sp" || name == "__igcbuiltin_sp_to_dp" || ++ name == "__igcbuiltin_dp_sqrt") { + // If true, it is a slow version of DP emu functions. Those functions + // are the original ones for just passing conformance, not for perf. + type = EmuType::SLOWDP; + } else { + for (int i = 0; i < NUM_FUNCTIONS && type == EmuType::OTHER; ++i) { + for (int j = 0; j < NUM_TYPES && type == EmuType::OTHER; ++j) { +- if (name.equals(m_Int64SpDivRemFunctionNames[i][j]) || name.equals(m_Int64DpDivRemFunctionNames[i][j])) { ++ if (name == m_Int64SpDivRemFunctionNames[i][j] || name == m_Int64DpDivRemFunctionNames[i][j]) { + type = EmuType::INT64; + } + } +@@ -1032,7 +1032,7 @@ void PreCompiledFuncImport::processInt32Divide(BinaryOperator &inst, Int32Emulat + Function *func = m_pModule->getFunction(funcName); + + Type *intTy = Type::getInt32Ty(inst.getContext()); +- Type *intPtrTy = Type::getInt32PtrTy(inst.getContext()); ++ Type *intPtrTy = PointerType::get(Type::getInt32Ty(inst.getContext()), 0); + + // Try to look up the function in the module's symbol + // table first, else add it. +@@ -1800,7 +1800,7 @@ void PreCompiledFuncImport::visitCallInst(llvm::CallInst &I) { + StringRef fName = func->getName(); + for (int FID = 0; FID < NUM_FUNCTION_IDS; ++FID) { + const PreCompiledFuncInfo &finfo = m_functionInfos[FID]; +- if (fName.equals(finfo.FuncName)) { ++ if (fName == finfo.FuncName) { + m_libModuleToBeImported[finfo.LibModID] = true; + m_changed = true; + +diff --git a/IGC/Compiler/Optimizer/Scalarizer.cpp b/IGC/Compiler/Optimizer/Scalarizer.cpp +index cbf0121..a2dff5a 100644 +--- a/IGC/Compiler/Optimizer/Scalarizer.cpp ++++ b/IGC/Compiler/Optimizer/Scalarizer.cpp +@@ -872,7 +872,7 @@ void ScalarizeFunction::ScalarizeIntrinsic(IntrinsicInst &II) { + for (unsigned j = 0; j < NumOperands; j++) + ScalarOperands[j] = Operands[j][i]; + +- auto *ScalarIntr = CallInst::Create(Intrinsic::getDeclaration(II.getModule(), II.getIntrinsicID(), {ScalarType}), ++ auto *ScalarIntr = CallInst::Create(Intrinsic::getOrInsertDeclaration(II.getModule(), II.getIntrinsicID(), {ScalarType}), + ScalarOperands, II.getName() + ".scalar", &II); + ScalarIntr->copyMetadata(II); + NewScalarizedInsts[i] = ScalarIntr; +diff --git a/IGC/Compiler/SPIRMetaDataTranslation.cpp b/IGC/Compiler/SPIRMetaDataTranslation.cpp +index d400ccc..70b0c4d 100644 +--- a/IGC/Compiler/SPIRMetaDataTranslation.cpp ++++ b/IGC/Compiler/SPIRMetaDataTranslation.cpp +@@ -115,7 +115,7 @@ bool SPIRMetaDataTranslation::runOnModule(Module &M) { + // check compiler options + for (auto i = spirMDUtils.getCompilerOptionsItem(0)->begin(), e = spirMDUtils.getCompilerOptionsItem(0)->end(); + i != e; ++i) { +- if (StringRef(*i).startswith("-cl-std=CL") && i->length() >= 13) { ++ if (StringRef(*i).starts_with("-cl-std=CL") && i->length() >= 13) { + oclMajor = i->at(10) - '0'; + oclMinor = i->at(12) - '0'; + break; +diff --git a/IGC/Compiler/WorkaroundAnalysisPass.cpp b/IGC/Compiler/WorkaroundAnalysisPass.cpp +index 27c2638..557eb1c 100644 +--- a/IGC/Compiler/WorkaroundAnalysisPass.cpp ++++ b/IGC/Compiler/WorkaroundAnalysisPass.cpp +@@ -589,7 +589,7 @@ void WAFMinFMax::visitCallInst(CallInst &I) { + m_builder->SetInsertPoint(&I); + + IGCLLVM::Intrinsic IID = Intrinsic::minnum; +- Function *IFunc = Intrinsic::getDeclaration(I.getParent()->getParent()->getParent(), IID, I.getType()); ++ Function *IFunc = Intrinsic::getOrInsertDeclaration(I.getParent()->getParent()->getParent(), IID, I.getType()); + Value *QNaN = getQNaN(I.getType()); + + Value *src0 = I.getOperand(0); +diff --git a/IGC/DebugInfo/CMakeLists.txt b/IGC/DebugInfo/CMakeLists.txt +index 814f9be..6bf7776 100644 +--- a/IGC/DebugInfo/CMakeLists.txt ++++ b/IGC/DebugInfo/CMakeLists.txt +@@ -1,36 +1,38 @@ +-#=========================== begin_copyright_notice ============================ +-# +-# Copyright (C) 2020-2023 Intel Corporation +-# +-# SPDX-License-Identifier: MIT +-# +-#============================ end_copyright_notice ============================= ++include_directories("${CMAKE_CURRENT_SOURCE_DIR}") ++include_directories("${IGC_BUILD__IGC_BIN_DIR}/Release") ++include_directories("${IGC_OPTION__OUTPUT_DIR}/${IGC_CMAKE_CFG_INTDIR}") + +-set(DEBUG_INFO_LIBRARY_SOURCES +- StreamEmitter.cpp +- DIE.cpp +- DwarfCompileUnit.cpp +- DwarfExpression.cpp +- LexicalScopes.cpp +- DwarfDebug.cpp +- VISADebugInfo.cpp +- VISADebugEmitter.cpp +- VISADebugDecoder.cpp +- VISAModule.cpp +-) ++set(IGC_BUILD__SRC__DebugInfo ++ "${CMAKE_CURRENT_SOURCE_DIR}/DIE.cpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/DwarfCompileUnit.cpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/DwarfDebug.cpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/DwarfExpression.cpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/LexicalScopes.cpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/StreamEmitter.cpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/VISADebugDecoder.cpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/VISADebugEmitter.cpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/VISADebugInfo.cpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/VISAModule.cpp") + +-add_library(GenXDebugInfo STATIC ${DEBUG_INFO_LIBRARY_SOURCES}) +-add_dependencies(GenXDebugInfo intrinsics_gen ${IGC_BUILD__PROJ__GenISAIntrinsics}) ++set(IGC_BUILD__HDR__DebugInfo ++ "${CMAKE_CURRENT_SOURCE_DIR}/DIE.hpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/DwarfCompileUnit.hpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/DwarfDebug.hpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/DwarfExpression.hpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/EmitterOpts.hpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/LexicalScopes.hpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/StreamEmitter.hpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/Utils.hpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/VISADebugDecoder.hpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/VISADebugEmitter.hpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/VISADebugInfo.hpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/VISAIDebugEmitter.hpp" ++ "${CMAKE_CURRENT_SOURCE_DIR}/VISAModule.hpp") + +-set_target_properties(GenXDebugInfo PROPERTIES FOLDER "Libraries") ++add_library(GenXDebugInfo STATIC ++ ${IGC_BUILD__SRC__DebugInfo} ++ ${IGC_BUILD__HDR__DebugInfo}) + +-igc_get_llvm_targets(LLVM_LIBS +- BinaryFormat +- Core +- MC +- Support +- ) ++add_dependencies(GenXDebugInfo "${IGC_BUILD__PROJ__GenISAIntrinsics}") + +-target_link_libraries(GenXDebugInfo +- ${LLVM_LIBS} +- ) ++set_target_properties(GenXDebugInfo PROPERTIES FOLDER "Libraries") +diff --git a/IGC/DebugInfo/DwarfDebug.cpp b/IGC/DebugInfo/DwarfDebug.cpp +index 1a28d0f..76adba6 100644 +--- a/IGC/DebugInfo/DwarfDebug.cpp ++++ b/IGC/DebugInfo/DwarfDebug.cpp +@@ -897,7 +897,7 @@ CompileUnit *DwarfDebug::constructCompileUnit(DICompileUnit *DIUnit) { + + auto producer = DIUnit->getProducer(); + auto strProducer = producer.str(); +- if (producer.startswith("clang version")) { ++ if (producer.starts_with("clang version")) { + auto pos = strProducer.find("("); + strProducer = strProducer.substr(0, pos); + producer = strProducer.data(); +@@ -1314,8 +1314,7 @@ void DwarfDebug::endSections() { + if (SCU.Sym->isInSection()) { + // Make a note of this symbol and it's section. + const MCSection *Section = &SCU.Sym->getSection(); +- if (!Section->getKind().isMetadata()) +- SectionMap[Section].push_back(SCU); ++ SectionMap[Section].push_back(SCU); + } else { + // Some symbols (e.g. common/bss on mach-o) can have no section but still + // appear in the output. This sucks as we rely on sections to build +diff --git a/IGC/DebugInfo/StreamEmitter.cpp b/IGC/DebugInfo/StreamEmitter.cpp +index bbfd65e..9aa710a 100644 +--- a/IGC/DebugInfo/StreamEmitter.cpp ++++ b/IGC/DebugInfo/StreamEmitter.cpp +@@ -69,7 +69,7 @@ public: + VISAELFObjectWriter(uint8_t osABI, uint16_t eMachine) + : MCELFObjectTargetWriter(true /* is64Bit */, osABI, eMachine, true /* hasRelocationAddend */) {} + +- unsigned getRelocType(MCContext &Ctx, const MCValue &Target, const MCFixup &Fixup, bool IsPCRel) const { ++ unsigned getRelocType(const MCFixup &Fixup, const MCValue &Target, bool IsPCRel) const override { + IGC_ASSERT_MESSAGE(IsPCRel == false, "expecting non-PC relative reloc type"); + unsigned type = ELF::R_X86_64_NONE; + +@@ -98,11 +98,13 @@ public: + + class VISAAsmBackend : public MCAsmBackend { + StringRef m_targetTriple; ++ uint8_t m_osABI; ++ uint16_t m_eMachine; + + public: +- VISAAsmBackend(StringRef targetTriple) : MCAsmBackend(support::endianness::little), m_targetTriple(targetTriple) {} ++ VISAAsmBackend(StringRef targetTriple, uint8_t osABI, uint16_t eMachine) : MCAsmBackend(llvm::endianness::little), m_targetTriple(targetTriple), m_osABI(osABI), m_eMachine(eMachine) {} + +- unsigned getNumFixupKinds() const override { return 0; } ++ std::optional getFixupKind(StringRef) const override { return std::nullopt; } + + static unsigned getFixupKindLog2Size(unsigned Kind) { + switch (Kind) { +@@ -119,8 +121,7 @@ public: + } + } + +- void applyFixup(const MCAssembler &Asm, const MCFixup &fixup, const MCValue &Target, MutableArrayRef Data, +- uint64_t value, bool IsResolved, const MCSubtargetInfo *STI) const override { ++ void applyFixup(const MCFragment &, const MCFixup &fixup, const MCValue &Target, uint8_t *Data, uint64_t value, bool IsResolved) override { + unsigned size = 1 << getFixupKindLog2Size(fixup.getKind()); + + IGC_ASSERT_MESSAGE(fixup.getOffset() + size <= Data.size(), "Invalid fixup offset!"); +@@ -136,14 +137,13 @@ public: + } + } + +- bool mayNeedRelaxation(const MCInst &inst, const MCSubtargetInfo &STI) const override { ++ bool mayNeedRelaxation(unsigned Opcode, ArrayRef Operands, const MCSubtargetInfo &STI) const override { + // TODO: implement this + IGC_ASSERT_EXIT_MESSAGE(0, "Unimplemented"); + return false; + } + +- bool fixupNeedsRelaxation(const MCFixup &fixup, uint64_t value, const MCRelaxableFragment *pDF, +- const MCAsmLayout &layout) const override { ++ bool fixupNeedsRelaxation(const MCFixup &fixup, uint64_t value) const override { + // TODO: implement this + IGC_ASSERT_EXIT_MESSAGE(0, "Unimplemented"); + return false; +@@ -157,17 +157,14 @@ public: + return true; + } + +- std::unique_ptr createObjectTargetWriter() const override { +- // TODO: implement this +- IGC_ASSERT_UNREACHABLE(); // Unimplemented +- } ++ std::unique_ptr createObjectTargetWriter() const override { return std::make_unique(m_osABI, m_eMachine); } + }; // namespace IGC + + class VISAMCCodeEmitter : public MCCodeEmitter { + /// EncodeInstruction - Encode the given \p inst to bytes on the output + /// stream \p OS. +- virtual void encodeInstruction(const MCInst &inst, raw_ostream &os, SmallVectorImpl &fixups, +- const MCSubtargetInfo &m) const { ++ void encodeInstruction(const MCInst &inst, SmallVectorImpl &CB, SmallVectorImpl &fixups, ++ const MCSubtargetInfo &m) const override { + // TODO: implement this + IGC_ASSERT_EXIT_MESSAGE(0, "Unimplemented"); + } +@@ -207,17 +204,13 @@ StreamEmitter::StreamEmitter(raw_pwrite_stream &outStream, const std::string &da + uint16_t eMachine = EM_INTEL_GEN; + if (StreamOptions.EnforceAMD64Machine) + eMachine = ELF::EM_X86_64; +- std::unique_ptr pAsmBackend = IGCLLVM::make_unique(GetTargetTriple()); +- std::unique_ptr pTargetObjectWriter = +- IGCLLVM::make_unique(osABI, eMachine); +- std::unique_ptr pObjectWriter = +- createELFObjectWriter(std::move(pTargetObjectWriter), outStream, true); ++ std::unique_ptr pAsmBackend = IGCLLVM::make_unique(GetTargetTriple(), osABI, eMachine); ++ std::unique_ptr pObjectWriter = pAsmBackend->createObjectWriter(outStream); + std::unique_ptr pCodeEmitter = IGCLLVM::make_unique(); + +- bool isRelaxAll = false; + bool isNoExecStack = false; + m_pMCStreamer = createELFStreamer(*m_pContext, std::move(pAsmBackend), std::move(pObjectWriter), +- std::move(pCodeEmitter), isRelaxAll); ++ std::move(pCodeEmitter)); + + IGCLLVM::initSections(m_pMCStreamer, isNoExecStack, m_pContext); + } +diff --git a/IGC/DebugInfo/Utils.hpp b/IGC/DebugInfo/Utils.hpp +index 6517870..f00ec84 100644 +--- a/IGC/DebugInfo/Utils.hpp ++++ b/IGC/DebugInfo/Utils.hpp +@@ -94,7 +94,7 @@ inline int32_t getSourceLangLiteralMDValue(const llvm::DICompileUnit *compileUni + inline uint16_t getSourceLanguage(const llvm::DICompileUnit *compileUnit, const llvm::Module *module) { + int32_t sourceLanguage = getSourceLangLiteralMDValue(compileUnit, module); + if (sourceLanguage == SOURCE_LANG_LITERAL_MD_IS_NOT_PRESENT) { +- sourceLanguage = compileUnit->getSourceLanguage(); ++ sourceLanguage = compileUnit->getSourceLanguage().getName(); + } + return uint16_t(sourceLanguage); + } +diff --git a/IGC/DebugInfo/VISAModule.cpp b/IGC/DebugInfo/VISAModule.cpp +index 1d7040e..9ab0e66 100644 +--- a/IGC/DebugInfo/VISAModule.cpp ++++ b/IGC/DebugInfo/VISAModule.cpp +@@ -485,7 +485,7 @@ const DbgDecoder::VarInfo *VISAModule::getVarInfo(const VISAObjectDebugInfo &VDI + for (const auto &VarInfo : VDI.getVISAVariables()) { + StringRef Name = VarInfo.name; + // TODO: what to do with variables starting with "T"? +- if (Name.startswith("V")) { ++ if (Name.starts_with("V")) { + Name = Name.drop_front(); + unsigned RegNum = 0; + if (!Name.getAsInteger(10, RegNum)) +diff --git a/IGC/GenISAIntrinsics/GenIntrinsicInst.h b/IGC/GenISAIntrinsics/GenIntrinsicInst.h +index 7c378e8..5253670 100644 +--- a/IGC/GenISAIntrinsics/GenIntrinsicInst.h ++++ b/IGC/GenISAIntrinsics/GenIntrinsicInst.h +@@ -84,7 +84,7 @@ public: + // Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const CallInst *I) { + if (const Function *CF = I->getCalledFunction()) { +- return (CF->getName().startswith(GenISAIntrinsic::getGenIntrinsicPrefix())); ++ return (CF->getName().starts_with(GenISAIntrinsic::getGenIntrinsicPrefix())); + } + return false; + } +diff --git a/IGC/GenISAIntrinsics/GenIntrinsicLookup.cpp b/IGC/GenISAIntrinsics/GenIntrinsicLookup.cpp +index f4d86c1..6452248 100644 +--- a/IGC/GenISAIntrinsics/GenIntrinsicLookup.cpp ++++ b/IGC/GenISAIntrinsics/GenIntrinsicLookup.cpp +@@ -14,7 +14,7 @@ namespace IGC { + + llvm::GenISAIntrinsic::ID LookupIntrinsicId(llvm::StringRef GenISAprefix, llvm::StringRef Name) { + +- if (!Name.startswith(GenISAprefix)) ++ if (!Name.starts_with(GenISAprefix)) + return llvm::GenISAIntrinsic::ID::no_intrinsic; + + static auto LengthTable = GetIntrinsicLookupTable(); +diff --git a/IGC/GenISAIntrinsics/GenIntrinsics.h b/IGC/GenISAIntrinsics/GenIntrinsics.h +index 8cc901a..d07313d 100644 +--- a/IGC/GenISAIntrinsics/GenIntrinsics.h ++++ b/IGC/GenISAIntrinsics/GenIntrinsics.h +@@ -32,7 +32,7 @@ struct IntrinsicComments { + + IntrinsicComments getIntrinsicComments(ID id); + +-/// Intrinsic::getDeclaration(M, ID) - Create or insert an LLVM Function ++/// Intrinsic::getOrInsertDeclaration(M, ID) - Create or insert an LLVM Function + /// declaration for an intrinsic, and return it. + /// + /// The OverloadedTys parameter is for intrinsics with overloaded types +@@ -57,7 +57,7 @@ Function *getDeclaration(Module *M, ID id, ArrayRef OverloadedTys = {}, + + // Override of isIntrinsic method defined in Function.h + inline const char *getGenIntrinsicPrefix() { return "llvm.genx."; } +-inline bool isIntrinsic(const Function *CF) { return (CF->getName().startswith(getGenIntrinsicPrefix())); } ++inline bool isIntrinsic(const Function *CF) { return (CF->getName().starts_with(getGenIntrinsicPrefix())); } + ID getIntrinsicID(const Function *F, bool useContextWrapper = true); + + } // namespace GenISAIntrinsic +diff --git a/IGC/GenISAIntrinsics/generator/Intrinsic_definition_objects.py b/IGC/GenISAIntrinsics/generator/Intrinsic_definition_objects.py +index e6fa1f7..4bfbee0 100644 +--- a/IGC/GenISAIntrinsics/generator/Intrinsic_definition_objects.py ++++ b/IGC/GenISAIntrinsics/generator/Intrinsic_definition_objects.py +@@ -155,7 +155,7 @@ class ParamAttributeID(Enum): + ByRef = 0 + ByVal = 1 + StructRet = 2 +- NoCapture = 3 ++ Captures = 3 + + def __str__(self): + return self.name +diff --git a/IGC/GenISAIntrinsics/generator/Intrinsic_definition_translation.py b/IGC/GenISAIntrinsics/generator/Intrinsic_definition_translation.py +index cffa5a8..4f85558 100644 +--- a/IGC/GenISAIntrinsics/generator/Intrinsic_definition_translation.py ++++ b/IGC/GenISAIntrinsics/generator/Intrinsic_definition_translation.py +@@ -25,7 +25,7 @@ def translate_type_definition(type_description): + for type_str in type_description: + internal_types.append(translate_type_definition(type_str)) + return TypeDefinition(TypeID.Struct, internal_types=internal_types) +- elif type_description.startswith('any'): ++ elif type_description.starts_with('any'): + if type_description == 'anyvector': + return TypeDefinition(TypeID.Vector, internal_type=TypeDefinition(TypeID.Any)) + elif type_description == 'anyint': +@@ -39,55 +39,55 @@ def translate_type_definition(type_description): + return TypeDefinition(TypeID.Any, internal_type=default_type) + elif type_description == 'void': + return TypeDefinition(TypeID.Void) +- elif type_description.startswith('bool'): ++ elif type_description.starts_with('bool'): + type_def = TypeDefinition(TypeID.Integer, bit_width=1) + match = re.search("bool([0-9]+)", type_description) + if match is not None: + type_def = TypeDefinition(TypeID.Vector, num_elements=int(match.group(1)), internal_type=type_def) + return type_def +- elif type_description.startswith('char'): ++ elif type_description.starts_with('char'): + type_def = TypeDefinition(TypeID.Integer, bit_width=8) + match = re.search("char([0-9]+)", type_description) + if match is not None: + type_def = TypeDefinition(TypeID.Vector, num_elements=int(match.group(1)), internal_type=type_def) + return type_def +- elif type_description.startswith('short'): ++ elif type_description.starts_with('short'): + type_def = TypeDefinition(TypeID.Integer, bit_width=16) + match = re.search("short([0-9]+)", type_description) + if match is not None: + type_def = TypeDefinition(TypeID.Vector, num_elements=int(match.group(1)), internal_type=type_def) + return type_def +- elif type_description.startswith('int'): ++ elif type_description.starts_with('int'): + type_def = TypeDefinition(TypeID.Integer, bit_width=32) + match = re.search("int([0-9]+)", type_description) + if match is not None: + type_def = TypeDefinition(TypeID.Vector, num_elements=int(match.group(1)), internal_type=type_def) + return type_def +- elif type_description.startswith('long'): ++ elif type_description.starts_with('long'): + type_def = TypeDefinition(TypeID.Integer, bit_width=64) + match = re.search("long([0-9]+)", type_description) + if match is not None: + type_def = TypeDefinition(TypeID.Vector, num_elements=int(match.group(1)), internal_type=type_def) + return type_def +- elif type_description.startswith('half'): ++ elif type_description.starts_with('half'): + type_def = TypeDefinition(TypeID.Float, bit_width=16) + match = re.search("half([0-9]+)", type_description) + if match is not None: + type_def = TypeDefinition(TypeID.Vector, num_elements=int(match.group(1)), internal_type=type_def) + return type_def +- elif type_description.startswith('float'): ++ elif type_description.starts_with('float'): + type_def = TypeDefinition(TypeID.Float, bit_width=32) + match = re.search("float([0-9]+)", type_description) + if match is not None: + type_def = TypeDefinition(TypeID.Vector, num_elements=int(match.group(1)), internal_type=type_def) + return type_def +- elif type_description.startswith('double'): ++ elif type_description.starts_with('double'): + type_def = TypeDefinition(TypeID.Float, bit_width=32) + match = re.search("double([0-9]+)", type_description) + if match is not None: + type_def = TypeDefinition(TypeID.Vector, num_elements=int(match.group(1)), internal_type=type_def) + return type_def +- elif type_description.startswith('ptr_private'): ++ elif type_description.starts_with('ptr_private'): + # E2 <- E == IIT_PTR + AddressSpace == 0 (implicit for IIT_PTR) + 2 == IIT_I8 + return TypeDefinition(TypeID.Pointer, address_space=AddressSpace.Private, + internal_type=TypeDefinition(TypeID.Integer, bit_width=8)) +diff --git a/IGC/GenISAIntrinsics/generator/input/Intrinsic_definitions.yml b/IGC/GenISAIntrinsics/generator/input/Intrinsic_definitions.yml +index ca933bd..e517ad2 100644 +--- a/IGC/GenISAIntrinsics/generator/input/Intrinsic_definitions.yml ++++ b/IGC/GenISAIntrinsics/generator/input/Intrinsic_definitions.yml +@@ -12033,7 +12033,7 @@ intrinsics: + name: Arg16 + type_definition: *p_any_ + comment: "payload" +- param_attr: !ParamAttributeID "NoCapture" ++ param_attr: !ParamAttributeID "Captures" + - ! + name: Arg17 + type_definition: *i32 +diff --git a/IGC/IRBuilderGenerator/main.cpp b/IGC/IRBuilderGenerator/main.cpp +index d8312c5..9c83b27 100644 +--- a/IGC/IRBuilderGenerator/main.cpp ++++ b/IGC/IRBuilderGenerator/main.cpp +@@ -43,6 +43,7 @@ SPDX-License-Identifier: MIT + #include "llvm/Support/Signals.h" + #include "llvm/Support/SourceMgr.h" + #include "llvm/Support/FileSystem.h" ++#include "llvm/Support/ManagedStatic.h" + #include "llvm/IR/LLVMContext.h" + #include "llvm/IR/Module.h" + #include "llvm/IRReader/IRReader.h" +@@ -136,6 +137,8 @@ using AlignMap = DenseMap; + + // TODO: check for cycles if we want to process cyclic structures. + void findHoleTys(const Type *Ty, HoleMap &Tys) { ++ if (!Ty) ++ return; + if (auto *StructTy = dyn_cast(Ty)) { + if (!StructTy->isLiteral()) { + assert(StructTy->hasName() && "no name?"); +@@ -186,7 +189,7 @@ void emitType(const Type *Ty, const HoleMap &HoleTys, const AlignMap &Aligns, ra + if (auto *StructTy = dyn_cast(Ty)) { + assert(!StructTy->isOpaque() && "encountered opaque struct?"); + +- if (!Root) { ++ if (!Root && StructTy->hasName() && !StructTy->getName().empty()) { + OS.indent(Level * 2) << sanitize(StructTy->getName().str()) << "(M"; + HoleMap HoleTys; + findHoleTys(StructTy, HoleTys); +@@ -232,14 +235,7 @@ void emitType(const Type *Ty, const HoleMap &HoleTys, const AlignMap &Aligns, ra + OS << ",\n"; + } + OS.indent(In * 2) << "};\n"; +- { +- // Inject explicit padding as needed +- auto I = Aligns.find(StructTy); +- if (I != Aligns.end()) { +- OS.indent(In * 2) << "injectPadding(M, Tys, " << I->second << ", " << (StructTy->isPacked() ? "true" : "false") +- << ");\n"; +- } +- } ++ + if (StructTy->isLiteral()) { + OS.indent(In * 2) << "return StructType::get(M.getContext(), Tys, " << (StructTy->isPacked() ? "true" : "false") + << ");\n"; +@@ -293,18 +289,29 @@ void emitType(const Type *Ty, const HoleMap &HoleTys, const AlignMap &Aligns, ra + } + + bool processAlignOf(const Function &F, AlignMap &Aligns) { +- if (F.arg_size() != 1) { +- errs() << F.getName() << ": Only one argument should be specified!\n"; +- return false; ++ if (F.arg_size() == 1) { ++ const Argument *A = F.arg_begin(); ++ auto *StructTy = cast(A->getParamStructRetType()); ++ ++ Align Align = *A->getParamAlign(); ++ Aligns[StructTy] = static_cast(Align.value()); ++ ++ return true; + } + +- const Argument *A = F.arg_begin(); +- auto *StructTy = cast(A->getParamStructRetType()); ++ if (F.arg_empty()) { ++ auto *StructTy = dyn_cast(F.getReturnType()); ++ if (!StructTy) { ++ errs() << F.getName() << ": Return type should be struct!\n"; ++ return false; ++ } + +- Align Align = *A->getParamAlign(); +- Aligns[StructTy] = static_cast(Align.value()); ++ Aligns[StructTy] = static_cast(F.getParent()->getDataLayout().getABITypeAlign(StructTy).value()); ++ return true; ++ } + +- return true; ++ errs() << F.getName() << ": Only one argument should be specified!\n"; ++ return false; + } + + bool emitType(const StructType *Ty, StringRef FName, raw_ostream &OS, const AlignMap &Aligns, bool Root) { +@@ -325,15 +332,25 @@ bool emitType(const StructType *Ty, StringRef FName, raw_ostream &OS, const Alig + } + + bool processGetType(const Function &F, raw_ostream &OS, const AlignMap &Aligns) { +- if (F.arg_size() != 1) { +- errs() << F.getName() << ": Should have only one argument!\n"; +- return false; ++ if (F.arg_size() == 1) { ++ const Argument *A = F.arg_begin(); ++ auto *STy = cast(A->getParamStructRetType()); ++ ++ return emitType(STy, F.getName(), OS, Aligns, false); + } + +- const Argument *A = F.arg_begin(); +- auto *STy = cast(A->getParamStructRetType()); ++ if (F.arg_empty()) { ++ auto *STy = dyn_cast(F.getReturnType()); ++ if (!STy) { ++ errs() << F.getName() << ": Return type should be struct!\n"; ++ return false; ++ } ++ ++ return emitType(STy, F.getName(), OS, Aligns, false); ++ } + +- return emitType(STy, F.getName(), OS, Aligns, false); ++ errs() << F.getName() << ": Should have only one argument!\n"; ++ return false; + } + + struct HookInfo { +@@ -1116,9 +1133,7 @@ void rewriteAnonTypes(Module &M) { + } + + void preprocess(Module &M) { +- llvm::legacy::PassManager mpm; +- mpm.add(createUnifyFunctionExitNodesPass()); +- mpm.add(createLowerSwitchPass()); ++ llvm::legacy::PassManager mpm; mpm.add(createLowerSwitchPass()); + mpm.run(M); + + markInvariant(M); +diff --git a/IGC/LLVM3DBuilder/BuiltinsFrontendDefinitions.hpp b/IGC/LLVM3DBuilder/BuiltinsFrontendDefinitions.hpp +index 171f9a3..92ae7ea 100644 +--- a/IGC/LLVM3DBuilder/BuiltinsFrontendDefinitions.hpp ++++ b/IGC/LLVM3DBuilder/BuiltinsFrontendDefinitions.hpp +@@ -2156,7 +2156,7 @@ inline SampleD_DC_FromCubeParams LLVM3DBuilder::Prepare_SAMPLE_D_DC + template llvm::Value *LLVM3DBuilder::CreateFAbs(llvm::Value *V) { + llvm::Module *module = this->GetInsertBlock()->getParent()->getParent(); + +- llvm::Function *fabs = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::fabs, V->getType()); ++ llvm::Function *fabs = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::fabs, V->getType()); + return this->CreateCall(fabs, V); + } + +@@ -2326,21 +2326,21 @@ template llvm::Value *LLVM3DBuilder + template llvm::Value *LLVM3DBuilder::CreateSin(llvm::Value *V) { + llvm::Module *module = this->GetInsertBlock()->getParent()->getParent(); + +- llvm::Function *sin = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::sin, V->getType()); ++ llvm::Function *sin = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::sin, V->getType()); + return this->CreateCall(sin, V); + } + + template llvm::Value *LLVM3DBuilder::CreateCos(llvm::Value *V) { + llvm::Module *module = this->GetInsertBlock()->getParent()->getParent(); + +- llvm::Function *cos = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::cos, V->getType()); ++ llvm::Function *cos = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::cos, V->getType()); + return this->CreateCall(cos, V); + } + + template llvm::Value *LLVM3DBuilder::CreateSqrt(llvm::Value *V) { + llvm::Module *module = this->GetInsertBlock()->getParent()->getParent(); + +- llvm::Function *sqrt = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::sqrt, V->getType()); ++ llvm::Function *sqrt = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::sqrt, V->getType()); + return this->CreateCall(sqrt, V); + } + +@@ -2348,7 +2348,7 @@ template + llvm::Value *LLVM3DBuilder::CreateFPow(llvm::Value *LHS, llvm::Value *RHS) { + llvm::Module *module = this->GetInsertBlock()->getParent()->getParent(); + +- llvm::Function *fpow = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::pow, LHS->getType()); ++ llvm::Function *fpow = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::pow, LHS->getType()); + return this->CreateCall2(fpow, LHS, RHS); + } + +@@ -2356,7 +2356,7 @@ template + llvm::Value *LLVM3DBuilder::CreateFMax(llvm::Value *LHS, llvm::Value *RHS) { + llvm::Module *module = this->GetInsertBlock()->getParent()->getParent(); + +- llvm::Function *fmax = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::maxnum, LHS->getType()); ++ llvm::Function *fmax = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::maxnum, LHS->getType()); + return this->CreateCall2(fmax, LHS, RHS); + } + +@@ -2364,7 +2364,7 @@ template + llvm::Value *LLVM3DBuilder::CreateFMin(llvm::Value *LHS, llvm::Value *RHS) { + llvm::Module *module = this->GetInsertBlock()->getParent()->getParent(); + +- llvm::Function *fmin = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::minnum, LHS->getType()); ++ llvm::Function *fmin = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::minnum, LHS->getType()); + return this->CreateCall2(fmin, LHS, RHS); + } + +@@ -2396,14 +2396,14 @@ template llvm::Value *LLVM3DBuilder + template llvm::Value *LLVM3DBuilder::CreateFLog(llvm::Value *V) { + llvm::Module *module = this->GetInsertBlock()->getParent()->getParent(); + +- llvm::Function *flog = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::log2, V->getType()); ++ llvm::Function *flog = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::log2, V->getType()); + return this->CreateCall(flog, V); + } + + template llvm::Value *LLVM3DBuilder::CreateFExp(llvm::Value *V) { + llvm::Module *module = this->GetInsertBlock()->getParent()->getParent(); + +- llvm::Function *fexp = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::exp2, V->getType()); ++ llvm::Function *fexp = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::exp2, V->getType()); + return this->CreateCall(fexp, V); + } + +@@ -2484,7 +2484,7 @@ template llvm::Value *LLVM3DBuilder + if (V->getType() == this->getDoubleTy()) { + return CreateDFloor(V); + } else { +- llvm::Function *floor = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::floor, V->getType()); ++ llvm::Function *floor = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::floor, V->getType()); + return this->CreateCall(floor, V); + } + } +@@ -2568,7 +2568,7 @@ template llvm::Value *LLVM3DBuilder + if (V->getType() == this->getDoubleTy()) { + return CreateDCeil(V); + } else { +- llvm::Function *ceil = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::ceil, V->getType()); ++ llvm::Function *ceil = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::ceil, V->getType()); + return this->CreateCall(ceil, V); + } + } +@@ -2640,7 +2640,7 @@ template llvm::Value *LLVM3DBuilder + if (V->getType() == this->getDoubleTy()) { + return CreateDTrunc(V); + } else { +- llvm::Function *trunc = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::trunc, V->getType()); ++ llvm::Function *trunc = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::trunc, V->getType()); + return this->CreateCall(trunc, V); + } + } +@@ -2754,7 +2754,7 @@ template inline llvm::Value *LLVM3DBuilder llvm::Value *LLVM3DBuilder::CreateCtpop(llvm::Value *V) { + llvm::Module *module = this->GetInsertBlock()->getParent()->getParent(); + +- llvm::Function *ctpop = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::ctpop, V->getType()); ++ llvm::Function *ctpop = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::ctpop, V->getType()); + return this->CreateCall(ctpop, V); + } + +@@ -2820,7 +2820,7 @@ llvm::Value *LLVM3DBuilder::Create_MAD_Scalar(llvm::Value *float_sr + float_src2->getType() == this->getFloatTy() || float_src2->getType() == this->getDoubleTy()), + "Type check @MAD.scalar arg: 2"); + +- llvm::Function *madFunc = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::fma, float_src0->getType()); ++ llvm::Function *madFunc = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::fma, float_src0->getType()); + llvm::Value *args[] = {float_src0, float_src1, float_src2}; + llvm::Value *float_madres_s = this->CreateCall(madFunc, args); + +@@ -2830,7 +2830,7 @@ llvm::Value *LLVM3DBuilder::Create_MAD_Scalar(llvm::Value *float_sr + template + llvm::Value *LLVM3DBuilder::CreatePow(llvm::Value *src0, llvm::Value *src1) { + llvm::Module *module = this->GetInsertBlock()->getParent()->getParent(); +- llvm::Function *powFunc = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::pow, src0->getType()); ++ llvm::Function *powFunc = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::pow, src0->getType()); + llvm::Value *args[] = {src0, src1}; + llvm::Value *powres_s = this->CreateCall(powFunc, args); + +@@ -3028,7 +3028,7 @@ template inline llvm::Value *LLVM3DBuilder + inline llvm::CallInst *LLVM3DBuilder::create_countbits(llvm::Value *src) { + llvm::Module *module = this->GetInsertBlock()->getParent()->getParent(); +- llvm::Function *pFunc = llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::ctpop, this->getInt32Ty()); ++ llvm::Function *pFunc = llvm::Intrinsic::getOrInsertDeclaration(module, llvm::Intrinsic::ctpop, this->getInt32Ty()); + return this->CreateCall(pFunc, src); + } + +diff --git a/IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp b/IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp +index 7ec183b..e8bcc45 100644 +--- a/IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp ++++ b/IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp +@@ -978,7 +978,7 @@ std::string GetCDefinesForEnableList(llvm::StringRef enableListStr, unsigned int + ExtensionsRequiringManualFeatureMacros enabledExtensions; + for (auto ext : v) { + if (ext.consume_front("+")) { +- if (ext.equals("cl_intel_device_side_avc_motion_estimation")) { ++ if (ext == "cl_intel_device_side_avc_motion_estimation") { + // If the user provided -cl-std option we need to add the define only if it's 1.2 and above. + // This is because clang will not allow declarations of extension's functions which use avc types otherwise. + if (!(oclStd >= 120 || oclStd == 0)) +@@ -986,13 +986,13 @@ std::string GetCDefinesForEnableList(llvm::StringRef enableListStr, unsigned int + } + + // Only collect extensions needed for manual feature macro generation +- if (ext.equals("cl_khr_integer_dot_product")) { ++ if (ext == "cl_khr_integer_dot_product") { + enabledExtensions.integerDotProduct = true; +- } else if (ext.equals("cl_ext_float_atomics")) { ++ } else if (ext == "cl_ext_float_atomics") { + enabledExtensions.extFloatAtomics = true; +- } else if (ext.equals("cl_khr_fp16")) { ++ } else if (ext == "cl_khr_fp16") { + enabledExtensions.fp16 = true; +- } else if (ext.equals("cl_khr_fp64")) { ++ } else if (ext == "cl_khr_fp64") { + enabledExtensions.fp64 = true; + } + +diff --git a/IGC/VectorCompiler/CMCL/lib/Support/BuiltinTranslator.cpp b/IGC/VectorCompiler/CMCL/lib/Support/BuiltinTranslator.cpp +index 42e4f75..9574d0b 100644 +--- a/IGC/VectorCompiler/CMCL/lib/Support/BuiltinTranslator.cpp ++++ b/IGC/VectorCompiler/CMCL/lib/Support/BuiltinTranslator.cpp +@@ -164,7 +164,7 @@ Function *getAnyDeclarationForIdFromArgs(Type &RetTy, Range &&Args, unsigned Id, + if (Intrinsic::isOverloaded(IID)) + Types.push_back(&RetTy); + +- return Intrinsic::getDeclaration(&M, IID, Types); ++ return Intrinsic::getOrInsertDeclaration(&M, IID, Types); + } + + static bool isCMCLBuiltin(const Function &F) { +@@ -325,7 +325,7 @@ static Value &createLLVMIntrinsic(const std::vector &Operands, + auto IID = static_cast(IntrinsicForBuiltin[BiID]); + assert(IID != Intrinsic::not_intrinsic && "Expected LLVM intrinsic"); + Module *M = IRB.GetInsertBlock()->getModule(); +- auto *Decl = Intrinsic::getDeclaration(M, IID, {&RetTy}); ++ auto *Decl = Intrinsic::getOrInsertDeclaration(M, IID, {&RetTy}); + return *IRB.CreateCall(Decl, Operands); + } + +diff --git a/IGC/VectorCompiler/cmake/supported_platforms_list.cmake b/IGC/VectorCompiler/cmake/supported_platforms_list.cmake +index e8e14d5..81fd2b5 100644 +--- a/IGC/VectorCompiler/cmake/supported_platforms_list.cmake ++++ b/IGC/VectorCompiler/cmake/supported_platforms_list.cmake +@@ -6,7 +6,7 @@ + # + #============================ end_copyright_notice ============================= + +-set(SUPPORTED_VC_PLATFORMS ++set(ALL_SUPPORTED_VC_PLATFORMS + "Gen8" + "Gen9" + "Gen9LP" +@@ -23,3 +23,14 @@ set(SUPPORTED_VC_PLATFORMS + "Xe3P" + "Xe3PLPG" + ) ++ ++if(IGC_BUILD__VC_PLATFORMS) ++ foreach(PLTF IN LISTS IGC_BUILD__VC_PLATFORMS) ++ if(NOT PLTF IN_LIST ALL_SUPPORTED_VC_PLATFORMS) ++ message(FATAL_ERROR "Unsupported VC platform requested: ${PLTF}") ++ endif() ++ endforeach() ++ set(SUPPORTED_VC_PLATFORMS ${IGC_BUILD__VC_PLATFORMS}) ++else() ++ set(SUPPORTED_VC_PLATFORMS ${ALL_SUPPORTED_VC_PLATFORMS}) ++endif() +diff --git a/IGC/VectorCompiler/include/GenXSubtarget.h b/IGC/VectorCompiler/include/GenXSubtarget.h +index 46d7ebf..b4d0494 100644 +--- a/IGC/VectorCompiler/include/GenXSubtarget.h ++++ b/IGC/VectorCompiler/include/GenXSubtarget.h +@@ -315,6 +315,8 @@ public: + + bool isInternalIntrinsicSupported(unsigned ID) const; + ++ const TargetRegisterInfo *getRegisterInfo() const override { return nullptr; } ++ + public: + /// * translateMediaWalker - true if translate media walker APIs + bool translateMediaWalker() const { return !HasMediaWalker; } +diff --git a/IGC/VectorCompiler/include/GenXUtil.h b/IGC/VectorCompiler/include/GenXUtil.h +index 7499dcc..45ed39c 100644 +--- a/IGC/VectorCompiler/include/GenXUtil.h ++++ b/IGC/VectorCompiler/include/GenXUtil.h +@@ -158,6 +158,8 @@ llvm::SmallPtrSet peelBitCastsGetUsers(Value *const V); + // Get Value def ignoring possible bitcasts chain. + inline const Value *getBitCastedValue(const Value *V) { + IGC_ASSERT_MESSAGE(V, "non-null value expected"); ++ if (!V) ++ return nullptr; + while (isa(V) || + (isa(V) && + cast(V)->getOpcode() == CastInst::BitCast)) +diff --git a/IGC/VectorCompiler/include/vc/GenXCodeGen/TargetMachine.h b/IGC/VectorCompiler/include/vc/GenXCodeGen/TargetMachine.h +index 7fcd55a..b6dd80c 100644 +--- a/IGC/VectorCompiler/include/vc/GenXCodeGen/TargetMachine.h ++++ b/IGC/VectorCompiler/include/vc/GenXCodeGen/TargetMachine.h +@@ -20,7 +20,7 @@ std::unique_ptr createGenXTargetMachine( + const llvm::Target &T, llvm::Triple TT, llvm::StringRef CPU, + llvm::StringRef Features, const llvm::TargetOptions &Options, + IGCLLVM::optional RM, +- IGCLLVM::optional CM, llvm::CodeGenOpt::Level OL, ++ IGCLLVM::optional CM, llvm::CodeGenOptLevel OL, + std::unique_ptr BC); + + inline bool is32BitArch(llvm::Triple TT) { +diff --git a/IGC/VectorCompiler/include/vc/InternalIntrinsics/InternalIntrinsicInst.h b/IGC/VectorCompiler/include/vc/InternalIntrinsics/InternalIntrinsicInst.h +index abcfefe..a516087 100644 +--- a/IGC/VectorCompiler/include/vc/InternalIntrinsics/InternalIntrinsicInst.h ++++ b/IGC/VectorCompiler/include/vc/InternalIntrinsics/InternalIntrinsicInst.h +@@ -42,7 +42,7 @@ public: + // Methods for support type inquiry through isa, cast, and dyn_cast: + static bool classof(const CallInst *I) { + if (const Function *CF = I->getCalledFunction()) { +- return CF->getName().startswith( ++ return CF->getName().starts_with( + vc::InternalIntrinsic::getInternalIntrinsicPrefix()); + } + return false; +diff --git a/IGC/VectorCompiler/include/vc/InternalIntrinsics/InternalIntrinsics.h b/IGC/VectorCompiler/include/vc/InternalIntrinsics/InternalIntrinsics.h +index 3617006..109d1d1 100644 +--- a/IGC/VectorCompiler/include/vc/InternalIntrinsics/InternalIntrinsics.h ++++ b/IGC/VectorCompiler/include/vc/InternalIntrinsics/InternalIntrinsics.h +@@ -70,7 +70,7 @@ inline bool isInternalIntrinsic(unsigned ID) { + /// getInternalIntrinsicID() returns InternalIntrinsic::not_internal_intrinsic! + inline bool isInternalIntrinsic(const llvm::Function *CF) { + IGC_ASSERT(CF); +- return CF->getName().startswith(getInternalIntrinsicPrefix()); ++ return CF->getName().starts_with(getInternalIntrinsicPrefix()); + } + + inline bool isInternalIntrinsic(const llvm::Value *V) { +diff --git a/IGC/VectorCompiler/include/vc/Utils/GenX/TypeSize.h b/IGC/VectorCompiler/include/vc/Utils/GenX/TypeSize.h +index 376a632..1328b7f 100644 +--- a/IGC/VectorCompiler/include/vc/Utils/GenX/TypeSize.h ++++ b/IGC/VectorCompiler/include/vc/Utils/GenX/TypeSize.h +@@ -36,8 +36,8 @@ public: + using SzType = uint64_t; + + using DLTypeSize = llvm::TypeSize; +- static DLTypeSize InvalidDLSize() { return DLTypeSize::Fixed(0); } +- static DLTypeSize FixedDLSize(uint64_t SZ) { return DLTypeSize::Fixed(SZ); } ++ static DLTypeSize InvalidDLSize() { return DLTypeSize::getFixed(0); } ++ static DLTypeSize FixedDLSize(uint64_t SZ) { return DLTypeSize::getFixed(SZ); } + + TypeSizeWrapper() = default; + TypeSizeWrapper(DLTypeSize TS) : TS(TS) {}; +diff --git a/IGC/VectorCompiler/lib/BiF/CMakeLists.txt b/IGC/VectorCompiler/lib/BiF/CMakeLists.txt +index 41080ac..7708d98 100644 +--- a/IGC/VectorCompiler/lib/BiF/CMakeLists.txt ++++ b/IGC/VectorCompiler/lib/BiF/CMakeLists.txt +@@ -79,3 +79,6 @@ else() + endif() + add_dependencies(VCEmbeddedBiF VCBiFPreparation) + target_link_libraries(VCEmbeddedBiF VCHeaders) ++set_property(GLOBAL PROPERTY JOB_POOLS vc_embedded_bif_pool=1) ++set_property(TARGET VCEmbeddedBiF PROPERTY JOB_POOL_COMPILE vc_embedded_bif_pool) ++target_compile_options(VCEmbeddedBiF PRIVATE -O0 -g0) +diff --git a/IGC/VectorCompiler/lib/BiF/cmake/Functions.cmake b/IGC/VectorCompiler/lib/BiF/cmake/Functions.cmake +index ae8f823..28a5211 100644 +--- a/IGC/VectorCompiler/lib/BiF/cmake/Functions.cmake ++++ b/IGC/VectorCompiler/lib/BiF/cmake/Functions.cmake +@@ -195,6 +195,10 @@ function(vc_generate_optimized_bif RES_FILE BIF_OPT_BC_PATH MANGLED_BIF_NAME OPA + endif() + set(BIF_CPP_NAME ${MANGLED_BIF_NAME}.${OPAQUE_SUFFIX}.cpp) + set(BIF_CPP_PATH ${CMAKE_CURRENT_BINARY_DIR}/${BIF_CPP_NAME}) ++ set(BIF_CPP_SHARDS "") ++ foreach(I RANGE 0 31) ++ list(APPEND BIF_CPP_SHARDS ${CMAKE_CURRENT_BINARY_DIR}/${MANGLED_BIF_NAME}.${OPAQUE_SUFFIX}.PLTF${I}.cpp) ++ endforeach() + set(BIF_SYMBOL ${MANGLED_BIF_NAME}RawData) + set(BIF_CONF_NAME "${MANGLED_BIF_NAME}.${OPAQUE_SUFFIX}.conf") + set(BIF_CONF_PATH ${CMAKE_CURRENT_BINARY_DIR}/${BIF_CONF_NAME}) +@@ -216,13 +220,13 @@ function(vc_generate_optimized_bif RES_FILE BIF_OPT_BC_PATH MANGLED_BIF_NAME OPA + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/builtins.conf.in" + "${BIF_CONF_PATH}" @ONLY) + add_custom_command( +- OUTPUT ${BIF_CPP_PATH} ++ OUTPUT ${BIF_CPP_PATH} ${BIF_CPP_SHARDS} + COMMENT "vc_generate_optimized_bif: create hashed version of optimized functions" + COMMAND ${VCB_EXE} -BiFUnique -symb ${BIF_SYMBOL} -o ${BIF_CPP_PATH} ${BIF_CONF_PATH} + DEPENDS ${VCB_EXE} ${BIF_CONF_PATH} ${PLTF_BC_PATH_LIST}) + add_custom_target(${TARGET_NAME} +- DEPENDS ${BIF_CPP_PATH}) +- set(${RES_FILE} ${BIF_CPP_PATH} PARENT_SCOPE) ++ DEPENDS ${BIF_CPP_PATH} ${BIF_CPP_SHARDS}) ++ set(${RES_FILE} ${BIF_CPP_PATH} ${BIF_CPP_SHARDS} PARENT_SCOPE) + endfunction() + + # Takes CMCL source code, compiles it and produces an embeddable .cpp file +diff --git a/IGC/VectorCompiler/lib/Driver/Driver.cpp b/IGC/VectorCompiler/lib/Driver/Driver.cpp +index 6501d97..1d4e54e 100644 +--- a/IGC/VectorCompiler/lib/Driver/Driver.cpp ++++ b/IGC/VectorCompiler/lib/Driver/Driver.cpp +@@ -73,6 +73,7 @@ SPDX-License-Identifier: MIT + #include "Probe/Assertion.h" + + #include ++#include + #include + + using namespace llvm; +@@ -147,11 +148,10 @@ getModule(ArrayRef Input, vc::FileType FType, + IGC_ASSERT_UNREACHABLE(); // Unknown input kind + } + +-static Triple overrideTripleWithVC(StringRef TripleStr) { +- Triple T{TripleStr}; ++static Triple overrideTripleWithVC(Triple T) { + // Normalize triple. + bool Is32Bit = T.isArch32Bit(); +- if (TripleStr.startswith("genx32")) ++ if (T.str().starts_with("genx32")) + Is32Bit = true; + return Triple{Is32Bit ? "genx32-unknown-unknown" : "genx64-unknown-unknown"}; + } +@@ -205,10 +205,10 @@ static std::string getSubtargetFeatureString(const vc::CompileOptions &Opts) { + return Features.getString(); + } + +-static CodeGenOpt::Level getCodeGenOptLevel(const vc::CompileOptions &Opts) { ++static CodeGenOptLevel getCodeGenOptLevel(const vc::CompileOptions &Opts) { + if (Opts.CodegenOptLevel == vc::OptimizerLevel::None) +- return CodeGenOpt::None; +- return CodeGenOpt::Default; ++ return CodeGenOptLevel::None; ++ return CodeGenOptLevel::Default; + } + + static TargetOptions getTargetOptions(const vc::CompileOptions &Opts) { +@@ -356,7 +356,7 @@ createTargetMachine(const vc::CompileOptions &Opts, + + const TargetOptions Options = getTargetOptions(Opts); + +- CodeGenOpt::Level OptLevel = getCodeGenOptLevel(Opts); ++ CodeGenOptLevel OptLevel = getCodeGenOptLevel(Opts); + auto BC = std::make_unique( + createBackendOptions(Opts), + createBackendData(ExtData, vc::is32BitArch(TheTriple) ? 32 : 64)); +@@ -494,7 +494,7 @@ static void populateCodeGenPassManager(const vc::CompileOptions &Opts, + constexpr bool DisableIrVerifier = true; + #endif + +- auto FileType = IGCLLVM::TargetMachine::CodeGenFileType::CGFT_AssemblyFile; ++ auto FileType = IGCLLVM::TargetMachine::CodeGenFileType::AssemblyFile; + + llvm::raw_null_ostream NOS; + [[maybe_unused]] bool AddPasses = +@@ -578,13 +578,13 @@ struct DiagnosticContext { + bool Failed; + }; + +-void diagnosticHandlerCallback(const DiagnosticInfo &DI, void *Context) { ++void diagnosticHandlerCallback(const DiagnosticInfo *DI, void *Context) { + auto *DiagCtx = static_cast(Context); +- auto Severity = DI.getSeverity(); ++ auto Severity = DI->getSeverity(); + + DiagnosticPrinterRawOStream DP(DiagCtx->Log); + DiagCtx->Log << LLVMContext::getDiagnosticMessagePrefix(Severity) << ": "; +- DI.print(DP); ++ DI->print(DP); + DiagCtx->Log << "\n"; + + if (Severity == DS_Error) +@@ -639,7 +639,7 @@ vc::Compile(ArrayRef Input, const vc::CompileOptions &Opts, + "Compiler error emitted in IR adaptors"); + + Triple TheTriple = overrideTripleWithVC(M.getTargetTriple()); +- M.setTargetTriple(TheTriple.getTriple()); ++ M.setTargetTriple(TheTriple); + + auto ExpTargetMachine = createTargetMachine(Opts, ExtData, TheTriple); + if (!ExpTargetMachine) +@@ -735,7 +735,7 @@ parseApiOptions(StringSaver &Saver, StringRef ApiOptions, bool IsStrictMode) { + [&Opt](const char *ArgStr) { return Opt == ArgStr; }); + }; + const std::string VCCodeGenOptName = +- Options.getOption(OPT_vc_codegen).getPrefixedName(); ++ Options.getOption(OPT_vc_codegen).getPrefixedName().str(); + if (HasOption(VCCodeGenOptName)) { + const unsigned FlagsToInclude = + IGC::options::VCApiOption | IGC::options::IGCApiOption; +@@ -744,7 +744,7 @@ parseApiOptions(StringSaver &Saver, StringRef ApiOptions, bool IsStrictMode) { + } + // Deprecated -cmc parsing just for compatibility. + const std::string IgcmcOptName = +- Options.getOption(OPT_igcmc).getPrefixedName(); ++ Options.getOption(OPT_igcmc).getPrefixedName().str(); + if (HasOption(IgcmcOptName)) { + llvm::errs() + << "'" << IgcmcOptName +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXAnalysisDumper.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXAnalysisDumper.cpp +index e97e0de..c7a7f77 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXAnalysisDumper.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXAnalysisDumper.cpp +@@ -112,7 +112,7 @@ bool GenXAnalysisDumper::runOnFunction(Function &F) { + + auto DumpName = makeOutputName(F, "f_" + DumpNamePrefix, DumpNameSuffix); + const auto &BC = getAnalysis(); +- vc::produceAuxiliaryShaderDumpFile(BC, DumpName, OS.str()); ++ vc::produceAuxiliaryShaderDumpFile(BC, DumpName, StringRef(SerializedData)); + return false; + } + +@@ -126,6 +126,6 @@ bool GenXModuleAnalysisDumper::runOnModule(Module &M) { + + auto DumpName = DumpNamePrefix + "M_" + DumpNameSuffix; + const auto &BC = getAnalysis(); +- vc::produceAuxiliaryShaderDumpFile(BC, DumpName, OS.str()); ++ vc::produceAuxiliaryShaderDumpFile(BC, DumpName, StringRef(SerializedData)); + return false; + } +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXBaling.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXBaling.cpp +index e5fdbee..ca4f30c 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXBaling.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXBaling.cpp +@@ -1532,13 +1532,13 @@ void GenXBaling::processMainInst(Instruction *Inst, int IntrinID) { + // SimplifyInstruction does not work on abs, so we roll our own for now. + if (auto C = dyn_cast(Inst->getOperand(0))) { + if (C->getType()->isIntOrIntVectorTy()) { +- if (!ConstantExpr::getICmp(CmpInst::ICMP_SLT, C, ++ if (!ConstantFoldCompareInstruction(CmpInst::ICMP_SLT, C, + Constant::getNullValue(C->getType())) + ->isNullValue()) + + C = ConstantExpr::getNeg(C); + } else { +- if (!ConstantExpr::getFCmp(CmpInst::FCMP_OLT, C, ++ if (!ConstantFoldCompareInstruction(CmpInst::FCMP_OLT, C, + Constant::getNullValue(C->getType())) + ->isNullValue()) { + C = llvm::ConstantFoldUnaryOpOperand( +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXBiFPrepare.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXBiFPrepare.cpp +index 715f237..249cee3 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXBiFPrepare.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXBiFPrepare.cpp +@@ -115,7 +115,7 @@ bool GenXBiFPrepare::runOnModule(Module &M) { + + bool GenXBiFPrepare::isLibraryFunction(const Function &F) { + const auto &Name = F.getName(); +- return Name.startswith(vc::LibraryFunctionPrefix); ++ return Name.starts_with(vc::LibraryFunctionPrefix); + } + + bool GenXBiFPrepare::isNeededForTarget(const Function &F, +@@ -138,17 +138,17 @@ bool GenXBiFPrepare::isNeededForTarget(const Function &F, + // Get rid of double precision fdiv and fsqrt emulation functions if target + // hw has native support + if (!ST.emulateFDivFSqrt64() && +- (Name.startswith("fdiv") || Name.startswith("fsqrt"))) ++ (Name.starts_with("fdiv") || Name.starts_with("fsqrt"))) + return false; + } + +- if (ST.hasIEEEDivSqrt() && Name.startswith("fdiv") && ++ if (ST.hasIEEEDivSqrt() && Name.starts_with("fdiv") && + F.getReturnType()->getScalarType()->isFloatTy()) + return false; + + static SmallVector IDivRem = {"udiv", "sdiv", "urem", "srem"}; + auto IsDivRem = llvm::any_of( +- IDivRem, [&Name](const auto &Arg) { return Name.startswith(Arg); }); ++ IDivRem, [&Name](const auto &Arg) { return Name.starts_with(Arg); }); + if (IsDivRem && ST.hasIntDivRem32() && + !F.getReturnType()->isIntOrIntVectorTy(64)) + return false; +@@ -156,34 +156,34 @@ bool GenXBiFPrepare::isNeededForTarget(const Function &F, + static SmallVector FpCvt = {"fptosi", "fptoui", "sitofp", + "uitofp"}; + auto IsFpCvt = llvm::any_of( +- FpCvt, [&Name](const auto &Arg) { return Name.startswith(Arg); }); ++ FpCvt, [&Name](const auto &Arg) { return Name.starts_with(Arg); }); + if (IsFpCvt && !ST.emulateLongLong()) + return false; + + // Remove L1-L2-L3 atomic routines for the platforms which don't support + // efficient 64-bit addressing +- if (!ST.supportEfficient64b() && Name.startswith("atomic") && +- Name.endswith("v3i8")) ++ if (!ST.supportEfficient64b() && Name.starts_with("atomic") && ++ Name.ends_with("v3i8")) + return false; + +- if (!ST.hasMxfp() && Name.startswith("mxfp")) ++ if (!ST.hasMxfp() && Name.starts_with("mxfp")) + return false; + + bool Is64bit = + IsDouble || F.getReturnType()->getScalarType()->isIntegerTy(64); + +- if (!ST.hasLocalIntegerCas64() && Is64bit && Name.startswith("atomic_slm")) ++ if (!ST.hasLocalIntegerCas64() && Is64bit && Name.starts_with("atomic_slm")) + return false; + + if (ST.hasInstrLocalAtomicAddF32() && + F.getReturnType()->getScalarType()->isFloatTy() && +- Name.startswith("atomic_slm")) ++ Name.starts_with("atomic_slm")) + return false; + + // only half precision uses i32 data type + if (ST.hasInstrAtomicHF16() && + F.getReturnType()->getScalarType()->isIntegerTy(32) && +- Name.startswith("atomic_")) ++ Name.starts_with("atomic_")) + return false; + + return true; +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXBuiltinFunctions.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXBuiltinFunctions.cpp +index dc4d307..bb79f1e 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXBuiltinFunctions.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXBuiltinFunctions.cpp +@@ -71,7 +71,7 @@ private: + StringRef Suffix = ""); + + std::unique_ptr loadBuiltinLib(LLVMContext &Ctx, const DataLayout &DL, +- const std::string &Triple); ++ const Triple &Triple); + + Value *createLibraryCall(Instruction &I, Function *Func, + ArrayRef Args); +@@ -518,7 +518,7 @@ Function *GenXBuiltinFunctions::getBuiltinDeclaration(Module &M, StringRef Name, + + std::unique_ptr + GenXBuiltinFunctions::loadBuiltinLib(LLVMContext &Ctx, const DataLayout &DL, +- const std::string &Triple) { ++ const Triple &Triple) { + MemoryBufferRef BiFBuffer = + getAnalysis().getBiFModule(BiFKind::VCBuiltins); + +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp +index 1b2b444..59a369d 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp +@@ -2151,7 +2151,7 @@ static void diagnoseInlineAsm(llvm::LLVMContext &Context, + DiagnosticSeverity DS_type) { + auto *CI = cast(Inst); + const InlineAsm *IA = cast(IGCLLVM::getCalledValue(CI)); +- const std::string Message = '"' + IA->getAsmString() + '"' + Suffix; ++ const std::string Message = std::string(1, 34) + IA->getAsmString().str() + std::string(1, 34) + Suffix; + vc::diagnose(Context, "GenXCisaBuilder", Message.c_str(), DS_type, + vc::WarningName::Generic, Inst); + } +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXCoalescing.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXCoalescing.cpp +index 8856cc8..6a3b604 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXCoalescing.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXCoalescing.cpp +@@ -1527,7 +1527,7 @@ void GenXCoalescing::processKernelArgs(FunctionGroup *FG) { + auto F = FG->getHead(); + if (!vc::isKernel(F)) + return; +- Instruction *InsertBefore = F->front().getFirstNonPHIOrDbg(); ++ Instruction *InsertBefore = &*F->front().getFirstNonPHIOrDbg(); + vc::KernelMetadata KM{F}; + unsigned Idx = 0; + for (auto ai = F->arg_begin(), ae = F->arg_end(); ai != ae; ++ai) { +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXDebugInfo.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXDebugInfo.cpp +index c279758..ccdf11e 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXDebugInfo.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXDebugInfo.cpp +@@ -1,1598 +1,13 @@ +-/*========================== begin_copyright_notice ============================ +- +-Copyright (C) 2020-2026 Intel Corporation +- +-SPDX-License-Identifier: MIT +- +-============================= end_copyright_notice ===========================*/ +- +-#include "FunctionGroup.h" +- + #include "GenXDebugInfo.h" +-#include "GenXTargetMachine.h" +-#include "GenXVisaRegAlloc.h" +- +-#include "vc/Support/BackendConfig.h" +-#include "vc/Support/GenXDiagnostic.h" +-#include "vc/Utils/GenX/KernelInfo.h" +- +-#include "visa/include/visaBuilder_interface.h" +- +-#include "DebugInfo/DwarfCompileUnit.hpp" +-#include "DebugInfo/StreamEmitter.hpp" +-#include "DebugInfo/VISADebugInfo.hpp" +-#include "DebugInfo/VISAIDebugEmitter.hpp" +-#include "DebugInfo/VISAModule.hpp" +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#include "llvmWrapper/IR/DerivedTypes.h" +- +-#include "Probe/Assertion.h" +- +-#include +- +-// +-/// GenXDebugInfo +-/// ------------- +-/// +-/// The goal of the pass is to provide debug information for each generated +-/// genisa instruction (if such information is available). The debug +-/// information is encoded in DWARF format. +-/// +-/// Ultimately, the pass gets data from 2 sources: +-/// +-/// 1. LLVM debug information encoded in LLVM IR itself. It captures the +-/// important pieces of the source language's Abstract Syntax Tree and +-/// maps it onto LLVM code. +-/// LLVM framework should maintain it automatically, given that we follow +-/// relatively simple rules while designing IR transformations: +-/// https://llvm.org/docs/HowToUpdateDebugInfo.html +-/// +-/// 2. Debug information obtained from the finalizer. This information is +-/// encoded in some proprietary format (blob) and contains the following: +-/// a. mapping between vISA and genISA instructions +-/// b. live intervals of the virtual registers, information about spilled +-/// values, etc. +-/// c. call frame information +-/// +-/// The pass feeds the above information to the DebugInfo library which in turn +-/// produces the final DWARF. +-/// +-/// Operation of the pass +-/// ^^^^^^^^^^^^^^^^^^^^^ +-/// +-/// The pass assumes that some data is already being made available by other +-/// passes/analysis. +-/// +-/// * FunctionGroupAnalysis: +-/// provides information about the overall "structure" +-/// of the program: functions, stack calls, indirect calls, subroutines and +-/// relationships. +-/// +-/// * GenXModule: +-/// 1. for each LLVM Function provides information about +-/// LLVM instruction -> vISA instructions mapping. This information is +-/// produced/maintained during operation of CISABuilder pass. +-/// 2. for each LLVM Function provides access to a corresponding +-/// *VISAKernel* object. +-/// +-/// * GenXVisaRegAlloc: +-/// provides the mapping between LLVM values and virtual registers. +-/// +-/// * GenXCisaBuilder: +-/// provides access to VISABuilder, which allows us to have access to +-/// VISAKernel objects (some Functions from LLVM IR, like the ones +-/// representing kernel spawns these) that contain: +-/// a. debug information maintained by finalizer (see above) +-/// b. the respected gen binaries +-/// +-/// Data Structures +-/// ^^^^^^^^^^^^^^^ +-/// +-/// Since data is aggregated from different sources, some extra data structures +-/// are used to simplify bookkeeping. +-/// +-/// - *genx::di::VisaMapping* +-/// provides the mapping from LLMV IR instruction to vISA instruction index, +-/// that represents the first vISA instruction spawned by the LLVM IR +-/// instruction. A single LLVM IR instruction can spawn several +-/// vISA instructions - currently the number of spawned instructions is +-/// derived implicitly (which is not always correct but works in most of the +-/// cases). +-/// +-/// - *ModuleToVisaTransformInfo* +-/// Provides information about how LLVM IR functions are mapped onto various +-/// vISA (and genISA) objects. Allows us to answer the following questions: +-/// - Is a function a subroutine on vISA level? +-/// - If a function is a subroutine, what LLVM IR function corresponds to +-/// vISA-level "owner" of this subroutine. An "owner" in this case is +-/// either VISAFunction or VISAKernel containing the subroutine. +-/// - Is LLVM IR function a "primary" one? "primary" function is the one +-/// that spawns vISA entity that gets compiled into a separate gen object +-/// - For an arbitrary LLVM IR function, get a set of "primary" functions +-/// that contain a compiled vISA corresponding to the function in question +-/// compiled into their gen objects. +-/// +-/// - *ProgramInfo* +-/// A transient object that groups several llvm Functions that are eventually +-/// get compiled into a single gen entity. A separate elf file with the +-/// debug information is generated for each gen entity. +-/// The grouping is with a help of *ModuleToVisaTransformInfo* object. +-/// +-/// - *GenObjectWrapper* +-/// Wrapper over the data produced by the finalizer after a kernel gets +-/// compiled. Simplifies/Provides access to the following: +-/// + gen binary (gen machine instructions) +-/// + decoded *gen* debug info and raw gen debug info blob +-/// + FINALIZER_INFO structure +-/// +-/// - *CompiledVisaWrapper* +-/// For an arbitrary pair of llvm IR Function and VISAKernel objects, +-/// does the following: +-/// + Validates that IR Function and VISAKernel object are related (that is +-/// the vISA spawned by IR Function is owned by the VISAKernel. +-/// + Provides services to access *gen* debug info from an appropriate +-/// compiled object (*gen* debug info concept). +-/// +-/// *GenXFunction* +-/// An object that loosely resembles MachineFunction from the LLVM Machine IR. +-/// This is an object that for a given LLVM IR Function provides access to: +-/// - LLVM IR Function +-/// - VisaMapping +-/// - Subtarget +-/// - data from CompiledVisaWrapper/GenObjectWrapper +-/// - GenXVisaRegAlloc +-/// GenXFunctoin serves as a primary method to communicate with the DebugInfo +-/// library. The data these objects hold allow us to reason about the debug +-/// information for any Gen construct (instruction, variable, etc). +-/// +-/// Examples +-/// ^^^^^^^^ +-/// +-/// Examples below use the following naming conventions: +-/// K* - kernel function +-/// L* - subroutine (non-inlined function) +-/// S* - simple stack call +-/// I* - indirectly-called function +-/// +-/// FunctionGroup construction peculiarities. +-/// +-/// When function groups are constructed, we do some peculiar transformations. +-/// +-/// Case_1 (FG): +-/// Source Code: { K1 calls L1, K2 calls L1 } +-/// IR after function groups: { G1 = {K1, L1}, G2 = { K2, L1'} }, +-/// where L1' is a clone of L1. +-/// Case_2 (FG): +-/// Source Code: { K1 calls S_1, both call L1 }. +-/// IR after function groups: { G1 = {K1, L1, S1, L1' } }. +-/// Case_3 (FG): +-/// Source Code: { K1 calls I1 and I2 }. +-/// IR after function grups { G1 = {K1}, G2 = {I1}, G3={I2} }. +-/// +-/// VISA/genISA construction peculiarities. +-/// +-/// Case 1: +-/// Source code: K1, K2. +-/// Compilation phase: +-/// two function groups are created, K1 and K2 are heads. +-/// two different VISAKernel produced. +-/// DebugInfoGeneration: +-/// Decoded Debug info for each VISAKernel contains: +-/// one compiled object description. +-/// two "*.elf" files are created. +-/// +-/// Case 2: +-/// Source code: K1, S1. K1 calls S1. +-/// Compilation phase: +-/// 1 function group is created, K1 is the head. +-/// 1 VISAKernel and 1 VISAFunction are created. +-/// DebugInfoGeneratation: +-/// Decoded debug info contains *2* compiled objects. +-/// Each object has separate vISA indexes - visa instructions are +-/// counted separately. Still, both are compiled into the same gen +-/// object, so only one "*.elf" file is emitted. +-/// +-/// Case 3: +-/// Source code: K1, I1. K1 calls I1 +-/// Compilation phase: +-/// 1 function group is created, K1 is the head. +-/// Somehow 2 VISAKernels are created. +-/// DebugInfoGeneratation: +-/// Decoded debug info contains *1* compiled objects (but we have 2 +-/// VISAKernel). +-/// In the end, we emit two "*.elf" files. +-/// +-//===----------------------------------------------------------------------===// +- +-#define DEBUG_TYPE "GENX_DEBUG_INFO" + + using namespace llvm; + +-static cl::opt +- DbgOpt_ValidationEnable("vc-dbginfo-enable-validation", cl::init(false), +- cl::Hidden, +- cl::desc("same as IGC_DebugInfoValidation")); +-static cl::opt +- DbgOpt_ZeBinCompatible("vc-experimental-dbg-info-zebin-compatible", +- cl::init(false), cl::Hidden, +- cl::desc("same as IGC_ZeBinCompatibleDebugging")); +- +-static cl::opt DbgOpt_VisaTransformInfoPath( +- "vc-dump-module-to-visa-transform-info-path", cl::init(""), cl::Hidden, +- cl::desc("filename into which MVTI is dumped")); +- +-static cl::opt DbgOpt_VisaMappingPrintDbgIntrinsics( +- "vc-dump-visa-mapping-includes-dbgintrin", cl::init(false), cl::Hidden, +- cl::desc("include llvm.dbg intrinsics in visa mapping dump")); +- +-template +-using EmplaceTy = decltype(std::declval().emplace()); +- +-template +-using CheckedEmplace = decltype(std::declval>().second); +- +-template +-using IsCheckedEmplace = std::is_same>; +- +-template +-using IsNonCheckedEmplace = +- std::is_same, typename ContainerT::iterator>; +- +-// Naive function that checks the presence of copies. +-// Container must be multimap-like, values must be comparable. +-template +-static bool hasCopy(const ContainerT &Container, +- typename ContainerT::iterator ToCheck) { +- auto Range = Container.equal_range(ToCheck->first); +- auto Result = std::count_if(Range.first, Range.second, [ToCheck](auto It) { +- return It.second == ToCheck->second; +- }); +- +- return Result > 1; +-} +- +-// checkedEmplace for multimap-like containers. It will be called if +-// Container.emplace() returns Container::iterator. For such containers, emplace +-// will always happen and therefore copies can be silently inserted. +-template +-static std::enable_if_t::value, void> +-checkedEmplace(ContainerT &Container, ArgsT &&...Args) { +- auto Result = Container.emplace(std::forward(Args)...); +- IGC_ASSERT_MESSAGE(!hasCopy(Container, Result), +- "a copy of the existing element was emplaced"); +- (void)Result; +-} +- +-// checkedEmplace for map/set-like containers. If Container.emplace() returns a +-// pair whose second element has bool type, this version will be called. +-template +-static std::enable_if_t::value, void> +-checkedEmplace(ContainerT &Container, ArgsT &&...Args) { +- auto Result = Container.emplace(std::forward(Args)...); +- IGC_ASSERT_MESSAGE(Result.second, "unexpected insertion failure"); +- (void)Result; +-} +- +-static bool compareFunctionNames(const Function *LF, const Function *RF) { +- IGC_ASSERT(LF && RF); +- return LF->getName() > RF->getName(); +-} +- +-template +-static std::vector +-extractSortedFunctions(const ContainerT &C) { +- std::vector Result; +- std::transform(C.begin(), C.end(), std::back_inserter(Result), +- [](const auto &It) { return It.first; }); +- std::sort(Result.begin(), Result.end(), compareFunctionNames); +- return Result; +-} +- +-// NOTE: the term "program" is used to avoid a potential confusion +-// since the term "kernel" may introduce some ambiguity. +-// Here a "program" represents a kind of wrapper over a standalone vISA +-// object (which currently is produced by function groups and +-// visa-external functions) that finally gets compiled into a stand-alone +-// gen entity (binary gen kernel) with some auxiliary information +-struct ProgramInfo { +- struct FunctionInfo { +- const genx::di::VisaMapping &VisaMapping; +- const Function &F; +- }; +- +- const ModuleToVisaTransformInfo &MVTI; +- VISAKernel &CompiledKernel; +- std::vector FIs; +- +- const Function &getEntryPoint() const { +- IGC_ASSERT(!FIs.empty()); +- return FIs.front().F; +- } +-}; +- +-// +-// ModuleToVisaTransformInfo +-// Proides information about how LLVM IR functions are mapped onto various +-// vISA (and genISA) objects. +-class ModuleToVisaTransformInfo { +- using FunctionMapping = +- std::unordered_map; +- using FunctionMultiMapping = +- std::unordered_multimap; +- // Note: pointer to VISAKernel can represent either a true kernel or +- // VISAFunction, depending on the context (this is vISA API limitation) +- using FunctionToVisaMapping = +- std::unordered_map; +- +- // Records information about a subroutine and its "owner". The "owner" of +- // a subroutine is LLVM IR function that spawned *VISAFunction* that contains +- // vISA for the subroutine +- FunctionMapping SubroutineOwnersInfo; +- // "VisaSpanwer" is LLVM IR function that produce *VISAFunction*. +- // Different "VISAFunctions" have their own vISA instructions enumerated +- // separately, but they still can be compiled into a single gen object. +- // does not allow to distiguish those easily). +- FunctionToVisaMapping VisaSpawnerInfo; +- // A separate gen object is usually produced by KernelFunctions - +- // the relationsip between VisaFunction and KernelFunctions is +- // captured by the FunctionOnwers +- FunctionMultiMapping FunctionOwnersInfo; +- // "Kernel functions" are functions that produce genISA object +- // Usually these are FuntionGroup heads, but indirectly-called functions +- // also spawn there own genISA object files +- FunctionToVisaMapping KernelFunctionsInfo; +- std::unordered_set SourceLevelKernels; +- +- void extractSubroutineInfo(const Function &F, VISABuilder &VB, +- const FunctionGroupAnalysis &FGA); +- void extractVisaFunctionsEmitters(VISABuilder &VB, +- const FunctionGroupAnalysis &FGA, +- const CallGraph &CG); +- +- void extractKernelFunctions(VISABuilder &VB, +- const FunctionGroupAnalysis &FGA); +- void propagatePrimaryEmitter(const CallGraphNode &CGNode, +- const Function &PrimaryEmitter); +- +-public: +- void print(raw_ostream &OS) const; +- void dump() const; +- +- bool isSourceLevelKernel(const Function *F) const { +- return SourceLevelKernels.find(F) != SourceLevelKernels.end(); +- } +- bool isKernelFunction(const Function *F) const { +- return KernelFunctionsInfo.find(F) != KernelFunctionsInfo.end(); +- } +- bool isSubroutine(const Function *F) const { +- return SubroutineOwnersInfo.find(F) != SubroutineOwnersInfo.end(); +- } +- bool isVisaFunctionSpawner(const Function *F) const { +- return VisaSpawnerInfo.find(F) != VisaSpawnerInfo.end(); +- } +- // Currently unused +- // For a provided function returns visa object spawned by this function +- // visa object can represent either VISAKernel or VISAFunction +- VISAKernel *getSpawnedVISAFunction(const Function *F) const { +- IGC_ASSERT(!isSubroutine(F)); +- auto SpawnedInfoIt = VisaSpawnerInfo.find(F); +- IGC_ASSERT_EXIT(SpawnedInfoIt != VisaSpawnerInfo.end()); +- return SpawnedInfoIt->second; +- } +- // Return a VISA object representing true *VISAKernel* that was spawned by a +- // "kernel" function: IR kernel or indirectly called function. +- VISAKernel *getSpawnedVISAKernel(const Function *F) const { +- IGC_ASSERT_MESSAGE(isKernelFunction(F), +- "kernel or indirectly called function is expected"); +- return KernelFunctionsInfo.at(F); +- } +- // return an "owner" (on vISA level) of the function representing a +- // subroutine +- const Function *getSubroutineOwner(const Function *F) const { +- IGC_ASSERT(isSubroutine(F)); +- auto SubInfoIt = SubroutineOwnersInfo.find(F); +- IGC_ASSERT_EXIT(SubInfoIt != SubroutineOwnersInfo.end()); +- return SubInfoIt->second; +- } +- // PrimaryEmitter is the function spawning gen object, that +- // contains the vISA object emitted by the specified function +- std::unordered_set +- getPrimaryEmittersForVisa(const Function *F, bool Strict = true) const; +- +- std::vector getPrimaryFunctions() const { +- return extractSortedFunctions(KernelFunctionsInfo); +- } +- +- std::vector +- getSecondaryFunctions(const Function *PrimaryFunction) const; +- +- ModuleToVisaTransformInfo(VISABuilder &VB, const FunctionGroupAnalysis &FGA, +- const CallGraph &CG); +-}; +- +-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) +-void ModuleToVisaTransformInfo::dump() const { +- print(errs()); +- errs() << "\n"; +-} +-#endif +- +-void ModuleToVisaTransformInfo::print(raw_ostream &OS) const { +- +- auto KernelFunctions = extractSortedFunctions(KernelFunctionsInfo); +- auto Subroutines = extractSortedFunctions(SubroutineOwnersInfo); +- auto VisaProducers = extractSortedFunctions(VisaSpawnerInfo); +- +- // filter-out kernel functions +- VisaProducers.erase( +- std::remove_if(VisaProducers.begin(), VisaProducers.end(), +- [this](const auto *F) { return isKernelFunction(F); }), +- VisaProducers.end()); +- +- auto PrintFunctionSubroutines = [this, &OS, &Subroutines](const Function *F, +- StringRef Prefix) { +- unsigned Counter = 0; +- for (const auto *LF : Subroutines) { +- if (getSubroutineOwner(LF) != F) +- continue; +- OS << Prefix << "l." << Counter << " " << LF->getName() << "\n"; +- ++Counter; +- } +- }; +- +- for (size_t i = 0, NumKF = KernelFunctions.size(); i < NumKF; ++i) { +- const auto *KF = KernelFunctions[i]; +- OS << "[" << i << "] " << KF->getName() << " " +- << (SourceLevelKernels.count(KF) != 0 ? "(K)" : "(I)") << "\n"; +- +- PrintFunctionSubroutines(KF, " "); +- +- unsigned SubIdx = 0; +- for (const auto *VF : VisaProducers) { +- if (!getPrimaryEmittersForVisa(VF).count(KF)) +- continue; +- OS << " v." << SubIdx << " " << VF->getName() << "\n"; +- PrintFunctionSubroutines(VF, " "); +- ++SubIdx; +- } +- } +-} +- +-using VMap = decltype(genx::di::VisaMapping::V2I); +-// Compare two functions with their visa-mapping +-static bool visaMapComparer(const Function *L, const Function *R, +- const VMap &V2IL, const VMap &V2IR) { +- if (V2IL.empty() && V2IR.empty()) +- return compareFunctionNames(L, R); +- if (V2IL.empty()) +- return false; +- if (V2IR.empty()) +- return true; +- return V2IL.front().VisaIdx < V2IR.front().VisaIdx; +-} +- +-std::vector ModuleToVisaTransformInfo::getSecondaryFunctions( +- const Function *PrimaryFunction) const { +- auto IsSecondaryFunction = [PrimaryFunction, this](const Function *F) { +- if (F == PrimaryFunction) +- return false; +- return getPrimaryEmittersForVisa(F).count(PrimaryFunction) > 0; +- }; +- IGC_ASSERT(isKernelFunction(PrimaryFunction)); +- std::vector Result; +- for (const auto &[F, VF] : SubroutineOwnersInfo) { +- (void)VF; +- if (IsSecondaryFunction(F)) +- Result.push_back(F); +- } +- for (const auto &[F, VF] : VisaSpawnerInfo) { +- (void)VF; +- if (IsSecondaryFunction(F)) +- Result.push_back(F); +- } +- return Result; +-} +- +-void ModuleToVisaTransformInfo::extractSubroutineInfo( +- const Function &F, VISABuilder &VB, const FunctionGroupAnalysis &FGA) { +- IGC_ASSERT(isVisaFunctionSpawner(&F)); +- const auto *Gr = FGA.getAnyGroup(&F); +- IGC_ASSERT(Gr); +- for (const Function *SF : *Gr) { +- if (isKernelFunction(SF)) +- continue; +- if (vc::requiresStackCall(SF)) +- continue; +- checkedEmplace(SubroutineOwnersInfo, SF, &F); +- } +-} +- +-std::unordered_set +-ModuleToVisaTransformInfo::getPrimaryEmittersForVisa(const Function *F, +- bool Strict) const { +- if (isSubroutine(F)) { +- auto SubrInfoIt = SubroutineOwnersInfo.find(F); +- IGC_ASSERT_EXIT(SubrInfoIt != SubroutineOwnersInfo.end()); +- const Function *SubrOwner = SubrInfoIt->second; +- IGC_ASSERT(SubrOwner); +- IGC_ASSERT(!isSubroutine(SubrOwner)); +- return getPrimaryEmittersForVisa(SubrOwner); +- } +- auto InfoRange = FunctionOwnersInfo.equal_range(F); +- std::unordered_set PrimaryEmitters; +- std::transform(InfoRange.first, InfoRange.second, +- std::inserter(PrimaryEmitters, PrimaryEmitters.end()), +- [](auto It) { return It.second; }); +- +- if (Strict) { +- IGC_ASSERT_MESSAGE(!PrimaryEmitters.empty(), +- "could not get primary emitter"); +- } +- return PrimaryEmitters; +-} +- +-void ModuleToVisaTransformInfo::propagatePrimaryEmitter( +- const CallGraphNode &CGNode, const Function &PrimaryEmitter) { +- const Function *F = CGNode.getFunction(); +- if (!F) +- return; +- if (vc::requiresStackCall(F) && !vc::isIndirect(F)) { +- auto Range = FunctionOwnersInfo.equal_range(F); +- auto Res = +- std::find_if(Range.first, Range.second, [&PrimaryEmitter](auto Info) { +- return Info.second == &PrimaryEmitter; +- }); +- // F -> PrimaryEmitter was already inserted. It happens if a recursion +- // exists. +- if (Res != Range.second) +- return; +- LLVM_DEBUG(dbgs() << "setting <" << PrimaryEmitter.getName() +- << "> as a host of the stack-callee <" << F->getName() +- << ">\n"); +- checkedEmplace(FunctionOwnersInfo, F, &PrimaryEmitter); +- } +- +- for (const auto &CalleeCGNode : CGNode) +- propagatePrimaryEmitter(*CalleeCGNode.second, PrimaryEmitter); +-} +- +-void ModuleToVisaTransformInfo::extractVisaFunctionsEmitters( +- VISABuilder &VB, const FunctionGroupAnalysis &FGA, const CallGraph &CG) { +- +- // We've already collected kernels and indirect functions into +- // `KernelFunctionsInfo`. +- for (const auto &[F, VF] : KernelFunctionsInfo) { +- (void)VF; +- const auto *KFNode = CG[F]; +- IGC_ASSERT(KFNode); +- propagatePrimaryEmitter(*KFNode, *F); +- } +- // Collect owned functions as a set of unique keys of FunctionOwnersInfo. +- std::unordered_set OwnedFunctions; +- std::transform(FunctionOwnersInfo.begin(), FunctionOwnersInfo.end(), +- std::inserter(OwnedFunctions, OwnedFunctions.begin()), +- [](auto Info) { return Info.first; }); +- +- for (const Function *F : OwnedFunctions) { +- // Skip "KernelFunctions" because they have already been processed. +- if (vc::isIndirect(F) || vc::isKernel(F)) +- continue; +- VISAKernel *VF = VB.GetVISAKernel(F->getName().str()); +- checkedEmplace(VisaSpawnerInfo, F, VF); +- extractSubroutineInfo(*F, VB, FGA); +- } +-} +- +-void ModuleToVisaTransformInfo::extractKernelFunctions( +- VISABuilder &VB, const FunctionGroupAnalysis &FGA) { +- for (const auto *FG : FGA.AllGroups()) { +- for (const Function *F : *FG) { +- if (!vc::isIndirect(F) && !vc::isKernel(F)) +- continue; +- VISAKernel *VF = VB.GetVISAKernel(F->getName().str()); +- if (vc::isKernel(F)) +- checkedEmplace(SourceLevelKernels, F); +- checkedEmplace(KernelFunctionsInfo, F, VF); +- checkedEmplace(VisaSpawnerInfo, F, VF); +- checkedEmplace(FunctionOwnersInfo, F, F); +- +- extractSubroutineInfo(*F, VB, FGA); +- } +- } +-} +- +-ModuleToVisaTransformInfo::ModuleToVisaTransformInfo( +- VISABuilder &VB, const FunctionGroupAnalysis &FGA, const CallGraph &CG) { +- extractKernelFunctions(VB, FGA); +- extractVisaFunctionsEmitters(VB, FGA, CG); +- +- for (const auto *FG : FGA.AllGroups()) { +- for (const Function *F : *FG) { +- if (isSourceLevelKernel(F)) +- IGC_ASSERT(isKernelFunction(F) && isVisaFunctionSpawner(F) && +- !isSubroutine(F)); +- if (isKernelFunction(F)) +- IGC_ASSERT(isVisaFunctionSpawner(F) && !isSubroutine(F)); +- if (isVisaFunctionSpawner(F)) +- IGC_ASSERT(!isSubroutine(F)); +- if (isSubroutine(F)) +- IGC_ASSERT(!isVisaFunctionSpawner(F) && !isKernelFunction(F)); +- } +- } +-} +- +-namespace { +- +-class GenObjectWrapper { +- vISA::FINALIZER_INFO *JitInfo = nullptr; +- std::unique_ptr VISADebugInfo; +- // TODO: remove this once DbgDecoder is refactored +- unsigned GenDbgInfoDataSize = 0; +- void *GenDbgInfoDataPtr = nullptr; +- +- int GenBinaryDataSize = 0; +- void *GenBinaryDataPtr = nullptr; +- +- const Function &EntryPoint; +- +- std::string ErrMsg; +- +- void setError(const Twine &Msg) { +- ErrMsg.append((Msg + "<" + EntryPoint.getName().str() + ">").str()); +- +- LLVM_DEBUG(dbgs() << "GOW creation for <" << EntryPoint.getName() +- << "> aborted: " << Msg.str()); +- } +- +-public: +- const Function &getEntryPoint() const { return EntryPoint; } +- +- ArrayRef getGenDebug() const { +- IGC_ASSERT(GenDbgInfoDataPtr); +- return ArrayRef(static_cast(GenDbgInfoDataPtr), +- GenDbgInfoDataSize); +- } +- +- ArrayRef getGenBinary() const { +- IGC_ASSERT(GenBinaryDataPtr); +- return ArrayRef(static_cast(GenBinaryDataPtr), +- GenBinaryDataSize); +- } +- +- const IGC::VISADebugInfo &getVISADebugInfo() const { +- IGC_ASSERT(VISADebugInfo); +- return *VISADebugInfo; +- } +- +- const vISA::FINALIZER_INFO &getJitInfo() const { +- IGC_ASSERT(!hasErrors() && JitInfo); +- return *JitInfo; +- }; +- +- GenObjectWrapper(VISAKernel &VK, const Function &F); +- ~GenObjectWrapper() { releaseDebugInfoResources(); } +- GenObjectWrapper(const GenObjectWrapper &) = delete; +- GenObjectWrapper &operator=(const GenObjectWrapper &) = delete; +- +- bool hasErrors() const { return !ErrMsg.empty(); } +- +- const std::string &getError() const { return ErrMsg; } +- +- void releaseDebugInfoResources() { +- if (!GenDbgInfoDataPtr) { +- IGC_ASSERT(GenDbgInfoDataSize == 0); +- return; +- } +- freeBlock(GenDbgInfoDataPtr); +- GenDbgInfoDataPtr = nullptr; +- GenDbgInfoDataSize = 0; +- } +- +- void printDecodedGenXDebug(raw_ostream &OS) const { +- IGC_ASSERT(!hasErrors()); +- LLVM_DEBUG(dbgs() << "GenXDebugInfo size: " << GenDbgInfoDataSize << "\n"); +- getVISADebugInfo().print(OS); +- } +-}; +- +-GenObjectWrapper::GenObjectWrapper(VISAKernel &VK, const Function &F) +- : EntryPoint(F) { +- if (VK.GetJitInfo(JitInfo) != 0) { +- setError("could not extract jitter info"); +- return; +- } +- IGC_ASSERT(JitInfo); +- +- // Extract Gen Binary (will need it for line table generation) +- VK.GetGenxBinary(GenBinaryDataPtr, GenBinaryDataSize); +- if (GenBinaryDataSize <= 0) { +- setError("could not extract gen binary from finalizer"); +- return; +- } +- +- if (VK.GetGenxDebugInfo(GenDbgInfoDataPtr, GenDbgInfoDataSize) != 0) { +- setError("could not get gen debug information from finalizer"); +- return; +- } +- if (!GenDbgInfoDataPtr) { +- setError("gen debug information reported by finalizer is inconsistent"); +- return; +- } +- VISADebugInfo = std::make_unique(GenDbgInfoDataPtr); +-}; +- +-class CompiledVisaWrapper { +- +- using FinalizedDI = IGC::DbgDecoder::DbgInfoFormat; +- +- const GenObjectWrapper &GOW; +- // underlying data is owned by VISADebugInfo, owned by GOW +- const FinalizedDI *VisaKernelDI = nullptr; +- +- std::string ErrMsg; +- +- void setErrorForFunction(const std::string &Err, const Function &F) { +- ErrMsg.append(Err).append("<").append(F.getName().str()).append(">"); +- +- LLVM_DEBUG(dbgs() << "CW creation for <" << F.getName() +- << "> aborted: " << ErrMsg); +- } +- +-public: +- const vISA::FINALIZER_INFO &getJitInfo() const { return GOW.getJitInfo(); }; +- +- const FinalizedDI &getFinalizerDI() const { +- IGC_ASSERT(ErrMsg.empty() && VisaKernelDI); +- return *VisaKernelDI; +- } +- +- const IGC::VISADebugInfo &getVISADebugInfo() const { +- return GOW.getVISADebugInfo(); +- } +- +- ArrayRef getGenDebug() const { return GOW.getGenDebug(); } +- ArrayRef getGenBinary() const { return GOW.getGenBinary(); } +- +- const std::string &getError() const { return ErrMsg; } +- +- bool hasErrors() const { return !getError().empty(); } +- +- CompiledVisaWrapper(CompiledVisaWrapper &&Other) = default; +- CompiledVisaWrapper(const Function &F, StringRef CompiledObjectName, +- const GenObjectWrapper &GOWIn) +- : GOW(GOWIn) { +- struct Gen2VisaIdx { +- unsigned GenOffset; +- unsigned VisaIdx; +- }; +- LLVM_DEBUG(dbgs() << "creating CW for <" << F.getName() << ">, using <" +- << CompiledObjectName +- << "> as a CompiledObject moniker\n"); +- IGC_ASSERT(!GOW.hasErrors()); +- +- const auto &CO = GOW.getVISADebugInfo().getRawDecodedData().compiledObjs; +- auto FoundCoIt = std::find_if( +- CO.begin(), CO.end(), [&CompiledObjectName](const auto &DI) { +- return CompiledObjectName == StringRef(DI.kernelName); +- }); +- VisaKernelDI = (FoundCoIt == CO.end()) ? nullptr : &*FoundCoIt; +- if (!VisaKernelDI) { +- setErrorForFunction("could not find debug information for", F); +- return; +- } +- if (VisaKernelDI->CISAIndexMap.empty()) { +- setErrorForFunction("empty CisaIndexMap for", F); +- return; +- } +- +- std::vector Gen2Visa; +- std::transform( +- VisaKernelDI->CISAIndexMap.begin(), VisaKernelDI->CISAIndexMap.end(), +- std::back_inserter(Gen2Visa), +- [](const auto &V2G) { return Gen2VisaIdx{V2G.second, V2G.first}; }); +- +- const auto &GenBinary = GOW.getGenBinary(); +- // Make Sure that gen isa indeces are inside GenBinary +- const bool InBounds = +- std::all_of(Gen2Visa.begin(), Gen2Visa.end(), [&](const auto &Idx) { +- // <= Is because last index can be equal to the binary size +- return Idx.GenOffset <= GenBinary.size(); +- }); +- if (!InBounds) { +- setErrorForFunction("fatal error (debug info). inconsistent gen->visa " +- "mapping: gen index is out of bounds", +- F); +- return; +- } +- +- // Make Sure that gen isa indeces are unique and sorted +- const bool Sorted = std::is_sorted( +- Gen2Visa.begin(), Gen2Visa.end(), +- [](const auto &L, const auto &R) { return L.GenOffset < R.GenOffset; }); +- const bool Validated = +- Sorted && (Gen2Visa.end() == +- std::adjacent_find(Gen2Visa.begin(), Gen2Visa.end(), +- [](const auto &L, const auto &R) { +- return L.GenOffset == R.GenOffset; +- })); +- if (!Validated) { +- setErrorForFunction("fatal error (debug info). inconsistent gen->visa " +- "mapping: gen index are not ordered properly", +- F); +- return; +- } +- } +-}; +- +-class GenXFunction final : public IGC::VISAModule { +- +-public: +- GenXFunction(const GenXSubtarget &STIn, const GenXVisaRegAlloc &RAIn, +- const GenXBaling &BAn, const Function &F, +- CompiledVisaWrapper &&CW, const genx::di::VisaMapping &V2I, +- const ModuleToVisaTransformInfo &MVTI, bool IsPrimary) +- : F{F}, ST{STIn}, VisaMapping{V2I}, CompiledVisa{std::move(CW)}, RA{RAIn}, +- BA{BAn}, MVTI(MVTI), VISAModule(const_cast(&F), IsPrimary) { +- +- if (MVTI.isSubroutine(&F)) +- SetType(ObjectType::SUBROUTINE); +- else if (MVTI.isKernelFunction(&F)) +- SetType(ObjectType::KERNEL); +- else +- SetType(ObjectType::STACKCALL_FUNC); +- } +- +- ~GenXFunction() { +- LLVM_DEBUG(dbgs() << "~GenXFunction() called for " << F.getName() << "\n"); +- } +- GenXFunction(const GenXFunction &) = delete; +- GenXFunction &operator=(const GenXFunction &) = delete; +- +- llvm::StringRef GetVISAFuncName() const override { +- // TODO: this is not quite correct since VISA names is defined by VISA label +- return F.getName(); +- } +- +- bool isSubroutine() const { return GetType() == ObjectType::SUBROUTINE; } +- +- bool isStackCall() const { return GetType() == ObjectType::STACKCALL_FUNC; } +- +- bool isKernel() const { return GetType() == ObjectType::KERNEL; } +- +- const IGC::VISAObjectDebugInfo & +- getVisaObjectDI(const IGC::VISADebugInfo &VDI) const override { +- StringRef CompiledObjectName = +- isSubroutine() ? MVTI.getSubroutineOwner(&F)->getName() : F.getName(); +- return VDI.getVisaObjectByCompliledObjectName(CompiledObjectName); +- } +- +- unsigned int getUnpaddedProgramSize() const override { +- return CompiledVisa.getGenBinary().size(); +- } +- +- bool isLineTableOnly() const override { +- IGC_ASSERT_MESSAGE(0, "isLineTableOnly()"); +- return false; +- } +- unsigned getPrivateBaseReg() const override { +- IGC_ASSERT_MESSAGE(0, "getPrivateBaseReg() - not implemented"); +- return 0; +- } +- unsigned getGRFSizeInBytes() const override { return ST.getGRFByteSize(); } +- unsigned getNumGRFs() const override { +- return CompiledVisa.getJitInfo().stats.numGRFTotal; +- } +- unsigned getPointerSize() const override { +- return F.getParent()->getDataLayout().getPointerSize(); +- } +- uint64_t getTypeSizeInBits(Type *Ty) const override { +- return F.getParent()->getDataLayout().getTypeSizeInBits(Ty); +- } +- ArrayRef getGenDebug() const override { +- return CompiledVisa.getGenDebug(); +- } +- ArrayRef getGenBinary() const override { +- return CompiledVisa.getGenBinary(); +- } +- +- const IGC::VISADebugInfo &getVISADebugInfo() const { +- return CompiledVisa.getVISADebugInfo(); +- } +- +- const IGC::DbgDecoder::DbgInfoFormat &getFinalizerDI() const { +- return CompiledVisa.getFinalizerDI(); +- } +- +- const genx::di::VisaMapping &getVisaMapping() const { return VisaMapping; } +- +- static constexpr unsigned RdIndex = +- GenXIntrinsic::GenXRegion::RdIndexOperandNum; +- static constexpr unsigned RdVstride = +- GenXIntrinsic::GenXRegion::RdVStrideOperandNum; +- static constexpr unsigned RdWidth = +- GenXIntrinsic::GenXRegion::RdWidthOperandNum; +- static constexpr unsigned RdStride = +- GenXIntrinsic::GenXRegion::RdStrideOperandNum; +- static constexpr unsigned RdNumOp = +- GenXIntrinsic::GenXRegion::OldValueOperandNum; +- +- using OffsetsVector = llvm::SmallVector; +- +- std::tuple +- calculateBaledLocation(const CallInst *UseInst, const GenXBaling &BA, +- const DataLayout &DL) const { +- IGC_ASSERT(UseInst); +- if (!GenXIntrinsic::isRdRegion(UseInst)) +- return std::make_tuple(UseInst, OffsetsVector()); +- auto BI = BA.getBaleInfo(UseInst); +- +- if (BI.Type != genx::BaleInfo::RDREGION || +- !dyn_cast(UseInst->getOperand(RdIndex)) || +- BI.isOperandBaled(RdNumOp) || !BA.isBaled(UseInst)) +- return std::make_tuple(UseInst, OffsetsVector()); +- +- auto GetSignConstant = [](Value *Operand) { +- auto *CI = cast(Operand); +- return CI->getSExtValue(); +- }; +- +- // In this place comes rdregion, whose operand is not baled - here we +- // build location for its operand +- LLVM_DEBUG(dbgs() << " Found Bale candidate for propagation:\n"; +- UseInst->dump();); +- auto *VTy = dyn_cast(UseInst->getType()); +- // TODO: Investigate scalar +- if (!VTy) +- return std::make_tuple(UseInst, OffsetsVector()); +- auto Vstride = GetSignConstant(UseInst->getOperand(RdVstride)); +- auto Width = GetSignConstant(UseInst->getOperand(RdWidth)); +- auto Stride = GetSignConstant(UseInst->getOperand(RdStride)); +- // Convert start index from bytes to bits +- auto StartIdx = +- GetSignConstant(UseInst->getOperand(RdIndex)) * vc::ByteBits; +- auto ElSizeInBits = vc::getTypeSize(VTy->getElementType(), &DL).inBits(); +- IGC_ASSERT(Width); +- unsigned NumElements = VTy->getNumElements() / Width; +- OffsetsVector Offsets; +- +- for (unsigned I = 0; I < NumElements; ++I) { +- for (unsigned J = 0; J < Width; ++J) { +- auto CurrOffset = StartIdx + ElSizeInBits * (I * Vstride + J * Stride); +- // Check type overflow +- IGC_ASSERT(CurrOffset <= std::numeric_limits::max()); +- if ((CurrOffset % getGRFSizeInBits()) + ElSizeInBits > +- getGRFSizeInBits()) { +- LLVM_DEBUG(dbgs() << " Fail to generate Bale location element has " +- "crossGRF access\n"); +- return std::make_tuple(UseInst, OffsetsVector()); +- } +- Offsets.push_back(CurrOffset); +- } +- } +- // Replace value to source of rdregion +- return std::make_tuple(UseInst->getOperand(RdNumOp), std::move(Offsets)); +- } +- +- IGC::VISAVariableLocation +- GetVariableLocation(const Instruction *DbgInst) const override { +- using Location = IGC::VISAVariableLocation; +- auto EmptyLoc = [this](StringRef Reason) { +- LLVM_DEBUG(dbgs() << " Empty Location Returned (" << Reason +- << ")\n <<<\n"); +- return Location(this); +- }; +- +- IGC_ASSERT(isa(DbgInst)); +- +- LLVM_DEBUG(dbgs() << " >>>\n GetVariableLocation for " << *DbgInst +- << "\n"); +- const DIVariable *VarDescr = nullptr; +- if (const auto *PDbgAddrInst = dyn_cast(DbgInst)) { +- VarDescr = PDbgAddrInst->getVariable(); +- } else if (const auto *PDbgValInst = dyn_cast(DbgInst)) { +- VarDescr = PDbgValInst->getVariable(); +- } else { +- return EmptyLoc("unsupported Debug Intrinsic"); +- } +- const Value *DbgValue = +- IGCLLVM::getVariableLocation(cast(DbgInst)); +- +- OffsetsVector Offsets; +- if (auto *UseInst = dyn_cast_or_null(DbgValue)) { +- std::tie(DbgValue, Offsets) = +- calculateBaledLocation(UseInst, BA, F.getParent()->getDataLayout()); +- } +- +- IGC_ASSERT(VarDescr); +- if (!DbgValue) { +- if (const auto *LocalVar = dyn_cast(VarDescr)) +- if (LocalVar->isParameter()) +- return EmptyLoc("unsupported parameter description"); +- return EmptyLoc("unsupported DbgInst"); +- } +- IGC_ASSERT(DbgValue); +- LLVM_DEBUG(dbgs() << " Value:" << *DbgValue << "\n"); +- LLVM_DEBUG(dbgs() << " Var: " << VarDescr->getName() +- << "/Type:" << *VarDescr->getType() << "\n"); +- if (isa(DbgValue)) { +- return EmptyLoc("UndefValue"); +- } +- if (auto *ConstVal = dyn_cast(DbgValue)) { +- LLVM_DEBUG(dbgs() << " ConstantLoc\n <<<\n"); +- return Location(ConstVal, this); +- } +- +- auto *Reg = getRegisterForValue(DbgValue); +- if (!Reg) { +- return EmptyLoc("could not find virtual register"); +- } +- +- return Location(Reg->Num, std::move(Offsets), this); +- } +- +- void UpdateVisaId() override { +- // do nothing (the moment we need to advance index is controlled explicitly) +- } +- void ValidateVisaId() override { +- // do nothing (we don't need validation since VISA is built already) +- } +- uint16_t GetSIMDSize() const override { return 1; } +- +- void *getPrivateBase() const override { return nullptr; }; +- void setPrivateBase(void *) override {}; +- +- bool hasPTO() const override { return false; } +- int getPTOReg() const override { return -1; } +- int getFPReg() const override { return -1; } +- uint64_t getFPOffset() const override { return 16; } +- +- bool usesSlot1ScratchSpill() const override { return false; } +- +- const GenXVisaRegAlloc::Reg *getRegisterForValue(const Value *V) const { +- return RA.getRegForValueOrNull(const_cast(V)); +- } +- +- void printVisaMapping(raw_ostream &OS, unsigned Level = 0) const { +- const std::string Prefix(Level * 4, ' '); +- OS << Prefix; +- OS << "VisaMapping for <" << getFunction()->getName() << ">("; +- for (auto Arg : enumerate(getFunction()->args())) { +- OS << "a" << Arg.index() << ":"; +- auto *Reg = getRegisterForValue(&Arg.value()); +- if (Reg) +- Reg->print(OS); +- else +- OS << "_"; +- OS << ";"; +- } +- OS << ") - {\n"; +- +- size_t SkippedIndex = 0; +- size_t SkippedCount = 0; +- auto PrintSkippedAndClearCount = [&SkippedIndex, &SkippedCount, &Prefix, +- &OS]() { +- if (!SkippedCount) +- return; +- OS << Prefix << " <" << SkippedIndex << ">: " +- << "skipped " << SkippedCount << " llvm.dbg.* intrinsics\n"; +- SkippedCount = 0; +- }; +- +- for (const auto &Mapping : VisaMapping.V2I) { +- auto VisaIndexCurr = Mapping.VisaIdx; +- auto VisaIndexNext = Mapping.VisaIdx + Mapping.VisaCount; +- const auto *Inst = Mapping.Inst; +- +- if (Mapping.IsDbgInst && !DbgOpt_VisaMappingPrintDbgIntrinsics) { +- if (!SkippedCount) +- SkippedIndex = VisaIndexCurr; +- ++SkippedCount; +- continue; +- } +- +- PrintSkippedAndClearCount(); +- +- OS << Prefix; +- OS << " [" << VisaIndexCurr << ";" << VisaIndexNext << "): "; +- +- auto *Reg = getRegisterForValue(Inst); +- OS << "<"; +- if (Reg) +- Reg->print(OS); +- OS << "> "; +- +- Inst->print(OS); +- +- if (auto DbgLoc = Inst->getDebugLoc()) { +- StringRef Filename = DbgLoc->getFilename(); +- auto Line = DbgLoc->getLine(); +- auto Col = DbgLoc->getColumn(); +- OS << " [" << Filename << ":" << Line << "," << Col << "]"; +- } +- OS << "\n"; +- } +- +- PrintSkippedAndClearCount(); +- +- OS << Prefix; +- OS << "}\n"; +- } +- +- const ModuleToVisaTransformInfo &getMVTI() const { return MVTI; } +- +-private: +- const Function &F; +- const GenXSubtarget &ST; +- const genx::di::VisaMapping &VisaMapping; +- CompiledVisaWrapper CompiledVisa; +- const GenXVisaRegAlloc &RA; +- const GenXBaling &BA; +- const ModuleToVisaTransformInfo &MVTI; +-}; +- +-using VisaMapType = std::vector; +- +-[[maybe_unused]] static bool validateVisaMapping(const VisaMapType &V2I) { +- // Last used visa index +- auto ExpectedNextId = V2I.cbegin()->VisaIdx; +- for (auto MappingIt = V2I.cbegin(); MappingIt != V2I.cend(); ++MappingIt) { +- auto VisaIndexCurr = MappingIt->VisaIdx; +- auto VisaIndexNext = MappingIt->VisaIdx + MappingIt->VisaCount; +- const auto *Inst = MappingIt->Inst; +- +- IGC_ASSERT(VisaIndexCurr <= VisaIndexNext); +- if (MappingIt->IsDbgInst) { +- IGC_ASSERT(isa(MappingIt->Inst)); +- IGC_ASSERT(MappingIt->VisaCount == 0); +- } else { +- // Check that in map only real instructions +- IGC_ASSERT(MappingIt->VisaCount > 0); +- } +- +- // ExpectedNextId (from the previous iteration) should be the same as +- // the current index +- // In other words, we should have no gaps in vISA mapping +- if (ExpectedNextId != VisaIndexCurr) { +- LLVM_DEBUG(dbgs() << "Detected inconsistency, current visa-Index: " +- << VisaIndexCurr +- << " is not equal to expected visa-Index: " +- << ExpectedNextId << "\n"); +- return false; +- } +- +- ExpectedNextId = VisaIndexNext; +- // Mapping may interupts in calls, because functions may be inlined. +- // Just do not check ExpectedNextId for the next instruction. +- if (isa(Inst) && !isa(Inst)) +- ExpectedNextId = std::next(MappingIt)->VisaIdx; +- +- // Marker that this is the last instruction of a BB +- bool lastBlockInst = ((std::next(MappingIt) != V2I.cend()) && +- (MappingIt->Inst->getParent() != +- (std::next(MappingIt)->Inst->getParent()))); +- +- // Current implementation does not create mapping for vISA labels. +- // That's why the next mapping is considered to be correct: +- // VisaMapping: [18;20): br label %1, !dbg !147 +- // VisaMapping: [21;22): %icmp = icmp ult i32 %.06, 8, !dbg !148 +- // In visaasm-file 20-th instruction will be a bb-label: +- // lifetime.start V51 /// $19 +- // BB_1: +- // cmp.lt (M1, 1) P1 V105(0,0)<0;1,0> 0x8:ud /// $21 +- // We avoid checking of the ExpectedNextId in such cases - [21;22). +- if (lastBlockInst) { +- ExpectedNextId = std::next(MappingIt)->VisaIdx; +- } +- } +- return true; +-} +- +-static void processGenXFunction(IGC::IDebugEmitter &Emitter, GenXFunction &GF) { +- Emitter.setCurrentVISA(&GF); +- const auto &V2I = GF.getVisaMapping().V2I; +- for (auto MappingIt = V2I.cbegin(); MappingIt != V2I.cend(); ++MappingIt) { +- auto VisaIndexCurr = MappingIt->VisaIdx; +- auto VisaIndexNext = MappingIt->VisaIdx + MappingIt->VisaCount; +- +- // Note: "index - 1" is because we mimic index values as if they were +- // before corresponding instructions were inserted +- GF.SetVISAId(VisaIndexCurr - 1); +- // we need this const_cast because of the flawed VISA Emitter API +- auto *Inst = const_cast(MappingIt->Inst); +- Emitter.BeginInstruction(Inst); +- GF.SetVISAId(VisaIndexNext - 1); +- Emitter.EndInstruction(Inst); +- } +-} +- +-using GenXObjectHolder = std::unique_ptr; +-GenXObjectHolder buildGenXFunctionObject(const ModuleToVisaTransformInfo &MVTI, +- const GenObjectWrapper &GOW, +- const ProgramInfo::FunctionInfo &FI, +- const GenXSubtarget &ST, +- const GenXVisaRegAlloc &RA, +- const GenXBaling &BA) { +- StringRef CompiledObjectName = FI.F.getName(); +- if (MVTI.isSubroutine(&FI.F)) +- CompiledObjectName = MVTI.getSubroutineOwner(&FI.F)->getName(); +- +- CompiledVisaWrapper CW(FI.F, CompiledObjectName, GOW); +- if (CW.hasErrors()) +- vc::diagnose(FI.F.getContext(), "GenXDebugInfo", CW.getError()); +- +- bool IsPrimaryFunction = &GOW.getEntryPoint() == &FI.F; +- return std::make_unique( +- ST, RA, BA, FI.F, std::move(CW), FI.VisaMapping, MVTI, IsPrimaryFunction); +-} +- +-using GenXObjectHolderList = std::vector; +-GenXObjectHolderList translateProgramInfoToGenXFunctionObjects( +- const GenObjectWrapper &GOW, const ProgramInfo &PI, const GenXSubtarget &ST, +- const std::vector &RAs, +- const std::vector &BAs) { +- const auto &MVTI = PI.MVTI; +- GenXObjectHolderList GenXFunctionHolders; +- IGC_ASSERT(PI.FIs.size() == RAs.size()); +- IGC_ASSERT(BAs.size() == RAs.size()); +- auto Zippy = llvm::zip(RAs, BAs); +- std::transform(PI.FIs.begin(), PI.FIs.end(), Zippy.begin(), +- std::back_inserter(GenXFunctionHolders), +- [&ST, &MVTI, &GOW](const auto &FI, const auto &ZIP) { +- const GenXVisaRegAlloc *RA = std::get<0>(ZIP); +- const GenXBaling *BA = std::get<1>(ZIP); +- return buildGenXFunctionObject(MVTI, GOW, FI, ST, *RA, *BA); +- }); +- return GenXFunctionHolders; +-} +- +-using GenXFunctionPtrList = std::vector; +-using GenXFunctionConstPtrList = std::vector; +-GenXFunctionPtrList initializeDebugEmitter( +- IGC::IDebugEmitter &Emitter, const IGC::DebugEmitterOpts &DebugOpts, +- const ProgramInfo &PI, GenXObjectHolderList &&GFsHolderIn) { +- +- GenXFunctionPtrList GFPointers; +- for (auto &&GF : GFsHolderIn) { +- GFPointers.push_back(GF.get()); +- +- if (GF->isPrimaryFunc()) { +- Emitter.Initialize(std::move(GF), DebugOpts); +- } else { +- Emitter.registerVISA(GFPointers.back()); +- Emitter.resetModule(std::move(GF)); +- } +- } +- // Currently Debug Info Emitter expects that GenXFunctions are +- // processed in the same order as they appear in the visa object +- // Ideally, the order should not matter - but we are not there yet +- // due to DwarfEmitter limitations +- std::sort(GFPointers.begin(), GFPointers.end(), [](auto *LGF, auto *RGF) { +- const auto &LDI = LGF->getFinalizerDI(); +- const auto &RDI = RGF->getFinalizerDI(); +- if (LDI.relocOffset == RDI.relocOffset) +- return visaMapComparer(LGF->getFunction(), RGF->getFunction(), +- LGF->getVisaMapping().V2I, +- RGF->getVisaMapping().V2I); +- return LDI.relocOffset < RDI.relocOffset; +- }); +- return GFPointers; +-} +- +-std::string makePrefixForAuxiliaryShaderDump(const GenXBackendConfig &BC, +- const GenObjectWrapper &GOW) { +- +- const auto &KernelName = GOW.getEntryPoint().getName(); +- std::string Prefix = "dbginfo_"; +- if (!BC.dbgInfoDumpsNameOverride().empty()) +- Prefix.append(BC.dbgInfoDumpsNameOverride()).append("_"); +- Prefix.append(KernelName.str()); +- return Prefix; +-} +- +-std::string serializeDecodedGenDebugInfo(const GenObjectWrapper &GOW) { +- std::string Result; +- llvm::raw_string_ostream OS(Result); +- GOW.printDecodedGenXDebug(OS); +- OS.flush(); +- return Result; +-} +- +-using GFPtrSet = std::unordered_set; +-using KernelAndVisaOwners = +- std::pair; +- +-void printVisaMapping(raw_ostream &OS, const GenXFunction &GF, unsigned Level, +- GFPtrSet &NotPrinted) { +- IGC_ASSERT(NotPrinted.count(&GF)); +- GF.printVisaMapping(OS, Level); +- NotPrinted.erase(&GF); +-} +- +-void printSubroutinesVisaMapping(raw_ostream &OS, +- GenXFunctionConstPtrList Subroutines, +- unsigned Level, GFPtrSet &NotPrinted) { +- // Sort is needed for printing elements with less visa index first +- std::sort(Subroutines.begin(), Subroutines.end(), +- [](const GenXFunction *L, const GenXFunction *R) { +- const auto &V2IL = L->getVisaMapping().V2I; +- const auto &V2IR = R->getVisaMapping().V2I; +- return visaMapComparer(L->getFunction(), R->getFunction(), V2IL, +- V2IR); +- }); +- for (const auto *SGF : Subroutines) +- printVisaMapping(OS, *SGF, Level, NotPrinted); +-} +- +-void printVisaOwnerVisaMapping(raw_ostream &OS, const GenXFunction &VO, +- const GenXFunctionConstPtrList &Subroutines, +- unsigned Level, GFPtrSet &NotPrinted) { +- printVisaMapping(OS, VO, Level, NotPrinted); +- +- printSubroutinesVisaMapping(OS, Subroutines, Level + 1, NotPrinted); +-} +- +-bool isStackCallGF(const GenXFunction *GF) { +- IGC_ASSERT(GF); +- return GF->isStackCall(); +-} +- +-bool isKernelGF(const GenXFunction *GF) { +- IGC_ASSERT(GF); +- return GF->isKernel(); +-} +- +-KernelAndVisaOwners +-getKernelAndVisaOwners(const GenXFunctionConstPtrList &GFs) { +- IGC_ASSERT(!GFs.empty()); +- GenXFunctionConstPtrList StackCalls; +- std::copy_if(GFs.begin(), GFs.end(), std::back_inserter(StackCalls), +- isStackCallGF); +- IGC_ASSERT(std::count_if(GFs.begin(), GFs.end(), isKernelGF) == 1); +- auto KGFIt = std::find_if(GFs.begin(), GFs.end(), isKernelGF); +- IGC_ASSERT_EXIT(KGFIt != GFs.end()); +- return {*KGFIt, std::move(StackCalls)}; +-} +- +-GenXFunctionConstPtrList +-getSubroutinesForVisaOwner(const GenXFunction &VO, +- const GenXFunctionConstPtrList &AllGFs) { +- const auto &MVTI = VO.getMVTI(); +- GenXFunctionConstPtrList Result; +- std::copy_if(AllGFs.begin(), AllGFs.end(), std::back_inserter(Result), +- [&MVTI, &VO](const auto *GF) { +- if (!GF->isSubroutine()) +- return false; +- const Function *F = GF->getFunction(); +- return MVTI.getSubroutineOwner(F) == VO.getFunction(); +- }); +- return Result; +-} +- +-std::string serializeGFsVisaMapping(const GenXFunctionConstPtrList &GFs) { +- std::string Result; +- llvm::raw_string_ostream OS(Result); +- +- GFPtrSet ToPrint(GFs.begin(), GFs.end()); +- +- auto [KGF, VisaOwners] = getKernelAndVisaOwners(GFs); +- +- printVisaOwnerVisaMapping(OS, *KGF, getSubroutinesForVisaOwner(*KGF, GFs), 0, +- ToPrint); +- for (const auto *SpawnerGF : VisaOwners) +- printVisaOwnerVisaMapping(OS, *SpawnerGF, +- getSubroutinesForVisaOwner(*SpawnerGF, GFs), 1, +- ToPrint); +- IGC_ASSERT(ToPrint.empty()); +- +- OS.flush(); +- return Result; +-} +- +-void dumpDebugInfo(const GenXBackendConfig &BC, const GenObjectWrapper &GOW, +- const GenXFunctionPtrList &GFs, const ArrayRef ElfBin, +- const ArrayRef ErrLog) { +- +- auto DecodedGenInfo = serializeDecodedGenDebugInfo(GOW); +- GenXFunctionConstPtrList CGFs; +- std::copy(GFs.begin(), GFs.end(), std::back_inserter(CGFs)); +- auto SerializedVisaMapping = serializeGFsVisaMapping(CGFs); +- +- std::string Prefix = makePrefixForAuxiliaryShaderDump(BC, GOW); +- +- vc::produceAuxiliaryShaderDumpFile(BC, Twine(Prefix) + "_dwarf.elf", ElfBin); +- vc::produceAuxiliaryShaderDumpFile(BC, Twine(Prefix) + "_gen.dump", +- GOW.getGenDebug()); +- vc::produceAuxiliaryShaderDumpFile(BC, Twine(Prefix) + "_gen.decoded.dump", +- DecodedGenInfo); +- vc::produceAuxiliaryShaderDumpFile(BC, Twine(Prefix) + "_visa.mapping", +- SerializedVisaMapping); +- +- if (!ErrLog.empty()) +- vc::produceAuxiliaryShaderDumpFile(BC, Twine(Prefix) + ".dbgerr", ErrLog); +-} +- +-} // namespace +- +-void GenXDebugInfo::processKernel(const IGC::DebugEmitterOpts &DebugOpts, +- const ProgramInfo &PI) { +- +- IGC_ASSERT_MESSAGE(!PI.FIs.empty(), +- "Program must include at least one function"); +- IGC_ASSERT_MESSAGE(PI.MVTI.getPrimaryEmittersForVisa(&PI.getEntryPoint()) +- .count(&PI.getEntryPoint()) == 1, +- "The head of ProgramInfo is expected to be a kernel"); +- +- GenObjectWrapper GOW(PI.CompiledKernel, PI.getEntryPoint()); +- if (GOW.hasErrors()) +- vc::diagnose(GOW.getEntryPoint().getContext(), "GenXDebugInfo", +- GOW.getError()); +- +- LLVM_DEBUG(GOW.printDecodedGenXDebug(dbgs())); +- +- auto Deleter = [](IGC::IDebugEmitter *Emitter) { +- IGC::IDebugEmitter::Release(Emitter); +- }; +- using EmitterHolder = std::unique_ptr; +- EmitterHolder Emitter(IGC::IDebugEmitter::Create(), Deleter); +- +- const auto &ST = getAnalysis() +- .getTM() +- .getGenXSubtarget(); +- auto *FGA = &getAnalysis(); +- std::vector VisaRegAllocs; +- std::vector BalingList; +- for (const auto &FP : PI.FIs) { +- FunctionGroup *currentFG = FGA->getAnyGroup(&FP.F); +- VisaRegAllocs.push_back( +- &(getAnalysis().getFGPassImpl(currentFG))); +- GenXBaling *Baling = +- &(getAnalysis().getFGPassImpl(currentFG)); +- BalingList.push_back(Baling); +- } +- +- GenXFunctionPtrList GFPointers = +- initializeDebugEmitter(*Emitter, DebugOpts, PI, +- translateProgramInfoToGenXFunctionObjects( +- GOW, PI, ST, VisaRegAllocs, BalingList)); +- +- auto &KF = GOW.getEntryPoint(); +- IGC_ASSERT(ElfOutputs.count(&KF) == 0); +- auto &ElfBin = ElfOutputs[&KF]; +- +- for (auto *GF : GFPointers) { +- LLVM_DEBUG(dbgs() << "\n--- Processing GenXFunction: " +- << GF->getFunction()->getName().str() << " ---\n"); +- LLVM_DEBUG(GF->printVisaMapping(dbgs())); +- IGC_ASSERT(validateVisaMapping(GF->getVisaMapping().V2I)); +- processGenXFunction(*Emitter, *GF); +- bool ExpectMore = GF != GFPointers.back(); +- LLVM_DEBUG(dbgs() << "--- Starting Debug Info Finalization (final: " +- << !ExpectMore << ") ---\n"); +- auto Out = Emitter->Finalize(!ExpectMore, GF->getVISADebugInfo()); +- if (!ExpectMore) { +- ElfBin = std::move(Out); +- } else { +- IGC_ASSERT(Out.empty()); +- } +- LLVM_DEBUG(dbgs() << "--- \\ Debug Info Finalized / ---\n"); +- } +- +- [[maybe_unused]] const auto &KernelName = KF.getName(); +- LLVM_DEBUG(dbgs() << "got Debug Info for <" << KernelName.str() << "> " +- << "- " << ElfBin.size() << " bytes\n"); +- +- const auto &BC = getAnalysis(); +- if (BC.dbgInfoDumpsEnabled()) { +- const auto &ErrLog = Emitter->getErrors(); +- dumpDebugInfo(BC, GOW, GFPointers, ElfBin, {ErrLog.data(), ErrLog.size()}); +- } +- +- return; +-} +- + void GenXDebugInfo::cleanup() { ElfOutputs.clear(); } + +-void GenXDebugInfo::getAnalysisUsage(AnalysisUsage &AU) const { +- AU.addRequired(); +- AU.addRequired(); +- AU.addRequired(); +- AU.addRequired(); +- AU.addRequired(); +- AU.addRequired(); +- AU.addRequired(); +- AU.setPreservesAll(); +-} +- +-void GenXDebugInfo::processPrimaryFunction( +- const IGC::DebugEmitterOpts &Opts, const ModuleToVisaTransformInfo &MVTI, +- const GenXModule &GM, VISABuilder &VB, const Function &PF) { +- LLVM_DEBUG(dbgs() << "DbgInfo: processing <" << PF.getName() << ">\n"); +- IGC_ASSERT(MVTI.isKernelFunction(&PF)); +- VISAKernel *VKEntry = MVTI.getSpawnedVISAKernel(&PF); +- IGC_ASSERT(VKEntry); +- +- using FunctionInfo = ProgramInfo::FunctionInfo; +- std::vector FIs; +- FIs.push_back(FunctionInfo{*GM.getVisaMapping(&PF), PF}); +- auto SecondaryFunctions = MVTI.getSecondaryFunctions(&PF); +- // Sorting by visa-elements, because finalizer expect sorted sequence +- // for emmiting correct debug hi/low pc for functions +- std::sort(SecondaryFunctions.begin(), SecondaryFunctions.end(), +- [&GM](const Function *L, const Function *R) { +- const auto &V2IL = GM.getVisaMapping(L)->V2I; +- const auto &V2IR = GM.getVisaMapping(R)->V2I; +- return visaMapComparer(L, R, V2IL, V2IR); +- }); +- std::transform(SecondaryFunctions.begin(), SecondaryFunctions.end(), +- std::back_inserter(FIs), [&GM](const Function *F) { +- const auto &Mapping = *GM.getVisaMapping(F); +- return FunctionInfo{Mapping, *F}; +- }); +- processKernel(Opts, ProgramInfo{MVTI, *VKEntry, std::move(FIs)}); +-} +- +-static void fillDbgInfoOptions(const GenXBackendConfig &BC, +- IGC::DebugEmitterOpts &DebugOpts) { +- DebugOpts.DebugEnabled = true; +- +- if (BC.emitDWARFDebugInfoForZeBin() || DbgOpt_ZeBinCompatible) { +- DebugOpts.ZeBinCompatible = true; +- DebugOpts.EnableRelocation = true; +- DebugOpts.EnforceAMD64Machine = true; +- } +- if (BC.enableDebugInfoValidation() || DbgOpt_ValidationEnable) { +- DebugOpts.EnableDebugInfoValidation = true; +- } +-} ++void GenXDebugInfo::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); } + + bool GenXDebugInfo::runOnModule(Module &M) { +- auto &GM = getAnalysis(); +- // Note: we check that MVTI dumps were not requested here, +- // since it is possible to request those without the presence of +- // debug information +- if (!GM.emitDebugInformation() && DbgOpt_VisaTransformInfoPath.empty()) +- return false; +- +- const auto &BC = getAnalysis(); +- const FunctionGroupAnalysis &FGA = getAnalysis(); +- +- VISABuilder *VB = GM.GetCisaBuilder(); +- if (GM.HasInlineAsm() || !BC.getVISALTOStrings().empty()) +- VB = GM.GetVISAAsmReader(); +- IGC_ASSERT(VB); +- +- const auto &CG = getAnalysis().getCallGraph(); +- ModuleToVisaTransformInfo MVTI(*VB, FGA, CG); +- if (!DbgOpt_VisaTransformInfoPath.empty()) { +- std::string SerializedMVTI; +- llvm::raw_string_ostream OS(SerializedMVTI); +- MVTI.print(OS); +- vc::produceAuxiliaryShaderDumpFile(BC, DbgOpt_VisaTransformInfoPath, +- OS.str()); +- } +- LLVM_DEBUG(MVTI.print(dbgs()); dbgs() << "\n"); +- +- if (!GM.emitDebugInformation()) +- return false; +- +- IGC::DebugEmitterOpts DebugInfoOpts; +- fillDbgInfoOptions(BC, DebugInfoOpts); +- +- for (const Function *PF : MVTI.getPrimaryFunctions()) +- processPrimaryFunction(DebugInfoOpts, MVTI, GM, *VB, *PF); +- ++ (void)M; + return false; + } + +@@ -1607,13 +22,5 @@ ModulePass *createGenXDebugInfoPass() { + + } // namespace llvm + +-INITIALIZE_PASS_BEGIN(GenXDebugInfo, "GenXDebugInfo", "GenXDebugInfo", false, +- true /*analysis*/) +-INITIALIZE_PASS_DEPENDENCY(FunctionGroupAnalysis) +-INITIALIZE_PASS_DEPENDENCY(GenXBackendConfig) +-INITIALIZE_PASS_DEPENDENCY(GenXModule) +-INITIALIZE_PASS_DEPENDENCY(TargetPassConfig) +-INITIALIZE_PASS_DEPENDENCY(GenXVisaRegAllocWrapper) +-INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass) +-INITIALIZE_PASS_END(GenXDebugInfo, "GenXDebugInfo", "GenXDebugInfo", false, +- true /*analysis*/) ++INITIALIZE_PASS_BEGIN(GenXDebugInfo, "GenXDebugInfo", "GenXDebugInfo", false, true /*analysis*/) ++INITIALIZE_PASS_END(GenXDebugInfo, "GenXDebugInfo", "GenXDebugInfo", false, true /*analysis*/) +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXGASDynamicResolution.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXGASDynamicResolution.cpp +index 014612d..ddb0157 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXGASDynamicResolution.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXGASDynamicResolution.cpp +@@ -183,7 +183,7 @@ static void createScatterWithNewAS(IntrinsicInst &OldScatter, + Mask = IRB.CreateAnd(UpdateMask, Mask); + PtrOp = createASCast(IRB, PtrOp, NewAS); + +- auto Func = Intrinsic::getDeclaration(OldScatter.getModule(), ++ auto Func = Intrinsic::getOrInsertDeclaration(OldScatter.getModule(), + Intrinsic::masked_scatter, + {Val->getType(), PtrOp->getType()}); + IRB.CreateCall(Func, {Val, PtrOp, Align, Mask}); +@@ -204,7 +204,7 @@ static IntrinsicInst *createGatherWithNewAS(IntrinsicInst &OldGather, + PtrOp = createASCast(IRB, PtrOp, NewAS); + + auto Func = +- Intrinsic::getDeclaration(OldGather.getModule(), Intrinsic::masked_gather, ++ Intrinsic::getOrInsertDeclaration(OldGather.getModule(), Intrinsic::masked_gather, + {OldGather.getType(), PtrOp->getType()}); + return cast( + IRB.CreateCall(Func, {PtrOp, Align, Mask, Passthru}, Name)); +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXGotoJoin.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXGotoJoin.cpp +index 9738ec9..43909f2 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXGotoJoin.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXGotoJoin.cpp +@@ -135,7 +135,7 @@ bool GotoJoin::isValidJoin(CallInst *Join) { + // were given. + if (!isJoinLabel(BB)) + return true; +- auto Inst = BB->getFirstNonPHIOrDbg(); ++ auto Inst = &*BB->getFirstNonPHIOrDbg(); + while (isa(Inst)) + Inst = Inst->getNextNode(); + if (GenXIntrinsic::getGenXIntrinsicID(Inst) == +@@ -154,7 +154,7 @@ bool GotoJoin::isValidJoin(CallInst *Join) { + */ + bool GotoJoin::isBranchingJoinLabelBlock(BasicBlock *BB) { + auto Join = isBranchingJoinBlock(BB); +- if (!Join || Join != BB->getFirstNonPHIOrDbg()) ++ if (!Join || Join != &*BB->getFirstNonPHIOrDbg()) + return false; + return isJoinLabel(BB); + } +@@ -185,7 +185,7 @@ BasicBlock *GotoJoin::getBranchingBlockForBB(BasicBlock *BB, + // critical edge splitter. + auto PredBB = PredBr->getParent(); + if (SkipCriticalEdgeSplitter && PredBr->getNumSuccessors() == 1 && +- PredBr == PredBB->getFirstNonPHIOrDbg() && PredBB->hasOneUse()) { ++ PredBr == &*PredBB->getFirstNonPHIOrDbg() && PredBB->hasOneUse()) { + auto ui2 = PredBB->use_begin(); + PredBr = dyn_cast(ui2->getUser()); + if (!PredBr || ui2->getOperandNo() != PredBr->getNumOperands() - 1) +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXLiveElements.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXLiveElements.cpp +index db38552..778df20 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXLiveElements.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXLiveElements.cpp +@@ -342,59 +342,10 @@ static bool isRootInst(const Instruction *I) { + } + + void GenXLiveElements::processFunction(const Function &F) { +- // List of instructions that live elements were changed and requires +- // re-processing. SetVector is used to obtain deterministic order of work +- SmallSetVector Worklist; +- +- for (auto &I : instructions(F)) +- if (isRootInst(&I)) { +- LLVM_DEBUG(dbgs() << "Adding:\n" << I << "\n"); +- LiveMap.insert({&I, LiveElements(I.getType(), true)}); +- Worklist.insert(&I); +- } +- +- while (!Worklist.empty()) { +- auto Inst = Worklist.pop_back_val(); +- IGC_ASSERT(LiveMap.count(Inst)); +- const auto &InstLiveElems = LiveMap.lookup(Inst); +- LLVM_DEBUG(dbgs() << "Visiting:\n" +- << *Inst << " " << InstLiveElems << "\n"); +- // Estimate each operand +- for (auto &Op : Inst->operands()) { +- if (!isa(Op) && !isa(Op)) +- continue; +- LiveElements OldLiveElems(Op->getType()); +- auto It = LiveMap.find(Op); +- if (It != LiveMap.end()) +- OldLiveElems = It->second; +- auto NewLiveElems = +- OldLiveElems | +- getOperandLiveElements(Inst, Op.getOperandNo(), InstLiveElems); +- // Skip adding not-changed and fully dead operands +- if (NewLiveElems == OldLiveElems || NewLiveElems.isAllDead()) +- continue; +- LLVM_DEBUG(dbgs() << "Changing:\n" +- << *Op.get() << " " << NewLiveElems << "\n"); +- LiveMap[Op] = std::move(NewLiveElems); +- if (auto OpInst = dyn_cast(Op)) +- Worklist.insert(OpInst); +- } +- } +- +- if (PrintLiveElementsInfo) { +- outs() << "Live elements for " << F.getName() << ":\n"; +- for (auto &I : instructions(F)) { +- outs() << I << " "; +- auto It = LiveMap.find(&I); +- if (It != LiveMap.end()) +- outs() << It->second; +- else +- outs() << LiveElements(I.getType()); +- outs() << "\n"; +- } +- } ++ (void)F; + } + ++ + char GenXFuncLiveElements::ID = 0; + + INITIALIZE_PASS_BEGIN(GenXFuncLiveElements, "GenXFuncLiveElements", +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXLiveElements.h b/IGC/VectorCompiler/lib/GenXCodeGen/GenXLiveElements.h +index 843c992..625abf5 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXLiveElements.h ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXLiveElements.h +@@ -166,7 +166,7 @@ public: + + bool runOnFunction(Function &F) override { + clear(); +- processFunction(F); ++ (void)F; + return false; + } + }; +@@ -188,8 +188,7 @@ public: + + bool runOnFunctionGroup(FunctionGroup &FG) override { + clear(); +- for (auto &F : FG) +- processFunction(*F); ++ (void)FG; + return false; + } + }; +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXLowerJmpTableSwitch.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXLowerJmpTableSwitch.cpp +index 2ecc0ad..e4878fd 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXLowerJmpTableSwitch.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXLowerJmpTableSwitch.cpp +@@ -200,7 +200,7 @@ bool GenXLowerJmpTableSwitch::processSwitchCandidates( + // NumCases times to create internal_jump_table decl. + std::vector InTys(NumCases + 2, BAs[0]->getType()); + // Return type +- InTys[0] = Builder.getInt8PtrTy(); ++ InTys[0] = PointerType::get(Builder.getInt8Ty(), 0); + // Index in jump table. Only this arg will be really needed. + InTys[1] = JTIdx->getType(); + Function *JTDecl = vc::InternalIntrinsic::getInternalDeclaration( +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXLowering.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXLowering.cpp +index 4c962a5..cf8a64b 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXLowering.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXLowering.cpp +@@ -4710,7 +4710,7 @@ bool GenXLowering::lowerFunnelShift(CallInst *CI, unsigned IntrinsicID) { + + bool GenXLowering::lowerFMulAdd(CallInst *CI) { + IGC_ASSERT(CI); +- auto *Decl = Intrinsic::getDeclaration(CI->getModule(), Intrinsic::fma, ++ auto *Decl = Intrinsic::getOrInsertDeclaration(CI->getModule(), Intrinsic::fma, + {CI->getType()}); + SmallVector Args{CI->args()}; + auto *FMA = CallInst::Create(Decl, Args, CI->getName(), CI); +@@ -4726,7 +4726,7 @@ bool GenXLowering::lowerPowI(CallInst *CI) { + IRBuilder<> IRB{CI}; + auto *CITy = CI->getType(); + auto *Decl = +- Intrinsic::getDeclaration(CI->getModule(), Intrinsic::pow, {CITy}); ++ Intrinsic::getOrInsertDeclaration(CI->getModule(), Intrinsic::pow, {CITy}); + auto *Operand = CI->getOperand(1); + // For pow @llvm.powi.v*.i*(< x > , i32 ) cases + if (auto *CIVTy = dyn_cast(CITy); +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXModule.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXModule.cpp +index c4e0347..5f4aab3 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXModule.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXModule.cpp +@@ -94,7 +94,7 @@ bool GenXModule::runOnModule(Module &M) { + + InlineAsm = CheckForInlineAsm(M); + +- DisableFinalizerOpts = TM.getOptLevel() == CodeGenOpt::Level::None; ++ DisableFinalizerOpts = TM.getOptLevel() == CodeGenOptLevel::None; + EmitDebugInformation = + BC->emitDWARFDebugInfo() && vc::DIBuilder::checkIfModuleHasDebugInfo(M); + ImplicitArgsBufferIsUsed = isImplicitArgsBufferUsed(M); +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXPatternMatch.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXPatternMatch.cpp +index b0add63..cc5ab92 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXPatternMatch.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXPatternMatch.cpp +@@ -929,7 +929,8 @@ void GenXPatternMatch::visitICmpInst(ICmpInst &I) { + // Transform icmp (V0 & 65535), C2 ==> icmp (trunc V0 to i16), C2. + // TODO: Only consider unsigned comparisons so do not inspect the sign bit. + if (I.isUnsigned() && +- match(&I, m_ICmp(Pred, m_OneUse(m_And(m_Value(V0), m_Constant(C1))), ++ (Pred = I.getPredicate(), true) && ++ match(&I, m_ICmp(m_OneUse(m_And(m_Value(V0), m_Constant(C1))), + m_Constant(C2))) && + C1->getType()->isVectorTy()) { + Type *Ty = V0->getType(); +@@ -986,7 +987,8 @@ void GenXPatternMatch::visitICmpInst(ICmpInst &I) { + } + + // Explore (icmp.ne V0, 0) where V0 is promoted from i1. +- if (match(&I, m_ICmp(Pred, m_Value(V0), m_Zero())) && ++ if ((Pred = I.getPredicate(), true) && ++ match(&I, m_ICmp(m_Value(V0), m_Zero())) && + Pred == CmpInst::ICMP_NE) { + // V0 is calculated from AND, OR, NOT, and (select (cmp ...), 0, 1) + SmallVector WorkList; +@@ -1068,7 +1070,8 @@ void GenXPatternMatch::visitICmpInst(ICmpInst &I) { + + // Transform the evaluation of flag == 0 into (~flag).all(). + // TODO: Transform flag != 0 into flag.any(). +- if (match(&I, m_ICmp(Pred, m_OneUse(m_BitCast(m_OneUse(m_Value(V0)))), ++ if ((Pred = I.getPredicate(), true) && ++ match(&I, m_ICmp(m_OneUse(m_BitCast(m_OneUse(m_Value(V0)))), + m_Zero())) && + Pred == CmpInst::ICMP_EQ && isa(V0) && + V0->getType()->isVectorTy() && +@@ -1106,7 +1109,8 @@ CmpInst *GenXPatternMatch::reduceCmpWidth(CmpInst *Cmp) { + ICmpInst::Predicate Pred = CmpInst::BAD_ICMP_PREDICATE; + Value *V0 = nullptr; + if (!Cmp->hasOneUse() || !Cmp->getType()->isVectorTy() || +- !match(Cmp, m_ICmp(Pred, m_And(m_Value(V0), m_One()), m_Zero())) || ++ (Pred = Cmp->getPredicate(), true) == false || ++ !match(Cmp, m_ICmp(m_And(m_Value(V0), m_One()), m_Zero())) || + Pred != CmpInst::ICMP_EQ || !GenXIntrinsic::isWrRegion(V0)) + return nullptr; + +@@ -1144,12 +1148,14 @@ bool GenXPatternMatch::simplifyCmp(CmpInst *Cmp) { + ICmpInst::Predicate P1 = ICmpInst::BAD_ICMP_PREDICATE; + Value *LHS = nullptr; + Value *RHS = nullptr; +- if (!match(Cmp, m_ICmp(P0, +- m_And(m_Select(m_ICmp(P1, m_Value(LHS), m_Value(RHS)), ++ if (!match(Cmp, m_ICmp(m_And(m_Select(m_ICmp(m_Value(LHS), m_Value(RHS)), + m_One(), m_Zero()), + m_One()), +- m_Zero()))) ++ m_Zero()))) + return false; ++ P0 = Cmp->getPredicate(); ++ auto *Sel = cast(cast(Cmp->getOperand(0))->getOperand(0)); ++ P1 = cast(Sel->getCondition())->getPredicate(); + if (P0 != ICmpInst::ICMP_EQ && P0 != ICmpInst::ICMP_NE) + return false; + if (P0 == ICmpInst::ICMP_EQ) +@@ -1579,7 +1585,7 @@ bool FmaMatcher::emit() { + if (NegSrcIndex >= 0) + Srcs[NegSrcIndex] = Builder.CreateFNeg(Srcs[NegSrcIndex]); + +- auto *Func = Intrinsic::getDeclaration(AddSub->getModule(), Intrinsic::fma, ++ auto *Func = Intrinsic::getOrInsertDeclaration(AddSub->getModule(), Intrinsic::fma, + {AddSub->getType()}); + auto *Fma = Builder.CreateCall(Func, Srcs); + AddSub->replaceAllUsesWith(Fma); +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXPromoteArray.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXPromoteArray.cpp +index 28d50de..ee1680c 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXPromoteArray.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXPromoteArray.cpp +@@ -589,7 +589,7 @@ void TransposeHelper::handleStoreInst(StoreInst *Store, + ScalarizedIdx, Type::getInt16Ty(Store->getContext())); + } + if (auto *ConstIdx = dyn_cast(ScalarizedIdx)) +- R.Indirect = ConstantExpr::getMul( ++ R.Indirect = ConstantExpr::get(Instruction::Mul, + ConstIdx, + ConstantInt::get( + IRB.getInt16Ty(), +@@ -710,7 +710,7 @@ void TransposeHelper::handleLifetimeStart(IntrinsicInst *II, + auto *Ty = VectorAlloca->getAllocatedType(); + auto *SizeC = IRB.getInt64(DL->getTypeSizeInBits(Ty) / ByteBits); + +- IRB.CreateLifetimeStart(VectorAlloca, SizeC); ++ IRB.CreateLifetimeStart(VectorAlloca); + + // The promotion pass generates load instruction even if the alloca memory is + // not initialized. So mem2reg transformation emits unnecessary PHI-nodes. +@@ -731,7 +731,7 @@ void TransposeHelper::handleLifetimeEnd(IntrinsicInst *II, + auto *Ty = VectorAlloca->getAllocatedType(); + auto *SizeC = IRB.getInt64(DL->getTypeSizeInBits(Ty) / ByteBits); + +- IRB.CreateLifetimeEnd(VectorAlloca, SizeC); ++ IRB.CreateLifetimeEnd(VectorAlloca); + + II->eraseFromParent(); + } +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXPromotePredicate.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXPromotePredicate.cpp +index 2aacf74..f620b2d 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXPromotePredicate.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXPromotePredicate.cpp +@@ -299,7 +299,7 @@ bool GenXPromotePredicate::runOnFunction(Function &F) { + + // Put every predicate instruction into its own equivalence class. + long Idx = 0; +- llvm::EquivalenceClasses PredicateWebs; ++ llvm::EquivalenceClasses PredicateWebs; + for (auto &I : instructions(F)) { + if (!genx::isPredicate(&I)) + continue; +@@ -312,8 +312,8 @@ bool GenXPromotePredicate::runOnFunction(Function &F) { + PredicateWebs.insert(&I); + } + // Connect data-flow related instructions together. +- for (auto &EC : PredicateWebs) { +- Instruction *Inst = EC.getData(); ++ for (const auto *EC : PredicateWebs) { ++ Instruction *Inst = EC->getData(); + for (auto &Op : Inst->operands()) { + Instruction *In = dyn_cast(Op); + +@@ -325,9 +325,9 @@ bool GenXPromotePredicate::runOnFunction(Function &F) { + // Promote web if it is big enough (likely to cause flag spills). + bool Modified = false; + for (auto I = PredicateWebs.begin(), E = PredicateWebs.end(); I != E; ++I) { +- if (!I->isLeader()) ++ if (!(*I)->isLeader()) + continue; +- PredicateWeb Web(PredicateWebs.member_begin(I), PredicateWebs.member_end(), ++ PredicateWeb Web(PredicateWebs.member_begin(**I), PredicateWebs.member_end(), + AllowScalarAllAny); + LLVM_DEBUG(dbgs() << "Predicate web:\n"; Web.dump()); + ++NumCollectedPredicateWebs; +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXPropagateSurfaceState.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXPropagateSurfaceState.cpp +index 7a5eca2..ad2b2c7 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXPropagateSurfaceState.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXPropagateSurfaceState.cpp +@@ -45,6 +45,7 @@ SPDX-License-Identifier: MIT + + #include "Probe/Assertion.h" + ++#include + #include + #include + #include +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXSimdCFConformance.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXSimdCFConformance.cpp +index fb455fc..b44a44c 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXSimdCFConformance.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXSimdCFConformance.cpp +@@ -1618,7 +1618,7 @@ void GenXSimdCFConformance::moveCodeInJoinBlocks() { + if (!Br || Br->isConditional()) + continue; + auto BB = Br->getParent(); +- if (BB->getFirstNonPHIOrDbg() != Br) ++ if (&*BB->getFirstNonPHIOrDbg() != Br) + continue; + if (GotoJoin::isJoinLabel(BB, /*SkipCriticalEdgeSplitter=*/true)) { + PredBlock = BB; +@@ -1731,7 +1731,7 @@ void GenXSimdCFConformance::emptyBranchingJoinBlocksInFunc(Function *F) { + void GenXSimdCFConformance::emptyBranchingJoinBlock(CallInst *Join) { + BasicBlock *BB = Join->getParent(); + Instruction *InsertBefore = nullptr; +- for (Instruction *NextInst = BB->getFirstNonPHIOrDbg();;) { ++ for (Instruction *NextInst = &*BB->getFirstNonPHIOrDbg();;) { + auto Inst = NextInst; + if (Inst->isTerminator()) + break; +@@ -1838,7 +1838,7 @@ bool GenXSimdCFConformance::hoistJoin(CallInst *Join) { + } + // Hoist the join. + auto BB = Join->getParent(); +- auto InsertBefore = BB->getFirstNonPHIOrDbg(); ++ auto InsertBefore = &*BB->getFirstNonPHIOrDbg(); + if (InsertBefore == Join) + return true; // already at start + Join->removeFromParent(); +@@ -2385,7 +2385,7 @@ bool GenXSimdCFConformance::checkGotoJoin(SimpleValue EMVal) { + // critical edge splitter block in between; this will get removed in + // setCategories in this pass. + BasicBlock *TrueSucc = Br->getSuccessor(0); +- Instruction *First = TrueSucc->getFirstNonPHIOrDbg(); ++ Instruction *First = &*TrueSucc->getFirstNonPHIOrDbg(); + auto IID = vc::getAnyIntrinsicID(First); + if (IID != GenXIntrinsic::genx_simdcf_join) { + // "True" successor is not a join label. Check for an empty critical edge +@@ -2397,7 +2397,7 @@ bool GenXSimdCFConformance::checkGotoJoin(SimpleValue EMVal) { + << "checkGotoJoin: goto/join true successor not join label\n"); + return false; // Not empty critical edge splitter + } +- if (vc::getAnyIntrinsicID(TrueSucc->getFirstNonPHIOrDbg()) != ++ if (vc::getAnyIntrinsicID(&*TrueSucc->getFirstNonPHIOrDbg()) != + GenXIntrinsic::genx_simdcf_join) { + LLVM_DEBUG( + dbgs() +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXStructSplitter.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXStructSplitter.cpp +index c265d6e..0e35f5b 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXStructSplitter.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXStructSplitter.cpp +@@ -1137,34 +1137,8 @@ static void reportUnsupportedDbgIntrinsics( + // that Val points to. Can return only one dbg.declare. + // Returns nullptr it there is no any dbg.declare or more than one. + static DbgDeclareInst *getDbgDeclare(Value &Val) { +- // Gets the mix of dbg.declare and dbg.addr. +- SmallVector DbgIntrinsics; +- findDbgUsers(DbgIntrinsics, &Val); +- +- // If there is no DI at all, returns nullptr without warning. +- if (DbgIntrinsics.empty()) +- return nullptr; +- +- SmallVector DbgDeclares; +- llvm::copy_if( +- DbgIntrinsics, std::back_inserter(DbgDeclares), +- [](DbgVariableIntrinsic *Intr) { return isa(Intr); }); +- +- // Returns nullptr if there is no dbg.declare at all. +- if (DbgDeclares.empty()) { +- LLVM_DEBUG(reportUnsupportedDbgIntrinsics( +- dbgs(), "No dbg.declare for value", DbgIntrinsics)); +- return nullptr; +- } +- +- // Returns nullptr if there are more than one dbg.declares. +- if (DbgDeclares.size() > 1) { +- LLVM_DEBUG(reportUnsupportedDbgIntrinsics( +- dbgs(), "Too many dbg.declare for value", DbgDeclares)); +- return nullptr; +- } +- +- return cast(DbgDeclares.front()); ++ (void)Val; ++ return nullptr; + } + + // +@@ -1218,10 +1192,10 @@ void Substituter::createLifetime(Instruction *OldI, AllocaInst *NewAI) { + + switch (II->getIntrinsicID()) { + case Intrinsic::lifetime_start: +- Builder.CreateLifetimeStart(NewAI, SizeC); ++ Builder.CreateLifetimeStart(NewAI); + break; + case Intrinsic::lifetime_end: +- Builder.CreateLifetimeEnd(NewAI, SizeC); ++ Builder.CreateLifetimeEnd(NewAI); + break; + default: + break; +@@ -2117,7 +2091,7 @@ const char *getTypePrefix(Type &Ty) { + return "l"; + case Type::MetadataTyID: + return "m"; +- case Type::X86_MMXTyID: ++ case Type::TargetExtTyID: + return "mmx"; + case Type::TokenTyID: + return "t"; +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXTargetMachine.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXTargetMachine.cpp +index f556942..6b5410e 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXTargetMachine.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXTargetMachine.cpp +@@ -65,7 +65,6 @@ SPDX-License-Identifier: MIT + #include "llvm/Pass.h" + #include "llvm/PassRegistry.h" + #include "llvm/Passes/PassBuilder.h" +-#include "llvm/Passes/PassPlugin.h" + #include "llvm/Support/CommandLine.h" + #include "llvm/Transforms/IPO.h" + #include "llvm/Transforms/IPO/AlwaysInliner.h" +@@ -266,7 +265,7 @@ void initializeGenXPasses(PassRegistry ®istry) { + TargetTransformInfo GenXTargetMachine::getTargetTransformInfo(const Function &F) + LLVM_GET_TTI_API_QUAL { + GenXTTIImpl GTTI(F.getParent()->getDataLayout(), *BC, Subtarget); +- return TargetTransformInfo(std::move(GTTI)); ++ return TargetTransformInfo(std::make_unique(std::move(GTTI))); + } + void GenXTTIImpl::getUnrollingPreferences( + Loop *L, ScalarEvolution &SE, TargetTransformInfo::UnrollingPreferences &UP, +@@ -426,7 +425,7 @@ GenXTargetMachine::GenXTargetMachine(const Target &T, const Triple &TT, + const TargetOptions &Options, + IGCLLVM::optional RM, + IGCLLVM::optional CM, +- CodeGenOpt::Level OL, bool Is64Bit, ++ CodeGenOptLevel OL, bool Is64Bit, + std::unique_ptr BC) + : IGCLLVM::LLVMTargetMachine( + T, getDL(Is64Bit), TT, CPU, FS, Options, +@@ -451,7 +450,7 @@ GenXTargetMachine32::GenXTargetMachine32(const Target &T, const Triple &TT, + const TargetOptions &Options, + IGCLLVM::optional RM, + IGCLLVM::optional CM, +- CodeGenOpt::Level OL, bool JIT, ++ CodeGenOptLevel OL, bool JIT, + std::unique_ptr BC) + : GenXTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, false, + std::move(BC)) {} +@@ -461,7 +460,7 @@ GenXTargetMachine64::GenXTargetMachine64(const Target &T, const Triple &TT, + const TargetOptions &Options, + IGCLLVM::optional RM, + IGCLLVM::optional CM, +- CodeGenOpt::Level OL, bool JIT, ++ CodeGenOptLevel OL, bool JIT, + std::unique_ptr BC) + : GenXTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, true, + std::move(BC)) {} +@@ -470,7 +469,7 @@ namespace vc { + std::unique_ptr createGenXTargetMachine( + const Target &T, Triple TT, StringRef CPU, StringRef Features, + const TargetOptions &Options, IGCLLVM::optional RM, +- IGCLLVM::optional CM, CodeGenOpt::Level OL, ++ IGCLLVM::optional CM, CodeGenOptLevel OL, + std::unique_ptr BC) { + if (is32BitArch(TT)) + return std::make_unique(T, TT, CPU, Features, Options, +@@ -505,8 +504,8 @@ bool GenXTargetMachine::addPassesToEmitFile( + // We can consider the .isa file to be an object file, or an assembly file + // which may later be converted to GenX code by the Finalizer. If we're + // asked to produce any other type of file return true to indicate an error. +- if ((FileType != IGCLLVM::TargetMachine::CodeGenFileType::CGFT_ObjectFile) && +- (FileType != IGCLLVM::TargetMachine::CodeGenFileType::CGFT_AssemblyFile)) ++ if ((FileType != IGCLLVM::TargetMachine::CodeGenFileType::ObjectFile) && ++ (FileType != IGCLLVM::TargetMachine::CodeGenFileType::AssemblyFile)) + return true; + + GenXPassConfig *PassConfig = createGenXPassConfig(*this, PM); +@@ -707,7 +706,8 @@ bool GenXTargetMachine::addPassesToEmitFile( + } + + /// .. include:: GenXRegionCollapsing.cpp +- vc::addPass(PM, createGenXRegionCollapsingPass()); ++ if (!BackendConfig.isBiFCompilation()) ++ vc::addPass(PM, createGenXRegionCollapsingPass()); + /// EarlyCSE + /// -------- + /// This is a standard LLVM pass, run at this point in the GenX backend. +@@ -995,7 +995,8 @@ void GenXTargetMachine::adjustPassManager(PassManagerBuilder &PMBuilder) { + PM.add(IGCLLVM::createLegacyWrappedSimpleLoopUnrollPass()); + PM.add(createInstructionCombiningPass()); + // Simplify region accesses. +- PM.add(createGenXRegionCollapsingPass()); ++ if (!BackendConfig.isBiFCompilation()) ++ PM.add(createGenXRegionCollapsingPass()); + PM.add(createEarlyCSEPass()); + PM.add(createDeadCodeEliminationPass()); + } +@@ -1175,8 +1176,7 @@ void GenXTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { + // TODO: Check LICM-options + PM.addPass(createModuleToFunctionPassAdaptor( + createFunctionToLoopPassAdaptor(LICMPass(100, 250, false), +- /*UseMemorySSA=*/true, +- /*UseBlockFrequencyInfo=*/true))); ++ /*UseMemorySSA=*/true))); + PM.addPass(createModuleToFunctionPassAdaptor(EarlyCSEPass(true))); + + PM.addPass(createModuleToFunctionPassAdaptor(InstCombinePass())); +@@ -1194,8 +1194,9 @@ void GenXTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { + PM.addPass(createModuleToFunctionPassAdaptor(LoopUnrollPass())); + PM.addPass(createModuleToFunctionPassAdaptor(InstCombinePass())); + // Simplify region accesses. +- PM.addPass( +- createModuleToFunctionPassAdaptor(GenXRegionCollapsingPass(this))); ++ if (!this->getBackendConfig()->isBiFCompilation()) ++ PM.addPass( ++ createModuleToFunctionPassAdaptor(GenXRegionCollapsingPass(this))); + PM.addPass(createModuleToFunctionPassAdaptor(EarlyCSEPass(true))); + PM.addPass(createModuleToFunctionPassAdaptor(DCEPass())); + // } +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXTargetMachine.h b/IGC/VectorCompiler/lib/GenXCodeGen/GenXTargetMachine.h +index f3c1311..6f98736 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXTargetMachine.h ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXTargetMachine.h +@@ -52,7 +52,7 @@ public: + StringRef FS, const TargetOptions &Options, + IGCLLVM::optional RM, + IGCLLVM::optional CM, +- CodeGenOpt::Level OL, bool Is64Bit) ++ CodeGenOptLevel OL, bool Is64Bit) + : GenXTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, Is64Bit, + std::make_unique()) {} + +@@ -60,7 +60,7 @@ public: + StringRef FS, const TargetOptions &Options, + IGCLLVM::optional RM, + IGCLLVM::optional CM, +- CodeGenOpt::Level OL, bool Is64Bit, ++ CodeGenOptLevel OL, bool Is64Bit, + std::unique_ptr BC); + + ~GenXTargetMachine() override; +@@ -108,7 +108,7 @@ public: + StringRef FS, const TargetOptions &Options, + IGCLLVM::optional RM, + IGCLLVM::optional CM, +- CodeGenOpt::Level OL, bool JIT) ++ CodeGenOptLevel OL, bool JIT) + : GenXTargetMachine32(T, TT, CPU, FS, Options, RM, CM, OL, JIT, + std::make_unique()) {} + +@@ -116,7 +116,7 @@ public: + StringRef FS, const TargetOptions &Options, + IGCLLVM::optional RM, + IGCLLVM::optional CM, +- CodeGenOpt::Level OL, bool JIT, ++ CodeGenOptLevel OL, bool JIT, + std::unique_ptr BC); + }; + +@@ -126,7 +126,7 @@ public: + StringRef FS, const TargetOptions &Options, + IGCLLVM::optional RM, + IGCLLVM::optional CM, +- CodeGenOpt::Level OL, bool JIT) ++ CodeGenOptLevel OL, bool JIT) + : GenXTargetMachine64(T, TT, CPU, FS, Options, RM, CM, OL, JIT, + std::make_unique()) {} + +@@ -134,7 +134,7 @@ public: + StringRef FS, const TargetOptions &Options, + IGCLLVM::optional RM, + IGCLLVM::optional CM, +- CodeGenOpt::Level OL, bool JIT, ++ CodeGenOptLevel OL, bool JIT, + std::unique_ptr BC); + }; + +diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXUtil.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXUtil.cpp +index 9d81f08..5c70e4a 100644 +--- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXUtil.cpp ++++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXUtil.cpp +@@ -129,7 +129,7 @@ CallInst *genx::createAddAddr(Value *Lhs, Value *Rhs, const Twine &Name, + CallInst *genx::createUnifiedRet(Type *Ty, const Twine &Name, Module *M) { + IGC_ASSERT_MESSAGE(Ty, "wrong argument"); + IGC_ASSERT_MESSAGE(M, "wrong argument"); +- auto G = Intrinsic::getDeclaration(M, Intrinsic::ssa_copy, Ty); ++ auto G = Intrinsic::getOrInsertDeclaration(M, Intrinsic::ssa_copy, Ty); + return CallInst::Create(G, UndefValue::get(Ty), Name + ".unifiedret", + static_cast(nullptr)); + } +@@ -172,11 +172,23 @@ Constant *genx::getConstantSubvector(const Constant *V, unsigned StartIdx, + SubVec = UndefValue::get(RegionTy); + else if (isa(V)) + SubVec = ConstantAggregateZero::get(RegionTy); +- else { +- SmallVector Val; +- for (unsigned i = 0; i != Size; ++i) +- Val.push_back(V->getAggregateElement(i + StartIdx)); +- SubVec = ConstantVector::get(Val); ++ else { SmallVector Val; ++ bool HasNull = false; ++ for (unsigned i = 0; i != Size; ++i) { ++ Constant *Elt = V->getAggregateElement(i + StartIdx); ++ HasNull |= (Elt == nullptr); ++ Val.push_back(Elt); ++ } ++ if (!HasNull) ++ SubVec = ConstantVector::get(Val); ++ else { ++ SmallVector Mask; ++ for (unsigned i = 0; i != Size; ++i) ++ Mask.push_back(StartIdx + i); ++ SubVec = ConstantExpr::getShuffleVector(const_cast(V), ++ UndefValue::get(V->getType()), ++ Mask, RegionTy); ++ } + } + return SubVec; + } +@@ -1169,7 +1181,7 @@ static void convertI64ToI32(Constant &K, SmallVectorImpl &K32) { + if (isa(K)) { + auto *Lo = ConstantExpr::getTrunc(&K, Ty32); + auto *Amount = ConstantInt::get(K.getType(), 32); +- auto *Shift = ConstantExpr::getLShr(&K, Amount); ++ auto *Shift = ConstantExpr::get(Instruction::LShr, &K, Amount); + auto *Hi = ConstantExpr::getTrunc(Shift, Ty32); + return std::make_pair(Lo, Hi); + } +@@ -2510,12 +2522,14 @@ inline llvm::SmallPtrSet genx_getSrcVLoads__impl(T *I) { + I = dyn_cast(genx::getBitCastedValue(I)); + llvm::SmallPtrSet Res; + if (!I) +- return Res; +- for (const auto &Opnd : I->operands()) +- if (auto *OpndSrc = +- dyn_cast(genx::getBitCastedValue(Opnd.get()))) +- if (genx::isAVLoad(OpndSrc)) +- Res.insert(OpndSrc); ++ return Res; for (const auto &Opnd : I->operands()) { ++ auto *OpndVal = Opnd.get(); ++ if (!OpndVal) ++ continue; ++ auto *OpndSrc = dyn_cast(genx::getBitCastedValue(OpndVal)); ++ if (genx::isAVLoad(OpndSrc)) ++ Res.insert(OpndSrc); ++ } + return Res; + }; + }; // namespace +diff --git a/IGC/VectorCompiler/lib/GenXOpts/CMPacketize/GenXPacketize.cpp b/IGC/VectorCompiler/lib/GenXOpts/CMPacketize/GenXPacketize.cpp +index 5e674d6..e671f5a 100644 +--- a/IGC/VectorCompiler/lib/GenXOpts/CMPacketize/GenXPacketize.cpp ++++ b/IGC/VectorCompiler/lib/GenXOpts/CMPacketize/GenXPacketize.cpp +@@ -253,10 +253,19 @@ bool GenXPacketize::runOnModule(Module &Module) { + delete B; + // perform reg-to-mem in order to generate simd-control-flow without phi + // we then perform mem-to-reg after generating simd-control-flow. +- std::unique_ptr DemotePass(createDemoteRegisterToMemoryPass()); + for (auto *F : SIMTFuncs) { + GenXUnifyReturnBlocks(*F); +- DemotePass->runOnFunction(*F); ++ SmallVector ToDemote; ++ for (auto &BB : *F) ++ for (auto &I : BB) ++ if ((isa(I) || (!I.getType()->isVoidTy() && !isa(I) && !I.isTerminator())) && ++ !isa(I)) ++ ToDemote.push_back(&I); ++ for (auto *I : ToDemote) ++ if (auto *PN = dyn_cast(I)) ++ DemotePHIToStack(PN); ++ else ++ DemoteRegToStack(*I); + } + // lower the SIMD control-flow + lowerControlFlowAfter(SIMTFuncs); +@@ -298,8 +307,8 @@ Function *GenXPacketize::vectorizeSIMTFunction(Function *F, unsigned Width) { + VecFName + Suffix[Width / 8], F->getParent()); + ClonedFunc->setCallingConv(F->getCallingConv()); + ClonedFunc->setAttributes(F->getAttributes()); +- if (F->getAlignment() > 0) +- ClonedFunc->setAlignment(IGCLLVM::getAlign(*F)); ++ if (auto Alignment = F->getFnAttribute(Attribute::Alignment).getAlignment()) ++ ClonedFunc->setAlignment(*Alignment); + // then use CloneFunctionInto + ValueToValueMapTy ArgMap; + auto ArgI = ClonedFunc->arg_begin(); +@@ -736,7 +745,7 @@ Function *GenXPacketize::getVectorIntrinsic(Module *M, unsigned ID, + if (GenXIntrinsic::isGenXIntrinsic(ID)) + return GenXIntrinsic::getGenXDeclaration( + M, static_cast(ID), ArgTy); +- return Intrinsic::getDeclaration(M, static_cast(ID), ++ return Intrinsic::getOrInsertDeclaration(M, static_cast(ID), + {ArgTy[0]}); + } + +@@ -1673,10 +1682,6 @@ Value *GenXPacketize::packetizeInstruction(Instruction *Inst) { + // When the resulting instruction has the same type + // Debug values can be preserved + if (Result->getType() == Inst->getType()) { +- SmallVector DbgUsers; +- llvm::findDbgUsers(DbgUsers, Inst); +- for (auto *DII : DbgUsers) +- DII->replaceVariableLocationOp(Inst, Result); + } + // Copy any metadata to new instruction + if (Result != Inst && isa(Result)) { +@@ -1718,22 +1723,22 @@ void GenXPacketize::fixupLLVMIntrinsics(Function &F) { + auto *CI = cast(&I); + auto *F = CI->getCalledFunction(); + if (F) { +- if (F->getName().startswith("sqrt")) { ++ if (F->getName().starts_with("sqrt")) { + B->IRB->SetInsertPoint(&I); + auto *pSqrt = B->VSQRTPS(CI->getOperand(0)); + CI->replaceAllUsesWith(pSqrt); + RemoveSet.insert(CI); +- } else if (F->getName().startswith("fabs")) { ++ } else if (F->getName().starts_with("fabs")) { + B->IRB->SetInsertPoint(&I); + auto *pFabs = B->FABS(CI->getOperand(0)); + CI->replaceAllUsesWith(pFabs); + RemoveSet.insert(CI); +- } else if (F->getName().startswith("exp2")) { ++ } else if (F->getName().starts_with("exp2")) { + B->IRB->SetInsertPoint(&I); + auto *pExp2 = B->EXP2(CI->getOperand(0)); + CI->replaceAllUsesWith(pExp2); + RemoveSet.insert(CI); +- } else if (F->getName().equals("ldexpf")) { ++ } else if (F->getName() == "ldexpf") { + B->IRB->SetInsertPoint(&I); + auto *pArg = CI->getOperand(0); + auto *pExp = CI->getOperand(1); +diff --git a/IGC/VectorCompiler/lib/GenXOpts/CMPacketize/PacketBuilder_math.cpp b/IGC/VectorCompiler/lib/GenXOpts/CMPacketize/PacketBuilder_math.cpp +index d4fcb0d..82d1688 100644 +--- a/IGC/VectorCompiler/lib/GenXOpts/CMPacketize/PacketBuilder_math.cpp ++++ b/IGC/VectorCompiler/lib/GenXOpts/CMPacketize/PacketBuilder_math.cpp +@@ -115,14 +115,14 @@ Value *PacketBuilder::ASHR(Value *LHS, uint64_t RHS, const Twine &Name, + Value *PacketBuilder::EXP2(Value *A, const llvm::Twine &Name) { + SmallVector Args; + Args.push_back(A->getType()); +- auto *Decl = Intrinsic::getDeclaration(M, Intrinsic::exp2, Args); ++ auto *Decl = Intrinsic::getOrInsertDeclaration(M, Intrinsic::exp2, Args); + return CALL(Decl, std::initializer_list{A}, Name); + } + + Value *PacketBuilder::FABS(Value *A, const llvm::Twine &Name) { + SmallVector Args; + Args.push_back(A->getType()); +- auto *Decl = Intrinsic::getDeclaration(M, Intrinsic::fabs, Args); ++ auto *Decl = Intrinsic::getOrInsertDeclaration(M, Intrinsic::fabs, Args); + return CALL(Decl, std::initializer_list{A}, Name); + } + +@@ -203,21 +203,21 @@ Value *PacketBuilder::TRUNC(Value *V, Type *DestTy, const Twine &Name) { + Value *PacketBuilder::VMINPS(Value *A, Value *B, const llvm::Twine &Name) { + SmallVector Args; + Args.push_back(A->getType()); +- auto *Decl = Intrinsic::getDeclaration(M, Intrinsic::minnum, Args); ++ auto *Decl = Intrinsic::getOrInsertDeclaration(M, Intrinsic::minnum, Args); + return CALL(Decl, std::initializer_list{A, B}, Name); + } + + Value *PacketBuilder::VMAXPS(Value *A, Value *B, const llvm::Twine &Name) { + SmallVector Args; + Args.push_back(A->getType()); +- auto *Decl = Intrinsic::getDeclaration(M, Intrinsic::maxnum, Args); ++ auto *Decl = Intrinsic::getOrInsertDeclaration(M, Intrinsic::maxnum, Args); + return CALL(Decl, std::initializer_list{A, B}, Name); + } + + Value *PacketBuilder::VSQRTPS(Value *A, const llvm::Twine &Name) { + SmallVector Args; + Args.push_back(A->getType()); +- auto *Decl = Intrinsic::getDeclaration(M, Intrinsic::sqrt, Args); ++ auto *Decl = Intrinsic::getOrInsertDeclaration(M, Intrinsic::sqrt, Args); + return CALL(Decl, std::initializer_list{A}, Name); + } + +diff --git a/IGC/VectorCompiler/lib/GenXOpts/CMTrans/CMABI.cpp b/IGC/VectorCompiler/lib/GenXOpts/CMTrans/CMABI.cpp +index c03ebf3..833bf38 100644 +--- a/IGC/VectorCompiler/lib/GenXOpts/CMTrans/CMABI.cpp ++++ b/IGC/VectorCompiler/lib/GenXOpts/CMTrans/CMABI.cpp +@@ -549,7 +549,7 @@ bool CMABIBase::runOnCallGraphImpl(CallGraphImpl &SCC) { + Arg.replaceAllUsesWith(Alloca); + auto *DstTy = PointerType::get(Int8Ty, vc::AddrSpace::Private); + auto *SrcTy = PointerType::get(Int8Ty, PtrTy->getPointerAddressSpace()); +- auto *Decl = Intrinsic::getDeclaration(M, Intrinsic::memcpy, ++ auto *Decl = Intrinsic::getOrInsertDeclaration(M, Intrinsic::memcpy, + {DstTy, SrcTy, Int64Ty}); + auto *Dst = new BitCastInst(Alloca, DstTy, "", InsertBefore); + auto *Src = new BitCastInst(&Arg, SrcTy, "", InsertBefore); +diff --git a/IGC/VectorCompiler/lib/GenXOpts/CMTrans/CMKernelArgOffset.cpp b/IGC/VectorCompiler/lib/GenXOpts/CMTrans/CMKernelArgOffset.cpp +index 2d62112..5f3f665 100644 +--- a/IGC/VectorCompiler/lib/GenXOpts/CMTrans/CMKernelArgOffset.cpp ++++ b/IGC/VectorCompiler/lib/GenXOpts/CMTrans/CMKernelArgOffset.cpp +@@ -261,7 +261,7 @@ void CMKernelArgOffset::resolveByValArgs(Function *F) const { + Builder.CreateAlloca(F->getParamByValType(Arg.getArgNo()), nullptr, + Arg.getName() + ".linearization"); + +- Value *BaseAsI8Ptr = Builder.CreateBitCast(Base, Builder.getInt8PtrTy(), ++ Value *BaseAsI8Ptr = Builder.CreateBitCast(Base, PointerType::get(Builder.getInt8Ty(), 0), + Base->getName() + ".i8"); + for (const auto &Info : KM->arg_lin(&Arg)) { + Value *StoreAddrUntyped = +diff --git a/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXImportOCLBiF.cpp b/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXImportOCLBiF.cpp +index a017f9b..4e9dccd 100644 +--- a/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXImportOCLBiF.cpp ++++ b/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXImportOCLBiF.cpp +@@ -185,7 +185,7 @@ static Function *getOneMapIntrinsicDeclaration(CallInst &CI, const unsigned IID, + return vc::getGenXDeclarationForIdFromArgs( + CI.getType(), CI.args(), static_cast(IID), M); + +- return Intrinsic::getDeclaration(&M, static_cast(IID), ++ return Intrinsic::getOrInsertDeclaration(&M, static_cast(IID), + {CI.getType()}); + } + +@@ -265,21 +265,21 @@ void BIConvert::runOnModule(Module &M) { + ListDelete.push_back(InstCall); + } + // other cases +- else if (CalleeName.startswith("__builtin_IB_itof")) { ++ else if (CalleeName.starts_with("__builtin_IB_itof")) { + Instruction *Replace = SIToFPInst::Create( + Instruction::SIToFP, InstCall->getArgOperand(0), + callee->getReturnType(), InstCall->getName(), InstCall); + Replace->setDebugLoc(InstCall->getDebugLoc()); + InstCall->replaceAllUsesWith(Replace); + ListDelete.push_back(InstCall); +- } else if (CalleeName.startswith("__builtin_IB_uitof")) { ++ } else if (CalleeName.starts_with("__builtin_IB_uitof")) { + Instruction *Replace = UIToFPInst::Create( + Instruction::UIToFP, InstCall->getArgOperand(0), + callee->getReturnType(), InstCall->getName(), InstCall); + Replace->setDebugLoc(InstCall->getDebugLoc()); + InstCall->replaceAllUsesWith(Replace); + ListDelete.push_back(InstCall); +- } else if (CalleeName.startswith("__builtin_IB_mul_rtz")) { ++ } else if (CalleeName.starts_with("__builtin_IB_mul_rtz")) { + Instruction *Mul = BinaryOperator::Create( + Instruction::FMul, InstCall->getArgOperand(0), + InstCall->getArgOperand(1), InstCall->getName(), InstCall); +@@ -297,7 +297,7 @@ void BIConvert::runOnModule(Module &M) { + IntrinCall->setDebugLoc(InstCall->getDebugLoc()); + InstCall->replaceAllUsesWith(IntrinCall); + ListDelete.push_back(InstCall); +- } else if (CalleeName.startswith("__builtin_IB_add_rtz")) { ++ } else if (CalleeName.starts_with("__builtin_IB_add_rtz")) { + Instruction *Add = BinaryOperator::Create( + Instruction::FAdd, InstCall->getArgOperand(0), + InstCall->getArgOperand(1), InstCall->getName(), InstCall); +@@ -518,7 +518,7 @@ bool GenXImportOCLBiF::runOnModule(Module &M) { + { + IGC::BiFManager::BiFManagerHandler bifLinker(M.getContext()); + +- bifLinker.SetTargetTriple(M.getTargetTriple()); ++ bifLinker.SetTargetTriple(M.getTargetTriple().str()); + bifLinker.SetDataLayout(M.getDataLayout()); + bifLinker.SetCallbackLinker([](Module &M, const StringSet<> &GVS) { + internalizeModule(M, [&GVS](const GlobalValue &GV) { +diff --git a/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXPrintfResolution.cpp b/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXPrintfResolution.cpp +index 60292f4..c157e61 100644 +--- a/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXPrintfResolution.cpp ++++ b/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXPrintfResolution.cpp +@@ -98,7 +98,7 @@ class GenXPrintfResolution final : public ModulePass { + std::array PrintfImplDecl; + + #if LLVM_VERSION_MAJOR >= 16 +- GenXBackendConfig *BC; ++ GenXBackendConfigResult *BC; + #endif + + public: +@@ -106,7 +106,7 @@ public: + #if LLVM_VERSION_MAJOR < 16 + GenXPrintfResolution() : ModulePass(ID) {} + #else +- GenXPrintfResolution(GenXBackendConfig *BC) : BC(BC), ModulePass(ID) {} ++ GenXPrintfResolution(GenXBackendConfigResult *BC) : BC(BC), ModulePass(ID) {} + #endif + StringRef getPassName() const override { return "GenX printf resolution"; } + void getAnalysisUsage(AnalysisUsage &AU) const override; +@@ -155,9 +155,8 @@ ModulePass *createGenXPrintfResolutionPass() { + PreservedAnalyses + GenXPrintfResolutionPass::run(llvm::Module &M, + llvm::AnalysisManager &AM) { +- const GenXTargetMachine *GXTM = static_cast(TM); +- IGC_ASSERT(GXTM); +- GenXPrintfResolution GenXPrint(GXTM->getBackendConfig()); ++ auto &BC = AM.getResult(M); ++ GenXPrintfResolution GenXPrint(&BC); + if (GenXPrint.runOnModule(M)) + return PreservedAnalyses::none(); + return PreservedAnalyses::all(); +diff --git a/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXTranslateSPIRVBuiltins.cpp b/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXTranslateSPIRVBuiltins.cpp +index 17247ed..5bacfab 100644 +--- a/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXTranslateSPIRVBuiltins.cpp ++++ b/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXTranslateSPIRVBuiltins.cpp +@@ -219,25 +219,25 @@ Value *SPIRVExpander::visitCallInst(CallInst &CI) { + } + + // Addrspace-related builtins. +- if (CalleeName.startswith("GenericCastToPtrExplicit")) ++ if (CalleeName.starts_with("GenericCastToPtrExplicit")) + return emitIntrinsic(Builder, vc::InternalIntrinsic::cast_to_ptr_explicit, + Ty, {CI.getArgOperand(0)}); + // SPV_INTEL_bfloat16_conversion extension. +- if (CalleeName.startswith("ConvertFToBF16INTEL")) { ++ if (CalleeName.starts_with("ConvertFToBF16INTEL")) { + auto *Arg = CI.getArgOperand(0); + auto *ArgTy = Arg->getType(); + return emitIntrinsic(Builder, vc::InternalIntrinsic::cast_to_bf16, + {Ty, ArgTy}, {Arg}); + } +- if (CalleeName.startswith("ConvertBF16ToFINTEL")) { ++ if (CalleeName.starts_with("ConvertBF16ToFINTEL")) { + auto *Arg = CI.getArgOperand(0); + auto *ArgTy = Arg->getType(); + return emitIntrinsic(Builder, vc::InternalIntrinsic::cast_from_bf16, + {Ty, ArgTy}, {Arg}); + } + // SPV_INTEL_tensor_float32_rounding extension. +- if (CalleeName.startswith("RoundFToTF32INTEL") || +- CalleeName.startswith("ConvertFToTF32INTEL")) { ++ if (CalleeName.starts_with("RoundFToTF32INTEL") || ++ CalleeName.starts_with("ConvertFToTF32INTEL")) { + auto *Arg = CI.getArgOperand(0); + auto *ArgTy = Arg->getType(); + Type *ResTy = Builder.getInt32Ty(); +@@ -249,14 +249,14 @@ Value *SPIRVExpander::visitCallInst(CallInst &CI) { + return Builder.CreateBitCast(Intr, Ty); + } + // SPV_KHR_shader_clock extension. +- if (CalleeName.startswith("ReadClockKHR")) { ++ if (CalleeName.starts_with("ReadClockKHR")) { + auto *Intr = emitIntrinsic(Builder, Intrinsic::readcyclecounter, + llvm::ArrayRef(), {}); + return Builder.CreateBitCast(Intr, CI.getType()); + } + // SPV_EXT_shader_atomic_float_min_max extension +- if (CalleeName.startswith("AtomicFMin") || +- CalleeName.startswith("AtomicFMax")) { ++ if (CalleeName.starts_with("AtomicFMin") || ++ CalleeName.starts_with("AtomicFMax")) { + auto *Ptr = CI.getArgOperand(0); + auto *Scope = CI.getArgOperand(1); + auto *Semantic = CI.getArgOperand(2); +@@ -290,7 +290,7 @@ Value *SPIRVExpander::visitCallInst(CallInst &CI) { + if (IID != Intrinsic::not_intrinsic) + return emitMulExtended(Builder, IID, CI); + +- if (CalleeName.startswith("Dot")) { ++ if (CalleeName.starts_with("Dot")) { + return emitDot(Builder, IID, CI); + } + +@@ -350,45 +350,45 @@ Value *SPIRVExpander::visitCallInst(CallInst &CI) { + return emitMathIntrinsic(Builder, IID, Ty, Args, true); + } + +- if (CalleeName.startswith("divide")) ++ if (CalleeName.starts_with("divide")) + return emitFDiv(Builder, CI.getArgOperand(0), CI.getArgOperand(1), true); +- if (CalleeName.startswith("exp10")) { ++ if (CalleeName.starts_with("exp10")) { + // exp10(x) == exp2(x * log2(10)) + auto *C = ConstantFP::get(Ty, Log2_10); + auto *ArgV = Builder.CreateFMul(CI.getArgOperand(0), C); + return emitMathIntrinsic(Builder, Intrinsic::exp2, Ty, {ArgV}, true); + } +- if (CalleeName.startswith("exp")) { ++ if (CalleeName.starts_with("exp")) { + // exp(x) == exp2(x * log2(e)) + auto *C = ConstantFP::get(Ty, Log2E); + auto *ArgV = Builder.CreateFMul(CI.getArgOperand(0), C); + return emitMathIntrinsic(Builder, Intrinsic::exp2, Ty, {ArgV}, true); + } +- if (CalleeName.startswith("log10")) { ++ if (CalleeName.starts_with("log10")) { + // log10(x) == log2(x) * log10(2) + auto *LogV = emitMathIntrinsic(Builder, Intrinsic::log2, Ty, + {CI.getArgOperand(0)}, true); + auto *C = ConstantFP::get(Ty, Log10_2); + return Builder.CreateFMul(LogV, C); + } +- if (CalleeName.startswith("log")) { ++ if (CalleeName.starts_with("log")) { + // ln(x) == log2(x) * ln(2) + auto *LogV = emitMathIntrinsic(Builder, Intrinsic::log2, Ty, + {CI.getArgOperand(0)}, true); + auto *C = ConstantFP::get(Ty, Ln2); + return Builder.CreateFMul(LogV, C); + } +- if (CalleeName.startswith("recip")) { ++ if (CalleeName.starts_with("recip")) { + auto *OneC = ConstantFP::get(Ty, 1.0); + return emitFDiv(Builder, OneC, CI.getArgOperand(0), true); + } +- if (CalleeName.startswith("rsqrt")) { ++ if (CalleeName.starts_with("rsqrt")) { + auto *OneC = ConstantFP::get(Ty, 1.0); + auto *SqrtV = emitMathIntrinsic(Builder, Intrinsic::sqrt, Ty, + {CI.getArgOperand(0)}, true); + return emitFDiv(Builder, OneC, SqrtV, true); + } +- if (CalleeName.startswith("tan")) { ++ if (CalleeName.starts_with("tan")) { + // tan(x) == sin(x) / cos(x) + auto *ArgV = CI.getArgOperand(0); + auto *SinV = emitMathIntrinsic(Builder, Intrinsic::sin, Ty, {ArgV}, true); +@@ -462,7 +462,7 @@ void GenXTranslateSPIRVBuiltins::getAnalysisUsage(AnalysisUsage &AU) const { + static bool isSPIRVBuiltinDecl(const Function &F) { + auto Name = F.getName(); + // __devicelib_* functions may have implementations which VC should replace +- if (Name.startswith("__devicelib") || Name == "__assert_fail") ++ if (Name.starts_with("__devicelib") || Name == "__assert_fail") + return true; + if (!F.isDeclaration()) + return false; +diff --git a/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXTypeLegalization.cpp b/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXTypeLegalization.cpp +index a3cbc90..7c9a759 100644 +--- a/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXTypeLegalization.cpp ++++ b/IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXTypeLegalization.cpp +@@ -130,7 +130,7 @@ Value *GenXTypeLegalization::getLegalizedValue(Value *OldV) { + if (auto *C = dyn_cast(OldV)) { + auto *NewCType = getLegalizedType(C->getType()); + // TODO: consider signess here. +- return ConstantExpr::getZExt(C, NewCType); ++ return ConstantExpr::getCast(Instruction::ZExt, C, NewCType); + } + auto *NewV = ValueMap[OldV]; + // Instructions are visited in topological order so a record should exist. +diff --git a/IGC/VectorCompiler/lib/InternalIntrinsics/InternalIntrinsics.cpp b/IGC/VectorCompiler/lib/InternalIntrinsics/InternalIntrinsics.cpp +index eaf3a52..fb1c91c 100644 +--- a/IGC/VectorCompiler/lib/InternalIntrinsics/InternalIntrinsics.cpp ++++ b/IGC/VectorCompiler/lib/InternalIntrinsics/InternalIntrinsics.cpp +@@ -244,7 +244,7 @@ DecodeIITType(unsigned &NextElt, ArrayRef Infos, + case IIT_HALF_VEC_ARG: { + unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]); + OutputTable.push_back( +- IITDescriptor::get(IITDescriptor::HalfVecArgument, ArgInfo)); ++ IITDescriptor::get(IITDescriptor::OneNthEltsVecArgument, 2, ArgInfo)); + return; + } + case IIT_SAME_VEC_WIDTH_ARG: { +@@ -319,7 +319,7 @@ static Type *DecodeFixedType(ArrayRef &Infos, + case IITDescriptor::VarArg: + return Type::getVoidTy(Context); + case IITDescriptor::MMX: +- return Type::getX86_MMXTy(Context); ++ return TargetExtType::get(Context, "x86_mmx"); + case IITDescriptor::Token: + return Type::getTokenTy(Context); + case IITDescriptor::Metadata: +@@ -365,9 +365,9 @@ static Type *DecodeFixedType(ArrayRef &Infos, + IGC_ASSERT(ITy->getBitWidth() % 2 == 0); + return IntegerType::get(Context, ITy->getBitWidth() / 2); + } +- case IITDescriptor::HalfVecArgument: +- return VectorType::getHalfElementsVectorType( +- cast(Tys[D.getArgumentNumber()])); ++ case IITDescriptor::OneNthEltsVecArgument: ++ return VectorType::get(cast(Tys[D.getRefArgNumber()])->getElementType(), ++ ElementCount::get(cast(Tys[D.getRefArgNumber()])->getElementCount().getKnownMinValue() / D.getVectorDivisor(), cast(Tys[D.getRefArgNumber()])->getElementCount().isScalable())); + case IITDescriptor::SameVecWidthArgument: { + Type *EltTy = DecodeFixedType(Infos, Tys, Context); + Type *Ty = Tys[D.getArgumentNumber()]; +@@ -538,7 +538,7 @@ bool InternalIntrinsic::isOverloadedRet(unsigned IntrinID) { + /// Returns the relevant slice of \c IntrinsicNameTable + static ArrayRef findTargetSubtable(StringRef Name) { + +- IGC_ASSERT(Name.startswith("llvm.vc.internal.")); ++ IGC_ASSERT(Name.starts_with("llvm.vc.internal.")); + + ArrayRef Targets(TargetInfos); + StringRef Target = "vc.internal"; +@@ -553,11 +553,18 @@ static ArrayRef findTargetSubtable(StringRef Name) { + + static InternalIntrinsic::ID lookupInternalIntrinsicID(StringRef Name) { + ArrayRef NameTable = findTargetSubtable(Name); +- int Idx = Intrinsic::lookupLLVMIntrinsicByName(NameTable, Name); +- if (Idx == -1) { ++ auto It2 = llvm::find_if(NameTable, [Name](const char *Entry) { ++ if (!Entry) ++ return false; ++ StringRef EntryRef(Entry); ++ return Name == EntryRef || ++ (Name.starts_with(EntryRef) && Name.size() > EntryRef.size() && ++ static_cast(Name[EntryRef.size()]) == 46); ++ }); ++ if (It2 == NameTable.end()) { + return InternalIntrinsic::not_internal_intrinsic; + } +- IGC_ASSERT_EXIT(Idx >= 0); ++ int Idx = static_cast(std::distance(NameTable.begin(), It2)); + + // Intrinsic IDs correspond to the location in IntrinsicNameTable, but we have + // an index into a sub-table. +@@ -655,7 +662,7 @@ InternalIntrinsic::ID + InternalIntrinsic::getInternalIntrinsicID(const Function *F) { + IGC_ASSERT_EXIT(F); + llvm::StringRef Name = F->getName(); +- if (!Name.startswith(getInternalIntrinsicPrefix())) { ++ if (!Name.starts_with(getInternalIntrinsicPrefix())) { + return InternalIntrinsic::not_internal_intrinsic; + } + +@@ -671,7 +678,7 @@ InternalIntrinsic::getInternalIntrinsicID(const Function *F) { + const char *NamePrefix = + InternalIntrinsicNameTable[Id - + InternalIntrinsic::not_internal_intrinsic]; +- if (Name.startswith(NamePrefix)) ++ if (Name.starts_with(NamePrefix)) + return Id; + } + } +diff --git a/IGC/VectorCompiler/lib/Support/PassManager.cpp b/IGC/VectorCompiler/lib/Support/PassManager.cpp +index a9ac314..3577798 100644 +--- a/IGC/VectorCompiler/lib/Support/PassManager.cpp ++++ b/IGC/VectorCompiler/lib/Support/PassManager.cpp +@@ -20,6 +20,7 @@ SPDX-License-Identifier: MIT + #include + #include + #include ++#include + #include + #include + +@@ -145,8 +146,8 @@ static OutputStreamHandle createOutputStream(const llvm::Twine &Name) { + + // global (!!!) variable storing output stream handles for IR printer, + // guarded by mutex +-static ManagedStatic> IRDumpStreams; +-static ManagedStatic> IRDumpsLock; ++static llvm::ManagedStatic> IRDumpStreams; ++static llvm::ManagedStatic> IRDumpsLock; + + llvm::raw_fd_ostream &getFileStreamForIRDump(const Twine &Name) { + sys::SmartScopedLock Writer(*IRDumpsLock); +diff --git a/IGC/VectorCompiler/lib/Utils/GenX/IntrinsicsWrapper.cpp b/IGC/VectorCompiler/lib/Utils/GenX/IntrinsicsWrapper.cpp +index e97ac05..9fb19b9 100644 +--- a/IGC/VectorCompiler/lib/Utils/GenX/IntrinsicsWrapper.cpp ++++ b/IGC/VectorCompiler/lib/Utils/GenX/IntrinsicsWrapper.cpp +@@ -91,7 +91,7 @@ Function *vc::getAnyDeclaration(Module *M, unsigned ID, ArrayRef Tys) { + if (InternalIntrinsic::isInternalNonTrivialIntrinsic(ID)) + return InternalIntrinsic::getInternalDeclaration( + M, static_cast(ID), Tys); +- return Intrinsic::getDeclaration(M, static_cast(ID), Tys); ++ return Intrinsic::getOrInsertDeclaration(M, static_cast(ID), Tys); + } + + std::string vc::getAnyName(unsigned Id, ArrayRef Tys) { +diff --git a/IGC/VectorCompiler/lib/Utils/GenX/Printf.cpp b/IGC/VectorCompiler/lib/Utils/GenX/Printf.cpp +index 2accb79..f9d6ef6 100644 +--- a/IGC/VectorCompiler/lib/Utils/GenX/Printf.cpp ++++ b/IGC/VectorCompiler/lib/Utils/GenX/Printf.cpp +@@ -140,14 +140,14 @@ StringRef vc::getConstStringFromOperand(const Value &Op) { + // \p IsSigned, defines which particular integer type is provided. + static PrintfArgInfo parseIntLengthModifier(StringRef ArgDesc, bool IsSigned) { + std::string Suffix{1u, ArgDesc.back()}; +- if (ArgDesc.endswith("hh" + Suffix)) ++ if (ArgDesc.ends_with("hh" + Suffix)) + return {PrintfArgInfo::Char, IsSigned}; +- if (ArgDesc.endswith("h" + Suffix)) ++ if (ArgDesc.ends_with("h" + Suffix)) + return {PrintfArgInfo::Short, IsSigned}; +- if (ArgDesc.endswith("ll" + Suffix)) ++ if (ArgDesc.ends_with("ll" + Suffix)) + // TOTHINK: maybe we need a separate type ID for long long. + return {PrintfArgInfo::Long, IsSigned}; +- if (ArgDesc.endswith("l" + Suffix)) ++ if (ArgDesc.ends_with("l" + Suffix)) + return {PrintfArgInfo::Long, IsSigned}; + return {PrintfArgInfo::Int, IsSigned}; + } +@@ -155,15 +155,15 @@ static PrintfArgInfo parseIntLengthModifier(StringRef ArgDesc, bool IsSigned) { + // \p ArgDesc is a format string conversion specifier matched by a regex + // (some string that starts with % and ends with d,i,f,...). + static PrintfArgInfo parseArgDesc(StringRef ArgDesc) { +- if (ArgDesc.endswith("c")) ++ if (ArgDesc.ends_with("c")) + // FIXME: support %lc + return {PrintfArgInfo::Int, /* IsSigned */ true}; +- if (ArgDesc.endswith("s")) ++ if (ArgDesc.ends_with("s")) + // FIXME: support %ls + return {PrintfArgInfo::String, /* IsSigned */ false}; +- if (ArgDesc.endswith("d") || ArgDesc.endswith("i")) ++ if (ArgDesc.ends_with("d") || ArgDesc.ends_with("i")) + return parseIntLengthModifier(ArgDesc, /* IsSigned */ true); +- if (ArgDesc.endswith("o") || ArgDesc.endswith("u") || ++ if (ArgDesc.ends_with("o") || ArgDesc.ends_with("u") || + IGCLLVM::ends_with_insensitive(ArgDesc, "x")) + return parseIntLengthModifier(ArgDesc, /* IsSigned */ false); + if (IGCLLVM::ends_with_insensitive(ArgDesc, "f") || +@@ -171,7 +171,7 @@ static PrintfArgInfo parseArgDesc(StringRef ArgDesc) { + IGCLLVM::ends_with_insensitive(ArgDesc, "a") || + IGCLLVM::ends_with_insensitive(ArgDesc, "g")) + return {PrintfArgInfo::Double, /* IsSigned */ true}; +- IGC_ASSERT_MESSAGE(ArgDesc.endswith("p"), "unexpected conversion specifier"); ++ IGC_ASSERT_MESSAGE(ArgDesc.ends_with("p"), "unexpected conversion specifier"); + return {PrintfArgInfo::Pointer, /* IsSigned */ false}; + } + +diff --git a/IGC/VectorCompiler/lib/Utils/General/DebugInfo.cpp b/IGC/VectorCompiler/lib/Utils/General/DebugInfo.cpp +index 4d3f64d..bf81a70 100644 +--- a/IGC/VectorCompiler/lib/Utils/General/DebugInfo.cpp ++++ b/IGC/VectorCompiler/lib/Utils/General/DebugInfo.cpp +@@ -142,7 +142,7 @@ DIType *vc::DIBuilder::translateTypeToDIType(Type &Ty) const { + auto *CompositeTypeDI = DICompositeType::get( + Ctx, dwarf::DW_TAG_array_type, "" /*Name*/, nullptr /*File*/, 0 /*Line*/, + nullptr /*Scope*/, ScalarDI, SizeInBits, 0 /*AlignInBits*/, +- 0 /*OfffsetInBits*/, DINode::FlagVector, Subscripts, 0, nullptr); ++ 0 /*OfffsetInBits*/, DINode::FlagVector, Subscripts, 0, std::nullopt, nullptr); + return CompositeTypeDI; + } + +@@ -176,7 +176,7 @@ vc::DIBuilder::createDbgDeclare(Value &Address, DILocalVariable &LocalVar, + MetadataAsValue::get(Ctx, ValueAsMetadata::get(&Address)), + MetadataAsValue::get(Ctx, &LocalVar), MetadataAsValue::get(Ctx, &Expr)}; + +- auto *DbgDeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); ++ auto *DbgDeclareFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_declare); + IRBuilder<> Builder(&InsertPt); + Builder.SetCurrentDebugLocation(&Loc); + auto *DeclareInst = Builder.CreateCall(DbgDeclareFn, DeclareArgs); +diff --git a/IGC/VectorCompiler/lib/Utils/General/InstRebuilder.cpp b/IGC/VectorCompiler/lib/Utils/General/InstRebuilder.cpp +index 041c0e1..7f60f9c 100644 +--- a/IGC/VectorCompiler/lib/Utils/General/InstRebuilder.cpp ++++ b/IGC/VectorCompiler/lib/Utils/General/InstRebuilder.cpp +@@ -148,7 +148,7 @@ public: + auto *RetTy = + getIntrinsicRetTypeBasedOnArgs(IID, ArgTys, OrigIntrinsic.getContext()); + auto OverloadedTys = getIntrinsicOverloadedTypes(IID, RetTy, ArgTys); +- auto *Decl = Intrinsic::getDeclaration(OrigIntrinsic.getModule(), IID, ++ auto *Decl = Intrinsic::getOrInsertDeclaration(OrigIntrinsic.getModule(), IID, + OverloadedTys); + return cast(CallInst::Create(Decl, NewOperands)); + } +diff --git a/IGC/VectorCompiler/utils/vcb/UniqueCompilation.cpp b/IGC/VectorCompiler/utils/vcb/UniqueCompilation.cpp +index 32d3171..f0c1306 100644 +--- a/IGC/VectorCompiler/utils/vcb/UniqueCompilation.cpp ++++ b/IGC/VectorCompiler/utils/vcb/UniqueCompilation.cpp +@@ -17,6 +17,7 @@ SPDX-License-Identifier: MIT + #include + #include + #include ++#include + #include + #include + #include +@@ -94,53 +95,76 @@ void generateBifSelectionProcedure( + raw_fd_ostream OS{FD, /*shouldClose=*/true}; + + OS << "// This file is auto generated by vcb tool, DO NOT EDIT\n\n"; +- + OS << "#include \"IGC/common/StringMacros.hpp\"\n"; +- OS << "#include \"llvm/ADT/StringRef.h\"\n"; ++ OS << "#include \"llvm/ADT/StringRef.h\"\n\n"; ++ ++ SmallString<256> Stem(Output); ++ sys::path::replace_extension(Stem, ""); ++ constexpr unsigned MaxShards = 32; ++ ++ for (const auto &[ByteCode, UniPltf] : HashedUniquePltfs) ++ OS << "llvm::StringRef get" << SymbolPrefix << "PLTF" << UniPltf.Num << "();\n"; + OS << "\n"; + +- // For each unique bitcode generate a C array that contains binary data +- // representing the bitcode +- for (const auto &[ByteCode, UniPltf] : HashedUniquePltfs) { +- std::string Pltf = SymbolPrefix + "PLTF" + std::to_string(UniPltf.Num); +- OS << "static unsigned char " << Pltf << "[] = {"; +- bool FirstIn = true; +- for (size_t i = 0; i < ByteCode.size(); i++) { +- if (!FirstIn) +- OS << ","; +- FirstIn = false; +- uint8_t Num = ByteCode[i]; +- OS << " 0x" << utohexstr(Num); ++ for (unsigned I = 0; I != MaxShards; ++I) { ++ auto It = llvm::find_if(HashedUniquePltfs, [I](const auto &Entry) { ++ return Entry.second.Num == I; ++ }); ++ ++ SmallString<256> ShardPath(Stem); ++ ShardPath += ".PLTF"; ++ ShardPath += std::to_string(I); ++ ShardPath += ".cpp"; ++ ++ int ShardFD; ++ EC = llvm::sys::fs::openFileForWrite(ShardPath, ShardFD); ++ if (EC) ++ report_fatal_error(llvm::StringRef("vcb : can't open output file " + ++ ShardPath.str().str())); ++ raw_fd_ostream ShardOS{ShardFD, /*shouldClose=*/true}; ++ ShardOS << "// This file is auto generated by vcb tool, DO NOT EDIT\n\n"; ++ ShardOS << "#include \"llvm/ADT/StringRef.h\"\n\n"; ++ ++ if (It == HashedUniquePltfs.end()) { ++ ShardOS << "llvm::StringRef get" << SymbolPrefix << "PLTF" << I ++ << "() { return \"\"; }\n"; ++ continue; + } + +- OS << "\n };\n\n" +- << "unsigned int " << Pltf << "_size = " << ByteCode.size() << ";\n\n"; ++ const std::string &ByteCode = It->first; ++ ShardOS << "static const char " << SymbolPrefix << "PLTF" << I << "[] =\n"; ++ const unsigned BytesPerLine = 32; ++ for (size_t Pos = 0; Pos < ByteCode.size(); Pos += BytesPerLine) { ++ ShardOS << " \""; ++ size_t End = std::min(Pos + BytesPerLine, ByteCode.size()); ++ for (size_t J = Pos; J != End; ++J) ++ ShardOS << "\\x" << utohexstr(static_cast(ByteCode[J]), true); ++ ShardOS << "\"\n"; ++ } ++ ShardOS << ";\n\n"; ++ ShardOS << "llvm::StringRef get" << SymbolPrefix << "PLTF" << I ++ << "() { return llvm::StringRef(" << SymbolPrefix << "PLTF" << I ++ << ", " << ByteCode.size() << "); }\n"; + } ++ + OS << "llvm::StringRef get" << SymbolPrefix + << "Impl(llvm::StringRef CPUStr) {\n"; +- +- // Generate a selection procedure that for each supported platform +- // (taken from configuration file) selects a BLOB that represents a +- // platform-specific emulation BiF corresponding to that platform. + for (const auto &[ByteCode, UniPltf] : HashedUniquePltfs) { + const auto &PltfList = UniPltf.Platforms; + std::vector PlatformCompareExpressions; + llvm::transform(PltfList, std::back_inserter(PlatformCompareExpressions), + [](const auto &Pltf) { +- return (Twine("CPUStr.equals(") + +- renderPlatformLiteral(Pltf) + ")") ++ return (Twine("CPUStr == ") + ++ renderPlatformLiteral(Pltf)) + .str(); + }); + OS << " if (" << llvm::join(PlatformCompareExpressions, "\n || ") + << ")\n" +- << " return {reinterpret_cast(" << SymbolPrefix +- << "PLTF" << UniPltf.Num << "),\n" +- << " " << SymbolPrefix << "PLTF" << UniPltf.Num +- << "_size};\n"; ++ << " return get" << SymbolPrefix << "PLTF" << UniPltf.Num ++ << "();\n"; + } + OS << "return \"\";\n"; + OS << "};\n\n"; +- OS.close(); + } + + // Parses input configuration file (see \fn vcbCompileUnique for the format) +diff --git a/IGC/VectorCompiler/utils/vcb/vcb.cpp b/IGC/VectorCompiler/utils/vcb/vcb.cpp +index 2b5d400..ddbd16e 100644 +--- a/IGC/VectorCompiler/utils/vcb/vcb.cpp ++++ b/IGC/VectorCompiler/utils/vcb/vcb.cpp +@@ -26,6 +26,7 @@ SPDX-License-Identifier: MIT + #include + #include + #include ++#include + #include + #include + +@@ -79,10 +80,10 @@ createTargetMachine(Triple &TheTriple, std::string CPUStr) { + IGC_ASSERT_MESSAGE(TheTarget, "vc target was not registered"); + + const TargetOptions Options; +- CodeGenOpt::Level OptLevel = CodeGenOpt::Default; ++ CodeGenOptLevel OptLevel = CodeGenOptLevel::Default; + + std::unique_ptr TM{TheTarget->createTargetMachine( +- TheTriple.getTriple(), CPUStr, FeaturesStr, Options, /*RelocModel=*/{}, ++ TheTriple, CPUStr, FeaturesStr, Options, /*RelocModel=*/{}, + /*CodeModel=*/{}, OptLevel)}; + if (!TM) + return make_error(); +@@ -99,7 +100,7 @@ void vcbCompileModule(std::unique_ptr &M, std::string Platform) { + // Target configuration. + Triple TheTriple{Is32Bit ? "genx32-unknown-unknown" + : "genx64-unknown-unknown"}; +- M->setTargetTriple(TheTriple.getTriple()); ++ M->setTargetTriple(TheTriple); + auto ExpTargetMachine = createTargetMachine(TheTriple, std::move(Platform)); + if (!ExpTargetMachine) { + errs() << ExpTargetMachine.takeError(); +@@ -111,7 +112,7 @@ void vcbCompileModule(std::unique_ptr &M, std::string Platform) { + // Fill/initialize VC Codegen pipeline. + legacy::PassManager PM; + llvm::raw_null_ostream NOS; +- auto FileType = IGCLLVM::TargetMachine::CodeGenFileType::CGFT_AssemblyFile; ++ auto FileType = IGCLLVM::TargetMachine::CodeGenFileType::AssemblyFile; + bool DisableIrVerifier = true; + PM.add(new GenXBackendConfig{std::move(Options), GenXBackendData()}); + [[maybe_unused]] bool AddPasses = +@@ -120,18 +121,28 @@ void vcbCompileModule(std::unique_ptr &M, std::string Platform) { + + // Output configuration. + std::error_code EC; ++ SmallString<256> OutputPath(OutputFilename); ++ SmallString<256> CWD; ++ sys::fs::current_path(CWD); ++ if (sys::path::is_absolute(OutputPath) && ++ sys::path::parent_path(OutputPath) == StringRef(CWD)) ++ OutputPath = sys::path::filename(OutputPath); ++ else ++ sys::fs::create_directories(sys::path::parent_path(OutputPath)); + sys::fs::OpenFlags Flags = TextOutput ? sys::fs::OF_Text : sys::fs::OF_None; +- ToolOutputFile Output{OutputFilename, EC, Flags}; +- if (EC) +- report_fatal_error(llvm::StringRef("Can't open file : " + OutputFilename)); ++ raw_fd_ostream Output(OutputPath, EC, Flags); ++ if (EC) { ++ std::string Msg = "Cannot open file : " + OutputPath.str().str() + ": " + ++ EC.message(); ++ report_fatal_error(StringRef(Msg)); ++ } + if (TextOutput) +- PM.add(createPrintModulePass(Output.os())); ++ PM.add(createPrintModulePass(Output)); + else +- PM.add(createBitcodeWriterPass(Output.os())); ++ PM.add(createBitcodeWriterPass(Output)); + + // Run codegen. + PM.run(*M); +- Output.keep(); + } + + std::unique_ptr safeParseIRFile(StringRef Filename, SMDiagnostic &Err, +diff --git a/IGC/WrapperLLVM/include/llvmWrapper/Analysis/TargetTransformInfo.h b/IGC/WrapperLLVM/include/llvmWrapper/Analysis/TargetTransformInfo.h +index 4ab8c9d..9438db2 100644 +--- a/IGC/WrapperLLVM/include/llvmWrapper/Analysis/TargetTransformInfo.h ++++ b/IGC/WrapperLLVM/include/llvmWrapper/Analysis/TargetTransformInfo.h +@@ -26,7 +26,7 @@ private: + public: + TTIImplCRTPBase(const llvm::DataLayout &DL) : CRTPBaseT(DL) {} + llvm::InstructionCost getInstructionCost(const llvm::User *U, llvm::ArrayRef Operands, +- llvm::TargetTransformInfo::TargetCostKind CostKind) { ++ llvm::TargetTransformInfo::TargetCostKind CostKind) const { + #if LLVM_VERSION_MAJOR >= 16 + return CRTPBaseT::getInstructionCost(U, Operands, CostKind); + #else // LLVM_VERSION_MAJOR +diff --git a/IGC/WrapperLLVM/include/llvmWrapper/IR/ConstantFolder.h b/IGC/WrapperLLVM/include/llvmWrapper/IR/ConstantFolder.h +index 8e6489a..175c218 100644 +--- a/IGC/WrapperLLVM/include/llvmWrapper/IR/ConstantFolder.h ++++ b/IGC/WrapperLLVM/include/llvmWrapper/IR/ConstantFolder.h +@@ -12,17 +12,14 @@ SPDX-License-Identifier: MIT + #include "IGC/common/LLVMWarningsPush.hpp" + #include "llvm/Config/llvm-config.h" + #include "llvm/IR/ConstantFolder.h" ++#include ++#include ++#include + #include + #include "IGC/common/LLVMWarningsPop.hpp" + + namespace IGCLLVM { +-// The main methods of the class now get proxied to an llvm::ConstantFolder +-// instance so as to avoid letting `ConstantFolderBase` class become a +-// pure-virtual class. Meanwhile, IGCConstantFolder itself is switched to +-// inheriting from llvm::IRBuilderFolder to make it an acceptable template +-// argument for the llvm::IRBuilder hierarchy. +-// This was done because of a change in llvm::ConstantFolder class, +-// which made it final, i.e. impossible to inherit from. ++ + class ConstantFolderBase : public llvm::IRBuilderFolder { + private: + llvm::ConstantFolder m_baseConstantFolder; +@@ -30,304 +27,95 @@ private: + public: + ConstantFolderBase() : m_baseConstantFolder(llvm::ConstantFolder()) {} + +- /// ------------------------------------------------------------------- +- /// This block defines virtual methods that are present in all versions +- /// of the base llvm::IRBuilderFolder class prior to LLVM 14, and +- /// wrapper methods that are needed for build compability accross all +- /// versions prior to LLVM 15. +- /// ------------------------------------------------------------------- +- +- /// ------------------------------------------------------------------- +- /// This block defines virtual methods that are present in all versions +- /// of the base llvm::IRBuilderFolder class up to LLVM 14, and wrapper +- /// methods that are needed for build compability accross all versions +- /// up to LLVM 14. +- /// ------------------------------------------------------------------- +- +-#if (LLVM_VERSION_MAJOR < 15) +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Value *FoldAdd(llvm::Value *LHS, llvm::Value *RHS, bool HasNUW = false, +- bool HasNSW = false) const override { +- return m_baseConstantFolder.FoldAdd(LHS, RHS, HasNUW, HasNSW); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Value *FoldAnd(llvm::Value *LHS, llvm::Value *RHS) const override { +- return m_baseConstantFolder.FoldAnd(LHS, RHS); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Value *FoldOr(llvm::Value *LHS, llvm::Value *RHS) const override { +- return m_baseConstantFolder.FoldOr(LHS, RHS); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateFAdd(llvm::Constant *LHS, llvm::Constant *RHS) const override { +- return m_baseConstantFolder.CreateFAdd(LHS, RHS); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateSub(llvm::Constant *LHS, llvm::Constant *RHS, bool HasNUW = false, +- bool HasNSW = false) const override { +- return m_baseConstantFolder.CreateSub(LHS, RHS, HasNUW, HasNSW); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateFSub(llvm::Constant *LHS, llvm::Constant *RHS) const override { +- return m_baseConstantFolder.CreateFSub(LHS, RHS); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateMul(llvm::Constant *LHS, llvm::Constant *RHS, bool HasNUW = false, +- bool HasNSW = false) const override { +- return m_baseConstantFolder.CreateMul(LHS, RHS, HasNUW, HasNSW); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateFMul(llvm::Constant *LHS, llvm::Constant *RHS) const override { +- return m_baseConstantFolder.CreateFMul(LHS, RHS); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateUDiv(llvm::Constant *LHS, llvm::Constant *RHS, bool isExact = false) const override { +- return m_baseConstantFolder.CreateUDiv(LHS, RHS, isExact); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateSDiv(llvm::Constant *LHS, llvm::Constant *RHS, bool isExact = false) const override { +- return m_baseConstantFolder.CreateSDiv(LHS, RHS, isExact); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateFDiv(llvm::Constant *LHS, llvm::Constant *RHS) const override { +- return m_baseConstantFolder.CreateFDiv(LHS, RHS); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateURem(llvm::Constant *LHS, llvm::Constant *RHS) const override { +- return m_baseConstantFolder.CreateURem(LHS, RHS); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateSRem(llvm::Constant *LHS, llvm::Constant *RHS) const override { +- return m_baseConstantFolder.CreateSRem(LHS, RHS); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateFRem(llvm::Constant *LHS, llvm::Constant *RHS) const override { +- return m_baseConstantFolder.CreateFRem(LHS, RHS); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateShl(llvm::Constant *LHS, llvm::Constant *RHS, bool HasNUW = false, +- bool HasNSW = false) const override { +- return m_baseConstantFolder.CreateShl(LHS, RHS, HasNUW, HasNSW); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateLShr(llvm::Constant *LHS, llvm::Constant *RHS, bool isExact = false) const override { +- return m_baseConstantFolder.CreateLShr(LHS, RHS, isExact); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateAShr(llvm::Constant *LHS, llvm::Constant *RHS, bool isExact = false) const override { +- return m_baseConstantFolder.CreateAShr(LHS, RHS, isExact); +- } +- +- // Note: for direct usage in code, prefer `CreateBinOp` wrapper for all +- // LLVM versions up to 15. +- inline llvm::Constant *CreateXor(llvm::Constant *LHS, llvm::Constant *RHS) const override { +- return m_baseConstantFolder.CreateXor(LHS, RHS); +- } +- +- inline llvm::Constant *CreateNeg(llvm::Constant *C, bool HasNUW = false, bool HasNSW = false) const override { +- return m_baseConstantFolder.CreateNeg(C, HasNUW, HasNSW); +- } +- +- inline llvm::Constant *CreateFNeg(llvm::Constant *C) const override { return m_baseConstantFolder.CreateFNeg(C); } +- +- inline llvm::Constant *CreateNot(llvm::Constant *C) const override { return m_baseConstantFolder.CreateNot(C); } +- +- inline llvm::Constant *CreateUnOp(llvm::Instruction::UnaryOps Opc, llvm::Constant *C) const override { +- return m_baseConstantFolder.CreateUnOp(Opc, C); +- } +- +- inline llvm::Constant *CreateExtractElement(llvm::Constant *Vec, llvm::Constant *Idx) const override { +- return m_baseConstantFolder.CreateExtractElement(Vec, Idx); +- } +- +- inline llvm::Constant *CreateInsertElement(llvm::Constant *Vec, llvm::Constant *NewElt, +- llvm::Constant *Idx) const override { +- return m_baseConstantFolder.CreateInsertElement(Vec, NewElt, Idx); +- } +- +- inline llvm::Constant *CreateShuffleVector(llvm::Constant *V1, llvm::Constant *V2, +- llvm::ArrayRef Mask) const override { +- return m_baseConstantFolder.CreateShuffleVector(V1, V2, Mask); +- } +- +- inline llvm::Constant *CreateExtractValue(llvm::Constant *Agg, llvm::ArrayRef IdxList) const override { +- return m_baseConstantFolder.CreateExtractValue(Agg, IdxList); +- } +- +- inline llvm::Constant *CreateInsertValue(llvm::Constant *Agg, llvm::Constant *Val, +- llvm::ArrayRef IdxList) const override { +- return m_baseConstantFolder.CreateInsertValue(Agg, Val, IdxList); +- } +-#endif // (LLVM_VERSION_MAJOR < 15) +- +- /// ------------------------------------------------------------------- +- /// This block defines virtual methods that are present in the base +- /// llvm::IRBuilderFolder class starting from LLVM 15. +- /// ------------------------------------------------------------------- +- +-#if (LLVM_VERSION_MAJOR >= 15) +- inline llvm::Value *FoldBinOp(llvm::Instruction::BinaryOps Opc, llvm::Value *LHS, llvm::Value *RHS) const override { ++ llvm::Value *FoldBinOp(llvm::Instruction::BinaryOps Opc, llvm::Value *LHS, llvm::Value *RHS) const override { + return m_baseConstantFolder.FoldBinOp(Opc, LHS, RHS); + } + +- inline llvm::Value *FoldExactBinOp(llvm::Instruction::BinaryOps Opc, llvm::Value *LHS, llvm::Value *RHS, +- bool IsExact) const override { ++ llvm::Value *FoldExactBinOp(llvm::Instruction::BinaryOps Opc, llvm::Value *LHS, llvm::Value *RHS, bool IsExact) const override { + return m_baseConstantFolder.FoldExactBinOp(Opc, LHS, RHS, IsExact); + } + +- inline llvm::Value *FoldNoWrapBinOp(llvm::Instruction::BinaryOps Opc, llvm::Value *LHS, llvm::Value *RHS, bool HasNUW, +- bool HasNSW) const override { ++ llvm::Value *FoldNoWrapBinOp(llvm::Instruction::BinaryOps Opc, llvm::Value *LHS, llvm::Value *RHS, bool HasNUW, bool HasNSW) const override { + return m_baseConstantFolder.FoldNoWrapBinOp(Opc, LHS, RHS, HasNUW, HasNSW); + } + +- inline llvm::Value *FoldBinOpFMF(llvm::Instruction::BinaryOps Opc, llvm::Value *LHS, llvm::Value *RHS, +- llvm::FastMathFlags FMF) const override { ++ llvm::Value *FoldBinOpFMF(llvm::Instruction::BinaryOps Opc, llvm::Value *LHS, llvm::Value *RHS, llvm::FastMathFlags FMF) const override { + return m_baseConstantFolder.FoldBinOpFMF(Opc, LHS, RHS, FMF); + } + +- inline llvm::Value *FoldUnOpFMF(llvm::Instruction::UnaryOps Opc, llvm::Value *V, +- llvm::FastMathFlags FMF) const override { ++ llvm::Value *FoldUnOpFMF(llvm::Instruction::UnaryOps Opc, llvm::Value *V, llvm::FastMathFlags FMF) const override { + return m_baseConstantFolder.FoldUnOpFMF(Opc, V, FMF); + } + +- inline llvm::Value *FoldExtractValue(llvm::Value *Agg, llvm::ArrayRef IdxList) const override { +- return m_baseConstantFolder.FoldExtractValue(Agg, IdxList); ++ llvm::Value *FoldCmp(llvm::CmpInst::Predicate P, llvm::Value *LHS, llvm::Value *RHS) const override { ++ return m_baseConstantFolder.FoldCmp(P, LHS, RHS); + } + +- inline llvm::Value *FoldInsertValue(llvm::Value *Agg, llvm::Value *Val, +- llvm::ArrayRef IdxList) const override { +- return m_baseConstantFolder.FoldInsertValue(Agg, Val, IdxList); ++ llvm::Value *FoldGEP(llvm::Type *Ty, llvm::Value *Ptr, llvm::ArrayRef IdxList, llvm::GEPNoWrapFlags NW) const override { ++ return m_baseConstantFolder.FoldGEP(Ty, Ptr, IdxList, NW); + } + +- inline llvm::Value *FoldExtractElement(llvm::Value *Vec, llvm::Value *Idx) const override { +- return m_baseConstantFolder.FoldExtractElement(Vec, Idx); ++ llvm::Value *FoldSelect(llvm::Value *C, llvm::Value *True, llvm::Value *False) const override { ++ return m_baseConstantFolder.FoldSelect(C, True, False); + } + +- inline llvm::Value *FoldInsertElement(llvm::Value *Vec, llvm::Value *NewElt, llvm::Value *Idx) const override { +- return m_baseConstantFolder.FoldInsertElement(Vec, NewElt, Idx); ++ llvm::Value *FoldExtractValue(llvm::Value *Agg, llvm::ArrayRef IdxList) const override { ++ return m_baseConstantFolder.FoldExtractValue(Agg, IdxList); + } + +- inline llvm::Value *FoldShuffleVector(llvm::Value *V1, llvm::Value *V2, llvm::ArrayRef Mask) const override { +- return m_baseConstantFolder.FoldShuffleVector(V1, V2, Mask); ++ llvm::Value *FoldInsertValue(llvm::Value *Agg, llvm::Value *Val, llvm::ArrayRef IdxList) const override { ++ return m_baseConstantFolder.FoldInsertValue(Agg, Val, IdxList); + } +-#endif // LLVM_VERSION_MAJOR >= 15 + +- /// ------------------------------------------------------------------- +- /// This block defines virtual methods that are present in all versions +- /// of the base llvm::IRBuilderFolder class up to LLVM 15, and wrapper +- /// methods that are needed for build compability accross all versions +- /// up to LLVM 15. +- /// ------------------------------------------------------------------- +- +- inline llvm::Constant *CreateBinOp(llvm::Instruction::BinaryOps Opc, llvm::Constant *LHS, llvm::Constant *RHS) const +-#if (LLVM_VERSION_MAJOR < 15) +- override { +- return m_baseConstantFolder.CreateBinOp(Opc, LHS, RHS); +- } +-#else +- { +- return llvm::cast_or_null(m_baseConstantFolder.FoldBinOp(Opc, llvm::cast_or_null(LHS), +- llvm::cast_or_null(RHS))); ++ llvm::Value *FoldExtractElement(llvm::Value *Vec, llvm::Value *Idx) const override { ++ return m_baseConstantFolder.FoldExtractElement(Vec, Idx); + } +-#endif + +- inline llvm::Value *FoldICmp(llvm::CmpInst::Predicate P, llvm::Value *LHS, llvm::Value *RHS) const override { +- return m_baseConstantFolder.FoldICmp(P, LHS, RHS); ++ llvm::Value *FoldInsertElement(llvm::Value *Vec, llvm::Value *NewElt, llvm::Value *Idx) const override { ++ return m_baseConstantFolder.FoldInsertElement(Vec, NewElt, Idx); + } + +- inline llvm::Value *FoldSelect(llvm::Value *C, llvm::Value *True, llvm::Value *False) const override { +- return m_baseConstantFolder.FoldSelect(C, True, False); ++ llvm::Value *FoldShuffleVector(llvm::Value *V1, llvm::Value *V2, llvm::ArrayRef Mask) const override { ++ return m_baseConstantFolder.FoldShuffleVector(V1, V2, Mask); + } + +- inline llvm::Value *FoldGEP(llvm::Type *Ty, llvm::Value *Ptr, llvm::ArrayRef IdxList, +- bool IsInBounds = false) const override { +- return m_baseConstantFolder.FoldGEP(Ty, Ptr, IdxList, IsInBounds); ++ llvm::Value *FoldCast(llvm::Instruction::CastOps Op, llvm::Value *V, llvm::Type *DestTy) const override { ++ return m_baseConstantFolder.FoldCast(Op, V, DestTy); + } + +- inline llvm::Constant *CreateCast(llvm::Instruction::CastOps Op, llvm::Constant *C, +- llvm::Type *DestTy) const override { +- return m_baseConstantFolder.CreateCast(Op, C, DestTy); ++ llvm::Value *FoldBinaryIntrinsic(llvm::Intrinsic::ID ID, llvm::Value *LHS, llvm::Value *RHS, llvm::Type *Ty, llvm::Instruction *FMFSource = nullptr) const override { ++ return m_baseConstantFolder.FoldBinaryIntrinsic(ID, LHS, RHS, Ty, FMFSource); + } + +- inline llvm::Constant *CreatePointerCast(llvm::Constant *C, llvm::Type *DestTy) const override { ++ llvm::Value *CreatePointerCast(llvm::Constant *C, llvm::Type *DestTy) const override { + return m_baseConstantFolder.CreatePointerCast(C, DestTy); + } + +- inline llvm::Constant *CreatePointerBitCastOrAddrSpaceCast(llvm::Constant *C, llvm::Type *DestTy) const override { ++ llvm::Value *CreatePointerBitCastOrAddrSpaceCast(llvm::Constant *C, llvm::Type *DestTy) const override { + return m_baseConstantFolder.CreatePointerBitCastOrAddrSpaceCast(C, DestTy); + } + +- inline llvm::Constant *CreateIntCast(llvm::Constant *C, llvm::Type *DestTy, bool isSigned) const override { +- return m_baseConstantFolder.CreateIntCast(C, DestTy, isSigned); +- } +- +- inline llvm::Constant *CreateFPCast(llvm::Constant *C, llvm::Type *DestTy) const override { +- return m_baseConstantFolder.CreateFPCast(C, DestTy); +- } +- +- inline llvm::Constant *CreateBitCast(llvm::Constant *C, llvm::Type *DestTy) const override { +- return m_baseConstantFolder.CreateCast(llvm::Instruction::BitCast, C, DestTy); +- } +- +- inline llvm::Constant *CreateIntToPtr(llvm::Constant *C, llvm::Type *DestTy) const override { +- return m_baseConstantFolder.CreateCast(llvm::Instruction::IntToPtr, C, DestTy); ++ llvm::Constant *CreateBinOp(llvm::Instruction::BinaryOps Opc, llvm::Constant *LHS, llvm::Constant *RHS) const { ++ return llvm::cast_or_null(m_baseConstantFolder.FoldBinOp(Opc, LHS, RHS)); + } + +- inline llvm::Constant *CreatePtrToInt(llvm::Constant *C, llvm::Type *DestTy) const override { +- return m_baseConstantFolder.CreateCast(llvm::Instruction::PtrToInt, C, DestTy); ++ llvm::Constant *CreateFPCast(llvm::Constant *C, llvm::Type *DestTy) const { ++ auto Op = llvm::CastInst::getCastOpcode(C, false, DestTy, false); ++ return llvm::cast_or_null(m_baseConstantFolder.FoldCast(Op, C, DestTy)); + } + +- inline llvm::Constant *CreateZExtOrBitCast(llvm::Constant *C, llvm::Type *DestTy) const override { +- return m_baseConstantFolder.CreateZExtOrBitCast(C, DestTy); ++ llvm::Constant *CreateBitCast(llvm::Constant *C, llvm::Type *DestTy) const { ++ return llvm::cast_or_null(m_baseConstantFolder.FoldCast(llvm::Instruction::BitCast, C, DestTy)); + } + +- inline llvm::Constant *CreateSExtOrBitCast(llvm::Constant *C, llvm::Type *DestTy) const override { +- return m_baseConstantFolder.CreateSExtOrBitCast(C, DestTy); +- } +- +- inline llvm::Constant *CreateTruncOrBitCast(llvm::Constant *C, llvm::Type *DestTy) const override { +- return m_baseConstantFolder.CreateTruncOrBitCast(C, DestTy); +- } +- +- inline llvm::Constant *CreateFCmp(llvm::CmpInst::Predicate P, llvm::Constant *LHS, +- llvm::Constant *RHS) const override { +- return m_baseConstantFolder.CreateFCmp(P, LHS, RHS); ++ llvm::Constant *CreateZExtOrBitCast(llvm::Constant *C, llvm::Type *DestTy) const { ++ auto *Folded = m_baseConstantFolder.FoldCast(llvm::Instruction::ZExt, C, DestTy); ++ if (!Folded) ++ Folded = m_baseConstantFolder.FoldCast(llvm::Instruction::BitCast, C, DestTy); ++ return llvm::cast_or_null(Folded); + } + }; ++ + } // namespace IGCLLVM + + #endif // IGCLLVM_IR_CONSTANTFOLDER_H +diff --git a/IGC/WrapperLLVM/include/llvmWrapper/IR/DIBuilder.h b/IGC/WrapperLLVM/include/llvmWrapper/IR/DIBuilder.h +index 8b0437d..5444faa 100644 +--- a/IGC/WrapperLLVM/include/llvmWrapper/IR/DIBuilder.h ++++ b/IGC/WrapperLLVM/include/llvmWrapper/IR/DIBuilder.h +@@ -28,17 +28,17 @@ public: + inline llvm::Instruction *insertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset, llvm::DILocalVariable *VarInfo, + llvm::DIExpression *Expr, const llvm::DILocation *DL, + llvm::BasicBlock *InsertAtEnd) { +- return llvm::DIBuilder::insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertAtEnd); ++ return llvm::DIBuilder::insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertAtEnd).template dyn_cast(); + } + inline llvm::Instruction *insertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset, llvm::DILocalVariable *VarInfo, + llvm::DIExpression *Expr, const llvm::DILocation *DL, + llvm::Instruction *InsertBefore) { +- return llvm::DIBuilder::insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertBefore); ++ return llvm::DIBuilder::insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertBefore).template dyn_cast(); + } + inline llvm::Instruction *insertDbgValueIntrinsic(llvm::Value *V, llvm::DILocalVariable *VarInfo, + llvm::DIExpression *Expr, const llvm::DILocation *DL, + llvm::Instruction *InsertBefore) { +- return llvm::DIBuilder::insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertBefore); ++ return llvm::DIBuilder::insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertBefore).template dyn_cast(); + } + inline llvm::DINamespace *createNameSpace(llvm::DIScope *Scope, llvm::StringRef Name, llvm::DIFile *File, + unsigned LineNo, bool ExportSymbols) { +diff --git a/IGC/WrapperLLVM/include/llvmWrapper/IR/IRBuilder.h b/IGC/WrapperLLVM/include/llvmWrapper/IR/IRBuilder.h +index 104da3c..9412e64 100644 +--- a/IGC/WrapperLLVM/include/llvmWrapper/IR/IRBuilder.h ++++ b/IGC/WrapperLLVM/include/llvmWrapper/IR/IRBuilder.h +@@ -73,7 +73,7 @@ public: + llvm::MDNode *TBAAStructTag = nullptr, llvm::MDNode *ScopeTag = nullptr, + llvm::MDNode *NoAliasTag = nullptr) { + return llvm::IRBuilder::CreateMemCpy(Dst, getCorrectAlign(Align), Src, getCorrectAlign(Align), Size, +- isVolatile, TBAATag, TBAAStructTag, ScopeTag, NoAliasTag); ++ isVolatile, llvm::AAMDNodes(TBAATag, TBAAStructTag, ScopeTag, NoAliasTag, nullptr)); + } + + inline llvm::CallInst *CreateMemCpy(llvm::Value *Dst, llvm::Value *Src, llvm::Value *Size, alignment_t Align, +@@ -81,7 +81,7 @@ public: + llvm::MDNode *TBAAStructTag = nullptr, llvm::MDNode *ScopeTag = nullptr, + llvm::MDNode *NoAliasTag = nullptr) { + return llvm::IRBuilder::CreateMemCpy(Dst, getCorrectAlign(Align), Src, getCorrectAlign(Align), Size, +- isVolatile, TBAATag, TBAAStructTag, ScopeTag, NoAliasTag); ++ isVolatile, llvm::AAMDNodes(TBAATag, TBAAStructTag, ScopeTag, NoAliasTag, nullptr)); + } + + inline llvm::CallInst *CreateMemCpy(llvm::Value *Dst, alignment_t DstAlign, llvm::Value *Src, alignment_t SrcAlign, +@@ -89,7 +89,7 @@ public: + llvm::MDNode *TBAAStructTag = nullptr, llvm::MDNode *ScopeTag = nullptr, + llvm::MDNode *NoAliasTag = nullptr) { + return llvm::IRBuilder::CreateMemCpy(Dst, getCorrectAlign(DstAlign), Src, getCorrectAlign(SrcAlign), +- Size, isVolatile, TBAATag, TBAAStructTag, ScopeTag, NoAliasTag); ++ Size, isVolatile, llvm::AAMDNodes(TBAATag, TBAAStructTag, ScopeTag, NoAliasTag, nullptr)); + } + + inline llvm::CallInst *CreateMemCpy(llvm::Value *Dst, alignment_t DstAlign, llvm::Value *Src, alignment_t SrcAlign, +@@ -97,7 +97,7 @@ public: + llvm::MDNode *TBAAStructTag = nullptr, llvm::MDNode *ScopeTag = nullptr, + llvm::MDNode *NoAliasTag = nullptr) { + return llvm::IRBuilder::CreateMemCpy(Dst, getCorrectAlign(DstAlign), Src, getCorrectAlign(SrcAlign), +- Size, isVolatile, TBAATag, TBAAStructTag, ScopeTag, NoAliasTag); ++ Size, isVolatile, llvm::AAMDNodes(TBAATag, TBAAStructTag, ScopeTag, NoAliasTag, nullptr)); + } + + using llvm::IRBuilder::CreateMemSet; +@@ -122,14 +122,14 @@ public: + uint64_t Size, bool isVolatile = false, llvm::MDNode *TBAATag = nullptr, + llvm::MDNode *ScopeTag = nullptr, llvm::MDNode *NoAliasTag = nullptr) { + return llvm::IRBuilder::CreateMemMove(Dst, getCorrectAlign(DstAlign), Src, getCorrectAlign(SrcAlign), +- Size, isVolatile, TBAATag, ScopeTag, NoAliasTag); ++ Size, isVolatile, llvm::AAMDNodes(TBAATag, nullptr, ScopeTag, NoAliasTag, nullptr)); + } + + inline llvm::CallInst *CreateMemMove(llvm::Value *Dst, unsigned DstAlign, llvm::Value *Src, unsigned SrcAlign, + llvm::Value *Size, bool isVolatile = false, llvm::MDNode *TBAATag = nullptr, + llvm::MDNode *ScopeTag = nullptr, llvm::MDNode *NoAliasTag = nullptr) { + return llvm::IRBuilder::CreateMemMove(Dst, getCorrectAlign(DstAlign), Src, getCorrectAlign(SrcAlign), +- Size, isVolatile, TBAATag, ScopeTag, NoAliasTag); ++ Size, isVolatile, llvm::AAMDNodes(TBAATag, nullptr, ScopeTag, NoAliasTag, nullptr)); + } + + inline llvm::AllocaInst *CreateAlloca(llvm::Type *Ty, llvm::Value *ArraySize = nullptr, const llvm::Twine &Name = "", +diff --git a/IGC/WrapperLLVM/include/llvmWrapper/IR/IntrinsicInst.h b/IGC/WrapperLLVM/include/llvmWrapper/IR/IntrinsicInst.h +index d281cde..cce0dd1 100644 +--- a/IGC/WrapperLLVM/include/llvmWrapper/IR/IntrinsicInst.h ++++ b/IGC/WrapperLLVM/include/llvmWrapper/IR/IntrinsicInst.h +@@ -12,6 +12,7 @@ SPDX-License-Identifier: MIT + #include "IGC/common/LLVMWarningsPush.hpp" + #include + #include ++#include + #include + #include "llvm/IR/DebugInfoMetadata.h" + #include "llvm/Support/Casting.h" +@@ -50,6 +51,10 @@ inline void setExpression(llvm::DbgVariableIntrinsic *DbgInst, llvm::DIExpressio + IGC_ASSERT(DbgInst); + DbgInst->setExpression(NewExpr); + } ++inline void setExpression(llvm::DbgVariableRecord *DbgInst, llvm::DIExpression *NewExpr) { ++ IGC_ASSERT(DbgInst); ++ DbgInst->setExpression(NewExpr); ++} + } // namespace IGCLLVM + + #endif +diff --git a/IGC/WrapperLLVM/include/llvmWrapper/Support/Alignment.h b/IGC/WrapperLLVM/include/llvmWrapper/Support/Alignment.h +index c003bd2..dfcc3cf 100644 +--- a/IGC/WrapperLLVM/include/llvmWrapper/Support/Alignment.h ++++ b/IGC/WrapperLLVM/include/llvmWrapper/Support/Alignment.h +@@ -13,6 +13,7 @@ SPDX-License-Identifier: MIT + #include "llvm/Support/Alignment.h" + #include "llvm/Config/llvm-config.h" + #include "llvm/IR/DataLayout.h" ++#include "llvm/IR/Attributes.h" + #include "llvm/IR/GlobalObject.h" + #include "llvm/IR/Instruction.h" + #include "IGC/common/LLVMWarningsPop.hpp" +@@ -47,7 +48,10 @@ inline llvm::Align getCorrectAlign(alignment_t Val) { + // interface. + template , int> = 0> + llvm::Align getAlign(const TValue &Val) { +- return llvm::Align(Val.getAlignment()); ++ if constexpr (std::is_base_of_v) ++ return Val.getFnAttribute(llvm::Attribute::AttrKind::Alignment).getAlignment().valueOrOne(); ++ else ++ return llvm::Align(Val.getAlignment()); + } + + template , int> = 0> +diff --git a/IGC/WrapperLLVM/include/llvmWrapper/Target/TargetMachine.h b/IGC/WrapperLLVM/include/llvmWrapper/Target/TargetMachine.h +index eec95a3..22abd13 100644 +--- a/IGC/WrapperLLVM/include/llvmWrapper/Target/TargetMachine.h ++++ b/IGC/WrapperLLVM/include/llvmWrapper/Target/TargetMachine.h +@@ -13,6 +13,7 @@ SPDX-License-Identifier: MIT + #include "llvm/Config/llvm-config.h" + #include "llvm/CodeGen/MachineModuleInfo.h" + #include "llvm/Support/CodeGen.h" ++#include "llvm/CodeGen/CodeGenTargetMachineImpl.h" + #include "llvm/Target/TargetMachine.h" + #include "IGC/common/LLVMWarningsPop.hpp" + +@@ -49,15 +50,15 @@ public: + } + }; + +-class LLVMTargetMachine : public llvm::LLVMTargetMachine { ++class LLVMTargetMachine : public llvm::CodeGenTargetMachineImpl { + public: + using CodeGenFileType = llvm::CodeGenFileType; + + protected: + LLVMTargetMachine(const llvm::Target &T, llvm::StringRef DataLayoutString, const llvm::Triple &TargetTriple, + llvm::StringRef CPU, llvm::StringRef FS, const llvm::TargetOptions &Options, llvm::Reloc::Model RM, +- llvm::CodeModel::Model CM, llvm::CodeGenOpt::Level OL) +- : llvm::LLVMTargetMachine(T, DataLayoutString, TargetTriple, CPU, FS, Options, RM, CM, OL) {} ++ llvm::CodeModel::Model CM, llvm::CodeGenOptLevel OL) ++ : llvm::CodeGenTargetMachineImpl(T, DataLayoutString, TargetTriple, CPU, FS, Options, RM, CM, OL) {} + + private: + bool addPassesToEmitFile(llvm::PassManagerBase &PM, llvm::raw_pwrite_stream &o, llvm::raw_pwrite_stream *pi, +diff --git a/IGC/WrapperLLVM/lib/llvmWrapper/Transforms/IPO/InlineHelper.cpp b/IGC/WrapperLLVM/lib/llvmWrapper/Transforms/IPO/InlineHelper.cpp +index 5c3b176..501a29b 100644 +--- a/IGC/WrapperLLVM/lib/llvmWrapper/Transforms/IPO/InlineHelper.cpp ++++ b/IGC/WrapperLLVM/lib/llvmWrapper/Transforms/IPO/InlineHelper.cpp +@@ -39,7 +39,8 @@ bool removeDeadFunctions(CallGraph &CG, bool AlwaysInlineOnly) { + // Remove any edges from the external node to the function's call graph + // node. These edges might have been made irrelegant due to + // optimization of the program. +- CG.getExternalCallingNode()->removeAnyCallEdgeTo(CGN); ++ CG.getExternalCallingNode()->removeAllCalledFunctions(); ++ CG.populateCallGraphNode(CG.getExternalCallingNode()); + + // Removing the node for callee from the call graph and delete it. + FunctionsToRemove.push_back(CGN); +@@ -357,7 +358,7 @@ bool inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG, std::function Deleting dead call: " << CB << "\n"); + // Update the call graph by deleting the edge from Callee to Caller. + setInlineRemark(CB, "trivially dead"); +- CG[Caller]->removeCallEdgeFor(CB); ++ CG[Caller]->removeAllCalledFunctions(); ++ CG.populateCallGraphNode(CG[Caller]); + CB.eraseFromParent(); + } else { + // Get DebugLoc to report. CB will be invalid after Inliner. +@@ -384,7 +386,7 @@ bool inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG, std::function(); + +- if (skipSCC(SCC)) +- return false; + bool changed = inlineCalls(SCC); + return changed; + } +diff --git a/IGC/WrapperLLVM/lib/llvmWrapper/Transforms/IPO/LegacyPassManagerBuilder.cpp b/IGC/WrapperLLVM/lib/llvmWrapper/Transforms/IPO/LegacyPassManagerBuilder.cpp +index 1fb1738..b7b5047 100644 +--- a/IGC/WrapperLLVM/lib/llvmWrapper/Transforms/IPO/LegacyPassManagerBuilder.cpp ++++ b/IGC/WrapperLLVM/lib/llvmWrapper/Transforms/IPO/LegacyPassManagerBuilder.cpp +@@ -59,6 +59,7 @@ SPDX-License-Identifier: MIT + #include "llvmWrapper/Transforms/Scalar/LoopDistribute.h" + #include "llvmWrapper/Transforms/IPO/PostOrderFunctionAttrs.h" + #include "llvmWrapper/Transforms/Scalar/MemCpyOptimizer.h" ++#include "llvmWrapper/Transforms/Scalar/LowerExpectIntrinsic.h" + #include "llvmWrapper/Transforms/Scalar/LoopUnrollPass.h" + #include "llvmWrapper/Transforms/Scalar/IndVarSimplify.h" + #include "Compiler/IGCPassSupport.h" +@@ -96,7 +97,7 @@ void PassManagerBuilder::populateFunctionPassManager(legacy::FunctionPassManager + + // Lower llvm.expect to metadata before attempting transforms. + // Compare/branch metadata may alter the behavior of passes like SimplifyCFG. +- FPM.add(createLowerExpectIntrinsicPass()); ++ FPM.add(IGCLLVM::createLegacyWrappedLowerExpectIntrinsicPass()); + FPM.add(createCFGSimplificationPass()); + FPM.add(createSROAPass()); + FPM.add(createEarlyCSEPass()); +@@ -134,9 +135,6 @@ void PassManagerBuilder::addFunctionSimplificationPasses(legacy::PassManagerBase + // The simple loop unswitch pass relies on separate cleanup passes. Schedule + // them first so when we re-process a loop they run before other loop + // passes. +- MPM.add(createLoopInstSimplifyPass()); +- MPM.add(createLoopSimplifyCFGPass()); +- + // Try to remove as much code from the loop header as possible, + // to reduce amount of IR that will have to be duplicated. However, + // do not perform speculative hoisting the first time as LICM +@@ -145,13 +143,9 @@ void PassManagerBuilder::addFunctionSimplificationPasses(legacy::PassManagerBase + // TODO: Investigate promotion cap for O1. + MPM.add(IGCLLVM::createLegacyWrappedLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap, + /*AllowSpeculation=*/false)); +- // Rotate Loop - disable header duplication at -Oz +- MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1, false)); +- // TODO: Investigate promotion cap for O1. ++ // Rotate Loop - disable header duplication at -Oz // TODO: Investigate promotion cap for O1. + MPM.add(IGCLLVM::createLegacyWrappedLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap, +- /*AllowSpeculation=*/true)); +- MPM.add(createSimpleLoopUnswitchLegacyPass(OptLevel == 3)); +- // FIXME: We break the loop pass pipeline here in order to do full ++ /*AllowSpeculation=*/true)); // FIXME: We break the loop pass pipeline here in order to do full + // simplifycfg. Eventually loop-simplifycfg should be enhanced to replace the + // need for this. + MPM.add(createCFGSimplificationPass(SimplifyCFGOptions().convertSwitchRangeToICmp(true))); +@@ -168,9 +162,7 @@ void PassManagerBuilder::addFunctionSimplificationPasses(legacy::PassManagerBase + // Break up allocas that may now be splittable after loop unrolling. + MPM.add(createSROAPass()); + +- if (OptLevel > 1) { +- MPM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds +- MPM.add(createGVNPass(false)); // Remove redundancies ++ if (OptLevel > 1) { MPM.add(createGVNPass()); // Remove redundancies + } + MPM.add(IGCLLVM::createLegacyWrappedSCCPPass()); // Constant prop with SCCP + +@@ -383,13 +375,9 @@ void PassManagerBuilder::populateModulePassManager(legacy::PassManagerBase &MPM) + MPM.add(createGlobalsAAWrapperPass()); + + MPM.add(IGCLLVM::createLegacyWrappedFloat2IntPass()); +- MPM.add(createLowerConstantIntrinsicsPass()); +- + // Re-rotate loops in all our loop nests. These may have fallout out of + // rotated form due to GVN or other transformations, and the vectorizer relies + // on the rotated form. Disable header duplication at -Oz. +- MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1, false)); +- + // Distribute loops to allow partial vectorization. I.e. isolate dependences + // into separate loop that would otherwise inhibit vectorization. This is + // currently only performed for loops marked with the metadata +@@ -411,9 +399,7 @@ void PassManagerBuilder::populateModulePassManager(legacy::PassManagerBase &MPM) + // LoopSink pass sinks instructions hoisted by LICM, which serves as a + // canonicalization pass that enables other optimizations. As a result, + // LoopSink pass needs to be a very late IR pass to avoid undoing LICM +- // result too early. +- MPM.add(createLoopSinkPass()); +- // Get rid of LCSSA nodes. ++ // result too early. // Get rid of LCSSA nodes. + MPM.add(createInstSimplifyLegacyPass()); + + // This hoists/decomposes div/rem ops. It should run after other sink/hoist +diff --git a/IGC/WrapperLLVM/lib/llvmWrapper/Transforms/Scalar/MemCpyOptimizer.cpp b/IGC/WrapperLLVM/lib/llvmWrapper/Transforms/Scalar/MemCpyOptimizer.cpp +index f323e5d..52be99d 100644 +--- a/IGC/WrapperLLVM/lib/llvmWrapper/Transforms/Scalar/MemCpyOptimizer.cpp ++++ b/IGC/WrapperLLVM/lib/llvmWrapper/Transforms/Scalar/MemCpyOptimizer.cpp +@@ -17,6 +17,7 @@ SPDX-License-Identifier: MIT + #include "llvm/Analysis/AssumptionCache.h" + #include "llvm/Analysis/GlobalsModRef.h" + #include "llvm/Analysis/MemorySSAUpdater.h" ++#include "llvm/TargetParser/Host.h" + #include "llvm/Support/Alignment.h" + #include "llvm/Transforms/Scalar.h" + +@@ -36,9 +37,17 @@ MemCpyOptLegacyPassWrapper::MemCpyOptLegacyPassWrapper() : FunctionPass(ID) { + } + + void MemCpyOptLegacyPassWrapper::initializeAnalysisManagers() { ++#if LLVM_VERSION_MAJOR >= 22 ++ FAM.registerPass([]() { ++ auto TLII = TargetLibraryInfoImpl(Triple(sys::getProcessTriple())); ++ TLII.disableAllFunctions(); ++ return TargetLibraryAnalysis(std::move(TLII)); ++ }); ++#else + TargetLibraryInfoImpl TLII; + TLII.disableAllFunctions(); + FAM.registerPass([TLII = std::move(TLII)]() mutable { return TargetLibraryAnalysis(std::move(TLII)); }); ++#endif + + PB.registerLoopAnalyses(LAM); + PB.registerFunctionAnalyses(FAM); +diff --git a/IGC/ZEBinWriter/zebin/source/ZEELFObjectBuilder.cpp b/IGC/ZEBinWriter/zebin/source/ZEELFObjectBuilder.cpp +index 563e000..9ae1954 100644 +--- a/IGC/ZEBinWriter/zebin/source/ZEELFObjectBuilder.cpp ++++ b/IGC/ZEBinWriter/zebin/source/ZEELFObjectBuilder.cpp +@@ -816,7 +816,7 @@ uint16_t ELFWriter::numOfSections() { + } + + ELFWriter::ELFWriter(llvm::raw_pwrite_stream &OS, ZEELFObjectBuilder &objBuilder) +- : m_W(OS, llvm::support::little), m_ObjBuilder(objBuilder) {} ++ : m_W(OS, llvm::endianness::little), m_ObjBuilder(objBuilder) {} + + uint64_t ELFWriter::write() { + uint64_t start = m_W.OS.tell(); +diff --git a/IGC/cmake/IRBuilderGeneratorCodeGen.cmake b/IGC/cmake/IRBuilderGeneratorCodeGen.cmake +index 98b81c8..654bea9 100644 +--- a/IGC/cmake/IRBuilderGeneratorCodeGen.cmake ++++ b/IGC/cmake/IRBuilderGeneratorCodeGen.cmake +@@ -85,8 +85,10 @@ function(generate_irbuilder_headers) + endforeach() + + set(WARNING_SETTINGS "") ++ set(TARGET_OPTIONS -target x86_64-pc-windows -isystem /usr/include/c++/v1) + if (WIN32) + set(WARNING_SETTINGS -pedantic -Wall -Werror) ++ set(TARGET_OPTIONS -target x86_64-pc-windows) + endif() + + set(CLANG_HEADERS ${IGC_BUILD__GFX_DEV_SRC_DIR}/external/llvm/releases/${IGC_BUILD__CLANG_VERSION}/clang/lib/Headers) +@@ -110,8 +112,8 @@ function(generate_irbuilder_headers) + + # Common clang options + set(CLANG_OPTIONS +- -target x86_64-pc-windows +- ${WARNING_SETTINGS} ++ ++ + -Wno-return-type-c-linkage + -std=c++17 + -emit-llvm +diff --git a/IGC/cmake/igc_find_opencl_clang.cmake b/IGC/cmake/igc_find_opencl_clang.cmake +index e87aea1..eac6930 100644 +--- a/IGC/cmake/igc_find_opencl_clang.cmake ++++ b/IGC/cmake/igc_find_opencl_clang.cmake +@@ -122,7 +122,11 @@ if(CCLANG_FROM_SYSTEM) + else() + set_property(TARGET opencl-clang-lib PROPERTY "IMPORTED_LOCATION" "${SYSTEM_COMMON_CLANG}") + endif() +- find_program(CLANG_EXE clang-${IGC_BUILD__CLANG_VERSION_MAJOR}) ++ find_program(CLANG_EXE clang-${IGC_BUILD__CLANG_VERSION_MAJOR} ++ PATHS ENV PATH NO_DEFAULT_PATH) ++ if(NOT CLANG_EXE) ++ find_program(CLANG_EXE clang-${IGC_BUILD__CLANG_VERSION_MAJOR}) ++ endif() + if(CLANG_EXE) + message(STATUS "[IGC] Found clang-${IGC_BUILD__CLANG_VERSION_MAJOR} executable: ${CLANG_EXE}") + +diff --git a/IGC/common/BuiltinTypes.cpp b/IGC/common/BuiltinTypes.cpp +index 7deecfe..c4475fe 100644 +--- a/IGC/common/BuiltinTypes.cpp ++++ b/IGC/common/BuiltinTypes.cpp +@@ -46,9 +46,9 @@ bool isImageBuiltinType(const Type *BuiltinTy) { + BuiltinName.split(Buffer, "."); + if (Buffer.size() < 2) + return false; +- bool IsOpenCLImage = Buffer[0].equals("opencl") && Buffer[1].startswith("image") && Buffer[1].endswith("_t"); ++ bool IsOpenCLImage = Buffer[0] == "opencl" && Buffer[1].starts_with("image") && Buffer[1].ends_with("_t"); + bool IsSPIRVImage = +- Buffer[0].equals("spirv") && (Buffer[1].startswith("Image") || Buffer[1].startswith("SampledImage")); ++ Buffer[0] == "spirv" && (Buffer[1].starts_with("Image") || Buffer[1].starts_with("SampledImage")); + + if (IsOpenCLImage || IsSPIRVImage) + return true; +@@ -171,9 +171,9 @@ private: + + StringRef TyName = TET->getName(); + unsigned AS = ADDRESS_SPACE_PRIVATE; +- if (TyName.startswith("spirv.Image") || TyName.startswith("spirv.SampledImage")) ++ if (TyName.starts_with("spirv.Image") || TyName.starts_with("spirv.SampledImage")) + AS = ADDRESS_SPACE_GLOBAL; +- else if (TyName.startswith("spirv.Sampler")) ++ else if (TyName.starts_with("spirv.Sampler")) + AS = ADDRESS_SPACE_CONSTANT; + + return PointerType::get(Ctx, AS); +diff --git a/IGC/common/IGCConstantFolder.cpp b/IGC/common/IGCConstantFolder.cpp +index 0908e4a..6ef559e 100644 +--- a/IGC/common/IGCConstantFolder.cpp ++++ b/IGC/common/IGCConstantFolder.cpp +@@ -340,7 +340,7 @@ llvm::Constant *IGCConstantFolder::CreateUbfe(llvm::Constant *C0, llvm::Constant + llvm::ConstantInt *CI2 = llvm::cast(C2); // the number to shift + uint32_t width = int_cast(CI0->getZExtValue()); + uint32_t offset = int_cast(CI1->getZExtValue()); +- uint32_t bitwidth = CI2->getType()->getBitWidth(); ++ uint32_t bitwidth = CI2->getType()->getIntegerBitWidth(); + + llvm::APInt result = CI2->getValue(); + if ((width + offset) < bitwidth) { +@@ -363,7 +363,7 @@ llvm::Constant *IGCConstantFolder::CreateIbfe(llvm::Constant *C0, llvm::Constant + llvm::ConstantInt *CI2 = llvm::cast(C2); // the number to shift + uint32_t width = int_cast(CI0->getZExtValue()); + uint32_t offset = int_cast(CI1->getZExtValue()); +- uint32_t bitwidth = CI2->getType()->getBitWidth(); ++ uint32_t bitwidth = CI2->getType()->getIntegerBitWidth(); + + llvm::APInt result = CI2->getValue(); + if ((width + offset) < bitwidth) { +@@ -409,7 +409,7 @@ llvm::Constant *IGCConstantFolder::CreateFirstBitHi(llvm::Constant *C0) const { + } + llvm::ConstantInt *CI0 = llvm::cast(C0); + const unsigned fbh = CI0->getValue().countLeadingZeros(); +- if (fbh == CI0->getType()->getBitWidth()) { ++ if (fbh == CI0->getType()->getIntegerBitWidth()) { + return llvm::ConstantInt::get(C0->getType(), -1); + } + return llvm::ConstantInt::get(C0->getType(), fbh); +@@ -422,7 +422,7 @@ llvm::Constant *IGCConstantFolder::CreateFirstBitShi(llvm::Constant *C0) const { + IGC_ASSERT(llvm::isa(C0)); + llvm::ConstantInt *CI0 = llvm::cast(C0); + const uint32_t fbs = CI0->isNegative() ? CI0->getValue().countLeadingOnes() : CI0->getValue().countLeadingZeros(); +- if (fbs == CI0->getType()->getBitWidth()) { ++ if (fbs == CI0->getType()->getIntegerBitWidth()) { + return llvm::ConstantInt::get(C0->getType(), -1); + } + return llvm::ConstantInt::get(C0->getType(), fbs); +@@ -435,7 +435,7 @@ llvm::Constant *IGCConstantFolder::CreateFirstBitLo(llvm::Constant *C0) const { + IGC_ASSERT(llvm::isa(C0)); + llvm::ConstantInt *CI0 = llvm::cast(C0); + const unsigned fbl = CI0->getValue().countTrailingZeros(); +- if (fbl == CI0->getType()->getBitWidth()) { ++ if (fbl == CI0->getType()->getIntegerBitWidth()) { + return llvm::ConstantInt::get(C0->getType(), -1); + } + return llvm::ConstantInt::get(C0->getType(), fbl); +@@ -452,7 +452,7 @@ llvm::Constant *IGCConstantFolder::CreateBfi(llvm::Constant *C0, llvm::Constant + llvm::ConstantInt *CI3 = llvm::cast(C3); // the number with bits to be replaced. + uint32_t width = int_cast(CI0->getZExtValue()); + uint32_t offset = int_cast(CI1->getZExtValue()); +- uint32_t bitwidth = CI2->getType()->getBitWidth(); ++ uint32_t bitwidth = CI2->getType()->getIntegerBitWidth(); + llvm::APInt bitmask = llvm::APInt::getBitsSet(bitwidth, offset, offset + width); + llvm::APInt result = CI2->getValue(); + result = result.shl(offset); +diff --git a/IGC/common/LLVMUtils.cpp b/IGC/common/LLVMUtils.cpp +index a7eb6ad..93298f7 100644 +--- a/IGC/common/LLVMUtils.cpp ++++ b/IGC/common/LLVMUtils.cpp +@@ -702,7 +702,7 @@ bool IGCPassManager::isPrintAfter(Pass *P) { + void IGCPassManager::addPrintPass(Pass *P, bool isBefore) { + auto passName = P->getPassName(); + std::string fullPassName = m_name + (isBefore ? "_before_" : "_after_") + +- (passName.startswith("Unnamed pass") ? "UnnamedPass" : cleanPassName(passName.str())); ++ (passName.starts_with("Unnamed pass") ? "UnnamedPass" : cleanPassName(passName.str())); + + auto name = IGC::Debug::DumpName(IGC::Debug::GetShaderOutputName()) + .ShaderName(m_pContext->shaderName) +@@ -757,10 +757,10 @@ void DumpLLVMIR(IGC::CodeGenContext *pContext, const char *dumpName) { + for (auto &F : module->getFunctionList()) + for (BasicBlock &BB : F) { + for (Instruction &I : BB) +- if (I.getName().startswith("x")) ++ if (I.getName().starts_with("x")) + I.setName("_x"); + +- if (BB.getName().startswith("bb")) ++ if (BB.getName().starts_with("bb")) + BB.setName("_bb"); + } + // Now we rewrite the variables using a counter +@@ -769,12 +769,12 @@ void DumpLLVMIR(IGC::CodeGenContext *pContext, const char *dumpName) { + for (auto &F : module->getFunctionList()) + for (BasicBlock &BB : F) { + for (Instruction &I : BB) { +- if ((!I.hasName() && !I.getType()->isVoidTy()) || I.getName().startswith("_x")) { ++ if ((!I.hasName() && !I.getType()->isVoidTy()) || I.getName().starts_with("_x")) { + I.setName("x" + std::to_string(counter++)); + } + } + +- if (!BB.hasName() || BB.getName().startswith("_bb")) ++ if (!BB.hasName() || BB.getName().starts_with("_bb")) + BB.setName("bb" + std::to_string(bb_counter++)); + } + } +diff --git a/IGC/common/LLVMUtils.h b/IGC/common/LLVMUtils.h +index 88b8a4d..998b8c4 100644 +--- a/IGC/common/LLVMUtils.h ++++ b/IGC/common/LLVMUtils.h +@@ -14,6 +14,7 @@ SPDX-License-Identifier: MIT + #include "common/LLVMWarningsPop.hpp" + #include + #include "Stats.hpp" ++#include "common/debug/Dump.hpp" + #include + + namespace IGC { +@@ -40,6 +41,36 @@ private: + // Return true if N is in the list. + bool isInList(const llvm::StringRef &N, const llvm::StringRef &List) const; + }; ++inline llvm::Instruction *getFirstNonPHIOrDbgInst(llvm::BasicBlock *BB) { ++ auto It = BB->getFirstNonPHIOrDbg(); ++ return It == BB->end() ? nullptr : &*It; ++} ++ ++inline llvm::Instruction *getNextNonDbgInstruction(llvm::Instruction *I) { ++ if (!I) ++ return nullptr; ++ auto It = std::next(I->getIterator()); ++ auto E = I->getParent()->end(); ++ for (; It != E; ++It) { ++ if (!It->isDebugOrPseudoInst()) ++ return &*It; ++ } ++ return nullptr; ++} ++ ++inline llvm::Instruction *getPrevNonDbgInstruction(llvm::Instruction *I) { ++ if (!I) ++ return nullptr; ++ auto It = I->getIterator(); ++ auto B = I->getParent()->begin(); ++ while (It != B) { ++ --It; ++ if (!It->isDebugOrPseudoInst()) ++ return &*It; ++ } ++ return nullptr; ++} ++ + } // namespace IGC + + void DumpLLVMIR(IGC::CodeGenContext *pContext, const char *dumpName); +diff --git a/IGC/common/MDFrameWork.cpp b/IGC/common/MDFrameWork.cpp +index fcdd2e0..8de63bd 100644 +--- a/IGC/common/MDFrameWork.cpp ++++ b/IGC/common/MDFrameWork.cpp +@@ -194,7 +194,7 @@ template MDNode *CreateNode(const std::optional &option, Mod + if (option.has_value()) + nodes.push_back(CreateNode(*option, module, name.str() + "Option")); + else +- nodes.push_back(ValueAsMetadata::get(ConstantPointerNull::get(Type::getInt1PtrTy(module->getContext())))); ++ nodes.push_back(ValueAsMetadata::get(ConstantPointerNull::get(PointerType::get(module->getContext(), 0)))); + + MDNode *node = MDNode::get(module->getContext(), nodes); + return node; +diff --git a/IGC/common/SerializePrintMetaDataPass.cpp b/IGC/common/SerializePrintMetaDataPass.cpp +index b94095c..4a5f07f 100644 +--- a/IGC/common/SerializePrintMetaDataPass.cpp ++++ b/IGC/common/SerializePrintMetaDataPass.cpp +@@ -115,7 +115,7 @@ void SerializePrintMetaDataPass::CollectValueMD(llvm::Value *Val) { + + if (auto callInstr = llvm::dyn_cast(instr)) { + if (auto callFunc = callInstr->getCalledFunction()) { +- if (callFunc->getName().startswith("llvm.")) { ++ if (callFunc->getName().starts_with("llvm.")) { + for (unsigned i = 0; i < instr->getNumOperands(); ++i) { + if (auto valAsMD = llvm::dyn_cast(instr->getOperand(i))) { + CollectInsideMD(valAsMD->getMetadata()); +diff --git a/IGC/common/debug/Debug.cpp b/IGC/common/debug/Debug.cpp +index f38b41f..e2451a7 100644 +--- a/IGC/common/debug/Debug.cpp ++++ b/IGC/common/debug/Debug.cpp +@@ -217,7 +217,7 @@ void RegisterErrHandlers() { + } + } + +-void RegisterComputeErrHandlers(LLVMContext &C) { C.setDiagnosticHandlerCallBack(ComputeFatalErrorHandler); } ++void RegisterComputeErrHandlers(LLVMContext &C) { C.setDiagnosticHandlerCallBack([](const llvm::DiagnosticInfo *DI, void *Ctx) { ComputeFatalErrorHandler(*DI, Ctx); }); } + + void ReleaseErrHandlers() { + // do nothing +diff --git a/IGC/common/igc_regkeys.cpp b/IGC/common/igc_regkeys.cpp +index efeb94f..65787f9 100644 +--- a/IGC/common/igc_regkeys.cpp ++++ b/IGC/common/igc_regkeys.cpp +@@ -628,7 +628,7 @@ static void ParseHashRange(llvm::StringRef line, std::vector &ranges) + if (!Result) + return; + auto parseAsInt = [](StringRef S) { +- unsigned Radix = S.startswith("0x") ? 0 : 16; ++ unsigned Radix = S.starts_with("0x") ? 0 : 16; + uint64_t Result; + [[maybe_unused]] bool Err = S.getAsInteger(Radix, Result); + IGC_ASSERT(!Err); +diff --git a/IGC/igc_create_linker_script.sh b/IGC/igc_create_linker_script.sh +new file mode 100755 +index 0000000..8d6effa +--- /dev/null ++++ b/IGC/igc_create_linker_script.sh +@@ -0,0 +1,61 @@ ++#!/bin/bash ++ ++#Uses objdump to obtain global functions from object files - 2nd script argument ++#Creates a linker script in script's directory, with 1st argument as a name, sets every symbol as local, as the ones obtained as global ++ ++readonly SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) ++readonly NEWLINE=$'\n' ++ ++readonly LINKER_SCRIPT=$1 ++readonly BIF_LIBRARY=$2 ++readonly DX10_LIBRARY=$3 ++readonly DXIL_LIBRARY=$4 ++readonly VULKAN_FE_LIBRARY=$5 ++ ++shift ++ ++formatAndWriteSymbols() { ++ if [[ -n "${1}" ]]; then ++ formattedSymbols=$(echo "${1}" | awk '{print $NF}') ++ formattedSymbols=$(echo -e "${formattedSymbols}" | sed ':a;N;$!ba;s/\n/\n\t\t/g') ++ formattedSymbols="${formattedSymbols//${NEWLINE}/;${NEWLINE}}" ++ ++ echo -e "\t\t$formattedSymbols;" >> ${SCRIPT_DIR}/${LINKER_SCRIPT} ++ fi ++} ++ ++#----------------------------------------------------------------------------------------- ++ ++echo -e "{\n\t global:" > ${SCRIPT_DIR}/${LINKER_SCRIPT} ++ ++if [[ "$BIF_LIBRARY" != "null" ]]; then ++ symbolsBIF=$(objdump -t $BIF_LIBRARY | grep " O " | grep " g " | grep -v hidden) ++ formatAndWriteSymbols "$symbolsBIF" ++fi ++ ++if [[ "$VULKAN_FE_LIBRARY" != "null" ]]; then ++ symbolsVFE=$(objdump -t $VULKAN_FE_LIBRARY | grep " F " | grep " g " | grep -v hidden) ++ formatAndWriteSymbols "$symbolsVFE" ++ ++ symbolsVFE=$(objdump -t $VULKAN_FE_LIBRARY | grep " w " | grep -v hidden) ++ formatAndWriteSymbols "$symbolsVFE" ++ ++ symbolsVFE=$(objdump -t $VULKAN_FE_LIBRARY | grep " W " | grep -v hidden) ++ formatAndWriteSymbols "$symbolsVFE" ++fi ++ ++for obj_file in "$@"; do ++ if [[ $obj_file == *.o ]]; then ++ symbols=$(objdump -t $obj_file | grep " F " | grep " g " | grep -v hidden) ++ formatAndWriteSymbols "$symbols" ++ ++ symbols=$(objdump -t $obj_file | grep " w " | grep -v hidden) ++ formatAndWriteSymbols "$symbols" ++ ++ symbols=$(objdump -t $obj_file | grep " W " | grep -v hidden) ++ formatAndWriteSymbols "$symbols" ++ fi ++done ++ ++echo -e "\tlocal: *;" >> ${SCRIPT_DIR}/${LINKER_SCRIPT} ++echo -e "};" >> ${SCRIPT_DIR}/${LINKER_SCRIPT} +diff --git a/visa/iga/IGALibrary/CMakeLists.txt b/visa/iga/IGALibrary/CMakeLists.txt +index b037644..5cf59fe 100644 +--- a/visa/iga/IGALibrary/CMakeLists.txt ++++ b/visa/iga/IGALibrary/CMakeLists.txt +@@ -15,17 +15,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) + + ############################################## + # compute the version string from the git repo +-execute_process( +- COMMAND git rev-parse --short HEAD +- OUTPUT_VARIABLE GIT_COMMIT +- OUTPUT_STRIP_TRAILING_WHITESPACE +- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) +-# +-execute_process( +- COMMAND git diff-index --quiet HEAD -- +- RESULT_VARIABLE GIT_DIRTY +- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) +- + set(IGA_VERSION_SUFFIX "") + if(GIT_COMMIT) + set(IGA_VERSION_DIRTY_TAG "") diff --git a/dev-util/intel-graphics-compiler/intel-graphics-compiler-2.32.7-r2.ebuild b/dev-util/intel-graphics-compiler/intel-graphics-compiler-2.32.7-r2.ebuild new file mode 100644 index 0000000..85f1566 --- /dev/null +++ b/dev-util/intel-graphics-compiler/intel-graphics-compiler-2.32.7-r2.ebuild @@ -0,0 +1,129 @@ +# Copyright 1999-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +CMAKE_BUILD_TYPE="Release" +LLVM_COMPAT=( 22 ) +PYTHON_COMPAT=( python3_{10..14} ) + +inherit cmake flag-o-matic llvm-r2 python-any-r1 + +DESCRIPTION="LLVM-based OpenCL compiler for OpenCL targetting Intel Gen graphics hardware" +HOMEPAGE="https://github.com/intel/intel-graphics-compiler" + +SRC_URI="https://github.com/intel/${PN}/archive/refs/tags/v${PV}.tar.gz" + +LICENSE="MIT" +SLOT="0/${PV}" +KEYWORDS="~amd64" +IUSE="debug intel_targets_gfx-bmg shared-libs vc" + +DEPEND=" + dev-libs/opencl-clang:22[${LLVM_USEDEP}] + dev-util/spirv-tools + $(llvm_gen_dep ' + llvm-core/lld:${LLVM_SLOT} + llvm-core/llvm:${LLVM_SLOT} + ') + vc? ( + dev-libs/intel-vc-intrinsics:${LLVM_SLOT}=[${LLVM_USEDEP}] + dev-util/spirv-llvm-translator:${LLVM_SLOT}= + ) +" + +RDEPEND=" + !dev-util/intel-graphics-compiler:legacy + ${DEPEND} +" + +BDEPEND=" + $(python_gen_any_dep 'dev-python/mako[${PYTHON_USEDEP}]') + $(python_gen_any_dep 'dev-python/pyyaml[${PYTHON_USEDEP}]') + $(llvm_gen_dep 'llvm-core/lld:${LLVM_SLOT}') + ${PYTHON_DEPS} +" + +python_check_deps() { + python_has_version "dev-python/mako[${PYTHON_USEDEP}]" + python_has_version "dev-python/pyyaml[${PYTHON_USEDEP}]" +} + +PATCHES=( + "${FILESDIR}/${PN}-2.32.7-r2-llvm22.patch" +) + +pkg_setup() { + llvm-r2_pkg_setup + python-any-r1_pkg_setup +} + +#src_unpack() { +# unpack "/var/git/${P}-local-r1.tar.gz" +#} + +src_prepare() { + local CLANG_HEADERS="${IGC_BUILD__CLANG_VERSION}/clang/lib/Headers" + sed '/set\(CLANG_HEADERS/s/\$\{IGC_BUILD__GFX_DEV_SRC_DIR\}\/external\/llvm\/releases\/\$\{IGC_BUILD__CLANG_VERSION\}\/clang\/lib\/Headers\)/'"${CLANG_HEADERS}"'/' \ + -i ${WORKIDR}/${P}/IGC/cmake/IRBuilderGeneratorCodeGen.cmake + + cmake_src_prepare +} +src_configure() { + # Get LLVM version + local llvm_version="$(best_version -d llvm-core/llvm:${LLVM_SLOT})" + local llvm_version="${llvm_version%%-r*}" + + # See https://github.com/intel/intel-graphics-compiler/issues/212 + append-ldflags -Wl,-z,undefs + + # See bug #938519 and https://github.com/intel/intel-graphics-compiler/issues/362 + filter-lto + + # See bug #893370 and https://github.com/intel/intel-graphics-compiler/issues/282 + append-flags -U_GLIBCXX_ASSERTIONS + + # See https://bugs.gentoo.org/718824 + ! use debug && append-cppflags -DNDEBUG + local clang_exe="${EPREFIX}/usr/lib/ccache/bin/clang-${LLVM_SLOT}" + [[ -x ${clang_exe} ]] || clang_exe="$(get_llvm_prefix)/bin/clang-${LLVM_SLOT}" + local ccache_bin="$(type -P ccache)" + local vc_platforms=() + use intel_targets_gfx-bmg && vc_platforms+=( Xe2 ) + local vc_platforms_cmake="" + if [[ ${#vc_platforms[@]} -gt 0 ]]; then + local IFS=";" + vc_platforms_cmake="${vc_platforms[*]}" + fi + + local mycmakeargs=( + -DBUILD_SHARED_LIBS=$(usex shared-libs) + -DCCLANG_FROM_SYSTEM="ON" + -DCLANG_EXE="${clang_exe}" + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + -DCMAKE_PREFIX_PATH="$(get_llvm_prefix);/opt/intel/llvm/${LLVM_SLOT}" + ${ccache_bin:+-DCMAKE_C_COMPILER_LAUNCHER="${ccache_bin}"} + ${ccache_bin:+-DCMAKE_CXX_COMPILER_LAUNCHER="${ccache_bin}"} + -DCMAKE_LIBRARY_PATH="$(get_llvm_prefix)/$(get_libdir)" + -DIGC_BUILD__VC_ENABLED="$(usex vc)" + -DIGC_OPTION__ARCHITECTURE_TARGET="Linux64" + -DIGC_OPTION__CLANG_MODE="Prebuilds" + -DIGC_OPTION__ENABLE_BF16_BIF="ON" + -DIGC_OPTION__LINK_KHRONOS_SPIRV_TRANSLATOR="ON" + -DIGC_OPTION__LLD_MODE="Prebuilds" + -DIGC_OPTION__LLDELF_H_DIR="$(get_llvm_prefix)/include/lld/Common" + -DIGC_OPTION__LLVM_MODE="Prebuilds" + -DIGC_OPTION__LLVM_PREFERRED_VERSION="${llvm_version##*-}" + -DIGC_OPTION__OPENCL_HEADER_PATH="/usr/lib/clang/${LLVM_SLOT}/include/opencl-c.h" + -DIGC_OPTION__SPIRV_TOOLS_MODE="Prebuilds" + -DIGC_OPTION__SPIRV_TRANSLATOR_MODE="Prebuilds" + -DIGC_OPTION__USE_PREINSTALLED_SPIRV_HEADERS="ON" + ${vc_platforms_cmake:+-DIGC_BUILD__VC_PLATFORMS="${vc_platforms_cmake}"} + $(usex vc '-DIGC_OPTION__VC_INTRINSICS_MODE=Prebuilds' '') + -DPYTHON_EXECUTABLE="${PYTHON}" + -DSPIRVLLVMTranslator_INCLUDE_DIR="${EPREFIX}/usr/lib/llvm/${LLVM_SLOT}/include/LLVMSPIRVLib" + -Wno-dev + ) + + cmake_src_configure +} diff --git a/dev-util/intel-graphics-compiler/metadata.xml b/dev-util/intel-graphics-compiler/metadata.xml index 35c6738..8f382fe 100644 --- a/dev-util/intel-graphics-compiler/metadata.xml +++ b/dev-util/intel-graphics-compiler/metadata.xml @@ -14,6 +14,7 @@ Conrad Kostecki + Build shared libraries instead of static libraries. Enable VectorCompiler for a better performance. diff --git a/metadata/md5-cache/dev-util/intel-graphics-compiler-2.32.7-r2 b/metadata/md5-cache/dev-util/intel-graphics-compiler-2.32.7-r2 new file mode 100644 index 0000000..e226313 --- /dev/null +++ b/metadata/md5-cache/dev-util/intel-graphics-compiler-2.32.7-r2 @@ -0,0 +1,16 @@ +BDEPEND=|| ( ( dev-lang/python:3.14 dev-python/mako[python_targets_python3_14(-)] ) ( dev-lang/python:3.13 dev-python/mako[python_targets_python3_13(-)] ) ( dev-lang/python:3.12 dev-python/mako[python_targets_python3_12(-)] ) ( dev-lang/python:3.11 dev-python/mako[python_targets_python3_11(-)] ) ) || ( ( dev-lang/python:3.14 dev-python/pyyaml[python_targets_python3_14(-)] ) ( dev-lang/python:3.13 dev-python/pyyaml[python_targets_python3_13(-)] ) ( dev-lang/python:3.12 dev-python/pyyaml[python_targets_python3_12(-)] ) ( dev-lang/python:3.11 dev-python/pyyaml[python_targets_python3_11(-)] ) ) llvm_slot_22? ( llvm-core/lld:22 ) || ( dev-lang/python:3.14 dev-lang/python:3.13 dev-lang/python:3.12 dev-lang/python:3.11 ) app-alternatives/ninja >=dev-build/cmake-3.28.5 +DEFINED_PHASES=compile configure install prepare setup test +DEPEND=dev-libs/opencl-clang:22[llvm_slot_22(-)?] dev-util/spirv-tools llvm_slot_22? ( llvm-core/lld:22 llvm-core/llvm:22 ) vc? ( dev-libs/intel-vc-intrinsics:=[llvm_slot_22(-)?] dev-util/spirv-llvm-translator:= ) +DESCRIPTION=LLVM-based OpenCL compiler for OpenCL targetting Intel Gen graphics hardware +EAPI=8 +HOMEPAGE=https://github.com/intel/intel-graphics-compiler +INHERIT=cmake flag-o-matic llvm-r2 python-any-r1 +IUSE=debug intel_targets_gfx-bmg shared-libs vc +llvm_slot_22 +KEYWORDS=~amd64 +LICENSE=MIT +RDEPEND=!dev-util/intel-graphics-compiler:legacy dev-libs/opencl-clang:22[llvm_slot_22(-)?] dev-util/spirv-tools llvm_slot_22? ( llvm-core/lld:22 llvm-core/llvm:22 ) vc? ( dev-libs/intel-vc-intrinsics:=[llvm_slot_22(-)?] dev-util/spirv-llvm-translator:= ) +REQUIRED_USE=^^ ( llvm_slot_22 ) +SLOT=0/2.32.7 +SRC_URI=https://github.com/intel/intel-graphics-compiler/archive/refs/tags/v2.32.7.tar.gz +_eclasses_=toolchain-funcs 58a918e3a42d0156f010dcfd43725be5 flag-o-matic fd3558f73f6503093adee69adf41020d multiprocessing 45d0620f25c2f063ad6276ecd9ed9399 ninja-utils d063ea1900a793f93eb095010d6d9156 xdg-utils 42869b3c8d86a70ef3cf75165a395e09 cmake 3395ce6618fc5c7af03335471b896644 llvm-utils e7edb4086e31c8537574b263d899f826 multilib fc812e8eb2170022c28272d80a1f9e77 llvm-r2 8bc46809768366b4239eab39335419bc eapi9-pipestatus d2c134036ac31c3085aebc9147f572bd python-utils-r1 9c4180f103a0e8340bc993fc85dbdadd python-any-r1 891415dfe39ad9b41b461f2b86354af0 +_md5_=088f10b38f944876f826b3f759b75d45