Skip to content

Commit a3c793d

Browse files
committed
Deal with the byval case
1 parent e27fccc commit a3c793d

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

ir/memory.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1902,7 +1902,8 @@ expr Memory::blockPropertiesRefined(const Pointer &src, const Pointer &tgt)
19021902

19031903
return src.isBlockAlive() == tgt.isBlockAlive() &&
19041904
src.blockSize() == tgt.blockSize() &&
1905-
src.getAllocType() == tgt.getAllocType() &&
1905+
((src.isLocal() && tgt.isByval()) ||
1906+
src.getAllocType() == tgt.getAllocType()) &&
19061907
aligned;
19071908
}
19081909

ir/pointer.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ expr Pointer::encodeLoadedByteRefined(
497497
expr Pointer::encodeLocalPtrRefinement(
498498
const Pointer &other, set<expr> &undefs) const {
499499
expr tgt_bid = other.getShortBid();
500-
501500
expr ofs = expr::mkFreshVar("localblk_ofs", expr::mkUInt(0, bits_for_offset));
502501
Pointer this_ofs = *this + ofs;
503502
Pointer other_ofs = other + ofs;
@@ -506,15 +505,19 @@ expr Pointer::encodeLocalPtrRefinement(
506505
bool is_const_bid = this_ofs.getShortBid().isUInt(bid_const) &&
507506
tgt_bid.isUInt(bid_tgt_const);
508507
expr blkrefined;
509-
if (is_const_bid)
510-
// Look into the bytes
508+
if (is_const_bid && this->isByval().isFalse() && other.isByval().isFalse()) {
509+
// Look into the bytes.
510+
// If this or other pointer is byval, blockRefined cannot be used because
511+
// it requires both bids to be local or nonlocal
512+
// In the byval case, return the approximated result by simply checking
513+
// the block properties in the else clause below
511514
blkrefined = m.blockRefined(*this, other, (unsigned)bid_const,
512515
(unsigned)bid_tgt_const, undefs);
513-
else
516+
} else
514517
blkrefined = m.blockPropertiesRefined(*this, other);
515518

516-
return other.isLocal() && getOffset() == other.getOffset() &&
517-
move(blkrefined);
519+
return (other.isLocal() || other.isByval()) &&
520+
getOffset() == other.getOffset() && move(blkrefined);
518521
}
519522

520523
expr Pointer::encodeByValArgRefinement(
@@ -541,7 +544,8 @@ expr Pointer::fninputRefined(const Pointer &other, set<expr> &undef,
541544

542545
expr islocal = isLocal();
543546
expr local = false;
544-
if (!islocal.isFalse() && !other.isLocal().isFalse())
547+
if (!islocal.isFalse() &&
548+
(!other.isLocal().isFalse() || !other.isByval().isFalse()))
545549
local = encodeLocalPtrRefinement(other, undef);
546550

547551
local = (other.isLocal() || other.isByval()) && local;

ir/pointer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ class Pointer {
3737

3838
smt::expr encodeLoadedByteRefined(const Pointer &other,
3939
std::set<smt::expr> &undefs) const;
40+
// Encode the refinement between
41+
// (src ptr, tgt ptr) = (local, local) or (local, byval ptr)
4042
smt::expr encodeLocalPtrRefinement(const Pointer &other,
4143
std::set<smt::expr> &undefs) const;
44+
// Encode the refinement when two ptrs are given as byval args
4245
smt::expr encodeByValArgRefinement(const Pointer &otherByval,
4346
std::set<smt::expr> &undefs,
4447
unsigned byval_size) const;

0 commit comments

Comments
 (0)