Skip to content
Browse files

Only use TBAA when LLVM > 2.8. (#5782)

  • Loading branch information...
1 parent 7bbc1b0 commit 878371810de61632d58962608fb3db588d9c2fbd David Terei committed
Showing with 25 additions and 11 deletions.
  1. +4 −1 compiler/llvmGen/LlvmCodeGen.hs
  2. +8 −2 compiler/main/DriverPipeline.hs
  3. +13 −8 compiler/main/DynFlags.hs
View
5 compiler/llvmGen/LlvmCodeGen.hs
@@ -27,6 +27,7 @@ import UniqSupply
import Util
import SysTools ( figureLlvmVersion )
+import Data.IORef ( writeIORef )
import Data.Maybe ( fromMaybe )
import System.IO
@@ -47,10 +48,12 @@ llvmCodeGen dflags h us cmms
in (d,env')
in do
showPass dflags "LlVM CodeGen"
- bufh <- newBufHandle h
dumpIfSet_dyn dflags Opt_D_dump_llvm "LLVM Code" $ docToSDoc pprLlvmHeader
+ bufh <- newBufHandle h
Prt.bufLeftRender bufh $ pprLlvmHeader
ver <- (fromMaybe defaultLlvmVersion) `fmap` figureLlvmVersion dflags
+ -- cache llvm version for later use
+ writeIORef (llvmVersion dflags) ver
env' <- {-# SCC "llvm_datas_gen" #-}
cmmDataLlvmGens dflags bufh (setLlvmVer ver env) cdata []
{-# SCC "llvm_procs_gen" #-}
View
10 compiler/main/DriverPipeline.hs
@@ -1306,6 +1306,8 @@ runPhase SplitAs _input_fn dflags
runPhase LlvmOpt input_fn dflags
= do
+ ver <- io $ readIORef (llvmVersion dflags)
+
let lo_opts = getOpts dflags opt_lo
opt_lvl = max 0 (min 2 $ optLevel dflags)
-- don't specify anything if user has specified commands. We do this
@@ -1315,7 +1317,8 @@ runPhase LlvmOpt input_fn dflags
optFlag = if null lo_opts
then [SysTools.Option (llvmOpts !! opt_lvl)]
else []
- tbaa | dopt Opt_LlvmTBAA dflags = "--enable-tbaa=true"
+ tbaa | ver < 29 = "" -- no tbaa in 2.8 and earlier
+ | dopt Opt_LlvmTBAA dflags = "--enable-tbaa=true"
| otherwise = "--enable-tbaa=false"
@@ -1340,12 +1343,15 @@ runPhase LlvmOpt input_fn dflags
runPhase LlvmLlc input_fn dflags
= do
+ ver <- io $ readIORef (llvmVersion dflags)
+
let lc_opts = getOpts dflags opt_lc
opt_lvl = max 0 (min 2 $ optLevel dflags)
rmodel | opt_PIC = "pic"
| not opt_Static = "dynamic-no-pic"
| otherwise = "static"
- tbaa | dopt Opt_LlvmTBAA dflags = "--enable-tbaa=true"
+ tbaa | ver < 29 = "" -- no tbaa in 2.8 and earlier
+ | dopt Opt_LlvmTBAA dflags = "--enable-tbaa=true"
| otherwise = "--enable-tbaa=false"
-- hidden debugging flag '-dno-llvm-mangler' to skip mangling
View
21 compiler/main/DynFlags.hs
@@ -588,7 +588,9 @@ data DynFlags = DynFlags {
haddockOptions :: Maybe String,
-- | what kind of {-# SCC #-} to add automatically
- profAuto :: ProfAuto
+ profAuto :: ProfAuto,
+
+ llvmVersion :: IORef (Int)
}
class HasDynFlags m where
@@ -824,13 +826,15 @@ initDynFlags dflags = do
refFilesToClean <- newIORef []
refDirsToClean <- newIORef Map.empty
refGeneratedDumps <- newIORef Set.empty
+ refLlvmVersion <- newIORef 28
return dflags{
- ways = ways,
- buildTag = mkBuildTag (filter (not . wayRTSOnly) ways),
- rtsBuildTag = mkBuildTag ways,
- filesToClean = refFilesToClean,
- dirsToClean = refDirsToClean,
- generatedDumps = refGeneratedDumps
+ ways = ways,
+ buildTag = mkBuildTag (filter (not . wayRTSOnly) ways),
+ rtsBuildTag = mkBuildTag ways,
+ filesToClean = refFilesToClean,
+ dirsToClean = refDirsToClean,
+ generatedDumps = refGeneratedDumps,
+ llvmVersion = refLlvmVersion
}
-- | The normal 'DynFlags'. Note that they is not suitable for use in this form
@@ -922,7 +926,8 @@ defaultDynFlags mySettings =
extensions = [],
extensionFlags = flattenExtensionFlags Nothing [],
log_action = defaultLogAction,
- profAuto = NoProfAuto
+ profAuto = NoProfAuto,
+ llvmVersion = panic "defaultDynFlags: No llvmVersion"
}
type LogAction = Severity -> SrcSpan -> PprStyle -> MsgDoc -> IO ()

0 comments on commit 8783718

Please sign in to comment.
Something went wrong with that request. Please try again.