Skip to content

Commit 2fb1c26

Browse files
authored
Merge pull request #1260 from GaloisInc/1259-remove-unused-monoids
G/C unused Monoid and Semigroup instances in crucible-mir
2 parents eb6bd6f + cb53598 commit 2fb1c26

File tree

8 files changed

+22
-37
lines changed

8 files changed

+22
-37
lines changed

crucible-mir/CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# next -- TBA
2+
3+
* The calling sequence of ```translateMIR``` has changed: the first argument,
4+
which should always have been passed as ```mempty```, has been removed.
5+
This will require adjustments in any downstream callers.
6+
* The corresponding implicit argument in the ```Pass``` type has been removed.
7+
* The Semigroup and Monoid instances for Collection, CollectionState, and
8+
RustModule have been removed. It is not expected that there are any
9+
downstream users.
10+
111
# 0.3 -- 2024-08-30
212

313
* Implement byte-to-char casts.

crucible-mir/src/Mir/Generator.hs

-13
Original file line numberDiff line numberDiff line change
@@ -395,19 +395,6 @@ $(return [])
395395

396396
-- ** Operations and instances
397397

398-
instance Semigroup RustModule where
399-
(RustModule cs1 cm1 ex1) <> (RustModule cs2 cm2 ex2) =
400-
RustModule (cs1 <> cs2) (cm1 <> cm2) (ex1 <> ex2)
401-
instance Monoid RustModule where
402-
mempty = RustModule mempty mempty mempty
403-
404-
instance Semigroup CollectionState where
405-
(CollectionState hm1 vm1 sm1 dm1 chm1 col1) <> (CollectionState hm2 vm2 sm2 dm2 chm2 col2) =
406-
(CollectionState (hm1 <> hm2) (vm1 <> vm2) (sm1 <> sm2) (dm1 <> dm2) (Map.unionWith (<>) chm1 chm2) (col1 <> col2))
407-
instance Monoid CollectionState where
408-
mempty = CollectionState mempty mempty mempty mempty mempty mempty
409-
410-
411398
instance Show (MirExp s) where
412399
show (MirExp tr e) = (show e) ++ ": " ++ (show tr)
413400

crucible-mir/src/Mir/Mir.hs

-12
Original file line numberDiff line numberDiff line change
@@ -585,18 +585,6 @@ makeLenses ''Instance
585585
makeLenses ''NamedTy
586586
makeWrapped ''Substs
587587

588-
--------------------------------------------------------------------------------------
589-
-- Other instances for ADT types
590-
--------------------------------------------------------------------------------------
591-
592-
instance Semigroup Collection where
593-
(Collection f1 a1 a1' t1 s1 v1 n1 tys1 r1) <> (Collection f2 a2 a2' t2 s2 v2 n2 tys2 r2) =
594-
Collection (f1 <> f2) (a1 <> a2) (a1' <> a2') (t1 <> t2) (s1 <> s2) (v1 <> v2) (n1 <> n2) (tys1 <> tys2) (r1 <> r2)
595-
instance Monoid Collection where
596-
mempty = Collection mempty mempty mempty mempty mempty mempty mempty mempty mempty
597-
598-
599-
600588
--------------------------------------------------------------------------------------
601589
--- aux functions ---
602590
--------------------------------------------------------------------------------------

crucible-mir/src/Mir/ParseTranslate.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ uninternMir col = uninternTys unintern (col { _namedTys = mempty })
6969

7070
-- | Translate a MIR collection to Crucible
7171
translateMIR :: (HasCallStack, ?debug::Int, ?assertFalseOnError::Bool, ?printCrucible::Bool)
72-
=> CollectionState -> Collection -> C.HandleAllocator -> IO RustModule
73-
translateMIR lib col halloc =
72+
=> Collection -> C.HandleAllocator -> IO RustModule
73+
translateMIR col halloc =
7474
let ?customOps = Mir.customOps in
75-
let col0 = let ?mirLib = lib^.collection in rewriteCollection col
76-
in let ?libCS = lib in transCollection col0 halloc
75+
let col0 = rewriteCollection col
76+
in transCollection col0 halloc

crucible-mir/src/Mir/Pass.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import Mir.Pass.AllocateEnum ( passAllocateEnum )
2323

2424
import Debug.Trace
2525

26-
type Pass = (?debug::Int, ?mirLib::Collection, HasCallStack) => Collection -> Collection
26+
type Pass = (?debug::Int, HasCallStack) => Collection -> Collection
2727

2828
--------------------------------------------------------------------------------------
2929
infixl 0 |>

crucible-mir/src/Mir/Pass/AllocateEnum.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ and replace them with a single aggregate assignment
4141

4242

4343

44-
passAllocateEnum :: (HasCallStack, ?debug::Int, ?mirLib::Collection) => Collection -> Collection
44+
passAllocateEnum :: (HasCallStack, ?debug::Int) => Collection -> Collection
4545
passAllocateEnum col =
46-
let ?col = ?mirLib <> col in
46+
let ?col = col in
4747
col & functions %~ fmap (& fbody %~ mblocks %~ map pcr)
4848

4949

crucible-mir/src/Mir/Trans.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,7 @@ mkCrateHashesMap
22492249
-- | transCollection: translate a MIR collection
22502250
transCollection ::
22512251
(HasCallStack, ?debug::Int, ?assertFalseOnError::Bool,
2252-
?libCS::CollectionState, ?customOps::CustomOpMap,
2252+
?customOps::CustomOpMap,
22532253
?printCrucible::Bool)
22542254
=> M.Collection
22552255
-> FH.HandleAllocator
@@ -2286,14 +2286,14 @@ transCollection col halloc = do
22862286
colState = CollectionState hmap vm sm dm chm col
22872287

22882288
-- translate all of the functions
2289-
fnInfo <- mapM (stToIO . transDefine (?libCS <> colState)) (Map.elems (col^.M.functions))
2289+
fnInfo <- mapM (stToIO . transDefine colState) (Map.elems (col^.M.functions))
22902290
let pairs1 = [(name, cfg) | (name, cfg, _) <- fnInfo]
22912291
let transInfo = Map.fromList [(name, fti) | (name, _, fti) <- fnInfo]
2292-
pairs2 <- mapM (stToIO . transVtable (?libCS <> colState)) (Map.elems (col^.M.vtables))
2292+
pairs2 <- mapM (stToIO . transVtable colState) (Map.elems (col^.M.vtables))
22932293

22942294
pairs3 <- Maybe.catMaybes <$> mapM (\intr -> case intr^.M.intrInst of
22952295
Instance (IkVirtual dynTraitName methodIndex) methodId _substs ->
2296-
stToIO $ Just <$> transVirtCall (?libCS <> colState)
2296+
stToIO $ Just <$> transVirtCall colState
22972297
(intr^.M.intrName) methodId dynTraitName methodIndex
22982298
_ -> return Nothing) (Map.elems (col ^. M.intrinsics))
22992299

crux-mir/src/Mir/Language.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ runTestsWithExtraOverrides bindExtra (cruxOpts, mirOpts) = do
253253

254254
-- Translate to crucible
255255
halloc <- C.newHandleAllocator
256-
mir <- translateMIR mempty col halloc
256+
mir <- translateMIR col halloc
257257

258258
C.AnyCFG staticInitCfg <- transStatics (mir^.rmCS) halloc
259259
let hi = C.cfgHandle staticInitCfg

0 commit comments

Comments
 (0)