diff --git a/.github/actions/setup_ubuntu_build/action.yml b/.github/actions/setup_ubuntu_build/action.yml index 1955a8942..261185f6d 100644 --- a/.github/actions/setup_ubuntu_build/action.yml +++ b/.github/actions/setup_ubuntu_build/action.yml @@ -6,8 +6,8 @@ inputs: description: 'llvm Build type (Release, RelAssert) - note we need to use RelAssert for the cache pattern matching' default: RelAssert llvm_version: - description: 'Major llvm version to use for fetching llvm cache e.g. 17' - default: 17 + description: 'Major llvm version to use for fetching llvm cache e.g. 18' + default: 18 ubuntu_version: description: 'Version of ubuntu used for cache retrieval and prerequisites' default: 22.04 diff --git a/.github/workflows/build_pr_cache.yml b/.github/workflows/build_pr_cache.yml index 2a20b9c75..c3344bce5 100644 --- a/.github/workflows/build_pr_cache.yml +++ b/.github/workflows/build_pr_cache.yml @@ -30,7 +30,7 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - # installs tools, ninja and installs llvm (default 17, RelAssert) and sets up cache + # installs tools, ninja and installs llvm (default 18, RelAssert) and sets up cache - name: setup-ubuntu uses: ./.github/actions/setup_ubuntu_build with: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f5e249102..4885965b1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -26,7 +26,7 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - # installs tools, ninja and installs llvm (default 17, RelAssert) and sets up cache + # installs tools, ninja and installs llvm (default 18, RelAssert) and sets up cache - name: setup-ubuntu uses: ./.github/actions/setup_ubuntu_build with: @@ -74,7 +74,7 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - # installs tools, ninja and installs llvm (default 17, RelAssert) and sets up cache + # installs tools, ninja and installs llvm (default 18, RelAssert) and sets up cache - name: setup-ubuntu uses: ./.github/actions/setup_ubuntu_build with: diff --git a/.github/workflows/create_llvm.yml b/.github/workflows/create_llvm.yml index a5a0d478d..9d2bf1c59 100644 --- a/.github/workflows/create_llvm.yml +++ b/.github/workflows/create_llvm.yml @@ -17,7 +17,7 @@ jobs: create_llvm_cache: strategy: matrix: - version: [17, 18] + version: [18, 19] os: [ubuntu-22.04, windows-2019] build_type: [Release, RelAssert] arch : [x86, x86_64, aarch64] @@ -25,15 +25,15 @@ jobs: # Reduce the versions of llvm for aarch64 & x86 architectures and windows, as # well as any windows os variants to reduce cache usage. - arch: aarch64 - version: 17 + version: 18 - arch: aarch64 build_type: Release - arch: x86 - version: 17 + version: 18 - arch: x86 build_type: Release - os: windows-2019 - version: 17 + version: 18 - os: windows-2019 build_type: Release - os: windows-2019 diff --git a/.github/workflows/create_publish_artifacts.yml b/.github/workflows/create_publish_artifacts.yml index 7ed095daa..5f139e17b 100644 --- a/.github/workflows/create_publish_artifacts.yml +++ b/.github/workflows/create_publish_artifacts.yml @@ -28,7 +28,7 @@ jobs: - name: Setup ubuntu uses: ./.github/actions/setup_ubuntu_build with: - llvm_version: 17 + llvm_version: 18 llvm_build_type: Release - name: Setup python diff --git a/.github/workflows/run_ock_demo.yml b/.github/workflows/run_ock_demo.yml index 7c9e1b0aa..4ef6f656d 100644 --- a/.github/workflows/run_ock_demo.yml +++ b/.github/workflows/run_ock_demo.yml @@ -27,7 +27,7 @@ jobs: - name: setup ubuntu uses: ./.github/actions/setup_ubuntu_build with: - llvm_version: 17 + llvm_version: 18 llvm_build_type: RelAssert - name: setup python diff --git a/cmake/DetectLLVMMSVCCRT.cmake b/cmake/DetectLLVMMSVCCRT.cmake index 291dae365..a1d1bf606 100644 --- a/cmake/DetectLLVMMSVCCRT.cmake +++ b/cmake/DetectLLVMMSVCCRT.cmake @@ -34,63 +34,10 @@ endif() # LLVM 18 uses the CMake default setting, which depends on the mode LLVM # was built in, not the mode we were built in. -if(LLVM_VERSION_MAJOR GREATER_EQUAL 18) - if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) - if(LLVM_BUILD_TYPE STREQUAL "Debug") - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL") - else() - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") - endif() +if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) + if(LLVM_BUILD_TYPE STREQUAL "Debug") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL") + else() + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") endif() - return() -endif() - -# Get the directory of cl.exe -get_filename_component(tools_dir "${CMAKE_C_COMPILER}" DIRECTORY) - -# Find the dumpbin.exe executable in the directory of cl.exe -find_program(dumpbin "dumpbin.exe" PATHS "${tools_dir}" NO_DEFAULT_PATH) - -if("${dumpbin}" STREQUAL "dumpbin-NOTFOUND") - message(WARNING "Could not detect which CRT LLVM was built against - " - "could not find 'dumpbin.exe'.") - return() -endif() - -# Get the location in the file-system of LLVMCore.lib -get_target_property(llvmcore LLVMCore LOCATION) - -if("${llvmcore}" STREQUAL "llvmcore-NOTFOUND") - message(WARNING "Could not detect which CRT LLVM was built against - " - "could not find location of 'LLVMCore.lib'.") - return() endif() - -# Get the directives that LLVMCore.lib contains -execute_process(COMMAND "${dumpbin}" "/DIRECTIVES" "${llvmcore}" - OUTPUT_VARIABLE output) - -# Find the first directive specifying what CRT to use -string(FIND "${output}" "/FAILIFMISMATCH:RuntimeLibrary=" position) - -# Strip away everything but the directive we want to examine -string(SUBSTRING "${output}" ${position} 128 output) - -# Remove the directive prefix which we don't need -string(REPLACE "/FAILIFMISMATCH:RuntimeLibrary=" "" output "${output}") - -# Get the position of the '_' character that breaks the CRT from all else -string(FIND "${output}" "_" position) - -# Substring output to be one of the four CRT values: MDd MD MTd MT -string(SUBSTRING "${output}" 0 ${position} output) - -# Set all possible CMAKE_BUILD_TYPE's to the CRT that LLVM was linked against -set(LLVM_USE_CRT_DEBUG "${output}") -set(LLVM_USE_CRT_RELWITHDEBINFO "${output}") -set(LLVM_USE_CRT_MINSIZEREL "${output}") -set(LLVM_USE_CRT_RELEASEASSERT "${output}") -set(LLVM_USE_CRT_RELEASE "${output}") - -# Include the LLVM cmake module to choose the correct CRT for our libraries -include(ChooseMSVCCRT) diff --git a/cmake/ImportLLVM.cmake b/cmake/ImportLLVM.cmake index ebd60a4df..b819a045e 100644 --- a/cmake/ImportLLVM.cmake +++ b/cmake/ImportLLVM.cmake @@ -76,8 +76,8 @@ include(DetectLLVMMSVCCRT) :cmake:variable:`LLVM_PACKAGE_VERSION` from the imported LLVM install is a supported version. #]=======================================================================] -set(CA_LLVM_MINIMUM_VERSION 17.0.0) -set(CA_LLVM_MAXIMUM_VERSION 18) +set(CA_LLVM_MINIMUM_VERSION 18.0.0) +set(CA_LLVM_MAXIMUM_VERSION 19) string(REPLACE ";" "', '" CA_LLVM_VERSIONS_PRETTY "${CA_LLVM_VERSIONS}") if("${LLVM_PACKAGE_VERSION}" VERSION_LESS "${CA_LLVM_MINIMUM_VERSION}") message(FATAL_ERROR diff --git a/modules/compiler/compiler_pipeline/source/align_module_structs_pass.cpp b/modules/compiler/compiler_pipeline/source/align_module_structs_pass.cpp index dd5a64c58..8355b0633 100644 --- a/modules/compiler/compiler_pipeline/source/align_module_structs_pass.cpp +++ b/modules/compiler/compiler_pipeline/source/align_module_structs_pass.cpp @@ -276,11 +276,7 @@ Function *cloneFunctionUpdatingTypes(Function &func, // Take attributes of old function newFunc->takeName(&func); -#if LLVM_VERSION_GREATER_EQUAL(18, 0) newFunc->updateAfterNameChange(); -#else - newFunc->recalculateIntrinsicID(); -#endif newFunc->setCallingConv(func.getCallingConv()); assert(func.isIntrinsic() == newFunc->isIntrinsic() && diff --git a/modules/compiler/compiler_pipeline/source/barrier_regions.cpp b/modules/compiler/compiler_pipeline/source/barrier_regions.cpp index 03118c52d..a54b2fd4d 100644 --- a/modules/compiler/compiler_pipeline/source/barrier_regions.cpp +++ b/modules/compiler/compiler_pipeline/source/barrier_regions.cpp @@ -971,11 +971,7 @@ void compiler::utils::Barrier::MakeLiveVariableMemType() { // Check if the alloca has a debug info source variable attached. If // so record this and the matching byte offset into the struct. -#if LLVM_VERSION_GREATER_EQUAL(18, 0) auto DbgIntrinsics = findDbgDeclares(member.value); -#else - auto DbgIntrinsics = FindDbgDeclareUses(member.value); -#endif for (auto DII : DbgIntrinsics) { if (auto dbgDeclare = dyn_cast(DII)) { debug_intrinsics_.push_back(std::make_pair(dbgDeclare, offset)); diff --git a/modules/compiler/compiler_pipeline/source/manual_type_legalization_pass.cpp b/modules/compiler/compiler_pipeline/source/manual_type_legalization_pass.cpp index f762f162f..db5c3bcf3 100644 --- a/modules/compiler/compiler_pipeline/source/manual_type_legalization_pass.cpp +++ b/modules/compiler/compiler_pipeline/source/manual_type_legalization_pass.cpp @@ -73,15 +73,7 @@ PreservedAnalyses compiler::utils::ManualTypeLegalizationPass::run( auto *&FPExt = FPExtVals[{V, ExtTy}]; if (!FPExt) { if (auto *I = dyn_cast(V)) { -#if LLVM_VERSION_GREATER_EQUAL(18, 0) - std::optional IPAD; - IPAD = I->getInsertionPointAfterDef(); -#else - std::optional IPAD; - if (auto *IPADRaw = I->getInsertionPointAfterDef()) { - IPAD = IPADRaw; - } -#endif + auto IPAD = I->getInsertionPointAfterDef(); assert(IPAD && "getInsertionPointAfterDef() should return an insertion point " "for all FP16 instructions"); diff --git a/modules/compiler/cookie/{{cookiecutter.target_name}}/source/module.cpp b/modules/compiler/cookie/{{cookiecutter.target_name}}/source/module.cpp index 7156bdf72..7898d954d 100644 --- a/modules/compiler/cookie/{{cookiecutter.target_name}}/source/module.cpp +++ b/modules/compiler/cookie/{{cookiecutter.target_name}}/source/module.cpp @@ -228,8 +228,7 @@ static llvm::TargetMachine *createTargetMachine(const {{cookiecutter.target_name return llvm_target->createTargetMachine( target.llvm_triple, target.llvm_cpu, target.llvm_features, options, {{cookiecutter.link_shared}} ? llvm::Reloc::Model::PIC_ : llvm::Reloc::Model::Static, - llvm::CodeModel::Small, - multi_llvm::CodeGenOptLevel::Aggressive); + llvm::CodeModel::Small, llvm::CodeGenOptLevel::Aggressive); } llvm::TargetMachine *{{cookiecutter.target_name.capitalize()}}Module::getTargetMachine() { diff --git a/modules/compiler/cookie/{{cookiecutter.target_name}}/source/target.cpp b/modules/compiler/cookie/{{cookiecutter.target_name}}/source/target.cpp index d2099f502..ee7c7ad36 100644 --- a/modules/compiler/cookie/{{cookiecutter.target_name}}/source/target.cpp +++ b/modules/compiler/cookie/{{cookiecutter.target_name}}/source/target.cpp @@ -21,18 +21,13 @@ #include #include +#include #include #include <{{cookiecutter.target_name}}/device_info.h> #include <{{cookiecutter.target_name}}/module.h> #include <{{cookiecutter.target_name}}/target.h> #include "{{cookiecutter.target_name}}/module.h" -#if LLVM_VERSION_GREATER_EQUAL(18, 0) -#include -#else -#include -#endif - namespace {{cookiecutter.target_name}} { {{cookiecutter.target_name.capitalize()}}Target::{{cookiecutter.target_name.capitalize()}}Target(const compiler::Info *compiler_info, compiler::Context *context, diff --git a/modules/compiler/multi_llvm/include/multi_llvm/basicblock_helper.h b/modules/compiler/multi_llvm/include/multi_llvm/basicblock_helper.h deleted file mode 100644 index e4175a27e..000000000 --- a/modules/compiler/multi_llvm/include/multi_llvm/basicblock_helper.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) Codeplay Software Limited -// -// Licensed under the Apache License, Version 2.0 (the "License") with LLVM -// Exceptions; you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations -// under the License. -// -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#ifndef MULTI_LLVM_BASICBLOCK_HELPER_H_INCLUDED -#define MULTI_LLVM_BASICBLOCK_HELPER_H_INCLUDED - -#include -#include - -namespace multi_llvm { -inline void insertBefore(llvm::Instruction *const I, - const llvm::BasicBlock::iterator InsertPos) { -#if LLVM_VERSION_GREATER_EQUAL(18, 0) - I->insertBefore(InsertPos); -#else - I->insertBefore(&*InsertPos); -#endif -} - -inline llvm::BasicBlock::iterator getFirstNonPHIIt(llvm::BasicBlock *const BB) { -#if LLVM_VERSION_GREATER_EQUAL(18, 0) - return BB->getFirstNonPHIIt(); -#else - return BB->getFirstNonPHI()->getIterator(); -#endif -} -} // namespace multi_llvm - -#endif // MULTI_LLVM_BASICBLOCK_HELPER_H_INCLUDED diff --git a/modules/compiler/multi_llvm/include/multi_llvm/enums.h b/modules/compiler/multi_llvm/include/multi_llvm/enums.h deleted file mode 100644 index e44b7ac6d..000000000 --- a/modules/compiler/multi_llvm/include/multi_llvm/enums.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) Codeplay Software Limited -// -// Licensed under the Apache License, Version 2.0 (the "License") with LLVM -// Exceptions; you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations -// under the License. -// -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#ifndef MULTI_LLVM_ENUMS_H_INCLUDED -#define MULTI_LLVM_ENUMS_H_INCLUDED - -#include -#include - -namespace multi_llvm { -#if LLVM_VERSION_MAJOR >= 18 - -typedef llvm::CodeGenFileType CodeGenFileType; -typedef llvm::CodeGenOptLevel CodeGenOptLevel; - -#else - -struct CodeGenFileType { - static constexpr auto AssemblyFile = llvm::CGFT_AssemblyFile; - static constexpr auto ObjectFile = llvm::CGFT_ObjectFile; - static constexpr auto Null = llvm::CGFT_Null; -}; - -struct CodeGenOptLevel { - static constexpr auto None = llvm::CodeGenOpt::None; - static constexpr auto Less = llvm::CodeGenOpt::Less; - static constexpr auto Default = llvm::CodeGenOpt::Default; - static constexpr auto Aggressive = llvm::CodeGenOpt::Aggressive; -}; - -#endif -} // namespace multi_llvm - -#endif // MULTI_LLVM_ENUMS_H_INCLUDED diff --git a/modules/compiler/multi_llvm/include/multi_llvm/loop_utils.h b/modules/compiler/multi_llvm/include/multi_llvm/loop_utils.h index 8301f9b63..fecfbec7c 100644 --- a/modules/compiler/multi_llvm/include/multi_llvm/loop_utils.h +++ b/modules/compiler/multi_llvm/include/multi_llvm/loop_utils.h @@ -13,6 +13,7 @@ // under the License. // // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + #ifndef MULTI_LLVM_LOOP_UTILS_H_INCLUDED #define MULTI_LLVM_LOOP_UTILS_H_INCLUDED @@ -21,17 +22,13 @@ namespace multi_llvm { -inline llvm::Value *createSimpleTargetReduction( - llvm::IRBuilderBase &B, const llvm::TargetTransformInfo *TTI, - llvm::Value *Src, llvm::RecurKind RdxKind) { +inline llvm::Value *createSimpleReduction(llvm::IRBuilderBase &B, + llvm::Value *Src, + llvm::RecurKind RdxKind) { #if LLVM_VERSION_MAJOR >= 20 - (void)TTI; return llvm::createSimpleReduction(B, Src, RdxKind); -#elif LLVM_VERSION_MAJOR >= 18 - (void)TTI; - return llvm::createSimpleTargetReduction(B, Src, RdxKind); #else - return llvm::createSimpleTargetReduction(B, TTI, Src, RdxKind); + return llvm::createSimpleTargetReduction(B, Src, RdxKind); #endif } diff --git a/modules/compiler/multi_llvm/include/multi_llvm/multi_llvm.h b/modules/compiler/multi_llvm/include/multi_llvm/multi_llvm.h index be4169aed..e238e6465 100644 --- a/modules/compiler/multi_llvm/include/multi_llvm/multi_llvm.h +++ b/modules/compiler/multi_llvm/include/multi_llvm/multi_llvm.h @@ -17,7 +17,6 @@ #ifndef MULTI_LLVM_MULTI_LLVM_H_INCLUDED #define MULTI_LLVM_MULTI_LLVM_H_INCLUDED -#include #include #include diff --git a/modules/compiler/riscv/source/module.cpp b/modules/compiler/riscv/source/module.cpp index 0681d9ab5..12575e232 100644 --- a/modules/compiler/riscv/source/module.cpp +++ b/modules/compiler/riscv/source/module.cpp @@ -196,7 +196,7 @@ static llvm::TargetMachine *createTargetMachine( target.llvm_triple, target.llvm_cpu, target.llvm_features, options, target.riscv_hal_device_info->link_shared ? llvm::Reloc::Model::PIC_ : llvm::Reloc::Model::Static, - llvm::CodeModel::Small, multi_llvm::CodeGenOptLevel::Aggressive); + llvm::CodeModel::Small, llvm::CodeGenOptLevel::Aggressive); } llvm::TargetMachine *riscv::RiscvModule::getTargetMachine() { diff --git a/modules/compiler/source/base/CMakeLists.txt b/modules/compiler/source/base/CMakeLists.txt index 465adc204..fea30b150 100644 --- a/modules/compiler/source/base/CMakeLists.txt +++ b/modules/compiler/source/base/CMakeLists.txt @@ -95,13 +95,11 @@ endif() set(CLANG_LIBS "clangCodeGen" "clangFrontend" "clangDriver" "clangParse" "clangSerialization" "clangSema" "clangAnalysis" "clangAST" "clangEdit" "clangASTMatchers" - "clangLex" "clangBasic" "clangSupport") -set(LLVM_LIBS "LLVMCodeGen" "LLVMOption" "LLVMCoroutines" "LLVMCoverage" - "LLVMLTO" "LLVMWindowsDriver" "LLVMFrontendHLSL") -if(LLVM_VERSION_MAJOR GREATER_EQUAL 18) - list(APPEND CLANG_LIBS "clangAPINotes" "clangBasic") - list(APPEND LLVM_LIBS "LLVMFrontendDriver") -endif() + "clangLex" "clangBasic" "clangSupport" "clangAPINotes" + "clangBasic") +set(LLVM_LIBS "LLVMCodeGen" "LLVMCoroutines" "LLVMCoverage" + "LLVMFrontendDriver" "LLVMFrontendHLSL" "LLVMLTO" "LLVMOption" + "LLVMWindowsDriver") # In-tree, we should have each of these library targets available. # Otherwise, we have to provide the full path to them. diff --git a/modules/compiler/source/base/source/base_module_pass_machinery.cpp b/modules/compiler/source/base/source/base_module_pass_machinery.cpp index 9e463fcb1..b9bb281e9 100644 --- a/modules/compiler/source/base/source/base_module_pass_machinery.cpp +++ b/modules/compiler/source/base/source/base_module_pass_machinery.cpp @@ -275,9 +275,6 @@ static std::unordered_map CallConvMap = { {"Cold", CallingConv::Cold}, {"GHC", CallingConv::GHC}, {"HiPE", CallingConv::HiPE}, -#if LLVM_VERSION_LESS(18, 0) - {"WebKit_JS", CallingConv::WebKit_JS}, -#endif {"AnyReg", CallingConv::AnyReg}, {"PreserveMost", CallingConv::PreserveMost}, {"PreserveAll", CallingConv::PreserveAll}, @@ -318,12 +315,10 @@ static std::unordered_map CallConvMap = { {"WASM_EmscriptenInvoke", CallingConv::WASM_EmscriptenInvoke}, {"AMDGPU_Gfx", CallingConv::AMDGPU_Gfx}, {"M68k_INTR", CallingConv::M68k_INTR}, -#if LLVM_VERSION_GREATER_EQUAL(17, 0) {"AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0", CallingConv::AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0}, {"AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2", CallingConv::AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2}, -#endif }; // For parseFixupCallingConventionPassOptions we check the param against diff --git a/modules/compiler/source/base/source/module.cpp b/modules/compiler/source/base/source/module.cpp index 0018b82f3..53b5f4dad 100644 --- a/modules/compiler/source/base/source/module.cpp +++ b/modules/compiler/source/base/source/module.cpp @@ -238,12 +238,7 @@ static bool loadKernelAPIHeader(clang::CompilerInstance &compiler, // stored inside the PCH file. llvm::BitstreamCursor &Cursor = moduleFile->InputFilesCursor; const clang::SavedStreamPosition SavedPosition(Cursor); -#if LLVM_VERSION_GREATER_EQUAL(18, 0) - // LLVM 18 introduces a new offset that should be included const uint64_t Base = moduleFile->InputFilesOffsetBase; -#else - const uint64_t Base = 0; -#endif if (Cursor.JumpToBit(Base + moduleFile->InputFileOffsets[0])) { return false; } diff --git a/modules/compiler/source/base/source/pass_pipelines.cpp b/modules/compiler/source/base/source/pass_pipelines.cpp index 454ae238c..0ce84f5f1 100644 --- a/modules/compiler/source/base/source/pass_pipelines.cpp +++ b/modules/compiler/source/base/source/pass_pipelines.cpp @@ -134,8 +134,8 @@ Result emitCodeGenFile(llvm::Module &M, TargetMachine *TM, raw_pwrite_stream &ostream, bool create_assembly) { legacy::PassManager PM; const CodeGenFileType type = !create_assembly - ? multi_llvm::CodeGenFileType::ObjectFile - : multi_llvm::CodeGenFileType::AssemblyFile; + ? llvm::CodeGenFileType::ObjectFile + : llvm::CodeGenFileType::AssemblyFile; if (TM->addPassesToEmitFile(PM, ostream, /*DwoOut*/ nullptr, type, /*DisableVerify*/ false)) { return compiler::Result::FAILURE; diff --git a/modules/compiler/spirv-ll/source/builder_debug_info.cpp b/modules/compiler/spirv-ll/source/builder_debug_info.cpp index 0fa30fd08..ae4e05b05 100644 --- a/modules/compiler/spirv-ll/source/builder_debug_info.cpp +++ b/modules/compiler/spirv-ll/source/builder_debug_info.cpp @@ -1002,15 +1002,9 @@ llvm::Expected DebugInfoBuilder::translate( "'Value' " + getIDAsStr(*op_val, &module) + " of DebugTypeMember " + getIDAsStr(op->IdResult(), &module) + " is not an OpConstant"); } -#if LLVM_VERSION_GREATER_EQUAL(18, 0) return getDIBuilder(op).createStaticMemberType( scope, *name, file, op->Line(), base_ty, flags, cast(val), llvm::dwarf::DW_TAG_variable); -#else - return getDIBuilder(op).createStaticMemberType(scope, *name, file, - op->Line(), base_ty, flags, - cast(val)); -#endif } auto size_or_error = getConstantIntValue(op->Size()); diff --git a/modules/compiler/targets/host/source/target.cpp b/modules/compiler/targets/host/source/target.cpp index 8f8783fa1..9786a0ee6 100644 --- a/modules/compiler/targets/host/source/target.cpp +++ b/modules/compiler/targets/host/source/target.cpp @@ -16,6 +16,8 @@ #include "host/target.h" +#include +#include #include #include #include @@ -33,18 +35,10 @@ #include #include #include +#include #include #include -#if LLVM_VERSION_GREATER_EQUAL(18, 0) -#include -#else -#include -#endif - -#include -#include - #include "host/device.h" #include "host/info.h" #include "host/module.h" @@ -94,8 +88,7 @@ static llvm::TargetMachine *createTargetMachine(llvm::Triple TT, const llvm::TargetOptions Options; return LLVMTarget->createTargetMachine( TripleStr, CPU, Features, Options, /*RM=*/std::nullopt, CM, - multi_llvm::CodeGenOptLevel::Aggressive, - /*JIT=*/true); + llvm::CodeGenOptLevel::Aggressive, /*JIT=*/true); } HostTarget::HostTarget(const HostInfo *compiler_info, @@ -419,7 +412,7 @@ compiler::Result HostTarget::initWithBuiltins( if (compiler_info->supports_deferred_compilation()) { llvm::orc::JITTargetMachineBuilder TMBuilder(triple); TMBuilder.setCPU(CPU); - TMBuilder.setCodeGenOptLevel(multi_llvm::CodeGenOptLevel::Aggressive); + TMBuilder.setCodeGenOptLevel(llvm::CodeGenOptLevel::Aggressive); TMBuilder.getFeatures().addFeaturesVector(Features.getFeatures()); auto Builder = llvm::orc::LLJITBuilder(); diff --git a/modules/compiler/tools/muxc/muxc.cpp b/modules/compiler/tools/muxc/muxc.cpp index 50bbb6766..2f176460f 100644 --- a/modules/compiler/tools/muxc/muxc.cpp +++ b/modules/compiler/tools/muxc/muxc.cpp @@ -57,13 +57,13 @@ static cl::opt WriteTextual( cl::init(true)); static cl::opt FileType( - "filetype", cl::init(multi_llvm::CodeGenFileType::AssemblyFile), + "filetype", cl::init(llvm::CodeGenFileType::AssemblyFile), cl::desc("Choose a file type:"), - cl::values(clEnumValN(multi_llvm::CodeGenFileType::AssemblyFile, "asm", + cl::values(clEnumValN(llvm::CodeGenFileType::AssemblyFile, "asm", "Emit a textual file"), - clEnumValN(multi_llvm::CodeGenFileType::ObjectFile, "obj", + clEnumValN(llvm::CodeGenFileType::ObjectFile, "obj", "Emit a binary object file"), - clEnumValN(multi_llvm::CodeGenFileType::Null, "null", + clEnumValN(llvm::CodeGenFileType::Null, "null", "Emit nothing, for performance testing"))); static cl::opt DeviceIdx( @@ -143,14 +143,14 @@ int main(int argc, char **argv) { } } - if (FileType == multi_llvm::CodeGenFileType::Null) { + if (FileType == llvm::CodeGenFileType::Null) { return 0; } // Open the output file. std::error_code EC; sys::fs::OpenFlags OpenFlags = sys::fs::OF_None; - if (FileType == multi_llvm::CodeGenFileType::AssemblyFile) { + if (FileType == llvm::CodeGenFileType::AssemblyFile) { OpenFlags |= sys::fs::OF_Text; } auto Out = std::make_unique(OutputFilename, EC, OpenFlags); @@ -160,7 +160,7 @@ int main(int argc, char **argv) { } llvm::ModulePassManager printMPM; - if (FileType == multi_llvm::CodeGenFileType::AssemblyFile) { + if (FileType == llvm::CodeGenFileType::AssemblyFile) { printMPM.addPass(llvm::PrintModulePass(Out->os())); } else { printMPM.addPass(llvm::BitcodeWriterPass(Out->os())); diff --git a/modules/compiler/vecz/source/control_flow_boscc.cpp b/modules/compiler/vecz/source/control_flow_boscc.cpp index 0563b0d58..04a36e875 100644 --- a/modules/compiler/vecz/source/control_flow_boscc.cpp +++ b/modules/compiler/vecz/source/control_flow_boscc.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -1026,7 +1025,7 @@ bool ControlFlowConversionState::BOSCCGadget::blendFinalize() { PHINode *blend = PHINode::Create(liveIn->getType(), 2, liveIn->getName() + ".boscc_blend"); - multi_llvm::insertBefore(blend, blendPoint->begin()); + blend->insertBefore(blendPoint->begin()); bool replaceUniform = false; bool replacePredicate = false; // For each predecessor, if it can reach the instruction, set the @@ -1096,7 +1095,7 @@ bool ControlFlowConversionState::BOSCCGadget::blendFinalize() { PHINode *blend = PHINode::Create( incoming->getType(), 1, incoming->getName() + ".boscc_lcssa"); - multi_llvm::insertBefore(blend, target->begin()); + blend->insertBefore(target->begin()); blend->addIncoming(incoming, runtimeCheckerBlock); PHI->setIncomingValue(idx, blend); } @@ -1219,7 +1218,7 @@ bool ControlFlowConversionState::BOSCCGadget::updateLoopBlendValues( auto createLatchIncoming = [&from, <ag, this] { auto *ret = PHINode::Create(from->getType(), 2, from->getName() + ".boscc_blend"); - multi_llvm::insertBefore(ret, LTag->latch->begin()); + ret->insertBefore(LTag->latch->begin()); Value *uniform = getUniformV(from); Value *default_val = getDefaultValue(from->getType()); for (BasicBlock *pred : predecessors(LTag->latch)) { diff --git a/modules/compiler/vecz/source/include/transform/packetization_helpers.h b/modules/compiler/vecz/source/include/transform/packetization_helpers.h index 53141575a..da3a9ad2f 100644 --- a/modules/compiler/vecz/source/include/transform/packetization_helpers.h +++ b/modules/compiler/vecz/source/include/transform/packetization_helpers.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -98,11 +97,9 @@ bool createSubSplats(const vecz::TargetInfo &TI, llvm::IRBuilder<> &B, /// /// Only works on RecurKind::And, Or, Xor, Add, Mul, FAdd, FMul, {S,U,F}Min, /// {S,U,F}Max. -llvm::Value *createMaybeVPTargetReduction(llvm::IRBuilderBase &B, - const llvm::TargetTransformInfo &TTI, - llvm::Value *Val, - llvm::RecurKind Kind, - llvm::Value *VL = nullptr); +llvm::Value *createMaybeVPReduction(llvm::IRBuilderBase &B, llvm::Value *Val, + llvm::RecurKind Kind, + llvm::Value *VL = nullptr); /// @brief Utility function to obtain an indices vector to be used in a gather /// operation. diff --git a/modules/compiler/vecz/source/transform/basic_mem2reg_pass.cpp b/modules/compiler/vecz/source/transform/basic_mem2reg_pass.cpp index af5e0f173..3aa856e54 100644 --- a/modules/compiler/vecz/source/transform/basic_mem2reg_pass.cpp +++ b/modules/compiler/vecz/source/transform/basic_mem2reg_pass.cpp @@ -183,11 +183,7 @@ bool BasicMem2RegPass::promoteAlloca(AllocaInst *Alloca) const { StoredValue = Store->getValueOperand(); ToDelete.push_back(Store); DIBuilder DIB(*Alloca->getModule(), /*AllowUnresolved*/ false); -#if LLVM_VERSION_GREATER_EQUAL(18, 0) auto DbgIntrinsics = findDbgDeclares(Alloca); -#else - auto DbgIntrinsics = FindDbgDeclareUses(Alloca); -#endif for (auto oldDII : DbgIntrinsics) { ConvertDebugDeclareToDebugValue(oldDII, Store, DIB); } diff --git a/modules/compiler/vecz/source/transform/control_flow_conversion_pass.cpp b/modules/compiler/vecz/source/transform/control_flow_conversion_pass.cpp index 38de9799d..0481b118b 100644 --- a/modules/compiler/vecz/source/transform/control_flow_conversion_pass.cpp +++ b/modules/compiler/vecz/source/transform/control_flow_conversion_pass.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include @@ -717,7 +716,7 @@ bool ControlFlowConversionState::Impl::createEntryMasks(BasicBlock &BB) { if (LTag->isLoopDivergent()) { PHINode *PHI = PHINode::Create(maskTy, 2, BB.getName() + ".entry_mask"); - multi_llvm::insertBefore(PHI, BB.begin()); + PHI->insertBefore(BB.begin()); PHI->addIncoming(MaskInfos[preheader].exitMasks[&BB], preheader); maskInfo.entryMask = PHI; LLVM_DEBUG(dbgs() << "Loop divergent loop header " << BB.getName() @@ -769,7 +768,7 @@ bool ControlFlowConversionState::Impl::createEntryMasks(BasicBlock &BB) { // A phi function of the predecessors otherwise. PHINode *PHI = PHINode::Create(maskTy, numPreds, BB.getName() + ".entry_mask"); - multi_llvm::insertBefore(PHI, BB.begin()); + PHI->insertBefore(BB.begin()); for (auto it = pred_begin(&BB); it != pred_end(&BB); ++it) { PHI->addIncoming(MaskInfos[*it].exitMasks[&BB], *it); } @@ -951,8 +950,7 @@ bool ControlFlowConversionState::Impl::createLoopExitMasks(LoopTag <ag) { // between the mask update and the loop exit mask phi. auto *const exitMask = PHINode::Create(maskTy, 2, exitBlock->getName() + ".loop_exit_mask"); - multi_llvm::insertBefore(exitMask, - multi_llvm::getFirstNonPHIIt(LTag.header)); + exitMask->insertBefore(LTag.header->getFirstNonPHIIt()); LMask.persistedDivergentExitMasks[exitingBlock] = exitMask; if (BOSCC) { BOSCC->createReference(exitMask, getDefaultValue(maskTy)); @@ -2097,7 +2095,7 @@ bool ControlFlowConversionState::Impl::generateDivergentLoopResults( << LTag.loop->getName() << "\n"); // First create instructions to save the value of the last iteration ... - IRBuilder<> B(LTag.header, multi_llvm::getFirstNonPHIIt(LTag.header)); + IRBuilder<> B(LTag.header, LTag.header->getFirstNonPHIIt()); for (Value *LLV : LTag.loopLiveValues) { LTag.loopResultPrevs[LLV] = B.CreatePHI(LLV->getType(), 2, LLV->getName() + ".prev"); @@ -2123,8 +2121,7 @@ bool ControlFlowConversionState::Impl::generateDivergentLoopResults( uniformLRP->setIncomingValue(1, LLV); - multi_llvm::insertBefore(uniformLRP, - multi_llvm::getFirstNonPHIIt(uniformHeader)); + uniformLRP->insertBefore(uniformHeader->getFirstNonPHIIt()); BOSCC->createReference(LRP, uniformLRP, true); } } @@ -2199,7 +2196,7 @@ bool ControlFlowConversionState::Impl::blendDivergentLoopLiveValues( PHINode *blend = PHINode::Create(LLV->getType(), 2, LLV->getName() + ".blend"); - multi_llvm::insertBefore(blend, LTag.pureExit->begin()); + blend->insertBefore(LTag.pureExit->begin()); // Replace all uses outside the loop. VECZ_FAIL_IF( @@ -2264,7 +2261,7 @@ bool ControlFlowConversionState::Impl::blendDivergentLoopExitMasks( PHINode *blend = PHINode::Create(prev->getType(), 2, prev->getName() + ".blend"); - multi_llvm::insertBefore(blend, LTag.pureExit->begin()); + blend->insertBefore(LTag.pureExit->begin()); // Replace all uses outside the loop. VECZ_FAIL_IF(!replaceUsesOutsideDivergentLoop(LTag, update, blend, @@ -2950,7 +2947,7 @@ bool ControlFlowConversionState::Impl::blendInstructions() { const unsigned numPreds = std::distance(pred_begin(B), pred_end(B)); Value *blend = nullptr; PHINode *PHI = PHINode::Create(T, numPreds, opDef->getName() + ".merge"); - multi_llvm::insertBefore(PHI, B->begin()); + PHI->insertBefore(B->begin()); const auto *const LTag = DR->getTag(B).loop; bool hasVisitedPred = false; diff --git a/modules/compiler/vecz/source/transform/packetization_helpers.cpp b/modules/compiler/vecz/source/transform/packetization_helpers.cpp index 4afe43e37..4e31c1850 100644 --- a/modules/compiler/vecz/source/transform/packetization_helpers.cpp +++ b/modules/compiler/vecz/source/transform/packetization_helpers.cpp @@ -268,13 +268,12 @@ bool createSubSplats(const vecz::TargetInfo &TI, IRBuilder<> &B, return true; } -Value *createMaybeVPTargetReduction(IRBuilderBase &B, - const TargetTransformInfo &TTI, Value *Val, - RecurKind Kind, Value *VL) { +Value *createMaybeVPReduction(IRBuilderBase &B, Value *Val, RecurKind Kind, + Value *VL) { assert(isa(Val->getType()) && "Must be vector type"); // If VL is null, it's not a vector-predicated reduction. if (!VL) { - return multi_llvm::createSimpleTargetReduction(B, &TTI, Val, Kind); + return multi_llvm::createSimpleReduction(B, Val, Kind); } auto IntrinsicOp = Intrinsic::not_intrinsic; switch (Kind) { diff --git a/modules/compiler/vecz/source/transform/packetizer.cpp b/modules/compiler/vecz/source/transform/packetizer.cpp index 69da33329..d578417f3 100644 --- a/modules/compiler/vecz/source/transform/packetizer.cpp +++ b/modules/compiler/vecz/source/transform/packetizer.cpp @@ -921,7 +921,7 @@ Value *Packetizer::Impl::reduceBranchCond(Value *cond, Instruction *terminator, // value. Value *&f = conds.front(); - return createMaybeVPTargetReduction(B, TTI, f, kind, VL); + return createMaybeVPReduction(B, f, kind, VL); } Packetizer::Result Packetizer::Impl::assign(Value *Scalar, Value *Vectorized) { @@ -976,7 +976,7 @@ Packetizer::Result Packetizer::Impl::packetize(Value *V) { if (newCond->getType()->isVectorTy()) { IRBuilder<> B(Branch); const RecurKind kind = RecurKind::Or; - newCond = createMaybeVPTargetReduction(B, TTI, newCond, kind, VL); + newCond = createMaybeVPReduction(B, newCond, kind, VL); } Branch->setCondition(newCond); @@ -1269,8 +1269,7 @@ Value *Packetizer::Impl::packetizeGroupReduction(Instruction *I) { } // Reduce to a scalar. - Value *v = createMaybeVPTargetReduction(B, TTI, opPackets.front(), - Info->Recurrence, VL); + Value *v = createMaybeVPReduction(B, opPackets.front(), Info->Recurrence, VL); // We leave the original reduction function and divert the vectorized // reduction through it, giving us a reduction over the full apparent @@ -1943,8 +1942,7 @@ Value *Packetizer::Impl::packetizeMaskVarying(Instruction *I) { } }(); - Value *anyOfMask = - createMaybeVPTargetReduction(B, TTI, vecMask, RecurKind::Or, VL); + Value *anyOfMask = createMaybeVPReduction(B, vecMask, RecurKind::Or, VL); anyOfMask->setName("any_of_mask"); if (isVector) { @@ -2389,8 +2387,7 @@ ValuePacket Packetizer::Impl::packetizeGroupScan( // Thus we essentially keep the original group scan, but change it to be an // exclusive one. auto *Reduction = Ops.front(); - Reduction = - createMaybeVPTargetReduction(B, TTI, Reduction, Scan.Recurrence, VL); + Reduction = createMaybeVPReduction(B, Reduction, Scan.Recurrence, VL); // Now we defer to an *exclusive* scan over the group. auto ExclScan = Scan; diff --git a/modules/compiler/vecz/source/transform/pre_linearize_pass.cpp b/modules/compiler/vecz/source/transform/pre_linearize_pass.cpp index fee752eb9..a98ec1855 100644 --- a/modules/compiler/vecz/source/transform/pre_linearize_pass.cpp +++ b/modules/compiler/vecz/source/transform/pre_linearize_pass.cpp @@ -121,8 +121,7 @@ InstructionCost calculateBoolReductionCost(LLVMContext &context, Module *module, auto *F = Function::Create(new_fty, Function::InternalLinkage, "tmp", module); auto *BB = BasicBlock::Create(context, "reduce", F); IRBuilder<> B(BB); - multi_llvm::createSimpleTargetReduction(B, &TTI, &*F->arg_begin(), - RecurKind::And); + multi_llvm::createSimpleReduction(B, &*F->arg_begin(), RecurKind::And); const InstructionCost cost = calculateBlockCost(*BB, TTI); // We don't really need that function in the module anymore because it's diff --git a/modules/compiler/vecz/source/vecz_pass_builder.cpp b/modules/compiler/vecz/source/vecz_pass_builder.cpp index f1a110b45..883dd9330 100644 --- a/modules/compiler/vecz/source/vecz_pass_builder.cpp +++ b/modules/compiler/vecz/source/vecz_pass_builder.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -75,10 +76,6 @@ #include "transform/scalarization_pass.h" #include "transform/ternary_transform_pass.h" -#if LLVM_VERSION_GREATER_EQUAL(18, 0) -#include -#endif - #define DEBUG_TYPE "vecz" using namespace llvm; using namespace vecz; @@ -278,10 +275,7 @@ bool vecz::buildPassPipeline(ModulePassManager &PM) { FPM.addPass(InterleavedGroupCombinePass(eInterleavedStore)); FPM.addPass(InterleavedGroupCombinePass(eInterleavedLoad)); FPM.addPass(InstCombinePass()); -#if LLVM_VERSION_GREATER_EQUAL(18, 0) - // LLVM 18 split this pass out of InstCombine FPM.addPass(InferAlignmentPass()); -#endif FPM.addPass(DCEPass()); FPM.addPass(SimplifyMaskedMemOpsPass());