Avoid calls to realloc for nvptx
Bernd Schmidt
bernds@codesourcery.com
Tue Oct 21 22:01:00 GMT 2014
This is a followup patch for the nvptx port. Since malloc and free are
magically provided by the ptx environment, but realloc is missing, it's
nontrivial to provide an implementation for it. The Fortran frontend
likes to generate calls to realloc, but in one case it seems like we can
compute the old size, and call a function that does malloc/memcpy/free
instead.
It seems desirable to continue calling plain realloc on most targets,
but the decision which function to use must happen after the LTO stage
for it to work when ptx is used as an offload target. The following
patch provides a new builtin function which gets expanded to one of the
two alternatives based on a target macro, and modifies the Fortran
frontend to call the new builtin instead of using realloc directly when
the old size is known.
Bootstrapped and tested on x86_64-linux. Two oddities: the last test run
had some plugin tests failing due to a version check; this went away
when I recompiled gcc/plugin.c - it doesn't seem like the sort of thing
that would be caused by this patch and I didn't see it in any of the
earlier test runs.
The other oddity is that the order of args when realloc is defined by
f95-lang seems reversed. However, fixing this causes infinite loops in
the fre1 pass for some Fortran tests so I've left it as-is for now.
Ok once the nvptx port is in?
Bernd
-------------- next part --------------
A non-text attachment was scrubbed...
Name: realloc.diff
Type: text/x-patch
Size: 12342 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20141021/ed5de9f7/attachment.bin>
More information about the Fortran
mailing list