On Fri, Jan 30, 2015 at 10:12:35AM +0100, Richard Biener wrote:
> Ok - without digging into why the above would fail with your patch
> (don't see that - the use in the function call can't be &opdd) - let's
> take a step back and decide whether we want to allow user-created
> function descriptors. And if we do that if we should rather expose
> this in a more sensible way to GCC, like with using a (target) builtin.
> Say, force you to do
>
> int (*f) (int) = __builtin_fdesc (opd.fd_func, opd.fd_toc, opd.fd_aux);
> return f (3);
>
> which would allow GCC to even optimize the call to a direct one
> if it (or the target) can fold reads from the __builtin_fdesc argument
> to a function decl. Similar builtins could allow you to inspect
> a function descriptor. That way the actual memory operations
> would be hidden from the middle-end.
That would be my preference too. Constructing the calls this way is so rare
that pessimizing 99.9% of code out there that doesn't ever need this is
IMHO undesirable.
Jakub