[fpc-devel] Arm compiler limitation

J. Gareth Moreton gareth at moreton-family.com
Thu Nov 23 21:55:06 CET 2023


Hi everyone,

So one of my recent merge requests 
(https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/516) has 
been having test failures on arm-linux, and this has confused me for a 
while because they don't occur on aarch64-linux (the two platforms share 
the same code in this particular case).  Well, after a lot of debugging 
and random shots in the dark, I've found the problem.

RegModifiedByInstruction and RegInInstruction doesn't handle 
NR_DEFAULTFLAGS on the Arm implementation - it always returns False, so 
calling RegUsedBetween or RegModifiedBetween for the flags register 
always returns a false negative.  The other fault is that it doesn't 
check if the input object is an instruction (there's no "if p.typ <> 
ait_instruction then Exit;" check).

I guess taking a step back and taking a breath can help find the 
solution, so I'll be fixing this with the merge request.

Kit

P.S. The above compiler methods are only used by the peephole optimizer, 
and Arm's peephole optimizer is relatively basic currently.



More information about the fpc-devel mailing list