return address register and liveness

"Rune Ibsen" <>
30 Mar 2003 00:48:17 -0500

          From comp.compilers

Related articles
return address register and liveness (Rune Ibsen) (2003-03-30)
| List of all articles for this month |

From: "Rune Ibsen" <>
Newsgroups: comp.compilers
Date: 30 Mar 2003 00:48:17 -0500
Organization: TDC Internet
Keywords: optimize, registers
Posted-Date: 30 Mar 2003 00:48:17 EST


In the process of writing a small kernel for the Digital AlphaPC
164SX, I'm considering how to make my processes automatically do some
deallocation when the function they are started with terminates. I'm
considering putting the address of some clean-up function in the
return address register just before I let my process run in user mode,
so that this function will be "called" when the procedure
terminates. However, the return address register is a callee-saves
register, so I'm wondering whether the compiler will just overwrite
this register when the process makes it's first function call. I'm
starting an initial process to start executing a function like

void INIT()
      start_proc(print_test, 1000);

where print_test is the function the new process should start executing and
1000 is the size of a user stack. When this start_proc call returns, I would
like INIT to "return" to some clean-up code. But I suspect that the compiler
will let the return address register be overwritten when start_proc is
called, since there is no explicit return-statement at the end of INIT.
In other words, is the value in the return address register always alive, or
will the above start_proc call overwrite the return address without saving
it for later restoring?
I'm using a GCC compiler, but at the moment I haven't got access to the
compiler and therefore cannot provide the exact version. If this or any
other information is needed, please advise me.

Kind regards,

Rune Ibsen

Mvh. Rune Ibsen
Dept. of Mathematics
Dept. of Computer Science
University of Copenhagen

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.