Skip to content

Commit 3ec73cf

Browse files
committed
Deal with the byval case
1 parent d77f885 commit 3ec73cf

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
@@ -1950,7 +1950,8 @@ expr Memory::blockPropertiesRefined(const Pointer &src, const Pointer &tgt)
19501950

19511951
return src.isBlockAlive() == tgt.isBlockAlive() &&
19521952
src.blockSize() == tgt.blockSize() &&
1953-
src.getAllocType() == tgt.getAllocType() &&
1953+
((src.isLocal() && tgt.isByval()) ||
1954+
src.getAllocType() == tgt.getAllocType()) &&
19541955
aligned;
19551956
}
19561957

ir/pointer.cpp

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

515-
return other.isLocal() && getOffset() == other.getOffset() &&
516-
move(blkrefined);
518+
return (other.isLocal() || other.isByval()) &&
519+
getOffset() == other.getOffset() && move(blkrefined);
517520
}
518521

519522
expr Pointer::encodeByValArgRefinement(
@@ -540,7 +543,8 @@ expr Pointer::fninputRefined(const Pointer &other, set<expr> &undef,
540543

541544
expr islocal = isLocal();
542545
expr local = false;
543-
if (!islocal.isFalse() && !other.isLocal().isFalse())
546+
if (!islocal.isFalse() &&
547+
(!other.isLocal().isFalse() || !other.isByval().isFalse()))
544548
local = encodeLocalPtrRefinement(other, undef);
545549

546550
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)