* fixed some crashes

git-svn-id: trunk@8588 -
This commit is contained in:
florian 2007-09-20 22:28:54 +00:00
parent 4d48f2c6ff
commit 8db40851c0

View File

@ -24,6 +24,7 @@ unit optcse;
{$i fpcdefs.inc}
{ $define csedebug}
{$define csestats}
interface
@ -37,6 +38,7 @@ unit optcse;
uses
globtype,
cclasses,
verbose,
nutils,
nbas,nld,
pass_1,
@ -70,7 +72,9 @@ unit optcse;
function collectnodes(var n:tnode; arg: pointer) : foreachnoderesult;
begin
{ node worth to add? }
if (node_complexity(n)>1) and (tstoreddef(n.resultdef).is_intregable or tstoreddef(n.resultdef).is_fpuregable) then
if (node_complexity(n)>1) and (tstoreddef(n.resultdef).is_intregable or tstoreddef(n.resultdef).is_fpuregable) and
{ adding tempref nodes is worthless but there complexity is probably <= 1 anyways }
not(n.nodetype in [temprefn]) then
begin
plists(arg)^.nodelist.Add(n);
plists(arg)^.locationlist.Add(@n);
@ -119,22 +123,25 @@ unit optcse;
for i:=0 to lists.nodelist.count-1 do
for j:=i+1 to lists.nodelist.count-1 do
begin
if tnode(lists.nodelist[i]).isequal(tnode(lists.nodelist[j])) then
if not(tnode(lists.nodelist[i]).nodetype in [tempcreaten,temprefn]) and
tnode(lists.nodelist[i]).isequal(tnode(lists.nodelist[j])) then
begin
if not(assigned(statements)) then
begin
nodes:=internalstatements(statements);
addstatement(statements,internalstatements(creates));
end;
{$ifdef csedebug}
{$if defined(csedebug) or defined(csestats)}
writeln(' ==== ');
printnode(output,tnode(lists.nodelist[i]));
writeln(' equals ');
printnode(output,tnode(lists.nodelist[j]));
writeln(' ==== ');
{$endif csedebug}
{$endif defined(csedebug) or defined(csestats)}
def:=tstoreddef(tnode(lists.nodelist[i]).resultdef);
if assigned(def) then
begin
if assigned(templist[i]) then
begin
templist[j]:=templist[i];
@ -166,6 +173,9 @@ unit optcse;
printnode(output,statements);
{$endif csedebug}
end;
end
else
internalerror(2007091701);
end;
end;
if assigned(statements) then