On 05/23/12 13:45, Steven Schveighoffer wrote:
> On Tue, 22 May 2012 23:31:59 -0400, Alex Rønne Petersen <[email protected]> 
> wrote:
> 
>> On 23-05-2012 05:22, Steven Schveighoffer wrote:
>>
>>> This solution looks crappy to me:
>>>
>>> void gc_collect(void *unused = null);
>>
>> BTW, any compiler with alias analysis and LTO might even decide to remove 
>> the call even with the unused parameter, since it, well, isn't used. I think 
>> we need a language-level solution here.
> 
> The LTO would have to be able to make decisions at link time based on purity, 
> because the call *does* do things, it just doesn't use the parameter.  I have 
> no idea, maybe you are right, it would be a hard problem to fix if this 
> happened.
>

A compiler can, once it notices the unused argument(s), (more or less) easily 
rewrite
(clone) the function and modify the callers to use the new version. And when 
the LTO
pass (re)compiles the program (from the intermediate representation in the 
object files)
it could already see the cloned version, and optimize based on that. So it is 
possible.

artur

Reply via email to