[cfe-commits] [patch] Alternative fix for pr9614

Peter Collingbourne peter at pcc.me.uk
Wed Oct 26 13:54:38 PDT 2011


On Wed, Oct 26, 2011 at 04:46:09PM -0400, Rafael Ávila de Espíndola wrote:
>> +  // PR9614. Avoid cases where the source code is lying to us. An available
>> +  // externally function should have an equivalent function somewhere else,
>> +  // but a function that calls itself is clearly not equivalent to the real
>> +  // implementation.
>> +  if (isTriviallyRecursiveViaAsm(F))
>> +    return false;
>> +  if (F->hasAttr<AlwaysInlineAttr>())
>> +    return true;
>> +  if (CodeGenOpts.OptimizationLevel == 0)
>> +    return false;
>> +  return true;
>>
>> Please keep the CodeGenOpts.OptimizationLevel test first, and put the
>> isTriviallyRecursiveViaAsm test at the end.
>
> I did that, but it changes the meaning for always_inline functions. We  
> can always revisit this if one is found in the wild.
>
> ...
>
>
> Besides that, it seems okay to me.

It looks ok to me, but wouldn't it be more efficient to somehow abort
IR generation for the current function if we find ourselves building
a trivially recursive call instruction?

Thanks,
-- 
Peter



More information about the cfe-commits mailing list