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: [PATCH 0/2] Require that constraints are used to reference global regs


Hi,

On Mon, 23 Apr 2018, Alexander Monakov wrote:

> In discussion of proposed fix for PR 44281 Michael said:
> [ https://gcc.gnu.org/ml/gcc-patches/2016-02/msg01963.html ]
> > [...] What I mean to say is, the following is currently proper use of 
> > global reg vars:
> > 
> > ----
> > register uint64_t ugh __asm__("rbx"); //r11, whatever
> > void write_into_ugh (void)
> > {
> >   asm volatile ("mov 1, %%rbx" :::);
> >   assert (ugh == 1);
> > }
> > ----
> > 
> > %rbx would have to be implicitly used/clobbered by the asm. [...]
> 
> I am skeptical. It is not documented 

In your follow-up patches you actually change the very documentation that 
makes the above valid and supported ...

> and it's not hard to come up with 
> examples where optimizations break this sort of usage, e.g.:

... meaning that all these cases are actually bugs to be fixed.

> In general it is impossible to make GCC "think" that asms may access 
> arbitrary global register variables by only patching DF. There's GIMPLE, 
> and on RTL there are other scanners beside DF (in fact PR 79985 that I 
> intend to close this way is due to sched-deps having other ideas than 
> DF).

Sure, so the other scanners need fixing as well.  An alternative is to 
massage the asms while constructing them (e.g. gimplification time) to 
read and write all global reg var registers.  Then all scanners will 
automatically work.

> So this never worked anywhere near reliably

I think you're exaggerating this, it worked fine in old compilers, in 
particular before DF, and it still works fine mostly, when you aren't 
knowning compiler internals to construct counter examples.

> and we should simply adjust the documentation to say that asms must use 
> constraints to say how they are accessing global reg vars.

IMHO we can't define our bugs away in this way, after saying for 
decades how something is supposed to work.  Especially not rushing it in a 
couple days before release.

So, I disagree with the intent of the patches.  If we were designing this 
extension of global reg vars from scratch I'd do as you suggest, but 
unfortunately we aren't.


Ciao,
Michael.


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