diff options
Diffstat (limited to 'compiler/GHC')
-rw-r--r-- | compiler/GHC/CmmToLlvm.hs | 11 | ||||
-rw-r--r-- | compiler/GHC/CmmToLlvm/Base.hs | 12 | ||||
-rw-r--r-- | compiler/GHC/SysTools/Tasks.hs | 8 |
3 files changed, 22 insertions, 9 deletions
diff --git a/compiler/GHC/CmmToLlvm.hs b/compiler/GHC/CmmToLlvm.hs index 21cfdf6dcd..95b682af38 100644 --- a/compiler/GHC/CmmToLlvm.hs +++ b/compiler/GHC/CmmToLlvm.hs @@ -66,7 +66,8 @@ llvmCodeGen logger dflags h cmm_stream let doWarn = wopt Opt_WarnUnsupportedLlvmVersion dflags when (not (llvmVersionSupported ver) && doWarn) $ putMsg logger dflags $ "You are using an unsupported version of LLVM!" $$ - "Currently only " <> text (llvmVersionStr supportedLlvmVersion) <> " is supported." <+> + "Currently only" <+> text (llvmVersionStr supportedLlvmVersionMin) <+> + "to" <+> text (llvmVersionStr supportedLlvmVersionMax) <+> "is supported." <+> "System LLVM version: " <> text (llvmVersionStr ver) $$ "We will try though..." let isS390X = platformArch (targetPlatform dflags) == ArchS390X @@ -75,8 +76,14 @@ llvmCodeGen logger dflags h cmm_stream "Warning: For s390x the GHC calling convention is only supported since LLVM version 10." <+> "You are using LLVM version: " <> text (llvmVersionStr ver) + -- HACK: the Nothing case here is potentially wrong here but we + -- currently don't use the LLVM version to guide code generation + -- so this is okay. + let llvm_ver :: LlvmVersion + llvm_ver = fromMaybe supportedLlvmVersionMin mb_ver + -- run code generation - a <- runLlvm logger dflags (fromMaybe supportedLlvmVersion mb_ver) bufh $ + a <- runLlvm logger dflags llvm_ver bufh $ llvmCodeGen' dflags cmm_stream bFlush bufh diff --git a/compiler/GHC/CmmToLlvm/Base.hs b/compiler/GHC/CmmToLlvm/Base.hs index a943bfcebb..eda29c1ec7 100644 --- a/compiler/GHC/CmmToLlvm/Base.hs +++ b/compiler/GHC/CmmToLlvm/Base.hs @@ -15,7 +15,8 @@ module GHC.CmmToLlvm.Base ( LiveGlobalRegs, LlvmUnresData, LlvmData, UnresLabel, UnresStatic, - LlvmVersion, supportedLlvmVersion, llvmVersionSupported, parseLlvmVersion, + LlvmVersion, supportedLlvmVersionMin, supportedLlvmVersionMax, + llvmVersionSupported, parseLlvmVersion, llvmVersionStr, llvmVersionList, LlvmM, @@ -265,6 +266,7 @@ llvmPtrBits platform = widthInBits $ typeWidth $ gcWord platform -- Newtype to avoid using the Eq instance! newtype LlvmVersion = LlvmVersion { llvmVersionNE :: NE.NonEmpty Int } + deriving (Eq, Ord) parseLlvmVersion :: String -> Maybe LlvmVersion parseLlvmVersion = @@ -281,11 +283,13 @@ parseLlvmVersion = (ver_str, rest) = span isDigit s -- | The LLVM Version that is currently supported. -supportedLlvmVersion :: LlvmVersion -supportedLlvmVersion = LlvmVersion (sUPPORTED_LLVM_VERSION NE.:| []) +supportedLlvmVersionMin, supportedLlvmVersionMax :: LlvmVersion +supportedLlvmVersionMin = LlvmVersion (sUPPORTED_LLVM_VERSION_MIN NE.:| []) +supportedLlvmVersionMax = LlvmVersion (sUPPORTED_LLVM_VERSION_MAX NE.:| []) llvmVersionSupported :: LlvmVersion -> Bool -llvmVersionSupported (LlvmVersion v) = NE.head v == sUPPORTED_LLVM_VERSION +llvmVersionSupported v = + v > supportedLlvmVersionMin && v <= supportedLlvmVersionMax llvmVersionStr :: LlvmVersion -> String llvmVersionStr = intercalate "." . map show . llvmVersionList diff --git a/compiler/GHC/SysTools/Tasks.hs b/compiler/GHC/SysTools/Tasks.hs index 694d3155c1..0fb74233fc 100644 --- a/compiler/GHC/SysTools/Tasks.hs +++ b/compiler/GHC/SysTools/Tasks.hs @@ -13,7 +13,7 @@ import GHC.Prelude import GHC.Platform import GHC.ForeignSrcLang -import GHC.CmmToLlvm.Base (LlvmVersion, llvmVersionStr, supportedLlvmVersion, parseLlvmVersion) +import GHC.CmmToLlvm.Base (LlvmVersion, llvmVersionStr, supportedLlvmVersionMin, supportedLlvmVersionMax, llvmVersionStr, parseLlvmVersion) import GHC.SysTools.Process import GHC.SysTools.Info @@ -234,8 +234,10 @@ figureLlvmVersion logger dflags = traceToolCommand logger dflags "llc" $ do errorMsg logger dflags $ vcat [ text "Warning:", nest 9 $ text "Couldn't figure out LLVM version!" $$ - text ("Make sure you have installed LLVM " ++ - llvmVersionStr supportedLlvmVersion) ] + text ("Make sure you have installed LLVM between " + ++ llvmVersionStr supportedLlvmVersionMin + ++ " and " + ++ llvmVersionStr supportedLlvmVersionMax) ] return Nothing) |