Browse Source

- 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 years ago
parent
commit
0b4d54fcb9
1 changed files with 27 additions and 0 deletions
  1. 27 0
      compiler/psub.pas

+ 27 - 0
compiler/psub.pas

@@ -1191,6 +1191,23 @@ implementation
         i : integer;
         i : integer;
         varsym : tabstractnormalvarsym;
         varsym : tabstractnormalvarsym;
         {RedoDFA : boolean;}
         {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
       begin
         { the initialization procedure can be empty, then we
         { the initialization procedure can be empty, then we
           don't need to generate anything. When it was an empty
           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
                not(target_info.system in systems_garbage_collected_managed_types) then
              internalerror(200405231);
              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}
 {$ifndef NoOpt}
             if not(cs_no_regalloc in current_settings.globalswitches) then
             if not(cs_no_regalloc in current_settings.globalswitches) then
               begin
               begin