summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/GHC/CmmToAsm.hs4
-rw-r--r--compiler/GHC/CmmToAsm/Config.hs1
-rw-r--r--compiler/GHC/Driver/Config/CmmToAsm.hs5
3 files changed, 8 insertions, 2 deletions
diff --git a/compiler/GHC/CmmToAsm.hs b/compiler/GHC/CmmToAsm.hs
index f28403e9b8..13b168db37 100644
--- a/compiler/GHC/CmmToAsm.hs
+++ b/compiler/GHC/CmmToAsm.hs
@@ -496,7 +496,7 @@ cmmNativeGen logger modLoc ncgImpl us fileIds dbgMap cmm count
-- tag instructions with register liveness information
-- also drops dead code. We don't keep the cfg in sync on
-- some backends, so don't use it there.
- let livenessCfg = if backendMaintainsCfg platform
+ let livenessCfg = if ncgEnableDeadCodeElimination config
then Just nativeCfgWeights
else Nothing
let (withLiveness, usLive) =
@@ -643,7 +643,7 @@ cmmNativeGen logger modLoc ncgImpl us fileIds dbgMap cmm count
let getBlks (CmmProc _info _lbl _live (ListGraph blocks)) = blocks
getBlks _ = []
- when ( backendMaintainsCfg platform &&
+ when ( ncgEnableDeadCodeElimination config &&
(ncgAsmLinting config || debugIsOn )) $ do
let blocks = concatMap getBlks shorted
let labels = setFromList $ fmap blockId blocks :: LabelSet
diff --git a/compiler/GHC/CmmToAsm/Config.hs b/compiler/GHC/CmmToAsm/Config.hs
index e981305845..ec4475ea14 100644
--- a/compiler/GHC/CmmToAsm/Config.hs
+++ b/compiler/GHC/CmmToAsm/Config.hs
@@ -45,6 +45,7 @@ data NCGConfig = NCGConfig
, ncgCmmStaticPred :: !Bool -- ^ Enable static control-flow prediction
, ncgEnableShortcutting :: !Bool -- ^ Enable shortcutting (don't jump to blocks only containing a jump)
, ncgComputeUnwinding :: !Bool -- ^ Compute block unwinding tables
+ , ncgEnableDeadCodeElimination :: !Bool -- ^ Whether to enable the dead-code elimination
}
-- | Return Word size
diff --git a/compiler/GHC/Driver/Config/CmmToAsm.hs b/compiler/GHC/Driver/Config/CmmToAsm.hs
index 91be35832a..3e075ee049 100644
--- a/compiler/GHC/Driver/Config/CmmToAsm.hs
+++ b/compiler/GHC/Driver/Config/CmmToAsm.hs
@@ -11,6 +11,7 @@ import GHC.Platform
import GHC.Unit.Types (Module)
import GHC.CmmToAsm.Config
import GHC.Utils.Outputable
+import GHC.CmmToAsm.BlockLayout
-- | Initialize the native code generator configuration from the DynFlags
initNCGConfig :: DynFlags -> Module -> NCGConfig
@@ -67,4 +68,8 @@ initNCGConfig dflags this_mod = NCGConfig
, ncgCmmStaticPred = gopt Opt_CmmStaticPred dflags
, ncgEnableShortcutting = gopt Opt_AsmShortcutting dflags
, ncgComputeUnwinding = debugLevel dflags > 0
+ , ncgEnableDeadCodeElimination = not (gopt Opt_InfoTableMap dflags)
+ -- Disable when -finfo-table-map is on (#20428)
+ && backendMaintainsCfg (targetPlatform dflags)
+ -- Enable if the platform maintains the CFG
}