1818#include " klee/Statistics/TimerStatIncrementer.h"
1919
2020#include " CoreStats.h"
21+ #include < cstring>
2122
2223namespace klee {
2324llvm::cl::OptionCategory
@@ -384,15 +385,15 @@ bool AddressSpace::resolve(ExecutionState &state, TimingSolver *solver,
384385// transparently avoid screwing up symbolics (if the byte is symbolic
385386// then its concrete cache byte isn't being used) but is just a hack.
386387
387- void AddressSpace::copyOutConcretes (const Assignment &assignment ) {
388+ void AddressSpace::copyOutConcretes () {
388389 for (const auto &object : objects) {
389390 auto &mo = object.first ;
390391 auto &os = object.second ;
391392 if (ref<ConstantExpr> sizeExpr =
392393 dyn_cast<ConstantExpr>(mo->getSizeExpr ())) {
393394 if (!mo->isUserSpecified && !os->readOnly &&
394395 sizeExpr->getZExtValue () != 0 ) {
395- copyOutConcrete (mo, os.get (), assignment );
396+ copyOutConcrete (mo, os.get ());
396397 }
397398 }
398399 }
@@ -407,27 +408,19 @@ ref<ConstantExpr> toConstantExpr(ref<Expr> expr) {
407408}
408409
409410void AddressSpace::copyOutConcrete (const MemoryObject *mo,
410- const ObjectState *os,
411- const Assignment &assignment) const {
412- if (ref<ConstantExpr> addressExpr =
413- dyn_cast<ConstantExpr>(mo->getBaseExpr ())) {
414- auto address =
415- reinterpret_cast <std::uint8_t *>(addressExpr->getZExtValue ());
416- AssignmentEvaluator evaluator (assignment, false );
417- if (ref<ConstantExpr> sizeExpr =
418- dyn_cast<ConstantExpr>(mo->getSizeExpr ())) {
419- size_t moSize = sizeExpr->getZExtValue ();
420- std::vector<uint8_t > concreteStore (moSize);
421- for (size_t i = 0 ; i < moSize; i++) {
422- auto byte = evaluator.visit (os->readValue8 (i));
423- concreteStore[i] = cast<ConstantExpr>(byte)->getZExtValue (Expr::Int8);
424- }
425- std::memcpy (address, concreteStore.data (), moSize);
411+ const ObjectState *os) const {
412+
413+ if (auto addressExpr = dyn_cast<ConstantExpr>(mo->getBaseExpr ())) {
414+ if (auto sizeExpr = dyn_cast<ConstantExpr>(mo->getSizeExpr ())) {
415+ auto address =
416+ reinterpret_cast <std::uint8_t *>(addressExpr->getZExtValue ());
417+ auto size = sizeExpr->getZExtValue ();
418+ std::memcpy (address, os->valueOS .concreteStore ->data (), size);
426419 }
427420 }
428421}
429422
430- bool AddressSpace::copyInConcretes (const Assignment &assignment ) {
423+ bool AddressSpace::copyInConcretes () {
431424 for (auto &obj : objects) {
432425 const MemoryObject *mo = obj.first ;
433426
@@ -436,8 +429,7 @@ bool AddressSpace::copyInConcretes(const Assignment &assignment) {
436429
437430 if (ref<ConstantExpr> arrayConstantAddress =
438431 dyn_cast<ConstantExpr>(mo->getBaseExpr ())) {
439- if (!copyInConcrete (mo, os.get (), arrayConstantAddress->getZExtValue (),
440- assignment))
432+ if (!copyInConcrete (mo, os.get (), arrayConstantAddress->getZExtValue ()))
441433 return false ;
442434 }
443435 }
@@ -447,24 +439,17 @@ bool AddressSpace::copyInConcretes(const Assignment &assignment) {
447439}
448440
449441bool AddressSpace::copyInConcrete (const MemoryObject *mo, const ObjectState *os,
450- uint64_t src_address,
451- const Assignment &assignment) {
452- AssignmentEvaluator evaluator (assignment, false );
442+ uint64_t src_address) {
453443 auto address = reinterpret_cast <std::uint8_t *>(src_address);
454- size_t moSize =
455- cast<ConstantExpr>(evaluator.visit (mo->getSizeExpr ()))->getZExtValue ();
456- std::vector<uint8_t > concreteStore (moSize);
457- for (size_t i = 0 ; i < moSize; i++) {
458- auto byte = evaluator.visit (os->readValue8 (i));
459- concreteStore[i] = cast<ConstantExpr>(byte)->getZExtValue (8 );
460- }
461- if (memcmp (address, concreteStore.data (), moSize) != 0 ) {
444+ size_t moSize = cast<ConstantExpr>(mo->getSizeExpr ())->getZExtValue ();
445+
446+ if (memcmp (address, os->valueOS .concreteStore ->data (), moSize) != 0 ) {
462447 if (os->readOnly ) {
463448 return false ;
464449 } else {
465450 ObjectState *wos = getWriteable (mo, os);
466451 for (size_t i = 0 ; i < moSize; i++) {
467- wos->write (i, ConstantExpr::create ( address[i], Expr::Int8) );
452+ wos->write8 (i, address[i]);
468453 }
469454 }
470455 }
0 commit comments