|
@@ -4627,6 +4627,17 @@ implementation
|
|
|
|
|
|
function tcallnode.paraneedsinlinetemp(para: tcallparanode; const pushconstaddr, complexpara: boolean): boolean;
|
|
|
begin
|
|
|
+ { We don't need temps for parameters that are already temps, except if
|
|
|
+ the passed temp could be put in a regvar while the parameter inside
|
|
|
+ the routine cannot be (e.g., because its address is taken in the
|
|
|
+ routine), or if the temp is a const and the parameter gets modified }
|
|
|
+ if (para.left.nodetype=temprefn) and
|
|
|
+ (not(ti_may_be_in_reg in ttemprefnode(para.left).tempflags) or
|
|
|
+ not(tparavarsym(para.parasym).varregable in [vr_none,vr_addr])) and
|
|
|
+ (not(ti_const in ttemprefnode(para.left).tempflags) or
|
|
|
+ (tparavarsym(para.parasym).varstate in [vs_initialised,vs_declared,vs_read])) then
|
|
|
+ exit(false);
|
|
|
+
|
|
|
{ We need a temp if the passed value will not be in memory, while
|
|
|
the parameter inside the routine must be in memory }
|
|
|
if (tparavarsym(para.parasym).varregable in [vr_none,vr_addr]) and
|
|
@@ -4760,17 +4771,6 @@ implementation
|
|
|
)
|
|
|
);
|
|
|
|
|
|
- { We don't need temps for parameters that are already temps, except if
|
|
|
- the passed temp could be put in a regvar while the parameter inside
|
|
|
- the routine cannot be (e.g., because its address is taken in the
|
|
|
- routine), or if the temp is a const and the parameter gets modified }
|
|
|
- if (para.left.nodetype=temprefn) and
|
|
|
- (not(ti_may_be_in_reg in ttemprefnode(para.left).tempflags) or
|
|
|
- not(tparavarsym(para.parasym).varregable in [vr_none,vr_addr])) and
|
|
|
- (not(ti_const in ttemprefnode(para.left).tempflags) or
|
|
|
- (tparavarsym(para.parasym).varstate in [vs_initialised,vs_declared,vs_read])) then
|
|
|
- exit;
|
|
|
-
|
|
|
{ check if we have to create a temp, assign the parameter's
|
|
|
contents to that temp and then substitute the parameter
|
|
|
with the temp everywhere in the function }
|