* limit initialization to register variables which really need to be initialized

git-svn-id: trunk@29569 -
This commit is contained in:
florian 2015-01-27 21:51:29 +00:00
parent 0f83e24145
commit 69ac7dd7ef
3 changed files with 16 additions and 5 deletions

View File

@ -4387,7 +4387,7 @@ implementation
var
href : treference;
begin
if (tsym(p).typ=staticvarsym) then
if (tsym(p).typ=staticvarsym) and not(tstaticvarsym(p).noregvarinitneeded) then
begin
{ Static variables can have the initialloc only set to LOC_CxREGISTER
or LOC_INVALID, for explaination see gen_alloc_symtable (PFV) }

View File

@ -1334,13 +1334,21 @@ implementation
{ iterate through life info of the first node }
for i:=0 to dfabuilder.nodemap.count-1 do
begin
if DFASetIn(GetUserCode.optinfo^.life,i) and
{ do not warn about parameters passed by var }
not((tnode(dfabuilder.nodemap[i]).nodetype=loadn) and (tloadnode(dfabuilder.nodemap[i]).symtableentry.typ=paravarsym) and
if DFASetIn(GetUserCode.optinfo^.life,i) then
begin
{ do not warn about parameters passed by var }
if not((tnode(dfabuilder.nodemap[i]).nodetype=loadn) and (tloadnode(dfabuilder.nodemap[i]).symtableentry.typ=paravarsym) and
(tparavarsym(tloadnode(dfabuilder.nodemap[i]).symtableentry).varspez=vs_var) and
{ function result is passed by var but it must be initialized }
not(vo_is_funcret in tparavarsym(tloadnode(dfabuilder.nodemap[i]).symtableentry).varoptions)) then
CheckAndWarn(GetUserCode,tnode(dfabuilder.nodemap[i]));
CheckAndWarn(GetUserCode,tnode(dfabuilder.nodemap[i]));
end
else
begin
if (tnode(dfabuilder.nodemap[i]).nodetype=loadn) and
(tloadnode(dfabuilder.nodemap[i]).symtableentry.typ in [staticvarsym,localvarsym]) then
tabstractnormalvarsym(tloadnode(dfabuilder.nodemap[i]).symtableentry).noregvarinitneeded:=true
end;
end;
end;

View File

@ -220,6 +220,9 @@ interface
currentregloc : TLocation;
{ migrated to a parentfpstruct because of nested access (not written to ppu, because not important and would change interface crc) }
inparentfpstruct : boolean;
{ the variable is not living at entry of the scope, so it does not need to be initialized if it is a reg. var
(not written to ppu, because not important and would change interface crc) }
noregvarinitneeded : boolean;
constructor create(st:tsymtyp;const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);
constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
function globalasmsym: boolean;