~jojo/Carth

8b64ffa814707c99abe1335ffd637a2a45a8f2fb — JoJo 1 year, 6 months ago cbb5eac
Better printing of verify exception
2 files changed, 7 insertions(+), 1 deletions(-)

M carth.cabal
M src/Compile.hs
M carth.cabal => carth.cabal +1 -0
@@ 54,6 54,7 @@ library
    , bytestring
    , containers
    , directory
    , exceptions
    , filepath
    , llvm-hs
    , llvm-hs-pure

M src/Compile.hs => src/Compile.hs +6 -1
@@ 11,10 11,12 @@ import LLVM.OrcJIT
import LLVM.OrcJIT.CompileLayer as CL
import LLVM.Linking
import LLVM.PassManager
import LLVM.Exception
import qualified LLVM.Relocation as Reloc
import qualified LLVM.CodeModel as CodeModel
import qualified LLVM.CodeGenOpt as CodeGenOpt
import Control.Monad
import Control.Monad.Catch
import System.FilePath
import System.Process
import System.Exit


@@ 26,6 28,7 @@ import qualified Data.Map as Map
import Foreign.Ptr
import Prelude hiding (mod)

import Misc
import Conf
import qualified Monomorphic
import Codegen


@@ 62,7 65,9 @@ handleProgram f file cfg pgm = withContext $ \ctx ->
            withModuleFromAST ctx amod $ \mod -> do
                verbose cfg ("   Verifying LLVM")
                when (getDebug cfg) $ writeLLVMAssemblyToFile' ".dbg.ll" mod
                verify mod
                catch (verify mod) $ \case
                    VerifyException msg ->
                        ice $ "LLVM verification exception:\n" ++ msg
                withPassManager (optPasses optLvl tm) $ \passman -> do
                    verbose cfg "   Optimizing"
                    _ <- runPassManager passman mod