Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
This bumps the `crucible` submodule to include GaloisInc/crucible#914. This
also bumps the `macaw` submodule to include GaloisInc/macaw#244, which adapts
`macaw-symbolic` to the `crucible` changes. These `crucible` changes require
some tweaks in the following libraries:

* In `heapster-saw`, we need to add a `NuMatching1` instance for `GlobalVar`
  now that `LLVM_SideConditions` has a field of type `GlobalVar Mem`. This
  also requires defining an opaque `NuMatching` instance for `Nonce` to support
  the `NuMatching1` instance for `GlobalVar`.

  Elsewhere in `heapster-saw`, we need to adapt a pattern match on
  `LLVM_SideConditions` to accommodate its new field.
* In `saw-script`, we need to make sure that `?recordLLVMAnnotation` is given
  three arguments, not two, so that its type matches what `HasLLVMAnn` expects.
  • Loading branch information
RyanGlScott committed Nov 29, 2021
1 parent 8abb655 commit cfb08e7
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion deps/crucible
16 changes: 14 additions & 2 deletions heapster-saw/src/Verifier/SAW/Heapster/CruUtil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import Data.Parameterized.Context hiding ((:>), empty, take, view)
import qualified Data.Parameterized.Context as Ctx
import Data.Parameterized.TraversableFC
import Data.Parameterized.BoolRepr
import Data.Parameterized.Nonce (Nonce)

-- import qualified Text.PrettyPrint.ANSI.Leijen as PP
import qualified Prettyprinter as PP
Expand All @@ -70,7 +71,7 @@ import Verifier.SAW.OpenTerm

-- | The lens into an 'RAssign' associated with a 'Member' proof
--
-- FIXME HERE: this should go into Hobbits, possibly using
-- FIXME HERE: this should go into Hobbits, possibly using
member :: Member ctx a -> Lens' (RAssign f ctx) (f a)
member memb = lens (RL.get memb) (flip (RL.set memb))

Expand Down Expand Up @@ -399,6 +400,17 @@ instance NuMatchingAny1 f => NuMatchingAny1 (LLVMExtensionExpr f) where
$(mkNuMatching [t| forall w f tp. NuMatchingAny1 f => LLVMStmt w f tp |])
-}

$(mkNuMatching [t| forall tp. GlobalVar tp |])

instance NuMatching (Nonce s tp) where
nuMatchingProof = unsafeMbTypeRepr

instance Closable (Nonce s tp) where
toClosed = unsafeClose

instance Liftable (Nonce s tp) where
mbLift = unClosed . mbLift . fmap toClosed

instance Closable (BV.BV w) where
toClosed = unsafeClose

Expand Down Expand Up @@ -729,7 +741,7 @@ cruCtxLookup (CruCtxCons _ tp) Member_Base = tp
cruCtxLookup (CruCtxCons ctx _) (Member_Step memb) = cruCtxLookup ctx memb

-- | Build a 'CruCtx' of the given length.
cruCtxReplicate :: NatRepr n -> TypeRepr a -> Some CruCtx
cruCtxReplicate :: NatRepr n -> TypeRepr a -> Some CruCtx
cruCtxReplicate n tp =
case isZeroNat n of
ZeroNat -> Some CruCtxNil
Expand Down
16 changes: 8 additions & 8 deletions heapster-saw/src/Verifier/SAW/Heapster/TypedCrucible.hs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ data TypedLLVMStmt ret ps_in ps_out where
-- Type:
-- > ps, x:ptr((rw,0) |-> p), cur_ps
-- > -o ps, x:ptr((rw,0) |-> eq(ret)), ret:p, cur_ps
TypedLLVMLoad ::
TypedLLVMLoad ::
(HasPtrWidth w, 1 <= sz, KnownNat sz) =>
!(TypedReg (LLVMPointerType w)) ->
!(LLVMFieldPerm w sz) ->
Expand Down Expand Up @@ -540,7 +540,7 @@ data TypedLLVMStmt ret ps_in ps_out where
-- referred to by a function pointer, assuming we know it has one:
--
-- Type: @x:llvm_funptr(p) -o ret:p@
TypedLLVMLoadHandle ::
TypedLLVMLoadHandle ::
HasPtrWidth w =>
!(TypedReg (LLVMPointerType w)) ->
!(TypeRepr (FunctionHandleType cargs ret)) ->
Expand Down Expand Up @@ -1338,7 +1338,7 @@ entryByID entryID =
over typedBlockEntries (replaceNth (blockEntryIx entryID blk) e) blk)


-- | Build an empty 'TypedBlock'
-- | Build an empty 'TypedBlock'
emptyBlockOfSort ::
[Maybe String] ->
Assignment CtxRepr cblocks ->
Expand Down Expand Up @@ -1943,7 +1943,7 @@ runPermCheckM names entryID args ghosts mb_perms_in m =
(tops_ns, args_ns) = RL.split Proxy args_prxs tops_args
(arg_names, local_names) = initialNames args names
st = emptyPermCheckState (distPermSet perms_in) tops_ns entryID local_names in

let go x = runGenStateContT x st (\_ () -> pure ()) in
go $
setVarTypes (Just "top") (noNames' stTopCtx) tops_ns stTopCtx >>>
Expand All @@ -1967,7 +1967,7 @@ initialNames CruCtxNil xs = (MNil, xs)
initialNames (CruCtxCons ts _) xs =
case initialNames ts xs of
(ys, z:zs) -> (ys :>: Constant z, zs)
(ys, [] ) -> (ys :>: Constant Nothing, [])
(ys, [] ) -> (ys :>: Constant Nothing, [])

-- | Compute an empty debug name assignment from a known context
noNames ::
Expand Down Expand Up @@ -2641,7 +2641,7 @@ ppCruRegAndPerms ctx r =
-- their permissions, the variables in those permissions etc., as in
-- 'varPermsTransFreeVars'
getRelevantPerms :: [SomeName CrucibleType] ->
PermCheckM ext cblocks blocks tops ret r ps r ps
PermCheckM ext cblocks blocks tops ret r ps r ps
(Some DistPerms)
getRelevantPerms (namesListToNames -> SomeRAssign ns) =
gets stCurPerms >>>= \perms ->
Expand Down Expand Up @@ -3106,7 +3106,7 @@ tcEmitLLVMSetExpr ctx loc (LLVM_PointerIte w cond_reg then_reg else_reg) =
PExpr_Bool True ->
dbgNames >>= \names ->
emitStmt knownRepr names loc
(TypedSetRegPermExpr knownRepr $
(TypedSetRegPermExpr knownRepr $
PExpr_Var $ typedRegVar tthen_reg) >>>= \(MNil :>: ret) ->
stmtRecombinePerms >>>
pure (addCtxName ctx ret)
Expand All @@ -3125,7 +3125,7 @@ tcEmitLLVMSetExpr ctx loc (LLVM_PointerIte w cond_reg then_reg else_reg) =
pure (addCtxName ctx ret)

-- For LLVM side conditions, treat each side condition as an assert
tcEmitLLVMSetExpr ctx loc (LLVM_SideConditions tp conds reg) =
tcEmitLLVMSetExpr ctx loc (LLVM_SideConditions _ tp conds reg) =
let treg = tcReg ctx reg in
foldr
(\(LLVMSideCondition cond_reg ub) rest_m ->
Expand Down
2 changes: 1 addition & 1 deletion src/SAWScript/Crucible/LLVM/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ setupLLVMCrucibleContext pathSat lm action =
{ Crucible.laxPointerOrdering = laxPointerOrdering
}
let ?intrinsicsOpts = Crucible.defaultIntrinsicsOptions
let ?recordLLVMAnnotation = \_ _ -> return ()
let ?recordLLVMAnnotation = \_ _ _ -> return ()
cc <-
io $
do let verbosity = simVerbose opts
Expand Down
2 changes: 1 addition & 1 deletion src/SAWScript/Crucible/LLVM/X86.hs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ llvm_verify_x86 (Some (llvmModule :: LLVMModule x)) path nm globsyms checkSat se
start <- io getCurrentTime
let ?ptrWidth = knownNat @64
let ?memOpts = C.LLVM.defaultMemOptions
let ?recordLLVMAnnotation = \_ _ -> return ()
let ?recordLLVMAnnotation = \_ _ _ -> return ()
sc <- getSharedContext
opts <- getOptions
basic_ss <- getBasicSS
Expand Down
2 changes: 1 addition & 1 deletion src/SAWScript/X86.hs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ translate opts elf fun =
sayLn ("Translating function: " ++ BSC.unpack name)

let ?memOpts = Crucible.defaultMemOptions
let ?recordLLVMAnnotation = \_ _ -> return ()
let ?recordLLVMAnnotation = \_ _ _ -> return ()

let sym = backend opts
sopts = Opts { optsSym = sym, optsCry = cryEnv opts, optsMvar = memvar opts }
Expand Down

0 comments on commit cfb08e7

Please sign in to comment.