https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113293
Alexander Monakov <amonakov at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amonakov at gcc dot gnu.org
--- Comment #3 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
(In reply to KBDeveloper from comment #2)
>
> Ah, that makes sense. I had assumed that taking the address of arg would
> force gcc to store it in memory somewhere.
> Is there a reason why gcc then allocates 8 bytes on the stack and fills r1
> with sp - #7? Or is what I had just UB and gcc can do whatever?
The compiler allocates stack memory for 'arg' and passes the address of 'arg'
to the asm; it is necessary in case the asm does something with it without
reading 'arg' itself. One example would be installing a hardware watchpoint on
that memory location.