View Issue Details

IDProjectCategoryView StatusLast Update
0038022FPCCompilerpublic2020-11-18 21:52
ReporterMarc Weustink Assigned ToFlorian  
Status resolvedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0038022: Invalid use of xmm register to copy argument data to stack
DescriptionWhen 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+}
  v: array of Variant;
  p: Pointer;
  SetLength(v, 2);
  v := VarArrayCreate([0, 127], varByte);
  p := VarArrayLock(v[1]);

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)
TagsNo tags attached.
Fixed in Revision47286
Attached Files


has duplicate 0037316 closedFlorian VarArrayLock does not work 



2020-11-02 23:16

administrator   ~0126701

Can you please check if r47286 helps?

Marc Weustink

2020-11-03 10:55

administrator   ~0126710

It would have helped if I posted a correct example:
 v[1] := VarArrayCreate([0, 127], varByte);

Anyway, I can confirm that it is fixed

Issue History

Date Modified Username Field Change
2020-11-02 10:43 Marc Weustink New Issue
2020-11-02 10:54 Marc Weustink Summary Invalid use of mmx register to copy argument data to stack => Invalid use of xmm register to copy argument data to stack
2020-11-02 10:54 Marc Weustink FPCTarget => -
2020-11-02 23:16 Florian Note Added: 0126701
2020-11-03 10:55 Marc Weustink Note Added: 0126710
2020-11-03 22:45 Florian Assigned To => Florian
2020-11-03 22:45 Florian Status new => resolved
2020-11-03 22:45 Florian Resolution open => fixed
2020-11-03 22:45 Florian Fixed in Version => 3.3.1
2020-11-03 22:45 Florian Fixed in Revision => 47286
2020-11-18 21:52 Florian Relationship added has duplicate 0037316