https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105046
Bug ID: 105046 Summary: [enhancement] Allow inline-assembly clobbers to overlap inputs Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: inline-asm Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: ehem+gccbugs at m5p dot com Target Milestone: --- From: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Clobbers-and-Scratch-Registers "Clobber descriptions may not in any way overlap with an input or output operand. For example, you may not have an operand describing a register class with one member when listing that register in the clobber list. Variables declared to live in specific registers (see Explicit Register Variables) and used as asm input or output operands must have no part mentioned in the clobber description. In particular, there is no way to specify that input operands get modified without also specifying them as output operands." Inline assembly language SHOULD be able to clobber inputs. Forcing clobbered inputs to be declared as outputs (which also forces them to be lvalues) is a recipe for introducing bugs into programs. The documentation leaves me with the impression this restriction was introduced with the initial implementation of extended inline assembly language (likely pre-2000). I suspect improvements in the back-end likely mean this can be readily removed. I'm unsure about allowing outputs to overlap clobbers. If the clobber list is treated as a list of registers/memory which are modified, then it would make sense to allow outputs to be clobbered. Issue is whether this is allowing programmers to be sloppy and cause more bugs, versus making the job easier. Alternatively a '-' prefix could be added for marking inputs which are clobbered in the assembly language. This could be a nicer expression, but changes the language.