[Bug fortran/70696] [Coarray] ICE on EVENT POST of host-associated EVENT_TYPE coarray

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jan 16 09:46:00 GMT 2019


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

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #17 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to vehre from comment #9)
> Author: vehre
> Date: Fri Jan 13 10:22:21 2017
> New Revision: 244407
> 
> URL: https://gcc.gnu.org/viewcvs?rev=244407&root=gcc&view=rev
> Log:
> gcc/testsuite/ChangeLog:
> 
> 2017-01-13  Andre Vehreschild  <vehre@gcc.gnu.org>
> 
> 	PR fortran/70696
> 	* gfortran.dg/coarray/event_3.f08: New test.

What is this test supposed to test? The _.optimized dump shows only:

--cut here--
;; Function main (main, funcdef_no=2, decl_uid=952, cgraph_uid=3,
symbol_order=2) (executed once)

__attribute__((externally_visible))
main (integer(kind=4) argc, character(kind=1) * * argv)
{
  struct FRAME.global_event FRAME.1;
  static integer(kind=4) options.0[7] = {2116, 4095, 0, 1, 1, 0, 31};
  integer(kind=4) _8;

  <bb 2> [local count: 1073741824]:
  _gfortran_set_args (argc_2(D), argv_3(D));
  _gfortran_set_options (7, &options.0[0]);
  _8 = FRAME.1.x;
  if (_8 != 0)
    goto <bb 3>; [0.04%]
  else
    goto <bb 4>; [99.96%]

  <bb 3> [local count: 429497]:
  _gfortran_error_stop_numeric (1, 0);

  <bb 4> [local count: 1073312328]:
  return 0;

}
--cut here--

which results in uninitialized load from FRAME.1. The resulting x86_64 assembly
is:

main:
.LFB2:
        .cfi_startproc
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        call    _gfortran_set_args
        movl    $options.0.3867, %esi
        movl    $7, %edi
        call    _gfortran_set_options
        xorl    %eax, %eax
        addq    $8, %rsp
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc

which does not test anything. While x86_64 optimizers are able to eliminate
uninitialized load, it remains in alpha assembly:

main:
        .frame $30,32,$26,0
        .mask 0x4000000,-32
$LFB2:
        .cfi_startproc
        ldah $29,0($27)         !gpdisp!1        #,,
        lda $29,0($29)          !gpdisp!1        #,,
$main..ng:
        lda $30,-32($30)         #,,
        .cfi_def_cfa_offset 32
        ldq $27,_gfortran_set_args($29)         !literal!3       #,,,
        stq $26,0($30)   #,
        .cfi_offset 26, -32
        .prologue 1
 # event_3.f08:10:   call exchange
        jsr $26,($27),_gfortran_set_args                !lituse_jsr!3    #,,
        ldah $29,0($26)         !gpdisp!4        #
        lda $16,7($31)   #,
        lda $29,0($29)          !gpdisp!4        #,,
        ldah $17,options.0.956($29)             !gprelhigh       # tmp75,,
        lda $17,options.0.956($17)              !gprellow        #,, tmp75
        ldq $27,_gfortran_set_options($29)              !literal!5       #,,,
        jsr $26,($27),_gfortran_set_options             !lituse_jsr!5    #,,
        ldah $29,0($26)         !gpdisp!6        #
 # event_3.f08:17:       if (cnt /= 2) error stop 1
        ldl $1,16($30)   # FRAME.1.x, FRAME.1.x
 # event_3.f08:10:   call exchange
        lda $29,0($29)          !gpdisp!6        #,,
 # event_3.f08:17:       if (cnt /= 2) error stop 1
        bis $31,$31,$31
        bne $1,$L4       #, FRAME.1.x,
 # event_3.f08:10:   call exchange
        mov $31,$0       #,
        ldq $26,0($30)   #,
        lda $30,32($30)  #,,
        .cfi_remember_state
        .cfi_restore 26
        .cfi_def_cfa_offset 0
        ret $31,($26),1
$L4:
        .cfi_restore_state
 # event_3.f08:17:       if (cnt /= 2) error stop 1
        mov $31,$17      #,
        ldq $27,_gfortran_error_stop_numeric($29)               !literal!2     
 #,,,
        lda $16,1($31)   #,
        jsr $26,($27),_gfortran_error_stop_numeric              !lituse_jsr!2  
 #,,
        .cfi_endproc
$LFE2:
        bis $31,$31,$31
        .end main

Please note:

        ldl $1,16($30)   # FRAME.1.x, FRAME.1.x
        ...
        bne $1,$L4       #, FRAME.1.x,

Which loads uninitialized value from the stack and later branches on non-zero
value. When the testcase is sun inside the debugger, it is evident that a
garbage value is loaded from the 16($30) stack location.


More information about the Gcc-bugs mailing list