Skip to content

Add preliminary support for LLVM 19 #4763

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

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ install_ubuntu_prerequisites_template: &INSTALL_UBUNTU_PREREQUISITES_TEMPLATE
environment:
CIRRUS_CLONE_DEPTH: 50
HOST_LDC_VERSION: 1.31.0
LLVM_VERSION: 18.1.8
LLVM_VERSION: a97cd9fa
GITHUB_TOKEN: ENCRYPTED[0955bd48c8d4e5391446fc0149d0719ad0b63df27ec9e6c180a5730a5b10dc7f28f09d1383423db158d21380ee2b022a]

task:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:

env:
CLANG_VERSION: 15.0.6
LLVM_VERSION: 18.1.8
LLVM_VERSION: a97cd9fa

jobs:
build-native:
Expand Down
12 changes: 5 additions & 7 deletions cmake/Modules/FindLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
# We also want an user-specified LLVM_ROOT_DIR to take precedence over the
# system default locations such as /usr/local/bin. Executing find_program()
# multiples times is the approach recommended in the docs.
set(llvm_config_names llvm-config-18.1 llvm-config181 llvm-config-18
set(llvm_config_names llvm-config-19.1 llvm-config191 llvm-config-19
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
Expand All @@ -46,9 +47,11 @@ if(APPLE)
# extra fallbacks for MacPorts & Homebrew
find_program(LLVM_CONFIG
NAMES ${llvm_config_names}
PATHS /opt/local/libexec/llvm-18/bin /opt/local/libexec/llvm-17/bin
PATHS /opt/local/libexec/llvm-19/bin
/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/bin
/usr/local/opt/llvm@19/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/bin
Expand Down Expand Up @@ -138,11 +141,6 @@ else()
string(REPLACE "-llibxml2.tbd" "-lxml2" LLVM_LDFLAGS ${LLVM_LDFLAGS})
endif()

if(${LLVM_VERSION_MAJOR} LESS "15")
# Versions below 15.0 do not support component windowsdriver
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "windowsdriver")
endif()

llvm_set(LIBRARY_DIRS libdir true)
llvm_set_libs(LIBRARIES libs "${LLVM_FIND_COMPONENTS}")
# LLVM bug: llvm-config --libs tablegen returns -lLLVM-3.8.0
Expand Down
6 changes: 5 additions & 1 deletion gen/dibuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,11 @@ void DIBuilder::EmitValue(llvm::Value *val, VarDeclaration *vd) {

llvm::Instruction *instr = DBuilder.insertDbgValueIntrinsic(
val, debugVariable, DBuilder.createExpression(),
IR->ir->getCurrentDebugLocation(), IR->scopebb());
IR->ir->getCurrentDebugLocation(), IR->scopebb())
#if LDC_LLVM_VER >= 1901
.dyn_cast<llvm::Instruction *>()
#endif
;
instr->setDebugLoc(IR->ir->getCurrentDebugLocation());
}

Expand Down
9 changes: 9 additions & 0 deletions gen/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ static llvm::Optional<PGOOptions> getPGOOptions() {
"" /*MemoryProfileUsePath*/, llvm::vfs::getRealFileSystem(),
#endif
PGOOptions::PGOAction::IRInstr, PGOOptions::CSPGOAction::NoCSAction,
#if LDC_LLVM_VER >= 1901
PGOOptions::ColdFuncOpt::Default,
#endif
debugInfoForProfiling, pseudoProbeForProfiling);
} else if (opts::isUsingIRBasedPGOProfile()) {
return PGOOptions(
Expand All @@ -316,6 +319,9 @@ static llvm::Optional<PGOOptions> getPGOOptions() {
"" /*MemoryProfileUsePath*/, llvm::vfs::getRealFileSystem(),
#endif
PGOOptions::PGOAction::IRUse, PGOOptions::CSPGOAction::NoCSAction,
#if LDC_LLVM_VER >= 1901
PGOOptions::ColdFuncOpt::Default,
#endif
debugInfoForProfiling, pseudoProbeForProfiling);
} else if (opts::isUsingSampleBasedPGOProfile()) {
return PGOOptions(
Expand All @@ -324,6 +330,9 @@ static llvm::Optional<PGOOptions> getPGOOptions() {
"" /*MemoryProfileUsePath*/, llvm::vfs::getRealFileSystem(),
#endif
PGOOptions::PGOAction::SampleUse, PGOOptions::CSPGOAction::NoCSAction,
#if LDC_LLVM_VER >= 1901
PGOOptions::ColdFuncOpt::Default,
#endif
debugInfoForProfiling, pseudoProbeForProfiling);
}
#if LDC_LLVM_VER < 1600
Expand Down
2 changes: 2 additions & 0 deletions runtime/druntime/src/ldc/intrinsics.di
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ 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;
else version (LDC_LLVM_1801) enum LLVM_version = 1801;
else version (LDC_LLVM_1901) enum LLVM_version = 1901;
else version (LDC_LLVM_2000) enum LLVM_version = 2000;
else static assert(false, "LDC LLVM version not supported");

enum LLVM_atleast(int major) = (LLVM_version >= major * 100);
Expand Down
2 changes: 1 addition & 1 deletion tests/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ config.available_features.add("llvm%d" % config.llvm_version)
# config.llvm_version: 309, 400, 500, ...
# plusoneable_llvmversion: 39, 40, 50, ...
plusoneable_llvmversion = config.llvm_version // 10 + config.llvm_version%10
for version in range(140, plusoneable_llvmversion+1):
for version in range(150, plusoneable_llvmversion+1):
config.available_features.add("atleast_llvm%d0%d" % (version//10, version%10))
for version in range(plusoneable_llvmversion, 201):
config.available_features.add("atmost_llvm%d0%d" % (version//10, version%10))
Expand Down
Loading
Loading