[Bug ipa/104303] [12 regression] gnatmake is miscompiled by IPA/modref

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Mar 31 12:51:00 GMT 2022


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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The store

D.5010.P_BOUNDS = &D.5011;

is

 <component_ref 0x7ffff4e951e0
    type <pointer_type 0x7ffff653b150
        type <record_type 0x7ffff653bf18 string___XUB type_4 DI
            size <integer_cst 0x7ffff6517c00 constant 64>
            unit-size <integer_cst 0x7ffff6517c18 constant 8>
            align:32 warn_if_not_align:0 symtab:0 alias-set 9 canonical-type
0x7ffff653bf18 fields <field_decl 0x7ffff6541260 LB0> Ada size <integer_cst
0x7ffff6517c00 64>
            pointer_to_this <pointer_type 0x7ffff653b150> chain <type_decl
0x7ffff6541428 string___XUB>>
        public unsigned DI size <integer_cst 0x7ffff6517c00 64> unit-size
<integer_cst 0x7ffff6517c18 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set 4 canonical-type
0x7ffff653b150>

    arg:0 <var_decl 0x7ffff4e9a090 D.5010
        type <record_type 0x7ffff653b348 string sizes-gimplified visited type_0
TI
            size <integer_cst 0x7ffff6517c48 constant 128>
            unit-size <integer_cst 0x7ffff6517c60 constant 16>
            align:64 warn_if_not_align:0 symtab:0 alias-set 2 canonical-type
0x7ffff653b348 fields <field_decl 0x7ffff6538ab0 P_ARRAY> context
<translation_unit_decl 0x7ffff6522168 concat5_pkg1.adb> unconstrained array
<unconstrained_array_type 0x7ffff653b540 string>
            pointer_to_this <pointer_type 0x7ffff4e9b498> chain <type_decl
0x7ffff6538c78 string>>
        used ignored TI concat5_pkg1.adb:15:5 size <integer_cst 0x7ffff6517c48
128> unit-size <integer_cst 0x7ffff6517c60 16>
        align:128 warn_if_not_align:0 context <function_decl 0x7ffff4e83900
concat5_pkg1__scan>
        chain <var_decl 0x7ffff4e9a120 D.5011 type <record_type 0x7ffff653bf18
string___XUB>
            addressable used ignored DI concat5_pkg1.adb:15:5 size <integer_cst
0x7ffff6517c00 64> unit-size <integer_cst 0x7ffff6517c18 8>
            align:32 warn_if_not_align:0 context <function_decl 0x7ffff4e83900
concat5_pkg1__scan> chain <var_decl 0x7ffff4e9a240 saved_stack.10>>>
    arg:1 <field_decl 0x7ffff6538b48 P_BOUNDS type <pointer_type
0x7ffff653b150>
        visited unsigned DI <built-in>:0:0 size <integer_cst 0x7ffff6517c00 64>
unit-size <integer_cst 0x7ffff6517c18 8>
        align:64 warn_if_not_align:0 offset_align 128
        offset <integer_cst 0x7ffff6517c30 constant 0> bit-offset <integer_cst
0x7ffff6517c00 64> context <record_type 0x7ffff653b348 string>>>

and the issue is that somehow the summary for

concat5_pkg1.make_failed (D.5010);

only has an base/ref/access node for MODREF_GLOBAL_MEMORY_PARM and
nothing else.  In .modref2 this function is just

void concat5_pkg1.make_failed (struct  s)
{
  struct string___XUB * s$P_BOUNDS;

  <bb 2> [local count: 1073741824]:
  concat5_pkg2.compare (s);
  return;

but we do

modref analyzing 'Concat5_Pkg1.Make_Failed/0' (ipa=0)
Past summary:
  loads:
    Every base
  stores:
    Every base
  Side effects
  Nondeterministic
  Global memory read
  Global memory written
 - Analyzing load: s
   - Read-only or local, ignoring.
 - Analyzing call:concat5_pkg2.compare (s);
 - Function availability <= AVAIL_INTERPOSABLE.
 - modref done with result: tracked.
  loads:
      Base 0: alias set 0
        Ref 0: alias set 0
          access: Base in global memory
  stores:
      Base 0: alias set 0
        Ref 0: alias set 0
          access: Base in global memory
  Side effects
  Nondeterministic
  Global memory read
  Global memory written

so it seems we fail to consider by-value escaping parameters.  Something
like the following, but it does not reproduce with that, so there must
be sth special with the Ada testcase.

struct X { int i; };

void foo (struct X);

static void __attribute__((noinline))
bar (struct X x)
{
  foo (x);
}

void baz ()
{
  struct X x;
  x.i = 1;
  bar (x);
}

Btw, if we disable modref2 the testcase works - so somehow dropping that we
load/store all bases wrecks things.

Honza?


More information about the Gcc-bugs mailing list