Re: cpuid_eax damages registers (2.4.7pre7)

H. Peter Anvin
2001-07-19T23:24:08Z

Julian Anastasov wrote:
>
> Hello,
>
> On Thu, 19 Jul 2001, Linus Torvalds wrote:
>
> > No. It's correct, because cpuid doesn't have any side effects (*), so we
> > don't need to mark it volatile. gcc is free to remove it if nothing uses
> > the outputs, for example. But gcc cannot (and generally does not) ignore
> > outputs that _are_ specified.
>
> My understanding was that eax, ... edx are declared as
> local vars and so their values can't be used out of the current
> function scope, even when they are defined in inline func. So, I
> assume they can be optimized (the fact is that they are not used)
> and may be gcc forgets them. True, may be the docs do not cover
> such situations but my first thought was not to explain everything
> with bugs.
>

Well, your first thought was wrong. It is a bug. Sorry.

However, your argument basically explains why adding "volatile" does work
-- it keeps gcc from thinking that it can optimize away something that it
otherwise couldn't.

However, it's still a bug.

-hpa