@@ -132,6 +132,7 @@ import qualified What4.Expr.Builder as W4
132
132
133
133
-- crucible
134
134
import qualified Lang.Crucible.Backend as Crucible
135
+ import qualified Lang.Crucible.Backend.Online as Crucible
135
136
import qualified Lang.Crucible.Backend.SAWCore as CrucibleSAW
136
137
import qualified Lang.Crucible.CFG.Core as Crucible
137
138
import qualified Lang.Crucible.CFG.Extension as Crucible
@@ -269,7 +270,7 @@ crucible_llvm_verify ::
269
270
TopLevel (SomeLLVM MS. CrucibleMethodSpecIR )
270
271
crucible_llvm_verify bic opts (Some lm) nm lemmas checkSat setup tactic =
271
272
do lemmas' <- checkModuleCompatibility lm lemmas
272
- withMethodSpec bic opts lm nm setup $ \ cc method_spec ->
273
+ withMethodSpec bic opts checkSat lm nm setup $ \ cc method_spec ->
273
274
do (res_method_spec, _) <- verifyMethodSpec bic opts cc method_spec lemmas' checkSat tactic Nothing
274
275
returnProof $ SomeLLVM res_method_spec
275
276
@@ -281,7 +282,7 @@ crucible_llvm_unsafe_assume_spec ::
281
282
LLVMCrucibleSetupM () {- ^ Boundary specification -} ->
282
283
TopLevel (SomeLLVM MS. CrucibleMethodSpecIR )
283
284
crucible_llvm_unsafe_assume_spec bic opts (Some lm) nm setup =
284
- withMethodSpec bic opts lm nm setup $ \ _ method_spec ->
285
+ withMethodSpec bic opts False lm nm setup $ \ _ method_spec ->
285
286
do printOutLnTop Info $
286
287
unwords [" Assume override" , (method_spec ^. csName)]
287
288
returnProof $ SomeLLVM method_spec
@@ -298,7 +299,7 @@ crucible_llvm_array_size_profile ::
298
299
crucible_llvm_array_size_profile assume bic opts (Some lm) nm lemmas setup = do
299
300
cell <- io $ newIORef (Map. empty :: Map Text. Text [Crucible. FunctionProfile ])
300
301
lemmas' <- checkModuleCompatibility lm lemmas
301
- withMethodSpec bic opts lm nm setup $ \ cc ms -> do
302
+ withMethodSpec bic opts False lm nm setup $ \ cc ms -> do
302
303
void . verifyMethodSpec bic opts cc ms lemmas' True assume $ Just cell
303
304
profiles <- io $ readIORef cell
304
305
pure . fmap (\ (fnm, prof) -> (Text. unpack fnm, prof)) $ Map. toList profiles
@@ -310,13 +311,13 @@ crucible_llvm_compositional_extract ::
310
311
String ->
311
312
String ->
312
313
[SomeLLVM MS. CrucibleMethodSpecIR ] ->
313
- Bool ->
314
+ Bool {- ^ check sat -} ->
314
315
LLVMCrucibleSetupM () ->
315
316
ProofScript SatResult ->
316
317
TopLevel (SomeLLVM MS. CrucibleMethodSpecIR )
317
318
crucible_llvm_compositional_extract bic opts (Some lm) nm func_name lemmas checkSat setup tactic =
318
319
do lemmas' <- checkModuleCompatibility lm lemmas
319
- withMethodSpec bic opts lm nm setup $ \ cc method_spec ->
320
+ withMethodSpec bic opts checkSat lm nm setup $ \ cc method_spec ->
320
321
do let value_input_parameters = mapMaybe
321
322
(\ (_, setup_value) -> setupValueAsExtCns setup_value)
322
323
(Map. elems $ method_spec ^. MS. csArgBindings)
@@ -447,13 +448,14 @@ checkModuleCompatibility llvmModule = foldM step []
447
448
withMethodSpec ::
448
449
BuiltinContext ->
449
450
Options ->
451
+ Bool {- ^ path sat -} ->
450
452
LLVMModule arch ->
451
453
String {- ^ Name of the function -} ->
452
454
LLVMCrucibleSetupM () {- ^ Boundary specification -} ->
453
455
((? lc :: Crucible. TypeContext , Crucible. HasPtrWidth (Crucible. ArchWidth arch ), Crucible. HasLLVMAnn Sym ) =>
454
456
LLVMCrucibleContext arch -> MS. CrucibleMethodSpecIR (LLVM arch ) -> TopLevel a ) ->
455
457
TopLevel a
456
- withMethodSpec bic opts lm nm setup action =
458
+ withMethodSpec bic opts pathSat lm nm setup action =
457
459
do (nm', parent) <- resolveSpecName nm
458
460
let edef = findDefMaybeStatic (modAST lm) nm'
459
461
let edecl = findDecl (modAST lm) nm'
@@ -468,7 +470,7 @@ withMethodSpec bic opts lm nm setup action =
468
470
469
471
Crucible. llvmPtrWidth (mtrans ^. Crucible. transContext) $ \ _ ->
470
472
fmap NE. head $ forM defOrDecls $ \ defOrDecl ->
471
- setupLLVMCrucibleContext bic opts lm $ \ cc ->
473
+ setupLLVMCrucibleContext bic opts pathSat lm $ \ cc ->
472
474
do let sym = cc^. ccBackend
473
475
474
476
pos <- getPosition
@@ -1204,11 +1206,12 @@ verifyPoststate opts sc cc mspec env0 globals ret =
1204
1206
setupLLVMCrucibleContext ::
1205
1207
BuiltinContext ->
1206
1208
Options ->
1209
+ Bool {- ^ enable path sat checking -} ->
1207
1210
LLVMModule arch ->
1208
1211
((? lc :: Crucible. TypeContext , Crucible. HasPtrWidth (Crucible. ArchWidth arch ), Crucible. HasLLVMAnn Sym ) =>
1209
1212
LLVMCrucibleContext arch -> TopLevel a ) ->
1210
1213
TopLevel a
1211
- setupLLVMCrucibleContext bic opts lm action =
1214
+ setupLLVMCrucibleContext bic opts pathSat lm action =
1212
1215
do halloc <- getHandleAlloc
1213
1216
let llvm_mod = modAST lm
1214
1217
let mtrans = modTrans lm
@@ -1234,6 +1237,10 @@ setupLLVMCrucibleContext bic opts lm action =
1234
1237
cacheTermsSetting <- W4. getOptionSetting W4. cacheTerms cfg
1235
1238
_ <- W4. setOpt cacheTermsSetting what4HashConsing
1236
1239
1240
+ -- enable online solver interactions if path sat checking is on
1241
+ enableOnlineSetting <- W4. getOptionSetting Crucible. enableOnlineBackend cfg
1242
+ _ <- W4. setOpt enableOnlineSetting pathSat
1243
+
1237
1244
W4. extendConfig
1238
1245
[ W4. opt
1239
1246
enableSMTArrayMemoryModel
@@ -1447,7 +1454,7 @@ crucible_llvm_extract bic opts (Some lm) fn_name =
1447
1454
when (any L. isAlias defTypes) $
1448
1455
throwTopLevel " Type aliases are not supported by `crucible_llvm_extract`."
1449
1456
Left err -> throwTopLevel (displayVerifExceptionOpts opts err)
1450
- setupLLVMCrucibleContext bic opts lm $ \ cc ->
1457
+ setupLLVMCrucibleContext bic opts False lm $ \ cc ->
1451
1458
case Map. lookup (fromString fn_name) (Crucible. cfgMap (ccLLVMModuleTrans cc)) of
1452
1459
Nothing -> throwTopLevel $ unwords [" function" , fn_name, " not found" ]
1453
1460
Just (_,cfg) -> io $ extractFromLLVMCFG opts (biSharedContext bic) cc cfg
@@ -1461,7 +1468,7 @@ crucible_llvm_cfg ::
1461
1468
crucible_llvm_cfg bic opts (Some lm) fn_name =
1462
1469
do let ctx = modTrans lm ^. Crucible. transContext
1463
1470
let ? lc = ctx^. Crucible. llvmTypeCtx
1464
- setupLLVMCrucibleContext bic opts lm $ \ cc ->
1471
+ setupLLVMCrucibleContext bic opts False lm $ \ cc ->
1465
1472
case Map. lookup (fromString fn_name) (Crucible. cfgMap (ccLLVMModuleTrans cc)) of
1466
1473
Nothing -> throwTopLevel $ unwords [" function" , fn_name, " not found" ]
1467
1474
Just (_,cfg) -> return (LLVM_CFG cfg)
0 commit comments