From c88f4e275af866737491290ccb10d9088c0428ff Mon Sep 17 00:00:00 2001 From: Sacha Verweij Date: Wed, 1 May 2024 21:02:31 -0700 Subject: [PATCH] Pass CodeGenOpt::Less to LLVM at O1 (rather than CodeGenOpt::None). (#37893) For context, please see https://github.com/JuliaLang/julia/pull/35086#issuecomment-700944522. Regarding alignment with clang, please see https://reviews.llvm.org/D28409 (/https://github.com/JuliaLang/julia/pull/35086#issuecomment-598282810). ``` Prior to Julia 1.5, Julia passed CodeGenOpt::Aggressive to LLVM at -O1. As of Julia 1.5, Julia passes CodeGenOpt::None to LLVM at -O1. This reduction in optimization effort at -O1 improved compilation latency, but induced appreciable runtime regressions. This commit makes Julia pass CodeGenOpt::Less to LLVM at -O1, mitigating the runtime regressions caused by CodeGenOpt::None, while retaining most of CodeGenOpt::None's latency improvements. This commit also aligns Julia's CodeGenOpt selection at -O1 with that of clang. ``` Best! :) --- src/jitlayers.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp index 0b47dfca507d2..ea21477c8f56c 100644 --- a/src/jitlayers.cpp +++ b/src/jitlayers.cpp @@ -608,7 +608,8 @@ CodeGenOpt::Level CodeGenOptLevelFor(int optlevel) #ifdef DISABLE_OPT return CodeGenOpt::None; #else - return optlevel < 2 ? CodeGenOpt::None : + return optlevel == 0 ? CodeGenOpt::None : + optlevel == 1 ? CodeGenOpt::Less : optlevel == 2 ? CodeGenOpt::Default : CodeGenOpt::Aggressive; #endif