Is store_expr(e,t,v!=m) safe?

Roger Sayle roger@www.eyesopen.com
Sun Apr 6 19:18:00 GMT 2003


I believe I've found a latent problem in expr.c, which may be the
source of (or contribute to) high priority PR optimization/8634.

At the bottom of store_field (around line 5678) is a call to
store_expr, which is shown below:

   return store_expr (exp, to_rtx, value_mode != VOIDmode);

The issue is that the third argument to store_expr, int want_value,
is documented as having the following semantics:

   If WANT_VALUE & 1 is 0, we return NULL, to make sure
   to catch quickly any cases where the caller uses the value
   and fails to set WANT_VALUE.

   If WANT_VALUE & 2 is set, this is a store into a call param on the
   stack, and block moves may need to be treated specially.


Now unless I'm confused, which is often the case, the true value of
the comparison in "value_mode != VOIDmode" is platform dependent, being
either 1 or -1 depending upon the target macro STORE_FLAG_VALUE.
This means on some platforms "want_value & 2" will be true and
on others it'll be false, for the above invocation.


This non-determinism would then control whether or not we use memcpy
to initialize const initializers, potentially including the one given
in the PR.

Could someone confirm the above analysis?  If correct, I'll prepare
a patch to change all affected calls to store_expr, to use the form

	"value_mode != VOIDmode ? 1 : 0"

If incorrect, my apologies, I'm never sure of these kinds of issues.

Many thanks in advance.

Roger
--



More information about the Gcc mailing list