Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop deprecated / unsupported setups for Halide 20 #8508

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions cmake/FindHalide_LLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions cmake/FindNodeJS.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 0 additions & 12 deletions cmake/FindV8.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 10 additions & 10 deletions run-clang-tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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

Expand Down Expand Up @@ -140,4 +140,4 @@ echo "run-clang-tidy finished with status ${RESULT}"

rm -rf "${CLANG_TIDY_BUILD_DIR}"

exit "${RESULT}"
exit "${RESULT}"
13 changes: 0 additions & 13 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 1 addition & 7 deletions src/CodeGen_Internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,12 +664,6 @@ std::unique_ptr<llvm::TargetMachine> 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{});
Expand All @@ -682,7 +676,7 @@ std::unique_ptr<llvm::TargetMachine> 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<llvm::TargetMachine>(tm);
}

Expand Down
4 changes: 1 addition & 3 deletions src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1161,7 +1160,6 @@ void CodeGen_LLVM::optimize_module() {
mpm.addPass(RelLookupTableConverterPass());
});
}
#endif

if (get_target().has_feature(Target::SanitizerCoverage)) {
pb.registerOptimizerLastEPCallback(
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 3 additions & 13 deletions src/CodeGen_PTX_Dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,17 +612,12 @@ vector<char> 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<TargetMachine>
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!";

Expand Down Expand Up @@ -688,7 +683,7 @@ vector<char> 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);
Expand Down Expand Up @@ -721,14 +716,9 @@ vector<char> 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);

Expand Down
12 changes: 1 addition & 11 deletions src/CodeGen_RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 1 addition & 5 deletions src/CodeGen_WebAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,14 @@ 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
// indirection, but when linked into a static binary 100% of this can be removed by
// 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 {
Expand Down
2 changes: 0 additions & 2 deletions src/CodeGen_X86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions src/JITModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,7 @@ void JITModule::compile_module(std::unique_ptr<llvm::Module> 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);
}
Expand Down
8 changes: 3 additions & 5 deletions src/LLVM_Headers.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -93,10 +93,8 @@
#include <llvm/Transforms/Instrumentation/ThreadSanitizer.h>
#include <llvm/Transforms/Scalar/GVN.h>
#include <llvm/Transforms/Utils/ModuleUtils.h>
#include <llvm/Transforms/Utils/SymbolRewriter.h>
#if LLVM_VERSION >= 180
#include <llvm/Transforms/Utils/RelLookupTableConverter.h>
#endif
#include <llvm/Transforms/Utils/SymbolRewriter.h>

// IWYU pragma: end_exports

Expand Down
11 changes: 1 addition & 10 deletions src/LLVM_Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,7 @@ std::unique_ptr<llvm::Module> 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) {
Expand Down Expand Up @@ -592,15 +588,10 @@ void create_static_library(const std::vector<std::string> &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
Expand Down
Loading