Forráskód Böngészése

* arm/a64: Bug fix where instructions optimised into "mov r0,r0"
could leave registers undefined in some circumstances

J. Gareth "Curious Kit" Moreton 1 éve
szülő
commit
1dbcba4796
1 módosított fájl, 16 hozzáadás és 0 törlés
  1. 16 0
      compiler/armgen/aoptarm.pas

+ 16 - 0
compiler/armgen/aoptarm.pas

@@ -541,6 +541,22 @@ Implementation
                     begin
                     begin
                       if MatchOperand(taicpu(next_hp).oper[0]^, taicpu(p).oper[0]^.reg) then
                       if MatchOperand(taicpu(next_hp).oper[0]^, taicpu(p).oper[0]^.reg) then
                         begin
                         begin
+                          { mov r0,r1; mov r1,r1 - remove second MOV here so
+                            so "RedundantMovProcess 2b" doesn't get erroneously
+                            applied }
+                          if MatchOperand(taicpu(next_hp).oper[0]^, taicpu(next_hp).oper[1]^.reg) then
+                            begin
+                              DebugMsg(SPeepholeOptimization + 'Mov2None 2a done', next_hp);
+
+                              if (next_hp = hp1) then
+                                { Don't let hp1 become a dangling pointer }
+                                hp1 := nil;
+
+                              asml.Remove(next_hp);
+                              next_hp.Free;
+                              Continue;
+                            end;
+
                           { Found another mov that writes entirely to the register }
                           { Found another mov that writes entirely to the register }
                           if RegUsedBetween(taicpu(p).oper[0]^.reg, p, next_hp) then
                           if RegUsedBetween(taicpu(p).oper[0]^.reg, p, next_hp) then
                             begin
                             begin