瀏覽代碼

* add debug statements
* avoid possible problems with unknown ra_ types

git-svn-id: trunk@21304 -

florian 13 年之前
父節點
當前提交
75e62e42e4
共有 1 個文件被更改,包括 17 次插入3 次删除
  1. 17 3
      compiler/aopt.pas

+ 17 - 3
compiler/aopt.pas

@@ -59,8 +59,10 @@ Unit aopt;
   Implementation
 
     uses
+      cutils,
       globtype, globals,
       verbose,
+      cpubase,
       cgbase,
       aoptda,aoptcpu,aoptcpud;
 
@@ -145,9 +147,12 @@ Unit aopt;
                           Else
                             Begin
                               hp1 := tai(p.previous);
+{$ifdef DEBUG_OPTALLOC}
+                              AsmL.InsertAfter(tai_comment.Create(strpnew('Removed allocation of '+std_regname(tai_regalloc(p).Reg))),p);
+{$endif DEBUG_OPTALLOC}
                               AsmL.remove(p);
                               p.free;
-                              p := hp1;                            
+                              p := hp1;
                               { not sure if this is useful, it even skips previous deallocs of the register (FK)
                               hp1 := p;
                               hp2 := nil;
@@ -160,9 +165,9 @@ Unit aopt;
                                   InsertLLItem(tai(hp2.previous), hp2, hp1);
                                 End;
                               }
-                            End;                            
+                            End;
                         End
-                      else
+                      else if tai_regalloc(p).ratype=ra_dealloc then
                         Begin
                           ExcludeRegFromUsedRegs(tai_regalloc(p).Reg,Regs);
                           hp1 := p;
@@ -174,14 +179,23 @@ Unit aopt;
                           If hp2 <> nil Then
                             Begin
                               hp1 := tai(p.previous);
+{$ifdef DEBUG_OPTALLOC}
+                              AsmL.InsertAfter(tai_comment.Create(strpnew('Moved deallocation of '+std_regname(tai_regalloc(p).Reg))),p);
+{$endif DEBUG_OPTALLOC}
                               AsmL.Remove(p);
                               InsertLLItem(hp2, tai(hp2.Next), p);
+{$ifdef DEBUG_OPTALLOC}
+                              AsmL.InsertAfter(tai_comment.Create(strpnew('Moved deallocation of '+std_regname(tai_regalloc(p).Reg)+' here')),hp2);
+{$endif DEBUG_OPTALLOC}
                               p := hp1;
                             End
                           else if findregalloc(tai_regalloc(p).reg, tai(p.next))
                             and getnextinstruction(p,hp1) then
                             begin
                               hp1 := tai(p.previous);
+{$ifdef DEBUG_OPTALLOC}
+                              AsmL.InsertAfter(tai_comment.Create(strpnew('Removed deallocation of '+std_regname(tai_regalloc(p).Reg))),p);
+{$endif DEBUG_OPTALLOC}
                               AsmL.remove(p);
                               p.free;
                               p := hp1;