Invalid use of xmm register to copy argument data to stack
Original Reporter info from Mantis: Marc @mweustink
-
Reporter name: Marc Weustink
Original Reporter info from Mantis: Marc @mweustink
- Reporter name: Marc Weustink
Description:
When an argument passed to a procedure is not aligned on a 16 byte boundary it will raise an exception.
The following program demonstrates it:
program vartest;
{$mode objfpc}{$H+}
uses
Variants;
var
v: array of Variant;
p: Pointer;
begin
SetLength(v, 2);
v := VarArrayCreate([0, 127], varByte);
p := VarArrayLock(v[1]);
end.
It results in an exception in the function VarArrayAsPSafeArray on the line v:=TVarData(a)
the generated code in 3.3.1 is
rtl-objpas\src\inc\variants.pp:3261 v:=TVarData(a);
0000000100019906 660f6f01 movdqa (%rcx),%xmm0
000000010001990A f30f7e4910 movq 0x10(%rcx),%xmm1
000000010001990F 660f7f442420 movdqa %xmm0,0x20(%rsp)
0000000100019915 660fd64c2430 movq %xmm1,0x30(%rsp)
the value of %rcx here is $11BE98
the generated code in 3.2.0 is (which is ok)
rtl-objpas\src\inc\variants.pp:3261 v:=TVarData(a);
0000000100019E7D 488b55f8 mov -0x8(%rbp),%rdx
0000000100019E81 488b02 mov (%rdx),%rax
0000000100019E84 488945d8 mov %rax,-0x28(%rbp)
0000000100019E88 488b4208 mov 0x8(%rdx),%rax
0000000100019E8C 488945e0 mov %rax,-0x20(%rbp)
0000000100019E90 488b4210 mov 0x10(%rdx),%rax
0000000100019E94 488945e8 mov %rax,-0x18(%rbp)
Mantis conversion info:
- Mantis ID: 38022
- OS: Windows
- OS Build: 10
- Build: 47282
- Platform: win64
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 47286 (#d5e20fa6)
- Monitored by: » Petr-K (Petr-K)