瀏覽代碼

* make sure that registers are of the right type before calling get_alias
on them (could cause crashes or, in very rare instances, wrong spilling
code)

git-svn-id: trunk@15600 -

Jonas Maebe 15 年之前
父節點
當前提交
a75016e67b
共有 1 個文件被更改,包括 10 次插入14 次删除
  1. 10 14
      compiler/x86/rgx86.pas

+ 10 - 14
compiler/x86/rgx86.pas

@@ -123,7 +123,8 @@ implementation
             case ops of
               1 :
                 begin
-                  if (oper[0]^.typ=top_reg) then
+                  if (oper[0]^.typ=top_reg) and
+                     (getregtype(oper[n+0]^.reg)=regtype) then
                     begin
                       if get_alias(getsupreg(oper[0]^.reg))<>orgreg then
                         internalerror(200410101);
@@ -142,21 +143,16 @@ implementation
                   if ops=3 then
                     n:=1;
                   if (oper[n+0]^.typ=top_reg) and
-                     (oper[n+1]^.typ=top_reg) and
-                     (get_alias(getsupreg(oper[n+0]^.reg))<>get_alias(getsupreg(oper[n+1]^.reg))) then
+                     (oper[n+1]^.typ=top_reg) then
                     begin
-                      { One of the arguments shall be able to be replaced }
                       if (getregtype(oper[n+0]^.reg)=regtype) and
                          (get_alias(getsupreg(oper[n+0]^.reg))=orgreg) then
                         replaceoper:=0+n
-                      else
-                        if (getregtype(oper[n+1]^.reg)=regtype) and
-                           (get_alias(getsupreg(oper[n+1]^.reg))=orgreg) then
-                          replaceoper:=1+n
-                      else
-                        internalerror(200704281);
-                    end;
-                  if (oper[n+0]^.typ=top_reg) and
+                      else if (getregtype(oper[n+1]^.reg)=regtype) and
+                         (get_alias(getsupreg(oper[n+1]^.reg))=orgreg) then
+                        replaceoper:=1+n;
+                    end
+                  else if (oper[n+0]^.typ=top_reg) and
                      (oper[n+1]^.typ=top_const) then
                     begin
                       if (getregtype(oper[0+n]^.reg)=regtype) and
@@ -164,8 +160,8 @@ implementation
                         replaceoper:=0+n
                       else
                         internalerror(200704282);
-                    end;
-                  if (oper[n+0]^.typ=top_const) and
+                    end
+                  else if (oper[n+0]^.typ=top_const) and
                      (oper[n+1]^.typ=top_reg) then
                     begin
                       if (getregtype(oper[1+n]^.reg)=regtype) and