@@ -69,7 +69,7 @@ static expr attr_to_bitvec(const ParamAttrs &attrs) {
6969namespace IR {
7070
7171Pointer::Pointer (const Memory &m, const expr &bid, const expr &offset,
72- const expr &attr) : m(const_cast <Memory&>(m) ),
72+ const expr &attr) : m(m ),
7373 p (prepend_if(expr::mkUInt(0 , 1 + padding_logical()),
7474 bid.concat(offset), hasLogicalBit())) {
7575 if (bits_for_ptrattrs)
@@ -78,7 +78,7 @@ Pointer::Pointer(const Memory &m, const expr &bid, const expr &offset,
7878}
7979
8080Pointer::Pointer (const Memory &m, const char *var_name,
81- const ParamAttrs &attr) : m(const_cast <Memory&>(m) ) {
81+ const ParamAttrs &attr) : m(m ) {
8282 unsigned bits = bitsShortBid () + bits_for_offset;
8383 p = expr::mkVar (var_name, bits, false )
8484 .zext (hasLocalBit () + (1 + padding_logical ()) * hasLogicalBit ());
@@ -87,13 +87,12 @@ Pointer::Pointer(const Memory &m, const char *var_name,
8787 assert (p.bits () == totalBits ());
8888}
8989
90- Pointer::Pointer (const Memory &m, expr repr)
91- : m(const_cast <Memory&>(m)), p(std::move(repr)) {
90+ Pointer::Pointer (const Memory &m, expr repr) : m(m), p(std::move(repr)) {
9291 assert (!p.isValid () || p.bits () == totalBits ());
9392}
9493
9594Pointer::Pointer (const Memory &m, unsigned bid, bool local, expr attr)
96- : m(const_cast <Memory&>(m) ), p(
95+ : m(m ), p(
9796 prepend_if (expr::mkUInt(0 , 1 + padding_logical()),
9897 prepend_if(expr::mkUInt(local, 1 ),
9998 expr::mkUInt(bid, bitsShortBid())
@@ -531,35 +530,12 @@ Pointer::isDereferenceable(const expr &bytes0, uint64_t align,
531530 bytes = bytes.round_up (expr::mkUInt (align, bytes));
532531 expr bytes_off = bytes.zextOrTrunc (bits_for_offset);
533532
534- auto block_constraints = [& ](const Pointer &p) {
533+ auto block_constraints = [= ](const Pointer &p) {
535534 expr ret = p.isBlockAlive ();
536535 if (iswrite)
537536 ret &= p.isWritable () && !p.isNoWrite ();
538537 else if (!ignore_accessability)
539538 ret &= !p.isNoRead ();
540-
541- // If we are loading from an argument and it has the 'initializes'
542- // attribute, make sure we have already stored to it before.
543- if (!ignore_accessability && !iswrite) {
544- auto &s = m.getState ();
545- for (auto &input0 : s.getFn ().getInputs ()) {
546- auto &input = static_cast <const Input&>(input0);
547- auto &inits = input.getAttributes ().initializes ;
548- if (inits.empty ())
549- continue ;
550-
551- Pointer arg (m, s[input].value );
552- expr offsets = true ;
553- for (auto [l, h] : inits) {
554- offsets &= (p.getOffset ().uge ((arg + l).getOffset ()) &&
555- p.getOffset ().ult ((arg + h).getOffset ())
556- ).implies (m.hasStored (p, bytes));
557- }
558- // TODO: isBasedOnArg is not sufficient; we have to store the arg number
559- // in the pointer as we can have 2 args with same initializes attr
560- ret&= (p.isBasedOnArg () && p.getBid () == arg.getBid ()).implies (offsets);
561- }
562- }
563539 return ret;
564540 };
565541
@@ -592,7 +568,6 @@ Pointer::isDereferenceable(const expr &bytes0, uint64_t align,
592568 DisjointExpr<expr> addrs (expr::mkUInt (0 , bits_ptr_address));
593569 expr ub = false ;
594570 bool all_same_size = true ;
595- expr addr = is_phy ? p.getPhysicalAddress () : p.getAddress ();
596571
597572 auto add = [&](unsigned start, unsigned limit, bool local) {
598573 for (unsigned i = start; i < limit; ++i) {
@@ -602,24 +577,20 @@ Pointer::isDereferenceable(const expr &bytes0, uint64_t align,
602577
603578 Pointer this_ptr (m, i, local, p.getAttrs ());
604579
605- bool same_size = bytes.eq (this_ptr.blockSizeAligned ());
606- expr this_addr = this_ptr.getLogAddress ();
607- expr offset = same_size ? expr::mkUInt (0 , addr) : addr - this_addr;
608-
609580 expr cond = p.isInboundsOf (this_ptr, bytes, is_phy) &&
610- block_constraints (this_ptr + offset );
581+ block_constraints (this_ptr);
611582 if (cond.isFalse ())
612583 continue ;
613584
614585 ub |= cond;
615586
616587 cond = p.isOfBlock (this_ptr, bytes, is_phy);
617588
618- all_same_size &= same_size ;
589+ all_same_size &= bytes. eq (this_ptr. blockSizeAligned ()) ;
619590
620591 bids.add (
621592 observes_local ? this_ptr.getBid () : this_ptr.getShortBid (), cond);
622- addrs.add (std::move (this_addr ), std::move (cond));
593+ addrs.add (this_ptr. getLogAddress ( ), std::move (cond));
623594 }
624595 };
625596 add (0 , m.numLocals (), true );
@@ -631,6 +602,8 @@ Pointer::isDereferenceable(const expr &bytes0, uint64_t align,
631602 if (!observes_local)
632603 bid = mkLongBid (bid, false );
633604
605+ expr addr = is_phy ? p.getPhysicalAddress () : p.getAddress ();
606+
634607 return { std::move (ub),
635608 Pointer (m, std::move (bid),
636609 all_same_size
@@ -711,9 +684,6 @@ Pointer::isDereferenceable(const expr &bytes0, uint64_t align,
711684 auto ptrs = std::move (all_ptrs)();
712685 p = ptrs ? *std::move (ptrs) : expr::mkUInt (0 , totalBits ());
713686
714- if (!ignore_accessability && iswrite)
715- m.record_store (*this , bytes);
716-
717687 return { std::move (exprs), *std::move (is_aligned)() };
718688}
719689
0 commit comments