CALL_USED_REGISTERS help

venkat venkat@acmet.com
Mon Dec 21 08:31:00 GMT 2009


Please see my reply below.

> -----Original Message-----
> From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
> Behalf Of Paulo J. Matos
> Sent: Friday, December 18, 2009 3:43 PM
> To: GCC-help
> Subject: CALL_USED_REGISTERS help
> 
> Hi,
> 
> I am reading the documentation of CALL_USED_REGISTERS and can't help
> but thing there is a typo (even though it is more probable that I am
> not understanding the documentation).
> It says:
> "Like FIXED_REGISTERS but has 1 for each register that is clobbered
> (in general) by function calls as well as for fixed registers. ... If
> a register has 0 in CALL_USED_REGISTERS, the compiler automatically
> saves it on function entry and restores it on function exit, if the
> register is used within the function. "
> 
> Is it has a 1, then it means that the register is clobbered. And 0
> means it is not clobbered. But if it is not clobbered, why does the
> compiler need to save it on function entry and restore it on function
> exit?
> I am not getting it...

This is my understanding.

Please consider the snip of c code as shown below:

(-----Snip-----)
lVar1 = 10 ;  <== allocate a register for lVar1
functioncall()
lVar2= lVar1; <== use the allocated register for ' lVar1'
(-----Snip-----)

If some registers are marked as clobbered, then GCC will not use those
register across function call.

But if some registers are marked as not clobbered, then GCC will allocate
registers across function calls. In such case 'lVar1' will get same register
at both places.

Now compiler must take care of preserving that register on ' functioncall '
entry and restore it on 'functioncall' exit.

> 
> Thanks,
> 
> --
> Paulo Jorge Matos - pocmatos at gmail.com
> http://www.pmatos.net



More information about the Gcc-help mailing list