__return_address()
Syntax:
The implicit prototype for the return address intrinsic is:
int __return_address(void)
Functionality:
__return_address() returns the value of the link register that will be used to return from the current function.
The return address intrinsic does not of itself affect the compilers ability to perform optimizations such as function inlining, tail-calling and code sharing. The value returned by __return_address() will reflect the optimizations performed.
If a function call is inlined then the value returned by __return_address() within the inlined function will be the return address for the inlined-into function.
If a function call is tail-called then the value returned by __return_address() within the called function will be the return address for the caller function.
Examples
static int foo() {
return __return_address();
}int bar() {
int i;
i = foo();
return i;
}with inlining enabled compiles to:
bar PROC
MOV r0,lr
BX lr
ENDP
with inlining disabled and tail-calling disabled compiles to:
||foo|| PROC
MOV r0,lr
BX lr
ENDP
bar PROC
STR lr,[sp,#-4]!
BL ||foo||
LDR pc,[sp],#4
ENDP
with inlining disabled and tail-calling enabled compiles to:
||foo|| PROC
MOV r0,lr
BX lr
ENDP
bar PROC
B ||foo||
ENDP