Przeglądaj źródła

- Delete all position markers from assembler code before optimization. Markers of this kind are not used by optimizer and are expected to be ignored, but ignoring them requires numerous checks in all target-specific optimizers and currently isn't done correctly. In turn, failure to ignore markers prevents optimization of procedure prologues and epilogues.

git-svn-id: trunk@28647 -
sergei 11 lat temu
rodzic
commit
0b4d54fcb9
1 zmienionych plików z 27 dodań i 0 usunięć
  1. 27 0
      compiler/psub.pas

+ 27 - 0
compiler/psub.pas

@@ -1191,6 +1191,23 @@ implementation
         i : integer;
         varsym : tabstractnormalvarsym;
         {RedoDFA : boolean;}
+
+        procedure delete_marker(anode: tasmnode);
+          var
+            ai: tai;
+          begin
+            if assigned(anode) then
+              begin
+                ai:=anode.currenttai;
+                if assigned(ai) then
+                  begin
+                    aktproccode.remove(ai);
+                    ai.free;
+                    anode.currenttai:=nil;
+                  end;
+              end;
+          end;
+
       begin
         { the initialization procedure can be empty, then we
           don't need to generate anything. When it was an empty
@@ -1581,6 +1598,16 @@ implementation
                not(target_info.system in systems_garbage_collected_managed_types) then
              internalerror(200405231);
 
+            { Position markers are only used to insert additional code after the secondpass
+              and before this point. They are of no use in optimizer. Instead of checking and
+              ignoring all over the optimizer, just remove them here. }
+            delete_marker(entry_asmnode);
+            delete_marker(loadpara_asmnode);
+            delete_marker(exitlabel_asmnode);
+            delete_marker(stackcheck_asmnode);
+            delete_marker(init_asmnode);
+            delete_marker(final_asmnode);
+
 {$ifndef NoOpt}
             if not(cs_no_regalloc in current_settings.globalswitches) then
               begin