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

            Bug ID: 104303
           Summary: [12 regression] gnatmake is miscompiled by IPA/modef
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ebotcazou at gcc dot gnu.org
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Created attachment 52315
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52315&action=edit
Cocatenated  testcase

The build is done at -O2 but the miscompilation already occurs at -O1 since:

2021-12-14  Jan Hubicka  <hubi...@ucw.cz>

        PR ipa/103585
        * ipa-modref-tree.c (modref_access_node::range_info_useful_p): Handle
        MODREF_GLOBAL_MEMORY_PARM.
        (modref_access_node::dump): Likewise.
        (modref_access_node::get_call_arg): Likewise.
        * ipa-modref-tree.h (enum modref_special_parms): Add
        MODREF_GLOBAL_MEMORY_PARM.
        (modref_access_node::useful_for_kill): Handle
        MODREF_GLOBAL_MEMORY_PARM.
        (modref:tree::merge): Add promote_unknown_to_global.
        * ipa-modref.c (verify_arg):New function.
        (may_access_nonescaping_parm_p): New function.
        (modref_access_analysis::record_global_memory_load): New member
        function.
        (modref_access_analysis::record_global_memory_store): Likewise.
        (modref_access_analysis::process_fnspec): Distingush global and local
        memory.
        (modref_access_analysis::analyze_call): Likewise.
        * tree-ssa-alias.c (ref_may_access_global_memory_p): New function.
        (modref_may_conflict): Use it.

I have attached a testcase for the gnat.dg testsuite:
  - gnatchop concat5.txt
  - gnatmake concat5 -O && ./concat5
  - gcc -c concat5_pkg1.adb -O -fdump-tree-dse2-details yields:

;; Function concat5_pkg1.scan (concat5_pkg1__scan, funcdef_no=3, decl_uid=4922,
cgraph_uid=2, symbol_order=1)

ipa-modref: call stmt concat5_pkg1.make_failed (D.5010);
ipa-modref: call to Concat5_Pkg1.Make_Failed/0 does not use ref:
D.5010.P_BOUNDS alias sets: 2->4
ipa-modref: call stmt concat5_pkg1.make_failed (D.5010);
ipa-modref: call to Concat5_Pkg1.Make_Failed/0 does not use ref: D.5010.P_ARRAY
alias sets: 2->6
ipa-modref: call stmt concat5_pkg1.make_failed (D.5010);
ipa-modref: call to Concat5_Pkg1.Make_Failed/0 does not use ref:
VIEW_CONVERT_EXPR<character[1:23]>((*S9b.6_22)[_12 ...]{lb: 1 sz: 1}) alias
sets: 8->8
  Deleted dead store: VIEW_CONVERT_EXPR<character[1:23]>((*S9b.6_22)[_12
...]{lb: 1 sz: 1}) = " should start with \'--\'";

  Deleted trivially dead stmt: _12 = (sizetype) _11;

  Deleted trivially dead stmt: _11 = iftmp.5_14 + 8;

ipa-modref: call stmt concat5_pkg1.make_failed (D.5010);
ipa-modref: call to Concat5_Pkg1.Make_Failed/0 does not use ref: (*S9b.6_22)[1
...]{lb: 1 sz: 1} alias sets: 8->8
  Deleted dead store: (*S9b.6_22)[1 ...]{lb: 1 sz: 1} = "option ";

but the stores are definitively not dead here.

Reply via email to