From 026dc74eba5566974a28a82ed77b7e3ea995830c Mon Sep 17 00:00:00 2001 From: Zentrik Date: Sun, 21 Apr 2024 23:45:55 +0100 Subject: [PATCH] Update CodeGenOpt to CodeGenOptLevel See https://github.com/llvm/llvm-project/pull/66295 --- src/aotcompile.cpp | 4 ++++ src/jitlayers.cpp | 14 ++++++++++++++ src/jitlayers.h | 5 +++++ 3 files changed, 23 insertions(+) diff --git a/src/aotcompile.cpp b/src/aotcompile.cpp index 9f372cbb5bf207..db56c1374bae3a 100644 --- a/src/aotcompile.cpp +++ b/src/aotcompile.cpp @@ -1634,7 +1634,11 @@ void jl_dump_native_impl(void *native_code, jl_ExecutionEngine->getTargetOptions(), RelocModel, CMModel, +#if JL_LLVM_VERSION >= 180000 + CodeGenOptLevel::Aggressive // -O3 TODO: respect command -O0 flag? +#else CodeGenOpt::Aggressive // -O3 TODO: respect command -O0 flag? +#endif )); fixupTM(*SourceTM); auto DL = jl_create_datalayout(*SourceTM); diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp index 8b9b7a1aa4b05a..db72f117730be8 100644 --- a/src/jitlayers.cpp +++ b/src/jitlayers.cpp @@ -607,6 +607,19 @@ jl_value_t *jl_dump_method_asm_impl(jl_method_instance_t *mi, size_t world, return jl_dump_function_asm(&llvmf_dump, emit_mc, asm_variant, debuginfo, binary, false); } +#if JL_LLVM_VERSION >= 180000 +CodeGenOptLevel CodeGenOptLevelFor(int optlevel) +{ +#ifdef DISABLE_OPT + return CodeGenOptLevel::None; +#else + return optlevel == 0 ? CodeGenOptLevel::None : + optlevel == 1 ? CodeGenOptLevel::Less : + optlevel == 2 ? CodeGenOptLevel::Default : + CodeGenOptLevel::Aggressive; +#endif +} +#else CodeGenOpt::Level CodeGenOptLevelFor(int optlevel) { #ifdef DISABLE_OPT @@ -618,6 +631,7 @@ CodeGenOpt::Level CodeGenOptLevelFor(int optlevel) CodeGenOpt::Aggressive; #endif } +#endif static auto countBasicBlocks(const Function &F) JL_NOTSAFEPOINT { diff --git a/src/jitlayers.h b/src/jitlayers.h index a849148653f07c..0be8c6ad993aff 100644 --- a/src/jitlayers.h +++ b/src/jitlayers.h @@ -26,6 +26,7 @@ #include "julia_internal.h" #include "platform.h" #include "llvm-codegen-shared.h" +#include "llvm-version.h" #include #include @@ -642,4 +643,8 @@ void optimizeDLSyms(Module &M); // NewPM #include "passes.h" +#if JL_LLVM_VERSION >= 180000 +CodeGenOptLevel CodeGenOptLevelFor(int optlevel) JL_NOTSAFEPOINT; +#else CodeGenOpt::Level CodeGenOptLevelFor(int optlevel) JL_NOTSAFEPOINT; +#endif