Skip to content

Commit

Permalink
Drop support for LLVM 14
Browse files Browse the repository at this point in the history
Mainly because opaque IR pointers appear buggy in LLVM 14 (LLVM
crashes when compiling druntime).
  • Loading branch information
kinke committed May 19, 2024
1 parent 3067b7b commit 2cd14c5
Show file tree
Hide file tree
Showing 30 changed files with 18 additions and 8,934 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
environment:
- PARALLELISM: 4
- CI_OS: linux
- LLVM_MAJOR: 14
- LLVM_MAJOR: 15
- HOST_LDC_VERSION: 1.24.0
- EXTRA_CMAKE_FLAGS: "-DMULTILIB=ON -DRT_SUPPORT_SANITIZERS=ON -DBUILD_LTO_LIBS=ON"
Ubuntu-20.04-sharedLibsOnly-gdmd:
Expand All @@ -116,7 +116,7 @@ jobs:
environment:
- PARALLELISM: 4
- CI_OS: linux
- LLVM_MAJOR: 14
- LLVM_MAJOR: 15
- EXTRA_APT_PACKAGES: gdmd
- EXTRA_CMAKE_FLAGS: "-DBUILD_SHARED_LIBS=ON -DBUILD_LTO_LIBS=ON -DD_COMPILER=gdmd -DLDC_LINK_MANUALLY=ON"

Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/supported_llvm_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ jobs:
host_dc: dmd-beta
llvm_version: 15.0.6
cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DLIB_SUFFIX=64 -DLDC_LINK_MANUALLY=ON
- job_name: macOS 11, LLVM 14, latest DMD beta
os: macos-11
host_dc: dmd-beta
llvm_version: 14.0.6
cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DLDC_LINK_MANUALLY=ON -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/cc
name: ${{ matrix.job_name }}
runs-on: ${{ matrix.os }}
env:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#### Big news

#### Platform support
- Supports LLVM 14 - 18. Support for LLVM 11, 12 and 13 was dropped.
- Supports LLVM 15 - 18. Support for LLVM 11 - 14 was dropped. The CLI options `-passmanager` and `-opaque-pointers` were removed.

#### Bug fixes

Expand Down
11 changes: 3 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ endfunction()
# Locate LLVM.
#

find_package(LLVM 14.0 REQUIRED
find_package(LLVM 15.0 REQUIRED
all-targets analysis asmparser asmprinter bitreader bitwriter codegen core
debuginfodwarf debuginfomsf debuginfopdb demangle
instcombine ipo instrumentation irreader libdriver linker lto mc
Expand Down Expand Up @@ -823,13 +823,8 @@ if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
copy_compilerrt_lib("darwin/libclang_rt.xray-fdr_osx.a" "libldc_rt.xray-fdr.a" FALSE)
copy_compilerrt_lib("darwin/libclang_rt.xray-profiling_osx.a" "libldc_rt.xray-profiling.a" FALSE)
elseif(UNIX)
if(LDC_LLVM_VER LESS 1500)
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_OS_DEFAULT "linux")
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH_DEFAULT "x86_64")
else()
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_OS_DEFAULT "x86_64-unknown-linux-gnu")
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH_DEFAULT "")
endif()
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_OS_DEFAULT "x86_64-unknown-linux-gnu")
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH_DEFAULT "")
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_OS "${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS_DEFAULT}" CACHE STRING "Non-Mac Posix: OS used as directory name for the compiler-rt source libraries, e.g., 'freebsd'.")
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH "${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH_DEFAULT}" CACHE STRING "Non-Mac Posix: architecture used as libname suffix for the compiler-rt source libraries, e.g., 'aarch64'.")
if(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH STREQUAL "")
Expand Down
5 changes: 1 addition & 4 deletions cmake/Modules/FindLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ set(llvm_config_names llvm-config-18.1 llvm-config181 llvm-config-18
llvm-config-17.0 llvm-config170 llvm-config-17
llvm-config-16.0 llvm-config160 llvm-config-16
llvm-config-15.0 llvm-config150 llvm-config-15
llvm-config-14.0 llvm-config140 llvm-config-14
llvm-config)
find_program(LLVM_CONFIG
NAMES ${llvm_config_names}
Expand All @@ -49,12 +48,10 @@ if(APPLE)
NAMES ${llvm_config_names}
PATHS /opt/local/libexec/llvm-18/bin /opt/local/libexec/llvm-17/bin
/opt/local/libexec/llvm-16/bin /opt/local/libexec/llvm-15/bin
/opt/local/libexec/llvm-14/bin /opt/local/libexec/llvm-13/bin
/opt/local/libexec/llvm-12/bin /opt/local/libexec/llvm-11/bin
/opt/local/libexec/llvm/bin
/usr/local/opt/llvm@18/bin /usr/local/opt/llvm@17/bin
/usr/local/opt/llvm@16/bin /usr/local/opt/llvm@15/bin
/usr/local/opt/llvm@14/bin /usr/local/opt/llvm/bin
/usr/local/opt/llvm/bin
NO_DEFAULT_PATH)
endif()

Expand Down
4 changes: 1 addition & 3 deletions driver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,8 @@ void parseCommandLine(Strings &sourceFiles) {
// enforce opaque IR pointers
#if LDC_LLVM_VER >= 1700
// supports opaque IR pointers only
#elif LDC_LLVM_VER >= 1500
#else
getGlobalContext().setOpaquePointers(true);
#else // LLVM 14
getGlobalContext().enableOpaquePointers();
#endif
}

Expand Down
8 changes: 1 addition & 7 deletions gen/abi/x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,7 @@ struct X86TargetABI : TargetABI {
// Keep alignment for LLVM 13+, to prevent invalid `movaps` etc.,
// but limit to 4 (required according to runnable/ldc_cabi1.d).
auto align4 = llvm::Align(4);
if (arg->attrs.getAlignment().
#if LDC_LLVM_VER >= 1500
value_or
#else
getValueOr
#endif
(align4) > align4)
if (arg->attrs.getAlignment().value_or(align4) > align4)
arg->attrs.addAlignmentAttr(align4);
}
}
Expand Down
4 changes: 0 additions & 4 deletions gen/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1139,11 +1139,7 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {

// function attributes
if (gABI->needsUnwindTables()) {
#if LDC_LLVM_VER >= 1500
func->setUWTableKind(llvm::UWTableKind::Default);
#else
func->addFnAttr(LLAttribute::UWTable);
#endif
}
if (opts::isAnySanitizerEnabled() &&
!opts::functionIsInSanitizerBlacklist(fd)) {
Expand Down
8 changes: 0 additions & 8 deletions gen/modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,7 @@ void addCoverageAnalysis(Module *m) {
ctor->setCallingConv(gABI->callingConv(LINK::d));
// Set function attributes. See functions.cpp:DtoDefineFunction()
if (global.params.targetTriple->getArch() == llvm::Triple::x86_64) {
#if LDC_LLVM_VER >= 1500
ctor->setUWTableKind(llvm::UWTableKind::Default);
#else
ctor->addFnAttr(LLAttribute::UWTable);
#endif
}

llvm::BasicBlock *bb = llvm::BasicBlock::Create(gIR->context(), "", ctor);
Expand Down Expand Up @@ -404,11 +400,7 @@ void registerModuleInfo(Module *m) {
}

void addModuleFlags(llvm::Module &m) {
#if LDC_LLVM_VER >= 1500
const auto ModuleMinFlag = llvm::Module::Min;
#else
const auto ModuleMinFlag = llvm::Module::Warning; // Fallback value
#endif

if (opts::fCFProtection == opts::CFProtectionType::Return ||
opts::fCFProtection == opts::CFProtectionType::Full) {
Expand Down
9 changes: 0 additions & 9 deletions gen/naked.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,20 +507,11 @@ llvm::CallInst *DtoInlineAsmExpr(const Loc &loc, llvm::StringRef code,
llvm::FunctionType *FT =
llvm::FunctionType::get(returnType, operandTypes, false);

#if LDC_LLVM_VER < 1500
// make sure the constraints are valid
if (!llvm::InlineAsm::Verify(FT, constraints)) {
error(loc, "inline asm constraints are invalid");
fatal();
}
#else
if (auto err = llvm::InlineAsm::verify(FT, constraints)) {
error(loc, "inline asm constraints are invalid");
llvm::errs() << err;
fatal();
}
#endif


// build asm call
bool sideeffect = true;
Expand Down
4 changes: 0 additions & 4 deletions gen/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,7 @@ struct LazyFunctionDeclarer {
// FIXME: Move to better place (abi-x86-64.cpp?)
// NOTE: There are several occurances if this line.
if (global.params.targetTriple->getArch() == llvm::Triple::x86_64) {
#if LDC_LLVM_VER >= 1500
fn->setUWTableKind(llvm::UWTableKind::Default);
#else
fn->addFnAttr(LLAttribute::UWTable);
#endif
}

fn->setCallingConv(gABI->callingConv(dty, false));
Expand Down
3 changes: 1 addition & 2 deletions runtime/druntime/src/ldc/intrinsics.di
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ else
static assert(false, "This module is only valid for LDC");
}

version (LDC_LLVM_1400) enum LLVM_version = 1400;
else version (LDC_LLVM_1500) enum LLVM_version = 1500;
version (LDC_LLVM_1500) enum LLVM_version = 1500;
else version (LDC_LLVM_1600) enum LLVM_version = 1600;
else version (LDC_LLVM_1700) enum LLVM_version = 1700;
else version (LDC_LLVM_1800) enum LLVM_version = 1800;
Expand Down
2 changes: 0 additions & 2 deletions tests/PGO/sample_based.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Test basic use of sample-based PGO profile

// REQUIRES: atleast_llvm1500

// RUN: split-file %s %t
// RUN: %ldc -O2 -c -gline-tables-only -output-ll -of=%t.ll -fprofile-sample-use=%t/pgo-sample.prof %t/testcase.d && FileCheck %s < %t.ll

Expand Down
20 changes: 8 additions & 12 deletions tests/codegen/gh3692.d
Original file line number Diff line number Diff line change
@@ -1,48 +1,44 @@
// https://github.com/ldc-developers/ldc/issues/3692

// REQUIRES: target_X86
// REQUIRES: atmost_llvm1409
// RUN: %ldc -mtriple=x86_64-linux-gnu -output-ll -of=%t.ll %s
// RUN: FileCheck %s < %t.ll


// D `int[3]` rewritten to LL `{ i64, i32 }` for SysV ABI - mismatching size and alignment
// CHECK: define void @_D6gh36924takeFG3iZv({ i64, i32 } %a_arg)
// CHECK-LABEL: define void @_D6gh36924takeFG3iZv({ i64, i32 } %a_arg)
void take(int[3] a)
{
// the `{ i64, i32 }` size is 16 bytes, so we need a padded alloca (with 8-bytes alignment)
// CHECK-NEXT: %.BaseBitcastABIRewrite_param_storage = alloca { i64, i32 }, align 8
// CHECK-NEXT: store { i64, i32 } %a_arg, { i64, i32 }* %.BaseBitcastABIRewrite_param_storage
// CHECK-NEXT: %a = bitcast { i64, i32 }* %.BaseBitcastABIRewrite_param_storage to [3 x i32]*
// CHECK-NEXT: = alloca { i64, i32 }, align 8
}

// CHECK: define void @_D6gh36924passFZv()
// CHECK-LABEL: define void @_D6gh36924passFZv()
void pass()
{
// CHECK-NEXT: %arrayliteral = alloca [3 x i32], align 4
// we need an extra padded alloca with proper alignment
// CHECK-NEXT: %.BaseBitcastABIRewrite_padded_arg_storage = alloca { i64, i32 }, align 8
// CHECK: %.BaseBitcastABIRewrite_arg = load { i64, i32 }, { i64, i32 }* %.BaseBitcastABIRewrite_padded_arg_storage
// CHECK: %.BaseBitcastABIRewrite_arg = load { i64, i32 }, {{\{ i64, i32 \}\*|ptr}} %.BaseBitcastABIRewrite_padded_arg_storage
take([1, 2, 3]);
}


// D `int[4]` rewritten to LL `{ i64, i64 }` for SysV ABI - mismatching alignment only
// CHECK: define void @_D6gh36925take4FG4iZv({ i64, i64 } %a_arg)
// CHECK-LABEL: define void @_D6gh36925take4FG4iZv({ i64, i64 } %a_arg)
void take4(int[4] a)
{
// the alloca should have 8-bytes alignment, even though a.alignof == 4
// CHECK-NEXT: %a = alloca [4 x i32], align 8
// CHECK-NEXT: %1 = bitcast [4 x i32]* %a to { i64, i64 }*
// CHECK-NEXT: store { i64, i64 } %a_arg, { i64, i64 }* %1
// CHECK: store { i64, i64 } %a_arg, {{\{ i64, i64 \}\*|ptr}} %
}

// CHECK: define void @_D6gh36925pass4FZv()
// CHECK-LABEL: define void @_D6gh36925pass4FZv()
void pass4()
{
// CHECK-NEXT: %arrayliteral = alloca [4 x i32], align 4
// we need an extra alloca with 8-bytes alignment
// CHECK-NEXT: %.BaseBitcastABIRewrite_padded_arg_storage = alloca { i64, i64 }, align 8
// CHECK: %.BaseBitcastABIRewrite_arg = load { i64, i64 }, { i64, i64 }* %.BaseBitcastABIRewrite_padded_arg_storage
// CHECK: %.BaseBitcastABIRewrite_arg = load { i64, i64 }, {{\{ i64, i64 \}\*|ptr}} %.BaseBitcastABIRewrite_padded_arg_storage
take4([1, 2, 3, 4]);
}
45 changes: 0 additions & 45 deletions tests/codegen/gh3692_llvm15.d

This file was deleted.

Loading

0 comments on commit 2cd14c5

Please sign in to comment.