Browse Source

* x86_64: warn only on negative offsets if rsp is involed, second part of #40113
+ tests

florian 2 years ago
parent
commit
5598ffc210
3 changed files with 35 additions and 1 deletions
  1. 1 1
      compiler/x86/rax86.pas
  2. 17 0
      tests/webtbf/tw40113c.pp
  3. 17 0
      tests/webtbs/tw40113d.pp

+ 1 - 1
compiler/x86/rax86.pas

@@ -854,7 +854,7 @@ begin
                   ;
               end;
 
-              if memoffset < 0 then
+              if ((operands[i].opr.ref.base=NR_ESP) or (operands[i].opr.ref.index=NR_ESP)) and (memoffset < 0) then
               begin
                 Message2(asmr_w_check_mem_operand_negative_offset,
                          //std_op2str[opcode],

+ 17 - 0
tests/webtbf/tw40113c.pp

@@ -0,0 +1,17 @@
+{ %cpu=x86_64 }
+{ %opt=-Sew }
+{ %fail }
+
+{$asmmode intel}
+begin
+	asm
+		movss xmm0, dword ptr [rsp-8] // (2)
+		lea   rax, @table[rip]
+		lea   rsp, [rsp+32]
+		jmp   @next
+		db    0, 1, 2, 3, 4, 5, 6, 7
+	@table:
+		db    8, 9, 10
+	@next:
+	end ['rax', 'xmm0'];
+end.

+ 17 - 0
tests/webtbs/tw40113d.pp

@@ -0,0 +1,17 @@
+{ %cpu=x86_64 }
+{ %opt=-Sew }
+{ %norun }
+
+{$asmmode intel}
+begin
+	asm
+		movss xmm0, dword ptr [rax-8] // (2)
+		lea   rax, @table[rip]
+		lea   rsp, [rsp+32]
+		jmp   @next
+		db    0, 1, 2, 3, 4, 5, 6, 7
+	@table:
+		db    8, 9, 10
+	@next:
+	end ['rax', 'xmm0'];
+end.