1

Couldn't quite understand the meaning of word "clobber". "hit (someone) hard." or "treat or deal with harshly." gcc manual 6.45.2.6 Clobbers

Nate Eldredge
  • 48,811
  • 6
  • 54
  • 82
mzhan017
  • 39
  • 5
  • Does this answer your question? [What is a clobber?](https://stackoverflow.com/questions/41899881/what-is-a-clobber) – yugr Jan 08 '22 at 05:15
  • yugr, thank you. I like the answer from Nate. just want to know the pure meaning of the clobber in the context. – mzhan017 Jan 09 '22 at 08:58

1 Answers1

1

"Clobber" in this context is common jargon for "overwrite arbitrarily". In other words, declaring a register as "clobbered" tells the compiler that this register may be overwritten with some other arbitrary value, and that the compiler should not assume anything about its contents when the asm code completes; its previous value is considered lost.

It's loosely from the meaning "hit": the analogy is that overwriting a register is like damaging or destroying its previous value, as if with physical force.

The manual defines it further down:

Clobbers: A comma-separated list of registers or other values changed by the AssemblerTemplate [...]

Nate Eldredge
  • 48,811
  • 6
  • 54
  • 82
  • I might have included the text from [even further down](https://gcc.gnu.org/onlinedocs/gcc-7.5.0/gcc/Extended-Asm.html#Clobbers): *While the compiler is aware of changes to entries listed in the output operands, the inline asm code may modify more than just the outputs. For example, calculations may require additional registers, or the processor may overwrite a register as a side effect of a particular assembler instruction. In order to inform the compiler of these changes, list them in the clobber list. Clobber list items are either register names or the special clobbers (listed below).* – David Wohlferd Jan 07 '22 at 21:07