[Patch] AArch64 OptPass1Shift register tracking fault 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 fault with the OptPass1Shift optimisation that sometimes causes a register to be deallocated when it's still in use, thus permitting incorrect optimisations later on. This specifically caused a crash when the compiler was built with the "-glttt -CriotR" parameters (but which disappeared when -OoNOPEEPHOLE was also specified).
Steps to reproduce:
Apply patch and confirm correct compilation and removal of crash at ppc2 stage when building with "-glttt -CriotR" options.
Additional information:
An example in the System unit (under -O2):
WIthout the Peephole Optimizer:
lsr x3,x3,1
mov x5,x3
.Ll778:
sub x1,x1,x5
.Ll779:
lsl x3,x5,1 <-- x5 is deallocated after this instruction
add x6,x0,x3
Incorrect:
.Ll778:
sub x1,x1,x3,lsr 1 <-- Peephole Optimizer notices that x5 is deallocated after this instruction even though it's actually in use, so mistakenly makes the lsr/sub optimisation
.Ll779:
add x6,x0,x5,lsl 1 <-- x5 is now undefined
Fixed:
lsr x5,x3,1
.Ll778:
sub x1,x1,x5
.Ll779:
add x6,x0,x5,lsl 1 <-- x5 is allocated up to this instruction so lsr/sub isn't optimised above.
Mantis conversion info:
- Mantis ID: 38691
- OS: LInux (Raspberry Pi OS)
- OS Build: 5.4.51-v8+
- Build: r49096
- Platform: aarch64-linux
- Version: 3.2.0
- Fixed in version: 3.3.1
- Fixed in revision: 49235 (#77681333)