Commit 87837181 authored by dterei's avatar dterei

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

parent 7bbc1b05
......@@ -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" #-}
......
......@@ -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
......
......@@ -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 ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment