That saved me so much work! I found the incorrect code - thanks Jonas! Trunk:
... mov x0,x22 bl SYSTEM_$$_NEWUNICODESTRING$INT64$$POINTER mov x23,x0 lsl x2,x22,#1 mov x1,x23 cbnz x20,.Lj3808 adrp x20,:got:FPC_EMPTYCHAR ldr x20,[x20, :got_lo12:FPC_EMPTYCHAR] .Lj3808: add x0,x20,x21,lsl #1 bl SYSTEM_$$_MOVE$formal$formal$INT64 stur x22,[x23, #-8] ... Faulty optimisation: ... mov x0,x22 bl SYSTEM_$$_NEWUNICODESTRING$INT64$$POINTER // mov x23,0 gets removed because the optimiser thinks x23 is no longer in use lsl x2,x22,#1 mov x1,x0 (*) <-- x0 changed to x23 cbnz x20,.Lj3808 adrp x20,:got:FPC_EMPTYCHAR ldr x20,[x20, :got_lo12:FPC_EMPTYCHAR] .Lj3808: add x0,x20,x21,lsl #1 bl SYSTEM_$$_MOVE$formal$formal$INT64 stur x22,[x23, #-8] <-- x23 is still in use (ERROR!) ... Now I just have to work out why the peephole optimiser thinks x23 is no longer in use after it changes (*), and why it hasn't caused a more obvious failure elsewhere. Gareth aka. Kit On Sun 23/08/20 12:09 , "J. Gareth Moreton via fpc-devel" fpc-devel@lists.freepascal.org sent: > Thanks Jonas - I'll see if I can pinpoint it now. > > > > Gareth aka. Kit > > > > On Sun 23/08/20 13:09 , Jonas Maebe via fpc-devel > fpc-devel@lists.freepascal.org sent: > > On 23/08/2020 12:48, J. Gareth Moreton via > fpc-devel wrote: > > > > > > I've found a pretty big optimisation that > > > benefits most ARM platforms, including AArch64, > but I'm getting a few > > random test failures. My investigations suggest > that functions like > > "fpc_chararray_to_unicodestr" and > > > > other string conversion routines are not > being > > optimised properly (they're raising Runtime > Error 216, which generally > > implies a fatal exception). For aarch64 in > particular, which unit contains > > the source code or > > > > implementation for these functions? > > > > > > > > > > > > They're in the system unit (for all platforms). > > > > > > > > > > > > > > > > > > Jonas > > > > > > _______________________________________________ > > > > > > fpc-devel maillist - fpc-devel@lists.freepascal.org > > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel > > > > > > > > > > > > > > > > > > > _______________________________________________ > > fpc-devel maillist - fpc-devel@lists.freepascal.org > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel > > > > > _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel