spicy icon indicating copy to clipboard operation
spicy copied to clipboard

Fix kill set construction for RHSs which can branch

Open bbannier opened this issue 7 months ago • 1 comments

Related to short-circuiting, this shouldn't always kill the previous declarations, since it might be context-dependent on whether it gets updated or not in assignment expressions:

function void f(int<64> i) {
    local x = "bad";
    local x2 = (i == 10) || ((x = "good") == "good");
    hilti::print(x);
}

Depending on i, x may end up as good or bad. It looks like x = "bad" is added to the kill set after x2, which would be wrong. Happy to punt that for later, but just pointing it out

Image

Originally posted by @evantypanski in https://github.com/zeek/spicy/pull/2126#discussion_r2240205405

bbannier avatar Jul 29 '25 15:07 bbannier

There's something hidden here: || and && are not really best thought of as expressions - they are control flow. If we just modeled them within the CFG as control flow (ie || expression has a branching path) then this issue is solved with current infrastructure

Each expression may then still correspond to a given CFG node that is its closest parent, even if the entire expression itself has multiple control flow nodes.

Then we don't need any special handling for assignment expressions or anything - || will just create a branching path in the CFG like an if (well, because it is an if)

evantypanski avatar Aug 10 '25 20:08 evantypanski