Skip to content

Commit 255122d

Browse files
author
Eddy Westbrook
committed
changed castPermForVar to the slightly more subtle castUnDetVarsForVar; also added a case to simplify1PermForDetVars to generalize eq(llvmword e) perms when e has undetermined vars
1 parent 60b4562 commit 255122d

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

heapster-saw/src/Verifier/SAW/Heapster/TypedCrucible.hs

+20-5
Original file line numberDiff line numberDiff line change
@@ -3601,11 +3601,19 @@ tcEmitLLVMStmt _arch _ctx _loc stmt =
36013601
-- * Permission Checking for Jump Targets and Termination Statements
36023602
----------------------------------------------------------------------
36033603

3604-
-- | Cast the primary permission for @x@ using any equality permissions in scope
3605-
castPermForVar :: NuMatchingAny1 r => ExprVar a -> ImplM vars s r RNil RNil ()
3606-
castPermForVar x =
3604+
-- | Cast the primary permission for @x@ using any equality permissions on
3605+
-- variables *not* in the supplied list of determined variables. The idea here
3606+
-- is that we are trying to simplify out and remove un-determined variables.
3607+
castUnDetVarsForVar :: NuMatchingAny1 r => NameSet CrucibleType -> ExprVar a ->
3608+
ImplM vars s r RNil RNil ()
3609+
castUnDetVarsForVar det_vars x =
3610+
(view varPermMap <$> getPerms) >>>= \var_perm_map ->
36073611
getPerm x >>>= \p ->
3608-
substEqsWithProof p >>>= \eqp ->
3612+
let nondet_perms =
3613+
NameMap.fromList $
3614+
filter (\(NameMap.NameAndElem y _) -> not $ NameSet.member y det_vars) $
3615+
NameMap.assocs var_perm_map in
3616+
let eqp = someEqProofFromSubst nondet_perms p in
36093617
implPushM x p >>>
36103618
implCastPermM x eqp >>>
36113619
implPopM x (someEqProofRHS eqp)
@@ -3657,6 +3665,13 @@ simplify1PermForDetVars det_vars l (ValPerm_LOwned ls _ _)
36573665
simplify1PermForDetVars det_vars _ p
36583666
| nameSetIsSubsetOf (freeVars p) det_vars = pure ()
36593667

3668+
-- If p is an equality permission to a word with undetermined variables,
3669+
-- existentially quantify over the word
3670+
simplify1PermForDetVars _ x p@(ValPerm_Eq (PExpr_LLVMWord e)) =
3671+
let mb_p = nu $ \z -> ValPerm_Eq $ PExpr_LLVMWord $ PExpr_Var z in
3672+
implPushM x p >>> introExistsM x e mb_p >>>
3673+
implPopM x (ValPerm_Exists mb_p)
3674+
36603675
-- Otherwise, drop p, because it is not determined
36613676
simplify1PermForDetVars _det_vars x p =
36623677
implPushM x p >>> implDropM x p
@@ -3670,7 +3685,7 @@ simplifyPermsForDetVars det_vars_list =
36703685
let det_vars = NameSet.fromList det_vars_list in
36713686
(permSetVars <$> getPerms) >>>= \vars ->
36723687
mapM_ (\(SomeName x) ->
3673-
castPermForVar x >>>
3688+
castUnDetVarsForVar det_vars x >>>
36743689
getPerm x >>>= simplify1PermForDetVars det_vars x) vars
36753690

36763691

0 commit comments

Comments
 (0)