Browse Source

* also check if ECX is nonvolatile in is_ecx_used. Not strictly necessary for the current set of i386 calling conventions, but good as an extra safety precaution in case new calling conventions are added or the code is adapted and used on other platforms.

git-svn-id: trunk@25839 -
nickysn 11 years ago
parent
commit
a0723ccfd5
1 changed files with 3 additions and 1 deletions
  1. 3 1
      compiler/i386/cgcpu.pas

+ 3 - 1
compiler/i386/cgcpu.pas

@@ -642,13 +642,15 @@ unit cgcpu;
 
 
       }
       }
 
 
-      { returns whether ECX is used as a parameter }
+      { returns whether ECX is used (either as a parameter or is nonvolatile and shouldn't be changed) }
       function is_ecx_used: boolean;
       function is_ecx_used: boolean;
         var
         var
           i: Integer;
           i: Integer;
           hp: tparavarsym;
           hp: tparavarsym;
           paraloc: PCGParaLocation;
           paraloc: PCGParaLocation;
         begin
         begin
+          if not (RS_ECX in paramanager.get_volatile_registers_int(procdef.proccalloption)) then
+            exit(true);
           for i:=0 to procdef.paras.count-1 do
           for i:=0 to procdef.paras.count-1 do
            begin
            begin
              hp:=tparavarsym(procdef.paras[i]);
              hp:=tparavarsym(procdef.paras[i]);