[fpc-devel] Might need some help with this one
J. Gareth Moreton
gareth at moreton-family.com
Thu Nov 26 21:20:33 CET 2020
Okay, so I have to specify "-MObjfpc -Sh" to get it to compile due to
what the code uses, and the bug still requires the use of -O2 to
appear. However... "fpc -MObjfpc -Sh -O2 -Ooregvar -alr -sr breakp.pp"
produces a bad binary.
I removed the register comments so it's clearer:
#  pChar(result)[i] := BarSym[(progress >= (0.75 + i) / divs) or (i
= int32(divs) - 1) and (progress >= 1)];
jbe .Lj10 <---- Register %ireg27q not initialised if this
instruction branches to .Lj10
movq %ireg31q,%ireg27q <---- Problem register: %ireg27q
movb %ireg35l,(%ireg33q,%ireg27q,1) <---- Problem register: %ireg27q
The problem register is %ireg27q - it's not being initialised if "jbe
.Lj10" branches. By your explanation, it seems that the code generator
is buggy on one of the nodes. Thanks for the tips in isolating where it
could be. To help out, I've attached the node dump file for the test
Gareth aka. Kit
On 26/11/2020 19:04, Yuriy Sydorov via fpc-devel wrote:
> On 26.11.2020 17:34, J. Gareth Moreton via fpc-devel wrote:
>> Hi everyone,
>> So a couple of people have reported that -O2 sometimes produces bad
>> code under x86_64. So far it seems isolated to that CPU.
>> After my own investigations with the attached code, the problem still
>> occurs even if the peephole optimizer is disabled, and the
>> uninitialised register is being allocated within conditional code
>> that is not always executed, rather than before or after it.
>> Anyone with any tips on where to dig next (register allocator, node
>> converter etc.) would be most appreciated!
> First compile with the "-Ooregvar -alr -sr" switches. You will get the
> assembler output with imaginary registers and notes about register
> allocations and de-allocations. Inspect if all is correct at this
> stage. If not then the a code generator of some node is buggy.
> Then compile with "-Ooregvar -alr". If the issue is present only at
> this stage, then the bug is in the register allocator.
> fpc-devel maillist - fpc-devel at lists.freepascal.org
This email has been checked for viruses by Avast antivirus software.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 20088 bytes
Desc: not available
More information about the fpc-devel