https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121235
Bug ID: 121235 Summary: Local register variable constraints aren't respected in extended asm Product: gcc Version: 15.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pi...@nobis-crew.org Target Milestone: --- I was following this documentation page here: https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html And I tried to naively copy/past the given example into compilable code: https://godbolt.org/z/bxj1TToTr In this code, I'm creating a function that's using the example from the documentation, having one input and one output, both with specific constraints on register names. The generated code with the comments shows precisely which register has been assigned, and it's not always respecting those constraints. Basically, when the inner function is compiled as a stand alone function, the constraints are properly respected, which could be by happenstance, but when the inner function is used inline by the outer function, suddenly the compiler is ignoring the constraints for the input values, for virtually every CPU architecture I can think of. The selected output register seems to be properly respected, but this may be happenstance, although the generated code seems to try to respect it nonetheless in some of the architecture, by swapping registers around. Am I reading the documentation wrong? It seems to me the provided example literally doesn't work, for any architecture, nor any version of gcc I can try on godbolt, ever since 4.x. It could simply be that the documentation isn't clear enough, but then this bug might be changed to a documentation bug to clarify what exactly is the only supported use for this feature. Currently, the only workaround I have is to force the function to be noinline.