This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH]: Fix unnecessary call clobbering due to type of global_var
On Sun, 5 Dec 2004, Diego Novillo wrote:
Daniel Berlin wrote:
OK. Though, for the test case you had sent privately, we need to find out
why is GV created at all.
* tree-ssa-alias.c (create_global_var): Use void_type_node,
It's this code:
/* Create .GLOBAL_VAR if we have too many call-clobbered
variables. We also create .GLOBAL_VAR when there no
call-clobbered variables to prevent code motion
transformations from re-arranging function calls that may
have side effects. For instance,
int a = f ();
There are no call-clobbered variables in foo(), so it would
be entirely possible for a pass to want to move the call to
f() after the call to g(). If f() has side effects, that
would be wrong. Creating .GLOBAL_VAR in this case will
insert VDEFs for it and prevent such transformations. */
if (n_clobbered == 0
|| ai->num_calls_found * n_clobbered >= (size_t) GLOBAL_VAR_THRESHOLD)
In particular, the n_clobbered == 0 part.
Not only is nothing clobbered in my test case, there are no function
So trivially, this should be "if ((n_clobbered == 0 && ai->num_calls_found > 0)
I'm about to submit a patch for this.
In the long run, we should probably find a nicer way of linking calls that
could have side-effects together in chains, instead of global var.