Prechádzať zdrojové kódy

Fix a critical bug in the register allocator (at least for CPUs with seperate address
registers like the M68k): check whether the register type of the base/index register
of the instruction's reference is the same as the one we are doing register allocation
for. Otherwise the address registers can become corrupted.

git-svn-id: trunk@22748 -

svenbarth 12 rokov pred
rodič
commit
2ada9a528b
1 zmenil súbory, kde vykonal 5 pridanie a 2 odobranie
  1. 5 2
      compiler/rgobj.pas

+ 5 - 2
compiler/rgobj.pas

@@ -2056,9 +2056,11 @@ unit rgobj;
                   if regtype in [R_INTREGISTER,R_ADDRESSREGISTER] then
                     with ref^ do
                       begin
-                        if (base <> NR_NO) then
+                        if (base <> NR_NO) and
+                            (getregtype(base)=regtype) then
                           addreginfo(base,instr.spilling_get_operation_type_ref(counter,base));
-                        if (index <> NR_NO) then
+                        if (index <> NR_NO) and
+                            (getregtype(index)=regtype) then
                           addreginfo(index,instr.spilling_get_operation_type_ref(counter,index));
                       end;
                 end;
@@ -2219,6 +2221,7 @@ unit rgobj;
                 begin
                   if regtype in [R_INTREGISTER,R_ADDRESSREGISTER] then
                     begin
+                      { no need to check for the register type here }
                       tryreplacereg(ref^.base);
                       tryreplacereg(ref^.index);
                     end;