@@ -693,16 +693,10 @@ verifyPrestate opts cc mspec globals =
693
693
let Just mem = Crucible. lookupGlobal lvar globals
694
694
695
695
-- Allocate LLVM memory for each 'crucible_alloc'
696
- (env1 , mem') <- runStateT
697
- (traverse (doAlloc cc) $ mspec ^. MS. csPreState . MS. csAllocs)
696
+ (env , mem') <- runStateT
697
+ (Map. traverseWithKey (doAlloc cc) ( mspec ^. MS. csPreState . MS. csAllocs) )
698
698
mem
699
699
700
- env2 <-
701
- Map. traverseWithKey
702
- (\ k _ -> executeFreshPointer cc k)
703
- (mspec ^. MS. csPreState . MS. csFreshPointers)
704
- let env = Map. unions [env1, env2]
705
-
706
700
mem'' <- setupGlobalAllocs cc mspec mem'
707
701
708
702
mem''' <- setupPrePointsTos mspec opts cc env (mspec ^. MS. csPreState . MS. csPointsTos) mem''
@@ -875,9 +869,13 @@ assertEqualVals cc v1 v2 =
875
869
doAlloc ::
876
870
(Crucible. HasPtrWidth (Crucible. ArchWidth arch )) =>
877
871
LLVMCrucibleContext arch ->
872
+ AllocIndex ->
878
873
LLVMAllocSpec ->
879
874
StateT MemImpl IO (LLVMPtr (Crucible. ArchWidth arch ))
880
- doAlloc cc (LLVMAllocSpec mut _memTy alignment sz loc) = StateT $ \ mem ->
875
+ doAlloc cc i (LLVMAllocSpec mut _memTy alignment sz loc fresh)
876
+ | fresh = liftIO $ executeFreshPointer cc i
877
+ | otherwise =
878
+ StateT $ \ mem ->
881
879
do let sym = cc^. ccBackend
882
880
sz' <- liftIO $ resolveSAWSymBV cc Crucible. PtrWidth sz
883
881
let l = show (W4. plSourceLoc loc)
@@ -1157,7 +1155,10 @@ verifyPoststate opts sc cc mspec env0 globals ret =
1157
1155
io $
1158
1156
runOverrideMatcher sym globals env0 terms0 initialFree poststateLoc $
1159
1157
do matchResult
1160
- learnCond opts sc cc mspec PostState (mspec ^. MS. csGlobalAllocs) (mspec ^. MS. csPostState)
1158
+ learnCond opts sc cc mspec PostState
1159
+ (mspec ^. MS. csGlobalAllocs)
1160
+ (mspec ^. MS. csPreState . MS. csAllocs)
1161
+ (mspec ^. MS. csPostState)
1161
1162
1162
1163
st <-
1163
1164
case matchPost of
@@ -1756,6 +1757,7 @@ crucible_alloc_with_mutability_and_size mut sz alignment bic opts lty =
1756
1757
, _allocSpecAlign = alignment'
1757
1758
, _allocSpecBytes = sz''
1758
1759
, _allocSpecLoc = loc
1760
+ , _allocSpecFresh = False
1759
1761
}
1760
1762
1761
1763
crucible_alloc ::
@@ -1861,6 +1863,7 @@ crucible_symbolic_alloc bic _opts ro align_bytes sz =
1861
1863
, _allocSpecAlign = alignment
1862
1864
, _allocSpecBytes = sz
1863
1865
, _allocSpecLoc = loc
1866
+ , _allocSpecFresh = False
1864
1867
}
1865
1868
n <- Setup. csVarCounter <<%= nextAllocIndex
1866
1869
Setup. currentState . MS. csAllocs . at n ?= spec
@@ -1907,12 +1910,13 @@ constructFreshPointer mid loc memTy =
1907
1910
n <- Setup. csVarCounter <<%= nextAllocIndex
1908
1911
sz <- liftIO $ scPtrWidthBvNat cctx $ Crucible. memTypeSize ? dl memTy
1909
1912
let alignment = Crucible. memTypeAlign ? dl memTy
1910
- Setup. currentState . MS. csFreshPointers . at n ?=
1913
+ Setup. currentState . MS. csAllocs . at n ?=
1911
1914
LLVMAllocSpec { _allocSpecMut = Crucible. Mutable
1912
1915
, _allocSpecType = memTy
1913
1916
, _allocSpecAlign = alignment
1914
1917
, _allocSpecBytes = sz
1915
1918
, _allocSpecLoc = loc
1919
+ , _allocSpecFresh = True
1916
1920
}
1917
1921
-- TODO: refactor
1918
1922
case mid of
0 commit comments