https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104303

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>:

https://gcc.gnu.org/g:8c0ebaf9f586100920a3c0849fb10e9985d7ae58

commit r12-8048-g8c0ebaf9f586100920a3c0849fb10e9985d7ae58
Author: Richard Biener <rguent...@suse.de>
Date:   Thu Apr 7 14:07:54 2022 +0200

    ipa/104303 - miscompilation of gnatmake

    Modref attempts to track memory accesses relative to the base pointers
    which are parameters of functions.
    If it fails, it still makes difference between unknown memory access and
    global memory access.  The second makes it possible to disambiguate with
    memory that is not accessible from outside world (i.e. everything that does
    not escape from the caller function).  This is useful so we do not punt
    when unknown function is called.

    The added ref_may_access_global_memory_p ends up using
    ptr_deref_may_alias_global_p which does not consider escaped automatic
    variables as global.  For modref those are still global since they
    can be accessed from functions called.

    The following adds a flag to the *_global_p APIs indicating whether
    escaped local memory should be considered as global or not and
    removes ref_may_access_global_memory_p in favor of using
    ref_may_alias_global_p with the flag set to true.

    2022-04-07  Richard Biener  <rguent...@suse.de>
                Jan Hubicka  <hubi...@ucw.cz>

            PR ipa/104303
            * tree-ssa-alias.h (ptr_deref_may_alias_global_p,
            ref_may_alias_global_p, ref_may_alias_global_p,
            stmt_may_clobber_global_p, pt_solution_includes_global): Add
            bool parameters indicating whether escaped locals should be
            considered global.
            * tree-ssa-structalias.cc (pt_solution_includes_global):
            When the new escaped_nonlocal_p flag is true also consider
            pt->vars_contains_escaped.
            * tree-ssa-alias.cc (ptr_deref_may_alias_global_p):
            Pass down new escaped_nonlocal_p flag.
            (ref_may_alias_global_p): Likewise.
            (stmt_may_clobber_global_p): Likewise.
            (ref_may_alias_global_p_1): Likewise.  For decls also
            query the escaped solution if true.
            (ref_may_access_global_memory_p): Remove.
            (modref_may_conflict): Use ref_may_alias_global_p with
            escaped locals considered global.
            (ref_maybe_used_by_stmt_p): Adjust.
            * ipa-fnsummary.cc (points_to_local_or_readonly_memory_p):
            Likewise.
            * tree-ssa-dse.cc (dse_classify_store): Likewise.
            * trans-mem.cc (thread_private_new_memory): Likewise, but
            consider escaped locals global.
            * tree-ssa-dce.cc (mark_stmt_if_obviously_necessary): Likewise.

            * gnat.dg/concat5.adb: New.
            * gnat.dg/concat5_pkg1.adb: Likewise.
            * gnat.dg/concat5_pkg1.ads: Likewise.
            * gnat.dg/concat5_pkg2.adb: Likewise.
            * gnat.dg/concat5_pkg2.ads: Likewise.

Reply via email to