Skip to content

Commit 332cbac

Browse files
committed
extend State::isImplied to take context into account
cf AliveToolkit#1149
1 parent a18a3bb commit 332cbac

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

ir/memory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ Memory::AliasSet Memory::computeAliasing(const Pointer &ptr, const expr &bytes,
10281028
expr offset = p.getOffset();
10291029
uint64_t bid;
10301030
if (shortbid.isUInt(bid) &&
1031-
(!isAsmMode() || state->isImplied(p.isInbounds(true)))) {
1031+
(!isAsmMode() || state->isImplied(p.isInbounds(true), true))) {
10321032
if (!is_local.isFalse() && bid < sz_local)
10331033
check_alias(this_alias, true, bid, offset);
10341034
if (!is_local.isTrue() && bid < sz_nonlocal)

ir/pointer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ Pointer::isDereferenceable(const expr &bytes0, uint64_t align,
651651
expr is_log = ptr.isLogical();
652652
expr inbounds = is_asm ? ptr.isInbounds(true) : expr(true);
653653

654-
if (is_asm && !inbounds.isTrue() && m.state->isImplied(inbounds))
654+
if (is_asm && !inbounds.isTrue() && m.state->isImplied(inbounds, domain))
655655
inbounds = true;
656656

657657
optional<expr> log_expr, phy_expr;

ir/state.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,12 +1376,13 @@ void State::finishInitializer() {
13761376
}
13771377
}
13781378

1379-
bool State::isImplied(const expr &e) {
1379+
bool State::isImplied(const expr &e, const expr &e_domain) {
13801380
if (domain.UB.contains(e))
13811381
return true;
13821382

1383-
if (check_expr(domain().notImplies(e), "UB inference", true).isUnsat()) {
1384-
domain.UB.add(e);
1383+
if (check_expr((e_domain && domain()).notImplies(e), "UB inference", true)
1384+
.isUnsat()) {
1385+
domain.UB.add(e_domain.implies(e));
13851386
return true;
13861387
}
13871388
return false;

ir/state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ class State {
335335
bool isInitializationPhase() const { return is_initialization_phase; }
336336
void finishInitializer();
337337

338-
bool isImplied(const smt::expr &e);
338+
bool isImplied(const smt::expr &e, const smt::expr &domain);
339339

340340
auto& getFn() const { return f; }
341341
auto& getMemory() const { return memory; }

0 commit comments

Comments
 (0)