ConcatCopy generates movdqa copies for unaligned reference
Summary
System Information
Linux/x86-64, Main branch as of ccc843f9
Steps to reproduce
cd compiler
make cycle
mv ppcx64 $HOME/bin/ppcx1
make FPC=$HOME/bin/ppcx1 LLVM=1 OPT="-O- -gw" clean all
mv ppcx64 $HOME/bin/ppcx1llvm
cd ../rtl/linux
make FPC=$HOME/bin/ppcx1llvm
What is the current bug behavior?
$ run
Starting program: /home/jmaebe/bin/ppcx2llgv -Fi../inc -Fi../x86_64 -Fi../unix -Fix86_64 -FE. -FU../../rtl/units/x86_64-linux -Cg -Fl/usr/lib/gcc/x86_64-linux-gnu/7 -dx86_64 -Us -Sg system.pp
Program received signal SIGSEGV, Segmentation fault.
0x00000000004c7f62 in GETCOPY (this=0x134d7e8) at aasmtai.pas:3135
$ x/i $pc-20
3135 p.oper[i]^:=oper[i]^;
0x4c7f4e <GETCOPY+110>: mov -0x14(%rbp),%edx
0x4c7f51 <GETCOPY+113>: mov 0x40(%rax,%rdx,8),%rax
0x4c7f56 <GETCOPY+118>: mov -0x8(%rbp),%rdx
0x4c7f5a <GETCOPY+122>: mov -0x14(%rbp),%ecx
0x4c7f5d <GETCOPY+125>: mov 0x40(%rdx,%rcx,8),%rdx
=> 0x4c7f62 <GETCOPY+130>: movdqa (%rdx),%xmm0
0x4c7f66 <GETCOPY+134>: movdqa 0x10(%rdx),%xmm1
0x4c7f6b <GETCOPY+139>: movdqa %xmm0,(%rax)
0x4c7f6f <GETCOPY+143>: movdqa %xmm1,0x10(%rax)
0x4c7f74 <GETCOPY+148>: mov -0x8(%rbp),%rdx
$ p/x $rdx
$2 = 0x1498a38
What is the expected (correct) behavior?
ConcatCopy should not use movdqa here, but movdqu. I don't know why it thinks that reference will be 16 bytes aligned.
Other remarks
Unrelated to this issue: GetRefAlignment
should use current_procinfo.framepointer
instead of NR_RBP
. RBP
could be used as a register variable in functions that use the stack pointer as frame pointer.