[PATCH] D13304: Avoid inlining in throw statement

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 8 14:59:52 PDT 2015


Yes, these are functionally equivalent. However, the difference between
these two is that the call to f() in 1st is in sub-expression of throw
statement, while the call in 2nd is not.
If the call is in the sub-expression of throw statements, we can guarantee
that the call is only invoked to be thrown. I just wanted to chase this
clear case.



> On Thu, Oct 8, 2015 at 9:54 AM, <junbuml at codeaurora.org> wrote:
>
>> > I think this actually makes it less general. You would presumably
>> perform
>> > different inlining for:
>> >
>> >   throw f(x, y);
>> >
>> > versus
>> >
>> >   auto k = f(x, y);
>> >   throw k;
>>
>> We need to differentiate between these two. For the second case, we
>> should
>> not add any attribute because it’s not invoked in the EH region and it
>> could have any other purposes other than exception handling. I believe
>> we
>> need to specifically handle only the case where we can guarantee that
>> the
>> call is invoked only in exception handling context.
>
>
> Modulo copying the value returned by f, those two are equivalent, and it's
> entirely reasonable to want to refactor one into the other. Such
> refactoring should not affect the optimizer's behavior on this code. Why
> do
> you think they should be treated differently?
>




More information about the cfe-commits mailing list