Re: deadcode optimization

fjh@cs.mu.OZ.AU (Fergus Henderson)
12 Mar 2001 02:35:30 -0500

          From comp.compilers

Related articles
[6 earlier articles]
Re: deadcode optimization fjh@cs.mu.OZ.AU (2001-03-08)
Re: deadcode optimization tgi@netgem.com (2001-03-08)
Re: deadcode optimization rog@vitanuova.com (2001-03-08)
Re: deadcode optimization stonybrk@ix.netcom.com (Norman Black) (2001-03-10)
Re: deadcode optimization stonybrk@ix.netcom.com (Norman Black) (2001-03-10)
Re: deadcode optimization fjh@cs.mu.OZ.AU (2001-03-10)
Re: deadcode optimization fjh@cs.mu.OZ.AU (2001-03-12)
Re: deadcode optimization stonybrk@ix.netcom.com (Norman Black) (2001-03-14)
Re: deadcode optimization stonybrk@ix.netcom.com (Norman Black) (2001-03-14)
Re: deadcode optimization broeker@physik.rwth-aachen.de (Hans-Bernhard Broeker) (2001-03-22)
Re: deadcode optimization marcov@stack.nl (Marco van de Voort) (2001-04-04)
Re: deadcode optimization stonybrk@ix.netcom.com (Norman Black) (2001-04-10)
Re: deadcode optimization marcov@toad.stack.nl (2001-04-12)
| List of all articles for this month |
From: fjh@cs.mu.OZ.AU (Fergus Henderson)
Newsgroups: comp.compilers
Date: 12 Mar 2001 02:35:30 -0500
Organization: Computer Science, University of Melbourne
References: 01-03-012 01-03-022 01-03-034 01-03-060 01-03-068
Keywords: optimize
Posted-Date: 12 Mar 2001 02:35:30 EST

"Norman Black" <stonybrk@ix.netcom.com> writes:
>> This is not so easy: what about static variables ? You can rename
>> them, but you will break debugger compatibility...
>
>It is that easy. Modula-2 and Ada support situations just like C
>static variables. No need to declare anything static, it just happens
>automatically. The compiler handles this easily since all globals in a
>compilation unit go into a single object which only has one bss and/or
>data section. This object is the one I mentioned previously that all
>other objects in the compilation unit archive refer to.


If you do that, then you won't get optimal dead code elimination.
Obviously you won't eliminate unused global data, but furthermore if
the initializers for that data contain function pointers, they can
drag in other unused code.


E.g. consider the following program:


void func(void) {
...
}


static void (*func_ptr)(void) = func;


int main() {
return 0;
}


Proper dead code elimination would eliminate everything except main().
But your suggested technique will drag in func_ptr, func(), and hence
everything that it calls.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
                                                                        | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.