further C++ fix opportunities
sam at delftcc.UUCP
sam at delftcc.UUCP
Sat Mar 1 00:46:23 AEST 1986
In article <34200001 at orstcs.UUCP>, nathan at orstcs.UUCP (nathan) writes:
> The "pcc" method [for returning structures] is no longer necessary.
> Now that each routine's type is known, space may be allocated for
> before the call. (Is it?)
Every routine's return type is supposed to be known in regular C, and
indeed, several C compilers (including some PCC-based ones) handle
structure returns the way you suggest.
In any case, as I understand it, C++ is implemented as an extra
pass which outputs C code (PCC intermediate code on some machines?),
and it can't affect the function calling sequence or any other part of
code generation. Even if it could, you want to keep the calling
sequences of C and C++ the same.
> Another problem, already present, now
> becomes evident. In returning a structure, one assigns to fields of a
> local variable, then returns it. This is copied into the return-value
> structure (whether on the stack, or elsewhere), after which the caller
> either copies it again or uses one field. This extra copying seems
> unnecessary. To avoid it, some sort of "self" structure is needed.
An good optimizer should eliminate the local variable-to-return value
copy. Question: are there any that do?
----
Sam Kendall allegra \
Delft Consulting Corp. seismo!cmcl2 ! delftcc!sam
+1 212 243-8700 ihnp4 /
ARPA: delftcc!sam at nyu.ARPA
More information about the Comp.lang.c
mailing list