[Bug tree-optimization/124868] [13 Regression] wrong code at -O{s, 2, 3} with "-fno-inline -fno-ipa-sra -fno-ipa-modref -fno-ipa-pure-const" on x86_64-linux-gnu since r13-4686
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jun 16 12:47:11 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124868
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:21bd348e140570a4caf4cc7fa8b5e906724583b6
commit r13-10368-g21bd348e140570a4caf4cc7fa8b5e906724583b6
Author: Richard Biener <rguenther@suse.de>
Date: Mon Apr 13 13:18:00 2026 +0200
tree-optimization/124868 - path isolation wrong-code
The path isolation code mishandles the case where in the same block
there's both a return of a local variable and a dereference of zero
but from different edges. In this case we re-use the produced block
copy for both isolated paths, causing a trap on the path to the
return of a non-local.
The least intrusive change I came up with separates both causes
and transforms, first isolating NULL dereferences and then
isolating returns of non-NULL. This will skip the latter transform
on paths which will now not return anyway.
To avoid duplicate diagnostics the handle_return_addr_local_phi_arg
only diagnoses cases in blocks dominated by the original block, not in
copies which still need SSA update and thus are falsely visited.
PR tree-optimization/124868
* gimple-ssa-isolate-paths.cc (handle_return_addr_local_phi_arg):
Do not diagnose returns in blocks not dominated by the PHI.
(find_implicit_erroneous_behavior): Do two sweeps over PHIs,
first for NULL dereferences and then for local address returns.
* gcc.dg/torture/pr124868.c: New testcase.
(cherry picked from commit 935d483a80c7ab96d4e483e62a5c2cc138409ed3)
More information about the Gcc-bugs
mailing list