diff options
author | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-19 19:54:39 +0000 |
---|---|---|
committer | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-19 19:54:39 +0000 |
commit | d7c24a635b8ec7dad69c558a863cf37033f52614 (patch) | |
tree | 34ff2bbd503cd433a6c4ba1b17d55a901bb07019 | |
parent | 8e6c0f149ad55bf103b20a5a1a7e8bf42ca787f5 (diff) | |
download | fpc-d7c24a635b8ec7dad69c558a863cf37033f52614.tar.gz |
* patch by J. Gareth Moreton: AArch64 OptPass1Shift register tracking fault fix, resolves #38691
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@49235 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r-- | compiler/aarch64/aoptcpu.pas | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/compiler/aarch64/aoptcpu.pas b/compiler/aarch64/aoptcpu.pas index 4ef898284e..dc5e327cf2 100644 --- a/compiler/aarch64/aoptcpu.pas +++ b/compiler/aarch64/aoptcpu.pas @@ -379,15 +379,23 @@ Implementation taicpu(hp1).oper[0]^.reg, taicpu(p).oper[1]^.reg, shifterop); + { Make sure the register used in the shifting is tracked all + the way through, otherwise it may become deallocated while + it's still live and cause incorrect optimisations later } + if (taicpu(hp1).oper[0]^.reg <> taicpu(p).oper[1]^.reg) then + begin + TransferUsedRegs(TmpUsedRegs); + UpdateUsedRegs(TmpUsedRegs, tai(p.Next)); + ALlocRegBetween(taicpu(p).oper[1]^.reg, p, hp1, TmpUsedRegs); + end; + taicpu(hp2).fileinfo:=taicpu(hp1).fileinfo; asml.insertbefore(hp2, hp1); - GetNextInstruction(p, hp2); - asml.remove(p); - asml.remove(hp1); - p.free; - hp1.free; - p:=hp2; - DebugMsg('Peephole FoldShiftProcess done', p); + + RemoveInstruction(hp1); + RemoveCurrentp(p); + + DebugMsg('Peephole FoldShiftProcess done', hp2); Result:=true; break; end; |