This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/49108] New: Support constructors tied to a variable


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49108

           Summary: Support constructors tied to a variable
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
            Blocks: 18918


Follow up to PR 49106.

There should be the possibility to tie (nested) constructors to a variable (of
the parent function), such that the constructor is optimized away if the parent
function is optimized way.

Fortran example (with -fcoarray=lib):

program main
contains
  subroutine foo()
    integer :: a[*] 
    a = 8
  end subroutine
end program main

Here, "foo()" is never called. With -fcoarray=lib gfortran creates a
constructor function to register the coarray "a" with the library. The
constructor is nested in "foo" - and obviously not needed if the function (or
the variable "a") is optimized away.

Expected: By tying the constructor to the variable, the constructor can be
optimized away if the variable is needed.


Dump of the Fortran program above:

_caf_init.1 ()
{
  a = (integer(kind=4) * restrict)
        _gfortran_caf_register (4, 0, &caf_token.0, 0B, 0B, 0);
}

foo ()
{
  static void * caf_token.0;
  static integer(kind=4) * restrict a;
  void _caf_init.1 (void);

  *a = 8;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]