Re: [PATCH v9 1/5] x86/boot: Remove "cc" clobber from memcmp()

From: Borislav Petkov

Date: Wed Sep 02 2026 - 19:59:16 EST


On Wed, Sep 02, 2026 at 03:29:44PM +0200, Michael Matz wrote:
> Strictly speaking, on x86, the '=@ccXY' constraints are register outputs
> into normal random integer registers (though they are of course
> initialized in a funny way), while the 'cc' clobber is not a register at
> all, but rather a fuzzy idea of "state" in old cc0-based compilers (which
> the x86 backend isn't anymore since, ... well, about forever, 1999). As
> such they both really don't conflict and ...
>
> > But then I'd expect that gcc would enforce that. I know it can't have it
> > when the clobbers contain input or output regs:
> >
> > In function ‘__memcmp’,
> > inlined from ‘main’ at memcmp.c:25:6:
> > memcmp.c:11:9: error: ‘asm’ operand has impossible constraints or there are not enough registers
> > 11 | asm volatile("test %3, %3\n\t"
> > | ^~~
> >
> > but with "cc" clobbers it works.
>
> ... hence there's nothing to report.

Aaaha, so the enforcement is solely documentation-based. :-)

> In fact what an explicit 'cc' clobber once meant in cc0 backends (that
> indiscriminated flag "state") is manufactured by the non-cc0 backends (all
> of them now) automatically whenever an asm has no flag output constraints at
> all. (On x86 that means it adds the "flags" register (internal name for the
> collection of flag status bits) to the clobber set automatically when there
> are no =@ccXY constraints).
>
> You can regard all 'cc' clobbers as pure source compatibility, they have
> no meaning anymore. But as they are so ubiquitous (even in our own docu),
> they remain recognized.

Ah ok, I see. so we'll simply forget them.

Thanks Micha!

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette