summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergo ERDI <gergo@erdi.hu>2021-11-16 11:56:45 +0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-11-25 05:01:59 -0500
commitb52a9a3fa3caf6672fa8c04ac3bd1df353af44cf (patch)
tree816f32cdff86041aaae02d07dbeb639afb4017e9
parentbe0a9470ad76f7dc63e05a84215a2a4d0fd833fd (diff)
downloadhaskell-b52a9a3fa3caf6672fa8c04ac3bd1df353af44cf.tar.gz
Add `llvmOptLevel` to `DynFlags` (#20500)
-rw-r--r--compiler/GHC/Driver/Pipeline/Execute.hs8
-rw-r--r--compiler/GHC/Driver/Session.hs4
2 files changed, 7 insertions, 5 deletions
diff --git a/compiler/GHC/Driver/Pipeline/Execute.hs b/compiler/GHC/Driver/Pipeline/Execute.hs
index 08a63c0125..133f3005b2 100644
--- a/compiler/GHC/Driver/Pipeline/Execute.hs
+++ b/compiler/GHC/Driver/Pipeline/Execute.hs
@@ -216,7 +216,7 @@ runLlvmLlcPhase pipe_env hsc_env input_fn = do
--
let dflags = hsc_dflags hsc_env
logger = hsc_logger hsc_env
- llvmOpts = case optLevel dflags of
+ llvmOpts = case llvmOptLevel dflags of
0 -> "-O1" -- required to get the non-naive reg allocator. Passing -regalloc=greedy is not sufficient.
1 -> "-O1"
_ -> "-O2"
@@ -250,7 +250,7 @@ runLlvmOptPhase pipe_env hsc_env input_fn = do
logger = hsc_logger hsc_env
let -- we always (unless -optlo specified) run Opt since we rely on it to
-- fix up some pretty big deficiencies in the code we generate
- optIdx = max 0 $ min 2 $ optLevel dflags -- ensure we're in [0,2]
+ optIdx = max 0 $ min 2 $ llvmOptLevel dflags -- ensure we're in [0,2]
llvmOpts = case lookup optIdx $ llvmPasses $ llvmConfig dflags of
Just passes -> passes
Nothing -> panic ("runPhase LlvmOpt: llvm-passes file "
@@ -410,8 +410,8 @@ runCcPhase cc_phase pipe_env hsc_env input_fn = do
| otherwise
= []
- let cc_opt | optLevel dflags >= 2 = [ "-O2" ]
- | optLevel dflags >= 1 = [ "-O" ]
+ let cc_opt | llvmOptLevel dflags >= 2 = [ "-O2" ]
+ | llvmOptLevel dflags >= 1 = [ "-O" ]
| otherwise = []
-- Decide next phase
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index e4c86e94c9..2a4d5aae3c 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -447,6 +447,7 @@ data DynFlags = DynFlags {
llvmConfig :: LlvmConfig,
-- ^ N.B. It's important that this field is lazy since we load the LLVM
-- configuration lazily. See Note [LLVM Configuration] in "GHC.SysTools".
+ llvmOptLevel :: Int, -- ^ LLVM optimisation level
verbosity :: Int, -- ^ Verbosity level: see Note [Verbosity levels]
optLevel :: Int, -- ^ Optimisation level
debugLevel :: Int, -- ^ How much debug information to produce
@@ -1191,6 +1192,7 @@ defaultDynFlags mySettings llvmConfig =
-- See Note [LLVM configuration].
llvmConfig = llvmConfig,
+ llvmOptLevel = 0,
-- ghc -M values
depMakefile = "Makefile",
@@ -1779,7 +1781,7 @@ setInteractivePrint f d = d { interactivePrint = Just f}
updOptLevel :: Int -> DynFlags -> DynFlags
-- ^ Sets the 'DynFlags' to be appropriate to the optimisation level
updOptLevel n dfs
- = dfs2{ optLevel = final_n }
+ = dfs2{ optLevel = final_n, llvmOptLevel = final_n }
where
final_n = max 0 (min 2 n) -- Clamp to 0 <= n <= 2
dfs1 = foldr (flip gopt_unset) dfs remove_gopts