Re: Global versus Stack variables

henry@spsystems.net (Henry Spencer)
21 Nov 2005 22:43:24 -0500

          From comp.compilers

Related articles
Global versus Stack variables shreyas76@gmail.com (shrey) (2005-11-19)
Re: Global versus Stack variables oliverhunt@gmail.com (oliverhunt@gmail.com) (2005-11-21)
Re: Global versus Stack variables gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-11-21)
Re: Global versus Stack variables henry@spsystems.net (2005-11-21)
Re: Global versus Stack variables torbenm@app-5.diku.dk (2005-11-21)
Re: Global versus Stack variables jatin.bhateja@amdocs.com (Jatin Bhateja) (2005-11-26)
Re: Global versus Stack variables napi@cs.indiana.edu (2005-11-26)
Re: Global versus Stack variables david.thompson1@worldnet.att.net (Dave Thompson) (2005-12-05)
| List of all articles for this month |

From: henry@spsystems.net (Henry Spencer)
Newsgroups: comp.compilers
Date: 21 Nov 2005 22:43:24 -0500
Organization: SP Systems, Toronto, Canada
References: 05-11-094
Keywords: design, optimize, storage

shrey <shreyas76@gmail.com> wrote:
>...What is the impact of a variable being a global or a local
>variable on optimizations. In other words, is it likelier to produce
>better code if a variable is local than global...


Broadly speaking, the more the compiler knows about how and where a
variable is used, the better the code it can produce. Particularly in
compiler systems that support separate compilation, it's often very
difficult to do any real optimization involving global variables, because
when compiling any particular module/procedure/etc., the compiler doesn't
know the whole story of how the variable is used. It's usually much
easier for a compiler to know everything about a local variable.
--
spsystems.net is temporarily off the air; | Henry Spencer
mail to henry at zoo.utoronto.ca instead. | henry@spsystems.net


Post a followup to this message

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