From 8b64ffa814707c99abe1335ffd637a2a45a8f2fb Mon Sep 17 00:00:00 2001 From: JoJo Date: Tue, 12 May 2020 20:57:08 +0200 Subject: [PATCH] Better printing of verify exception --- carth.cabal | 1 + src/Compile.hs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/carth.cabal b/carth.cabal index 3b3a9e5..e155433 100644 --- a/carth.cabal +++ b/carth.cabal @@ -54,6 +54,7 @@ library , bytestring , containers , directory + , exceptions , filepath , llvm-hs , llvm-hs-pure diff --git a/src/Compile.hs b/src/Compile.hs index 075b29f..752cf1b 100644 --- a/src/Compile.hs +++ b/src/Compile.hs @@ -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 -- 2.38.5