Преглед на файлове

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 години
родител
ревизия
2ada9a528b
променени са 1 файла, в които са добавени 5 реда и са изтрити 2 реда
  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
                   if regtype in [R_INTREGISTER,R_ADDRESSREGISTER] then
                     with ref^ do
                     with ref^ do
                       begin
                       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));
                           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));
                           addreginfo(index,instr.spilling_get_operation_type_ref(counter,index));
                       end;
                       end;
                 end;
                 end;
@@ -2219,6 +2221,7 @@ unit rgobj;
                 begin
                 begin
                   if regtype in [R_INTREGISTER,R_ADDRESSREGISTER] then
                   if regtype in [R_INTREGISTER,R_ADDRESSREGISTER] then
                     begin
                     begin
+                      { no need to check for the register type here }
                       tryreplacereg(ref^.base);
                       tryreplacereg(ref^.base);
                       tryreplacereg(ref^.index);
                       tryreplacereg(ref^.index);
                     end;
                     end;