Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andreistefanescu authored and RyanGlScott committed Jan 26, 2024
1 parent 4b2d605 commit 470cb28
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crucible-llvm/src/Lang/Crucible/LLVM/MemModel/Generic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1638,10 +1638,10 @@ possibleAllocs n mem =
newtype MemoIO m a = MemoIO (IORef (Either (m a) a))

putMemoIO :: MonadIO m => m a -> m (MemoIO m a)
putMemoIO comp = MemoIO <$> (liftIO $ newIORef $ Left comp)
putMemoIO comp = MemoIO <$> liftIO (newIORef $ Left comp)

getMemoIO :: MonadIO m => MemoIO m a -> m a
getMemoIO (MemoIO ref) = (liftIO $ readIORef ref) >>= \case
getMemoIO (MemoIO ref) = liftIO (readIORef ref) >>= \case
Left comp -> do
res <- comp
liftIO $ writeIORef ref $ Right res
Expand Down Expand Up @@ -1673,6 +1673,7 @@ asMemAllocationArrayStore sym w ptr mem
, [SomeAlloc _ _ (Just sz) _ _ _] <- List.nub (possibleAllocs blk_no mem)
, Just Refl <- testEquality w (bvWidth sz) =
do memo_nothing <- putMemoIO $ return Nothing
putStrLn $ "asMemAllocationArrayStore: base=" ++ show blk_no ++ " sz=" ++ show (printSymExpr sz)
result <- findArrayStore sym w blk_no (BV.zero w) sz memo_nothing $
memWritesAtConstant blk_no $ memWrites mem
return $ case result of
Expand All @@ -1693,6 +1694,7 @@ asMemMatchingArrayStore sym w ptr sz mem
| Just blk_no <- asNat (llvmPointerBlock ptr)
, memMemberArrayBlock (llvmPointerBlock ptr) mem
, Just off <- asBV (llvmPointerOffset ptr) = do
putStrLn $ "asMemMatchingArrayStore: ptr=" ++ show (blk_no, off) ++ " sz=" ++ show (printSymExpr sz)
memo_nothing <- putMemoIO $ return Nothing
findArrayStore sym w blk_no off sz memo_nothing $ memWritesAtConstant blk_no $ memWrites mem
| otherwise = return Nothing
Expand All @@ -1709,7 +1711,11 @@ findArrayStore ::
IO (Maybe (Pred sym, SymArray sym (SingleCtx (BaseBVType w)) (BaseBVType 8)))
findArrayStore sym w blk_no off sz memo_cont = \case
[] -> getMemoIO memo_cont
head_mem_write : tail_mem_writes -> case head_mem_write of
head_mem_write : tail_mem_writes -> do
putStrLn $ " findArrayStore: ptr=" ++ show (blk_no, off) ++ " sz=" ++ show (printSymExpr sz)
putStrLn $ " findArrayStore: write=" ++ (case head_mem_write of MemWrite{} -> "write"; WriteMerge{} -> "merge")

case head_mem_write of
MemWrite write_ptr write_source
| Just write_blk_no <- asNat (llvmPointerBlock write_ptr)
, blk_no == write_blk_no
Expand Down

0 comments on commit 470cb28

Please sign in to comment.