[llvm-dev] Allow CallSlot optimization for throwing functions for sret arguments

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 5 13:06:35 PST 2018


On 3/5/2018 6:16 AM, Björn Steinbrink wrote:
> The difference between that PR and this case is that the code in the
> PR took a reference through which the value was modified, while in
> this case we deal with a return value through an sret argument. I'm
> wondering whether the "must not throw" restriction could be relaxed in
> this case, to only apply when the destination is not an sret argument.
> Given that the return value is only valid when the function does not
> throw, it seems that the caller is always responsible to ensure that
> the value behind the sret pointer is only used in that case,
> introducing a temporary as necessary. Does that seem right?

I'm not sure we want to continue to overload the meaning of "sret" like 
this... the sret attribute affects the ABI on some targets, and we 
probably want to separate the ABI effect from the optimization hint.  So 
we should introduce a new attribute to support this sort of 
optimization, I think.

But yes, that's the right idea: you can optimize more aggressively if 
you know the temporary will be discarded if the call throws an 
exception.  (You can actually optimize in multiple places; see, for 
example, isKnownNonEscaping in LICM.)

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list