[cfe-commits] r70971 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGen/function-attributes.c test/CodeGen/functions.c

Chris Lattner clattner at apple.com
Tue May 5 09:22:06 PDT 2009


On May 5, 2009, at 12:22 AM, Eli Friedman wrote:
>> When defining a function whose type has no prototype, make an effort
>> to go back and clean up existing uses of the bitcasted function.   
>> This
>> is not just an optimization: it is required for correctness to get
>> always inline functions to work, see testcases in function- 
>> attributes.c.
>
> I'm curious, why do we model functions with no prototype as varargs in
> the first place?  It seems more consistent with the C definition of
> functions without a prototype to always bitcast to the used function
> type (i.e. model "int a();int b(){return a(1);}" as "call i32 (i32)*
> bitcast (i32()* @a to i32(i32)*)(i32 1)"): that way, issues like this
> would get handled transparently, and we wouldn't be abusing varargs
> (which would, for example, remove the need to set "%al" for such calls
> on x86-64).

This is a really interesting point, but I don't think it changes  
anything here.  We'd still need to have the cast-ripping-out code for  
cases that would introduce the bitcast (like your example).

-Chris



More information about the cfe-commits mailing list