[llvm-commits] [llvm-gcc-4.2] r53130 - /llvm-gcc-4.2/trunk/gcc/cgraphunit.c

Dale Johannesen dalej at apple.com
Fri Jul 4 19:29:08 PDT 2008


On Jul 4, 2008, at 11:46 AM, Eric Christopher wrote:

>>>>>
>>
>> If debug_foo is dead, and there are no objects of type foo or foo*
>> (either of which would cause the type to be emitted), why would you
>> want to do this?
>
> As I said, for debugging purposes, i.e. within gdb calling the  
> function.
> Think debug_tree from gcc.

Ah, it wasn't clear from your original mail you were talking about  
debugger-callable
functions, at least to me.  Yes, we do need to consider those, and  
that's the main
argument given in the PR for the 4.2 behavior.  In practice, however,  
gcc's debug
functions are all declared global, which is one reason I found the  
argument unpersuasive.
I don't know about -O0, but many compilers remove dead static  
functions at higher
optimization levels; making those functions static would be  
ineffective if you want
to have any chance of debugging the optimized version.  Therefore, I  
expect people
usually declare them global, as gcc does.  The lack of bug reports is  
supporting evidence.

>> (Apple-centric view):  Also, this is not a change in behavior from  
>> the
>> viewpoint of most users; it restores the 4.0 behavior.  g++'s  
>> behavior
>> changed from 3.3 to 4.0, and changed back from 4.0 to 4.2; I'm not
>> aware of any bug reports about either change.  So I don't believe  
>> this
>> is important to users.
>>
>
> Enh. Drove me nuts when it happened. I had to mark functions
> __attribute__((used)).

Did you file a bug report?

>>>> Make the function non-static.  Note that this only changes behavior
>>>> when compiling C++, not C.  In C++ the same thing already happens
>>>> for
>>>> inline functions and many other cases.
>>
>> This won't work when LTO is on, will it?  You need the explicit
>> "used" (actually, I'm not sure whether LTO honors that, but it ought
>> to).
>
> Well, hopefully people aren't using LTO with O0. That'd just be a
> little weird. :)

Sure, but the point is what to tell users to do.  My expectation is  
that compilers
(not just gcc and llvm) are going to get ever more aggressive about  
removing
dead stuff, so we should recommend "used".




More information about the llvm-commits mailing list