@@ -33,7 +33,7 @@ import Data.Data (Data)
33
33
import Data.HashMap.Strict (HashMap )
34
34
import Data.HashMap.Strict qualified as HM
35
35
import Data.IORef (IORef , modifyIORef' , newIORef , readIORef )
36
- import Foreign (ForeignPtr , finalizeForeignPtr , newForeignPtr , withForeignPtr )
36
+ import Foreign (ForeignPtr , Int64 , finalizeForeignPtr , newForeignPtr , withForeignPtr )
37
37
import Foreign qualified
38
38
import Foreign.C qualified as C
39
39
import Foreign.C.Types (CSize (.. ))
@@ -52,6 +52,7 @@ data KoreSymbol
52
52
data KoreError
53
53
data Block
54
54
type SizeT = CSize
55
+ type Int64T = Foreign. Int64
55
56
56
57
type KorePatternPtr = ForeignPtr KorePattern
57
58
type KoreSymbolPtr = ForeignPtr KoreSymbol
@@ -104,6 +105,7 @@ data API = API
104
105
, simplifyBool :: KorePatternPtr -> IO (Either LlvmError Bool )
105
106
, simplify :: KorePatternPtr -> KoreSortPtr -> IO (Either LlvmError ByteString )
106
107
, collect :: IO ()
108
+ , munmap :: IO ()
107
109
, mutex :: MVar ()
108
110
}
109
111
@@ -118,7 +120,7 @@ withDLib dlib = Linker.withDL dlib [Linker.RTLD_LAZY]
118
120
119
121
runLLVM :: API -> LLVM a -> IO a
120
122
runLLVM api (LLVM m) =
121
- withMVar api. mutex $ const $ runReaderT m api
123
+ withMVar api. mutex $ const ( runReaderT m api <* api . collect)
122
124
123
125
mkAPI :: Linker. DL -> IO API
124
126
mkAPI dlib = flip runReaderT dlib $ do
@@ -274,6 +276,7 @@ mkAPI dlib = flip runReaderT dlib $ do
274
276
pure $ Right result
275
277
else Left . LlvmError <$> errorMessage errPtr
276
278
279
+ munmap <- resetMunmapAllArenas -- HACK. Adjust name after llvm-backend dependency upgrade
277
280
mutableBytesEnabled <-
278
281
kllvmMutableBytesEnabled `catch` \ (_ :: IOException ) -> pure (pure 0 )
279
282
liftIO $
@@ -283,7 +286,7 @@ mkAPI dlib = flip runReaderT dlib $ do
283
286
" [Warn] Using an LLVM backend compiled with --llvm-mutable-bytes (unsound byte array semantics)"
284
287
285
288
mutex <- liftIO $ newMVar ()
286
- pure API {patt, symbol, sort, simplifyBool, simplify, collect, mutex}
289
+ pure API {patt, symbol, sort, simplifyBool, simplify, collect, munmap, mutex}
287
290
288
291
ask :: LLVM API
289
292
ask = LLVM Reader. ask
0 commit comments