1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
int foo(int,int,int,int) ; // not defined to disable inlining
int function_like_foo( int a, int b, int c, int d )
{
// function ike foo: expects initialised values in registers edi, esi, edx, ecx
return a+b+c+d ;
}
int bar()
{
int x = 5 ; // x is optimised away
// tail call with 5, 5, 5, 5 in registers edi, esi, edx, ecx
return foo(x,x,x,x) ;
}
int bar_ub() // silence serious warnings about uninitialised variable (no -Wall -Wextra)
{
int x ; // uninitialised variable
// ergo uninitialised values in registers edi, esi, edx, ecx
// unless the caller of bar_ub set initialized values into these registers,
// foo() would encounter a trap representation for integers
// eg. on windows, the kernel would trap this an throw STATUS_REG_NAT_CONSUMPTION
return foo(x,x,x,x) ;
}
|