Browse Source

* throw an internal error if the reference of lea contains a segment register

florian 3 years ago
parent
commit
1cd8c249b1
1 changed files with 6 additions and 3 deletions
  1. 6 3
      compiler/x86/aoptx86.pas

+ 6 - 3
compiler/x86/aoptx86.pas

@@ -4892,9 +4892,12 @@ unit aoptx86;
         Multiple: TCGInt;
         Multiple: TCGInt;
       begin
       begin
         Result:=false;
         Result:=false;
-        { removes seg register prefixes from LEA operations, as they
-          don't do anything}
-        taicpu(p).oper[0]^.ref^.Segment:=NR_NO;
+
+        { play save and throw an error if LEA uses a seg register prefix,
+          this is most likely an error somewhere else }
+        if taicpu(p).oper[0]^.ref^.Segment<>NR_NO then
+          internalerror(2022022001);
+
         { changes "lea (%reg1), %reg2" into "mov %reg1, %reg2" }
         { changes "lea (%reg1), %reg2" into "mov %reg1, %reg2" }
         if (taicpu(p).oper[0]^.ref^.base <> NR_NO) and
         if (taicpu(p).oper[0]^.ref^.base <> NR_NO) and
            (taicpu(p).oper[0]^.ref^.index = NR_NO) and
            (taicpu(p).oper[0]^.ref^.index = NR_NO) and