Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crucible: Introduce a helper to bind CFGs to their handles #1151

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
langston-barrett marked this conversation as resolved.
Show resolved Hide resolved

------------------------------------------------------------------------
-- 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
Loading