This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix latent bug in add_referenced_vars


Paul Schlie wrote:

Therefore the following comment may not be correct?:

  /* Initializers of external variables are used solely by frontends
     and serve no usefull value for us.  */

(although I may be misunderstanding the patch's effect/intent?)

Hmm, no, that is not what the patch does. Every symbol referenced by the program has to be registered with the optimizers so that we can put the symbol in SSA or FUD-chain form. So, we do an initial scan of the program looking and registering symbols. If you had a global variable

	int V;
	const int *GV = &V;

and then you had code like this:

*GV = ...;

Constant propagation would propagate &V into *GV, yielding *&V, which ends up looking like:

V = ...;

And now we have a completely different symbol on the LHS of the expression. That symbol V needs to be registered with the optimizers, otherwise we ICE sooner or later.

The patch simply ignores non-const DECL_EXTERNALs because the optimizers cannot assume that the initial value of a DECL_EXTERNAL stays the same all the time. So, by ignoring non-const DECL_EXTERNALs, we don't get into walking initializers for things that cgraph doesn't know about.


Diego.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]