On Wed, Jul 1, 2026 at 9:48 AM Eric Botcazou <[email protected]> wrote: > > Hi, > > this is a regression present on mainline, 16, 15 and 14 branches introduced by > the fix for PR tree-optimization/112653 (PTA and return). What happens is > that DSE incorrectly eliminates a call to __builtin_memcpy, whose destination > is obtained from (an equivalent of) malloc and is ultimately returned from the > function. But this happens only when the dynamic allocation is conditional. > > The difference between the unconditional and conditional cases is: > > ESCAPED_RETURN = { ESCAPED NONLOCAL HEAP(30) } > > vs > > ESCAPED_RETURN = { ANYTHING } > > The proposed fix is to apply in set_uids_in_ptset the same treatment to > ANYTHING in the escaped return case as in the escaped case. > > Tested on x86-64/Linux, OK for all affected branches?
OK for all affected branches - thanks for catching this and adding to test coverage. Thanks, Richard. > > > 2026-07-01 Eric Botcazou <[email protected]> > > * tree-ssa-structalias.cc (set_uids_in_ptset): If ANYTHING is > present in the ESCAPED_RETURN solution, record that the global > solution has an escaped heap if FROM contains a heap variable. > > > 2026-07-01 Eric Botcazou <[email protected]> > > * gnat.dg/opt109.adb: New test. > * gnat.dg/opt109_pkg.ads, gnat.dg/opt109_pkg.adb: New helper. > > -- > Eric Botcazou
