diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index 1b6b549214f4..1da47b0d1af2 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -30,11 +30,11 @@ jobs: steps: - uses: actions/checkout@v3 - name: Install clang-tidy - run: brew install llvm@17 ninja + run: brew install llvm@19 ninja lld - name: Run clang-tidy run: ./run-clang-tidy.sh env: - CLANG_TIDY_LLVM_INSTALL_DIR: /opt/homebrew/opt/llvm@17 + CLANG_TIDY_LLVM_INSTALL_DIR: /opt/homebrew/opt/llvm@19 check_cmake_file_lists: name: Check CMake file lists runs-on: ubuntu-20.04 diff --git a/CMakeLists.txt b/CMakeLists.txt index ffb68a0a2dc2..f4307308bbad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,7 +195,7 @@ option(THREADS_PREFER_PTHREAD_FLAG "When enabled, prefer to use the -pthread fla find_package(Threads REQUIRED) ## LLVM -find_package(Halide_LLVM 17...20 REQUIRED +find_package(Halide_LLVM 18...20 REQUIRED COMPONENTS WebAssembly X86 OPTIONAL_COMPONENTS AArch64 ARM Hexagon NVPTX PowerPC RISCV) diff --git a/README.md b/README.md index fd13c0a92f59..7d2bf83356f2 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ issue. At any point in time, building Halide requires either the latest stable version of LLVM, the previous stable version of LLVM, or trunk. At the time of writing, -this means versions 19, 18, and 17 are supported, but 16 is not. +this means versions 20, 19, and 18 are supported, but 17 is not. It is simplest to get a binary release of LLVM on macOS by using [Homebrew](https://brew.sh). Just run `brew install llvm`. On Debian flavors of @@ -165,10 +165,10 @@ If your OS does not have packages for LLVM, or you want more control over the configuration, you can build it yourself. First check it out from GitHub: ```shell -$ git clone --depth 1 --branch llvmorg-18.1.8 https://github.com/llvm/llvm-project.git +$ git clone --depth 1 --branch llvmorg-19.1.5 https://github.com/llvm/llvm-project.git ``` -(LLVM 18.1.8 is the most recent released LLVM at the time of writing. For +(LLVM 19.1.5 is the most recent released LLVM at the time of writing. For current trunk, use `main` instead) Then build it like so: @@ -305,10 +305,10 @@ Subsets of the tests can be selected with `-L` and include `correctness`, #### Building LLVM (optional) Follow these steps if you want to build LLVM yourself. First, download LLVM's -sources (these instructions use the 18.1.8 release). +sources (these instructions use the 19.1.5 release). ``` -D:\> git clone --depth 1 --branch llvm-org-18.1.8 https://github.com/llvm/llvm-project.git +D:\> git clone --depth 1 --branch llvm-org-19.1.5 https://github.com/llvm/llvm-project.git ``` As above, run `vcvarsall.bat` to pick between x86 and x64. Then configure LLVM diff --git a/cmake/FindHalide_LLVM.cmake b/cmake/FindHalide_LLVM.cmake index cf3b3994f1b4..706112742e37 100644 --- a/cmake/FindHalide_LLVM.cmake +++ b/cmake/FindHalide_LLVM.cmake @@ -13,13 +13,6 @@ find_package(LLVM ${PACKAGE_FIND_VERSION} CONFIG) set(Halide_LLVM_VERSION "${LLVM_PACKAGE_VERSION}") -# TODO: deprecated in Halide 19.0.0, remove in Halide 20.0.0 -if (NOT DEFINED Halide_LLVM_SHARED_LIBS AND DEFINED Halide_SHARED_LLVM) - set(Halide_LLVM_SHARED_LIBS "${Halide_SHARED_LLVM}") - message(DEPRECATION - "Halide_SHARED_LLVM has been renamed to Halide_LLVM_SHARED_LIBS.") -endif () - if (NOT DEFINED Halide_LLVM_SHARED_LIBS) # Normally, we don't like making decisions for our users. However, # this avoids an incompatible scenario that is checked below. So diff --git a/cmake/FindNodeJS.cmake b/cmake/FindNodeJS.cmake index a1168435e1cb..f1ff96339d7f 100644 --- a/cmake/FindNodeJS.cmake +++ b/cmake/FindNodeJS.cmake @@ -1,9 +1,3 @@ -if (EXISTS "${NODE_JS_EXECUTABLE}") - message(DEPRECATION "NODE_JS_EXECUTABLE has been renamed to NodeJS_EXECUTABLE") - set(NodeJS_EXECUTABLE "${NODE_JS_EXECUTABLE}") - set(NodeJS_EXECUTABLE "${NODE_JS_EXECUTABLE}" CACHE PATH "") -endif () - find_program( NodeJS_EXECUTABLE NAMES node nodejs diff --git a/cmake/FindV8.cmake b/cmake/FindV8.cmake index 887d52f45329..db49e7a014d8 100644 --- a/cmake/FindV8.cmake +++ b/cmake/FindV8.cmake @@ -1,17 +1,5 @@ -if (EXISTS "${V8_INCLUDE_PATH}") - message(DEPRECATION "V8_INCLUDE_PATH has been renamed to V8_INCLUDE_DIR") - set(V8_INCLUDE_DIR "${V8_INCLUDE_PATH}") - set(V8_INCLUDE_DIR "${V8_INCLUDE_PATH}" CACHE PATH "") -endif () - find_path(V8_INCLUDE_DIR v8.h) -if (EXISTS "${V8_LIB_PATH}") - message(DEPRECATION "V8_LIB_PATH has been renamed to V8_LIBRARY") - set(V8_LIBRARY "${V8_LIB_PATH}") - set(V8_LIBRARY "${V8_LIB_PATH}" CACHE FILEPATH "") -endif () - find_library( V8_LIBRARY NAMES v8_monolith diff --git a/run-clang-tidy.sh b/run-clang-tidy.sh index 571b41a65503..24b2dc9513cd 100755 --- a/run-clang-tidy.sh +++ b/run-clang-tidy.sh @@ -41,18 +41,18 @@ if [ -n "${FIX}" ]; then echo "Operating in -fix mode!" fi -# We are currently standardized on using LLVM/Clang 17 for this script. +# We are currently standardized on using LLVM/Clang 19 for this script. # Note that this is totally independent of the version of LLVM that you -# are using to build Halide itself. If you don't have LLVM17 installed, +# are using to build Halide itself. If you don't have LLVM19 installed, # you can usually install what you need easily via: # -# sudo apt-get install llvm-17 clang-17 libclang-17-dev clang-tidy-17 -# export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-17 +# sudo apt-get install llvm-19 clang-19 libclang-19-dev clang-tidy-19 +# export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-19 # # On macOS: # -# brew install llvm@17 -# export CLANG_TIDY_LLVM_INSTALL_DIR=/opt/homebrew/opt/llvm@17 +# brew install llvm@19 +# export CLANG_TIDY_LLVM_INSTALL_DIR=/opt/homebrew/opt/llvm@19 if [ -z "$CLANG_TIDY_LLVM_INSTALL_DIR" ]; then echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM installation dir for this script." @@ -62,11 +62,11 @@ fi echo "CLANG_TIDY_LLVM_INSTALL_DIR = ${CLANG_TIDY_LLVM_INSTALL_DIR}" VERSION=$("${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/clang-tidy" --version) -if [[ ${VERSION} =~ .*version\ 17.* ]] +if [[ ${VERSION} =~ .*version\ 19.* ]] then - echo "clang-tidy version 17 found." + echo "clang-tidy version 19 found." else - echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM 17 install!" + echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM 19 install!" exit 1 fi @@ -140,4 +140,4 @@ echo "run-clang-tidy finished with status ${RESULT}" rm -rf "${CLANG_TIDY_BUILD_DIR}" -exit "${RESULT}" \ No newline at end of file +exit "${RESULT}" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f5eb3e64f97f..ec77cf15e303 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -586,19 +586,6 @@ set(Halide_WASM_BACKEND "wabt" CACHE STRING "Which backend to use for Halide's WASM testing.") set_property(CACHE Halide_WASM_BACKEND PROPERTY STRINGS "wabt;V8;OFF") -if (WITH_WABT AND NOT WITH_V8) - message(DEPRECATION "WITH_WABT has been replaced by Halide_WASM_BACKEND=\"wabt\"") - set(Halide_WASM_BACKEND "wabt") -elseif (NOT WITH_WABT AND WITH_V8) - message(DEPRECATION "WITH_V8 has been replaced by Halide_WASM_BACKEND=\"V8\"") - set(Halide_WASM_BACKEND "V8") -elseif (WITH_WABT AND WITH_V8) - message(FATAL_ERROR "Cannot use both WABT and V8 at the same time, disable one of them.") -elseif (DEFINED WITH_WABT AND DEFINED WITH_V8 AND NOT WITH_WABT AND NOT WITH_V8) - message(DEPRECATION "Disabling both WITH_WABT and WITH_V8 has been replaced by Halide_WASM_BACKEND=\"OFF\"") - set(Halide_WASM_BACKEND "OFF") -endif () - if (MSVC AND Halide_WASM_BACKEND STREQUAL "wabt") message(WARNING "wabt is not yet supported on Windows") set(Halide_WASM_BACKEND "OFF") diff --git a/src/CodeGen_Internal.cpp b/src/CodeGen_Internal.cpp index c2147ff62b53..37efd14a2ba1 100644 --- a/src/CodeGen_Internal.cpp +++ b/src/CodeGen_Internal.cpp @@ -664,12 +664,6 @@ std::unique_ptr make_target_machine(const llvm::Module &mod bool use_large_code_model = get_md_bool(module.getModuleFlag("halide_use_large_code_model")).value_or(false); -#if LLVM_VERSION >= 180 - const auto opt_level = llvm::CodeGenOptLevel::Aggressive; -#else - const auto opt_level = llvm::CodeGenOpt::Aggressive; -#endif - // Get module mcpu_target and mattrs. std::string mcpu_target = get_md_string(module.getModuleFlag("halide_mcpu_target")).value_or(std::string{}); @@ -682,7 +676,7 @@ std::unique_ptr make_target_machine(const llvm::Module &mod options, use_pic ? llvm::Reloc::PIC_ : llvm::Reloc::Static, use_large_code_model ? llvm::CodeModel::Large : llvm::CodeModel::Small, - opt_level); + CodeGenOptLevel::Aggressive); return std::unique_ptr(tm); } diff --git a/src/CodeGen_LLVM.cpp b/src/CodeGen_LLVM.cpp index 31dddc3551af..c6527f6311d5 100644 --- a/src/CodeGen_LLVM.cpp +++ b/src/CodeGen_LLVM.cpp @@ -1147,7 +1147,6 @@ void CodeGen_LLVM::optimize_module() { using OptimizationLevel = llvm::OptimizationLevel; OptimizationLevel level = OptimizationLevel::O3; -#if LLVM_VERSION >= 180 if (tm->isPositionIndependent()) { // Add a pass that converts lookup tables to relative lookup tables to make them PIC-friendly. // See https://bugs.llvm.org/show_bug.cgi?id=45244 @@ -1161,7 +1160,6 @@ void CodeGen_LLVM::optimize_module() { mpm.addPass(RelLookupTableConverterPass()); }); } -#endif if (get_target().has_feature(Target::SanitizerCoverage)) { pb.registerOptimizerLastEPCallback( @@ -1240,7 +1238,7 @@ void CodeGen_LLVM::optimize_module() { } if (tm) { -#if LLVM_VERSION >= 180 && LLVM_VERSION < 190 +#if LLVM_VERSION < 190 tm->registerPassBuilderCallbacks(pb, /*PopulateClassToPassNames=*/false); #else tm->registerPassBuilderCallbacks(pb); diff --git a/src/CodeGen_PTX_Dev.cpp b/src/CodeGen_PTX_Dev.cpp index 093f237f558c..2a86ba3c7d49 100644 --- a/src/CodeGen_PTX_Dev.cpp +++ b/src/CodeGen_PTX_Dev.cpp @@ -612,17 +612,12 @@ vector CodeGen_PTX_Dev::compile_to_src() { options.NoZerosInBSS = false; options.GuaranteedTailCallOpt = false; -#if LLVM_VERSION >= 180 - const auto opt_level = CodeGenOptLevel::Aggressive; -#else - const auto opt_level = CodeGenOpt::Aggressive; -#endif std::unique_ptr target_machine(llvm_target->createTargetMachine(triple.str(), mcpu_target(), mattrs(), options, llvm::Reloc::PIC_, llvm::CodeModel::Small, - opt_level)); + CodeGenOptLevel::Aggressive)); internal_assert(target_machine.get()) << "Could not allocate target machine!"; @@ -688,7 +683,7 @@ vector CodeGen_PTX_Dev::compile_to_src() { using OptimizationLevel = llvm::OptimizationLevel; OptimizationLevel level = OptimizationLevel::O3; -#if LLVM_VERSION >= 180 && LLVM_VERSION < 190 +#if LLVM_VERSION < 190 target_machine->registerPassBuilderCallbacks(pb, /*PopulateClassToPassNames=*/false); #else target_machine->registerPassBuilderCallbacks(pb); @@ -721,14 +716,9 @@ vector CodeGen_PTX_Dev::compile_to_src() { // Output string stream -#if LLVM_VERSION >= 180 - const auto file_type = ::llvm::CodeGenFileType::AssemblyFile; -#else - const auto file_type = ::llvm::CGFT_AssemblyFile; -#endif // Ask the target to add backend passes as necessary. bool fail = target_machine->addPassesToEmitFile(module_pass_manager, ostream, nullptr, - file_type, true); + CodeGenFileType::AssemblyFile, true); internal_assert(!fail) << "Failed to set up passes to emit PTX source\n"; module_pass_manager.run(*module); diff --git a/src/CodeGen_RISCV.cpp b/src/CodeGen_RISCV.cpp index f768031dfc14..62df78138ddd 100644 --- a/src/CodeGen_RISCV.cpp +++ b/src/CodeGen_RISCV.cpp @@ -382,20 +382,10 @@ bool CodeGen_RISCV::call_riscv_vector_intrinsic(const RISCVIntrinsic &intrin, co left_arg, right_arg, }; -#if LLVM_VERSION >= 170 - // LLVM 17+ has "intrinsics" that set csrw internally; the rounding_mode is before vlen. + // LLVM has "intrinsics" that set csrw internally; the rounding_mode is before vlen. if (round_any) { call_args.push_back(rounding_mode); } -#else - // LLVM 16 requires explicitly setting csrw before calling the intrinsic - if (round_any) { - // Set vector fixed-point rounding flag for intrinsic. - llvm::FunctionType *csrw_llvm_type = llvm::FunctionType::get(void_t, {xlen_type}, false); - llvm::InlineAsm *inline_csrw = llvm::InlineAsm::get(csrw_llvm_type, "csrw vxrm,${0:z}", "rJ,~{memory}", true); - builder->CreateCall(inline_csrw, {rounding_mode}); - } -#endif call_args.push_back(actual_vlen); // Finally, make the call. diff --git a/src/CodeGen_WebAssembly.cpp b/src/CodeGen_WebAssembly.cpp index 666d97d7ed93..f3092c5dc22f 100644 --- a/src/CodeGen_WebAssembly.cpp +++ b/src/CodeGen_WebAssembly.cpp @@ -406,8 +406,7 @@ bool CodeGen_WebAssembly::use_soft_float_abi() const { } bool CodeGen_WebAssembly::use_pic() const { -#if LLVM_VERSION >= 180 - // Issues with WASM PIC and dynamic linking only got fixed in LLVM v18.x (June 26th 2023) + // Issues with WASM PIC and dynamic linking were fixed in LLVM v18.x (June 26th 2023) // See https://reviews.llvm.org/D153293 // Always emitting PIC "does add a little bloat to the object files, due to the extra @@ -415,9 +414,6 @@ bool CodeGen_WebAssembly::use_pic() const { // wasm-opt in release builds." // See https://github.com/halide/Halide/issues/7796 return true; -#else - return false; -#endif } int CodeGen_WebAssembly::native_vector_bits() const { diff --git a/src/CodeGen_X86.cpp b/src/CodeGen_X86.cpp index 90609e1477c6..16e4b10043c5 100644 --- a/src/CodeGen_X86.cpp +++ b/src/CodeGen_X86.cpp @@ -1083,11 +1083,9 @@ string CodeGen_X86::mattrs() const { attrs.emplace_back("+amx-bf16"); } } -#if LLVM_VERSION >= 180 if (gather_might_be_slow(target)) { attrs.emplace_back("+prefer-no-gather"); } -#endif if (target.has_feature(Target::AVX10_1)) { switch (target.vector_bits) { diff --git a/src/JITModule.cpp b/src/JITModule.cpp index 905d7b15ddc6..0d98e9baaf69 100644 --- a/src/JITModule.cpp +++ b/src/JITModule.cpp @@ -288,11 +288,7 @@ void JITModule::compile_module(std::unique_ptr m, const string &fu // Build TargetMachine llvm::orc::JITTargetMachineBuilder tm_builder(llvm::Triple(m->getTargetTriple())); tm_builder.setOptions(options); -#if LLVM_VERSION >= 180 tm_builder.setCodeGenOptLevel(CodeGenOptLevel::Aggressive); -#else - tm_builder.setCodeGenOptLevel(CodeGenOpt::Aggressive); -#endif if (target.arch == Target::Arch::RISCV) { tm_builder.setCodeModel(llvm::CodeModel::Medium); } diff --git a/src/LLVM_Headers.h b/src/LLVM_Headers.h index 416a62cd7390..e58254d7274e 100644 --- a/src/LLVM_Headers.h +++ b/src/LLVM_Headers.h @@ -1,10 +1,10 @@ #ifndef HALIDE_LLVM_HEADERS_H #define HALIDE_LLVM_HEADERS_H -#if LLVM_VERSION >= 170 +#if LLVM_VERSION >= 180 // We're good to go #else -#error "Compiling Halide requires LLVM 17.0 or newer" +#error "Compiling Halide requires LLVM 18.0 or newer" #endif // No msvc warnings from llvm headers please @@ -93,10 +93,8 @@ #include #include #include -#include -#if LLVM_VERSION >= 180 #include -#endif +#include // IWYU pragma: end_exports diff --git a/src/LLVM_Output.cpp b/src/LLVM_Output.cpp index ef2958b2889b..f33dc6f303ed 100644 --- a/src/LLVM_Output.cpp +++ b/src/LLVM_Output.cpp @@ -412,11 +412,7 @@ std::unique_ptr compile_module_to_llvm_module(const Module &module } void compile_llvm_module_to_object(llvm::Module &module, Internal::LLVMOStream &out) { -#if LLVM_VERSION >= 180 emit_file(module, out, llvm::CodeGenFileType::ObjectFile); -#else - emit_file(module, out, llvm::CGFT_ObjectFile); -#endif } void compile_llvm_module_to_assembly(llvm::Module &module, Internal::LLVMOStream &out) { @@ -592,15 +588,10 @@ void create_static_library(const std::vector &src_files_in, const T return; } -#if LLVM_VERSION >= 180 - const llvm::SymtabWritingMode write_symtab = llvm::SymtabWritingMode::NormalSymtab; -#else - const bool write_symtab = true; -#endif const auto kind = Internal::get_triple_for_target(target).isOSDarwin() ? llvm::object::Archive::K_BSD : llvm::object::Archive::K_GNU; const bool thin = false; auto result = llvm::writeArchive(dst_file, new_members, - write_symtab, kind, + llvm::SymtabWritingMode::NormalSymtab, kind, deterministic, thin, nullptr); internal_assert(!result) << "Failed to write archive: " << dst_file diff --git a/src/LLVM_Runtime_Linker.cpp b/src/LLVM_Runtime_Linker.cpp index b343f2ee26ea..e98ad708265b 100644 --- a/src/LLVM_Runtime_Linker.cpp +++ b/src/LLVM_Runtime_Linker.cpp @@ -317,7 +317,6 @@ DECLARE_NO_INITMOD(riscv_cpu_features) llvm::DataLayout get_data_layout_for_target(Target target) { if (target.arch == Target::X86) { -#if LLVM_VERSION >= 180 if (target.bits == 32) { if (target.os == Target::OSX) { return llvm::DataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:128-n8:16:32-S128"); @@ -347,37 +346,6 @@ llvm::DataLayout get_data_layout_for_target(Target target) { return llvm::DataLayout("e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"); } } -#else - if (target.bits == 32) { - if (target.os == Target::OSX) { - return llvm::DataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:128-n8:16:32-S128"); - } else if (target.os == Target::IOS) { - return llvm::DataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:128-n8:16:32-S128"); - } else if (target.os == Target::Windows) { - // For 32-bit MSVC targets, alignment of f80 values is 16 bytes (see https://reviews.llvm.org/D115942) - if (!target.has_feature(Target::JIT)) { - return llvm::DataLayout("e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32-a:0:32-S32"); - } else { - return llvm::DataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32-a:0:32-S32"); - } - } else { - // Linux/Android - return llvm::DataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"); - } - } else { // 64-bit - if (target.os == Target::OSX) { - return llvm::DataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"); - } else if (target.os == Target::IOS) { - return llvm::DataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"); - } else if (target.os == Target::Windows && !target.has_feature(Target::JIT)) { - return llvm::DataLayout("e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"); - } else if (target.os == Target::Windows) { - return llvm::DataLayout("e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"); - } else { - return llvm::DataLayout("e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"); - } - } -#endif } else if (target.arch == Target::ARM) { if (target.bits == 32) { if (target.os == Target::IOS) {