On Sat, Jan 05, 2019 at 11:45:42AM -0800, Steve Kargl wrote:
> Execution timeout is: 300
> spawn [open ...]
> STOP 2
> FAIL: gfortran.dg/class_alias.f90   -Os  execution test
> 
> STOP 2 occurs at the end of testcase, so I suspect finalization is messed up.

This is bizarre.  Changing the code where STOP 2 occurs to

  if (var_p%x .ne. 2) then
     print *, var_p%x
     STOP 2
  end if

Compiling with gfortran gives

% gfcx -o z -Os class_alias.f90 && ./z
           2
STOP 2

Something is broken with -Os and your patch.  The original dump
contains

  if (var_p._data->x != 2)
    {
      {
        struct __st_parameter_dt dt_parm.5;

        dt_parm.5.common.filename = &"class_alias.f90"[1]{lb: 1 sz: 1};
        dt_parm.5.common.line = 92;
        dt_parm.5.common.flags = 128;
        dt_parm.5.common.unit = 6;
        _gfortran_st_write (&dt_parm.5);
        _gfortran_transfer_integer_write (&dt_parm.5, &var_p._data->x, 4);
        _gfortran_st_write_done (&dt_parm.5);
      }
      _gfortran_stop_numeric (2, 0);
    }

which looks correct.  The -fdump-tree-optimized looks like var_p has been
sort of skipped. 

  _11 = var_a._data;
  _12 = _11->x;
  if (_12 != 2)
    goto <bb 6>; [0.04%]
  else
    goto <bb 7>; [99.96%]

  <bb 6> [local count: 429153]:
  _gfortran_stop_numeric (1, 0);   

This is the 'if (var_a%x /= 2) STOP 1' chunk.  We jump to <bb 7>,
which is the body of the if-endif block that contains STOP 2.

  <bb 7> [local count: 428982]:
  dt_parm.5.common.filename = &"class_alias.f90"[1]{lb: 1 sz: 1};
  dt_parm.5.common.line = 92;
  MEM[(integer(kind=4) *)&dt_parm.5] = 25769803904;
  _gfortran_st_write (&dt_parm.5);
  _14 = &MEM[(struct test *)_6].x;
  _gfortran_transfer_integer_write (&dt_parm.5, _14, 4);
  _gfortran_st_write_done (&dt_parm.5);
  dt_parm.5 ={v} {CLOBBER};
  _gfortran_stop_numeric (2, 0);

I would expect the basic block <bb 7> to look like

  <bb 7> [local count: xxxxx]
  _13 = var_p._data;
  _14 = _13->x;
  if (_14 != 2)
     goto <bb 8>
  else
     goto <bb 9>

Now, what is <bb 7> above would be the contents of <bb 8> and
<bb 9> would then jump to the deallocation statements.

-- 
Steve

Reply via email to