fitzgen edited PR #14008.
fitzgen edited PR #14008:
We were previously computing "observed" state per-region, and doing this in a
flow-sensitive manner. Observation flows backwards from observers to the
observed memory state's last mutator, however ourLastStoresis a forwards
flow-sensitive analysis, so its results for observation were not sound.This commit switches observation from being per-region and flow sensitive, to
being per-store instruction and flow insensitive. The set of observed store
instructions is computed up front in the existing fixed point that initializes
each block's initialLastStores. Dead-store elimination guards on its
candidate store not being in the observed-stores set.LastStores::meet_from
adds the last store instruction from each CFG predecessor to the observed-stores
set, which is what fixes the incorrect DSE of a store inside a loop from outside
that loop in #13990.Fixes #13990
:thumbs_up: cfallin submitted PR review:
Thanks for the update -- this looks right to me.
The "don't actually observe at update to same region" bit is really subtle -- basically the postdom check plus forward-flow combine to ensure that at possible overwriters, we see all outbound paths from the original store (there are no escaping/early-returning paths), so we can rely on any partial-overwrite causing a different last-store at that point. The case I had been imagining was where we had a (conflated to same coarse region) not-really-overwriter on a path to a return, so original store was still exposed; but if there is any path to an early return, later store won't postdom earlier store anyway. So :+1:
cfallin commented on PR #14008:
(Merge conflict before this can merge)
fitzgen updated PR #14008.
fitzgen has enabled auto merge for PR #14008.
fitzgen added PR #14008 Alias analysis: Make "observed" state per-instruction and flow insensitive to the merge queue.
:check: fitzgen merged PR #14008.
fitzgen removed PR #14008 Alias analysis: Make "observed" state per-instruction and flow insensitive from the merge queue.
Last updated: Aug 30 2026 at 09:07 UTC