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 support for LLVM9 #5121

Merged
merged 5 commits into from
Oct 19, 2020
Merged
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: 1 addition & 3 deletions .github/workflows/llvm_builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ jobs:
target_arch: [x86, arm]
target_bits: [32, 64]
target_os: [windows, linux, osx]
llvm_version: [9, 10, 11, 12]
llvm_version: [10, 11, 12]
include:
- llvm_version: 9
llvm_branch: release/9.x
- llvm_version: 10
llvm_branch: release/10.x
- llvm_version: 11
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,13 @@ jobs:
target_os: [linux, osx, windows]
llvm_version: [12]
build_tool: [cmake_shared]
# llvm_version: [9, 10, 11, 12] # TODO
# llvm_version: [10, 11, 12] # TODO
# build_tool: [cmake_shared, make] # TODO

# This section basically allows us to define additional values for
# each matrix entry, e.g. to map an llvm version number to the specific
# git branch that is needed.
include:
# - llvm_version: 9
# llvm_branch: release/9.x
# - llvm_version: 10
# llvm_branch: release/10.x
# - llvm_version: 11
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2059,7 +2059,7 @@ $(BUILD_DIR)/clang_ok:
@exit 1
endif

ifneq (,$(findstring $(LLVM_VERSION_TIMES_10), 90 100 110 120))
ifneq (,$(findstring $(LLVM_VERSION_TIMES_10), 100 110 120))
LLVM_OK=yes
endif

Expand Down
4 changes: 2 additions & 2 deletions dependencies/llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ find_package(Clang REQUIRED CONFIG HINTS "${LLVM_DIR}/../clang")
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

if (LLVM_PACKAGE_VERSION VERSION_LESS 9.0)
message(FATAL_ERROR "LLVM version must be 9.0 or newer")
if (LLVM_PACKAGE_VERSION VERSION_LESS 10.0)
message(FATAL_ERROR "LLVM version must be 10.0 or newer")
endif ()

if (LLVM_PACKAGE_VERSION VERSION_GREATER 12.0)
Expand Down
33 changes: 2 additions & 31 deletions src/CodeGen_ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,13 @@ CodeGen_ARM::CodeGen_ARM(Target target)
casts.push_back(p);

// Saturating add
#if LLVM_VERSION >= 100
if (t.is_int()) {
p.intrin32 = "llvm.sadd.sat" + t_str;
p.intrin64 = "llvm.sadd.sat" + t_str;
} else {
p.intrin32 = "llvm.uadd.sat" + t_str;
p.intrin64 = "llvm.uadd.sat" + t_str;
}
#else
if (t.is_int()) {
p.intrin32 = "llvm.arm.neon.vqadds" + t_str;
p.intrin64 = "llvm.aarch64.neon.sqadd" + t_str;
} else {
p.intrin32 = "llvm.arm.neon.vqaddu" + t_str;
p.intrin64 = "llvm.aarch64.neon.uqadd" + t_str;
}
#endif
p.pattern = cast(t, clamp(w_vector + w_vector, tmin, tmax));
casts.push_back(p);

Expand All @@ -142,23 +132,13 @@ CodeGen_ARM::CodeGen_ARM(Target target)

// Saturating subtract
// N.B. Saturating subtracts always widen to a signed type
#if LLVM_VERSION >= 100
if (t.is_int()) {
p.intrin32 = "llvm.ssub.sat" + t_str;
p.intrin64 = "llvm.ssub.sat" + t_str;
} else {
p.intrin32 = "llvm.usub.sat" + t_str;
p.intrin64 = "llvm.usub.sat" + t_str;
}
#else
if (t.is_int()) {
p.intrin32 = "llvm.arm.neon.vqsubs" + t_str;
p.intrin64 = "llvm.aarch64.neon.sqsub" + t_str;
} else {
p.intrin32 = "llvm.arm.neon.vqsubu" + t_str;
p.intrin64 = "llvm.aarch64.neon.uqsub" + t_str;
}
#endif
p.pattern = cast(t, clamp(ws_vector - ws_vector, tsmin, tsmax));
casts.push_back(p);

Expand Down Expand Up @@ -947,10 +927,8 @@ void CodeGen_ARM::visit(const Load *op) {
LoadInst *loadI = cast<LoadInst>(builder->CreateLoad(bitcastI));
#if LLVM_VERSION >= 110
loadI->setAlignment(Align(alignment));
#elif LLVM_VERSION >= 100
loadI->setAlignment(MaybeAlign(alignment));
#else
loadI->setAlignment(alignment);
loadI->setAlignment(MaybeAlign(alignment));
#endif
add_tbaa_metadata(loadI, op->name, slice_ramp);
Value *shuffleInstr = builder->CreateShuffleVector(loadI, undef, constantsV);
Expand Down Expand Up @@ -1025,7 +1003,6 @@ void CodeGen_ARM::visit(const Call *op) {
}

void CodeGen_ARM::visit(const LT *op) {
#if LLVM_VERSION >= 100
if (op->a.type().is_float() && op->type.is_vector()) {
// Fast-math flags confuse LLVM's aarch64 backend, so
// temporarily clear them for this instruction.
Expand All @@ -1035,13 +1012,11 @@ void CodeGen_ARM::visit(const LT *op) {
CodeGen_Posix::visit(op);
return;
}
#endif

CodeGen_Posix::visit(op);
}

void CodeGen_ARM::visit(const LE *op) {
#if LLVM_VERSION >= 100
if (op->a.type().is_float() && op->type.is_vector()) {
// Fast-math flags confuse LLVM's aarch64 backend, so
// temporarily clear them for this instruction.
Expand All @@ -1051,7 +1026,6 @@ void CodeGen_ARM::visit(const LE *op) {
CodeGen_Posix::visit(op);
return;
}
#endif

CodeGen_Posix::visit(op);
}
Expand All @@ -1060,10 +1034,7 @@ void CodeGen_ARM::codegen_vector_reduce(const VectorReduce *op, const Expr &init
if (neon_intrinsics_disabled() ||
op->op == VectorReduce::Or ||
op->op == VectorReduce::And ||
op->op == VectorReduce::Mul ||
// LLVM 9 has bugs in the arm backend for vector reduce
// ops. See https://github.com/halide/Halide/issues/5081
!(LLVM_VERSION >= 100)) {
op->op == VectorReduce::Mul) {
CodeGen_Posix::codegen_vector_reduce(op, init);
return;
}
Expand Down
11 changes: 1 addition & 10 deletions src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,9 @@ llvm::GlobalValue::LinkageTypes llvm_linkage(LinkageType t) {
// A local helper to make an llvm value type representing
// alignment. Can't be declared in a header without introducing a
// dependence on the LLVM headers.
#if LLVM_VERSION >= 100
llvm::Align make_alignment(int a) {
return llvm::Align(a);
}
#else
int make_alignment(int a) {
return a;
}
#endif

} // namespace

Expand Down Expand Up @@ -4458,9 +4452,7 @@ void CodeGen_LLVM::codegen_vector_reduce(const VectorReduce *op, const Expr &ini
return;
}

#if LLVM_VERSION >= 90
if (output_lanes == 1 &&
(target.arch != Target::ARM || LLVM_VERSION >= 100)) {
if (output_lanes == 1) {
const int input_lanes = val.type().lanes();
const int input_bytes = input_lanes * val.type().bytes();
const bool llvm_has_intrinsic =
Expand Down Expand Up @@ -4572,7 +4564,6 @@ void CodeGen_LLVM::codegen_vector_reduce(const VectorReduce *op, const Expr &ini
return;
}
}
#endif

if (output_lanes == 1 &&
factor > native_lanes &&
Expand Down
37 changes: 0 additions & 37 deletions src/CodeGen_PTX_Dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,39 +279,6 @@ void CodeGen_PTX_Dev::visit(const Store *op) {
if (emit_atomic_stores) {
user_assert(is_one(op->predicate)) << "Atomic update does not support predicated store.\n";
user_assert(op->value.type().bits() >= 32) << "CUDA: 8-bit or 16-bit atomics are not supported.\n";
#if LLVM_VERSION < 90
user_assert(op->value.type().is_scalar())
<< "CUDA atomic update does not support vectorization with LLVM version < 9.\n";
// Generate nvvm intrinsics for the atomics if this is a float atomicAdd.
// Otherwise defer to the llvm codegen. For llvm version >= 90, atomicrmw support floats so we
// can also refer to llvm.
// Half atomics are supported by compute capability 7.x or higher.
if (op->value.type().is_float() &&
(op->value.type().bits() == 32 ||
(op->value.type().bits() == 64 &&
(target.get_cuda_capability_lower_bound() >= 61)))) {
Expr val_expr = op->value;
Expr equiv_load = Load::make(op->value.type(), op->name, op->index, Buffer<>(), op->param, op->predicate, op->alignment);
Expr delta = simplify(common_subexpression_elimination(op->value - equiv_load));
// For atomicAdd, we check if op->value - store[index] is independent of store.
bool is_atomic_add = !expr_uses_var(delta, op->name);
if (is_atomic_add) {
Value *ptr = codegen_buffer_pointer(op->name, op->value.type(), op->index);
Value *val = codegen(delta);
llvm::Function *intrin = nullptr;
if (op->value.type().bits() == 32) {
intrin = module->getFunction("llvm.nvvm.atomic.load.add.f32.p0f32");
internal_assert(intrin) << "Could not find atomic intrinsics llvm.nvvm.atomic.load.add.f32.p0f32\n";
} else {
internal_assert(op->value.type().bits() == 64);
intrin = module->getFunction("llvm.nvvm.atomic.load.add.f64.p0f64");
internal_assert(intrin) << "Could not find atomic intrinsics llvm.nvvm.atomic.load.add.f64.p0f64\n";
}
value = builder->CreateCall(intrin, {ptr, val});
return;
}
}
#endif
}

// Do aligned 4-wide 32-bit stores as a single i128 store.
Expand Down Expand Up @@ -655,11 +622,7 @@ vector<char> CodeGen_PTX_Dev::compile_to_src() {

// Ask the target to add backend passes as necessary.
bool fail = target_machine->addPassesToEmitFile(module_pass_manager, ostream, nullptr,
#if LLVM_VERSION >= 100
::llvm::CGFT_AssemblyFile,
#else
TargetMachine::CGFT_AssemblyFile,
#endif
true);
if (fail) {
internal_error << "Failed to set up passes to emit PTX source\n";
Expand Down
9 changes: 0 additions & 9 deletions src/Introspection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ inline T load_misaligned(const T *p) {
return result;
}

#if LLVM_VERSION >= 100
typedef uint64_t llvm_offset_t;
#else
typedef uint32_t llvm_offset_t;
#endif

} // namespace

Expand Down Expand Up @@ -963,14 +959,9 @@ class DebugSections {

for (llvm::object::section_iterator iter = obj->section_begin();
iter != obj->section_end(); ++iter) {
#if LLVM_VERSION >= 100
auto expected_name = iter->getName();
internal_assert(expected_name);
llvm::StringRef name = expected_name.get();
#else
llvm::StringRef name;
iter->getName(name);
#endif
debug(2) << "Section: " << name.str() << "\n";
// ignore errors, just leave strings empty
auto e = iter->getContents();
Expand Down
22 changes: 9 additions & 13 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 >= 90
#if LLVM_VERSION >= 100
// We're good to go
#else
#error "Compiling Halide requires LLVM 9.0 or newer"
#error "Compiling Halide requires LLVM 10.0 or newer"
#endif

// This seems to be required by some LLVM header, which is likely an LLVM bug.
Expand All @@ -29,25 +29,23 @@
#include <llvm/ExecutionEngine/MCJIT.h>
#include <llvm/ExecutionEngine/SectionMemoryManager.h>

#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ErrorHandling.h"
#include <llvm/ADT/StringMap.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <llvm/Bitcode/BitcodeReader.h>
#include <llvm/Bitcode/BitcodeWriter.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/IR/PassTimingInfo.h>
#include <llvm/IR/Verifier.h>
#include <llvm/Linker/Linker.h>
#include <llvm/Passes/PassBuilder.h>
#if LLVM_VERSION >= 100
#include <llvm/Support/CodeGen.h>
#endif
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include <llvm/ADT/StringMap.h>
#include <llvm/IR/PassTimingInfo.h>
#include <llvm/Object/ArchiveWriter.h>
#include <llvm/Object/ObjectFile.h>
#include <llvm/Passes/PassBuilder.h>
#include <llvm/Support/CodeGen.h>
#include <llvm/Support/DataExtractor.h>
#include <llvm/Support/DynamicLibrary.h>
#include <llvm/Support/FileSystem.h>
Expand Down Expand Up @@ -75,11 +73,9 @@
#include <llvm/IR/Function.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Intrinsics.h>
#if LLVM_VERSION >= 100
#ifdef WITH_HEXAGON
#include <llvm/IR/IntrinsicsHexagon.h>
#endif
#endif
#include <llvm/IR/MDBuilder.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Value.h>
Expand Down
15 changes: 1 addition & 14 deletions src/LLVM_Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,7 @@ std::unique_ptr<llvm::Module> clone_module(const llvm::Module &module_in) {
} // namespace

void emit_file(const llvm::Module &module_in, Internal::LLVMOStream &out,
#if LLVM_VERSION >= 100
llvm::CodeGenFileType file_type
#else
llvm::TargetMachine::CodeGenFileType file_type
#endif
) {
llvm::CodeGenFileType file_type) {
Internal::debug(1) << "emit_file.Compiling to native code...\n";
Internal::debug(2) << "Target triple: " << module_in.getTargetTriple() << "\n";

Expand Down Expand Up @@ -405,19 +400,11 @@ 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 >= 100
emit_file(module, out, llvm::CGFT_ObjectFile);
#else
emit_file(module, out, llvm::TargetMachine::CGFT_ObjectFile);
#endif
}

void compile_llvm_module_to_assembly(llvm::Module &module, Internal::LLVMOStream &out) {
#if LLVM_VERSION >= 100
emit_file(module, out, llvm::CGFT_AssemblyFile);
#else
emit_file(module, out, llvm::TargetMachine::CGFT_AssemblyFile);
#endif
}

void compile_llvm_module_to_llvm_bitcode(llvm::Module &module, Internal::LLVMOStream &out) {
Expand Down
Loading