OPTIMIZATIONS
Application
-Rp(t|e)
t: Pass large return value by pointer, always with temporary
e: Pass large return value by pointer and temporary elimination
-Rpe
None
None
The Compiler supports this option even though returning a `large' return value may not be as efficient as using an additional pointer. The Compiler introduces an additional parameter for the return value if the return value cannot be passed in registers.
Consider the code in the following listing.
typedef struct { int i[10]; } S; S F(void); S s; void main(void) { s = F(); }
In the above case, with -Rpt, the code will appear as in the following listing.
void main(void) { S tmp; F(&tmp); s = tmp; /* struct copy */ }
The above approach is always correct but not efficient. Instead, pass the destination address directly to the callee. This makes it unnecessary to declare a temporary and a struct copy in the caller (i.e., -Rpe), as shown in the following listing.
void main(void) { F(&s); }
The above example may produce incorrect results for rare cases (for example, if the F() function returns something overlapping s). Because the Compiler does not detect such rare cases, two options are provided: the -Rpt (always correct, but inefficient), or -Rpe (efficient) options.