llvm-general-3.3.13.1: src/LLVM/General/Internal/Analysis.hs
module LLVM.General.Internal.Analysis where
import Control.Monad.Except
import Control.Monad.AnyCont
import qualified LLVM.General.Internal.FFI.Analysis as FFI
import qualified LLVM.General.Internal.FFI.LLVMCTypes as FFI
import LLVM.General.Internal.Module
import LLVM.General.Internal.Coding
-- | Run basic sanity checks on a 'Module'. Note that the same checks will trigger assertions
-- within LLVM if LLVM was built with them turned on, before this function can be is called.
verify :: Module -> ExceptT String IO ()
verify (Module m) = flip runAnyContT return $ do
errorPtr <- alloca
result <- decodeM =<< (liftIO $ FFI.verifyModule m FFI.verifierFailureActionReturnStatus errorPtr)
when result $ throwError =<< decodeM errorPtr