https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87984

--- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #18)
> (In reply to Richard Biener from comment #16)
> >   /* Clobber all memory and addressable symbols for asm ("" : : : "memory");
> > */
> >   if (gimple_asm_clobbers_memory_p (stmt))
> >     add_virtual_operand (fn, stmt, opf_def);
> > 
> > that would need to include walking all local and global reg vars and
> > architecturally comparing the underlying register.  Note how
> 
> We could cache a bool in struct function whether the function has any local
> hard register vars and just propagate that info during inlining etc. and
> just add virtual operand if there are any clobbers and any local register
> vars (or with that condition check them).

We could do that, yes.  So iff the semantics really are that arbitrary
local (and global?) reg vars can be clobbered at will in asms then we
have to do this.  If they need to appear in the clobbers we have to
do this whenever the clobbers are not empty [and there are global/local
reg vars].

What about -ffixed-X?  If you consider

  foo ();
  asm (...);
  asm (...);

and the asm not having virtual operands we could end up moving it
across a function call or exchanging the two asm()s.  (no, no
present pass on GIMPLE would do this I think).

I can't find the docs that say that clobbers might be elided in any case
so checking form non-empty clobbers might be enough?  Not sure if it
is generally advised/done to use scratch registers by simply clobbering
them.

Reply via email to