Skip to content

Commit

Permalink
crucible: Introduce a helper to bind CFGs to their handles (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
langston-barrett authored Dec 7, 2023
1 parent 96343bf commit 501623d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions crucible/src/Lang/Crucible/Simulator/OverrideSim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module Lang.Crucible.Simulator.OverrideSim
, getSymInterface
, ovrWithBackend
, bindFnHandle
, bindCFG
, exitExecution
, getOverrideArgs
, overrideError
Expand Down Expand Up @@ -246,6 +247,12 @@ bindFnHandle ::
bindFnHandle h s =
stateContext . functionBindings %= FnBindings . insertHandleMap h s . fnBindings

-- | Bind a CFG to its handle.
--
-- Computes postdominator information.
bindCFG :: CFG ext blocks args ret -> OverrideSim p sym ext rtp a r ()
bindCFG c = bindFnHandle (cfgHandle c) (UseCFG c (postdomInfo c))

------------------------------------------------------------------------
-- Mutable variables

Expand Down
3 changes: 1 addition & 2 deletions crux-mir/src/Mir/Overrides.hs
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,7 @@ bindFn _symOnline _cs fn cfg =
ovrWithBackend $ \bak ->
let s = backendGetSym bak in
case Map.lookup (textIdKey fn) (overrides bak) of
Nothing ->
bindFnHandle (cfgHandle cfg) $ UseCFG cfg (postdomInfo cfg)
Nothing -> bindCFG cfg
Just (SomeTypedOverride o@(TypedOverride f argTys retTy)) ->
case (,) <$> testEquality (cfgReturnType cfg) retTy <*> testEquality (cfgArgTypes cfg) argTys of
Nothing -> error $ "Mismatching override type for " ++ Text.unpack fn ++
Expand Down

0 comments on commit 501623d

Please sign in to comment.