[Patch] ARM -CriotR crash fix
Original Reporter info from Mantis: CuriousKit @CuriousKit
-
Reporter name: J. Gareth Moreton
Original Reporter info from Mantis: CuriousKit @CuriousKit
- Reporter name: J. Gareth Moreton
Description:
This patch fixes a build error when making the compiler under -CriotR options on arm platforms. The fault was due to RedundantMovProcess(p,hpfar1) causing hpfar1 to become a dangling pointer while still returning False (since p wasn't changed). To compensate and to ensure maximal compiler performance, the 2nd parameter of RedundantMovProcess is now a var parameter and if the instruction is removed, it is set to nil, hence causing hpfar1 to become nil which can be easily detected (in which case, the control flow returns to the beginning of the new 'while' loop, which previously was an 'if' statement that caused the subroutine to exit if hpfar1 couldn't be set).
Steps to reproduce:
Apply patch and confirm correct compilation, both normally and under -CriotR conditions.
Additional information:
Due to the construction of the while loop, the compiler is now sometimes more efficient under -O1 and -O2. For example, in the Classes disassembly:
.section .text.n_classes$_$tstream_$__$$_setsize64$int64,"ax"
.balign 4
.globl CLASSES$_$TSTREAM_$__$$_SETSIZE64$INT64
.type CLASSES$_$TSTREAM_$__$$_SETSIZE64$INT64,#function
CLASSES$_$TSTREAM_$__$$_SETSIZE64$INT64:
stmfd r13!,{r3,r14}
mov r1,r0 ; <-- Not optimal
ldr r1,[r1]
ldr r1,[r1, 124]
blx r1
ldmfd r13!,{r3,r15}
.Le38:
.size CLASSES$_$TSTREAM_$__$$_SETSIZE64$INT64, .Le38 - CLASSES$_$TSTREAM_$__$$_SETSIZE64$INT64
Under the patch:
.section .text.n_classes$_$tstream_$__$$_setsize64$int64,"ax"
.balign 4
.globl CLASSES$_$TSTREAM_$__$$_SETSIZE64$INT64
.type CLASSES$_$TSTREAM_$__$$_SETSIZE64$INT64,#function
CLASSES$_$TSTREAM_$__$$_SETSIZE64$INT64:
stmfd r13!,{r3,r14}
ldr r1,[r0] ; <-- Optimised
ldr r1,[r1, 124]
blx r1
ldmfd r13!,{r3,r15}
.Le38:
.size CLASSES$_$TSTREAM_$__$$_SETSIZE64$INT64, .Le38 - CLASSES$_$TSTREAM_$__$$_SETSIZE64$INT64
Mantis conversion info:
- Mantis ID: 38116
- OS: Linux (Raspberry Pi OS)
- OS Build: 5.4.51-v8+
- Build: r47529
- Platform: arm (32-bit)
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 47531 (#1014e530)