Take the following fortran code (were we know that write does not make the pointer escape): program main dimension x(10) write(3)n,(x(n),n=1,10) end
in the last tree dump we get: _gfortran_transfer_integer (&n, 4); n = 1; <L0>:; _gfortran_transfer_real (&x[n + -1], 4); n.3 = n; n = n.3 + 1; if (n.3 == 10) goto <L4>; else goto <L0>; See how n is marked as not a gimple variable which causes us to store it on the stack. Even though we know that _gfortran_transfer_real will not cause the pointer to escape. There should be a new attribute to mark functions as causing pointers not to escape at all. -- Summary: Pointer does not really escape with write Product: gcc Version: 4.0.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20165