From 71d9269b25f99ea6e965f16004768e377e466186 Mon Sep 17 00:00:00 2001 From: yury Date: Tue, 18 Dec 2018 14:01:57 +0000 Subject: [PATCH] Merged revision(s) 40585-40586 from trunk: * ARM: Remove preindexing and postindexing for LDR in some cases when removing superfluous MOVs. It fixes crash when calling Format() if rtl is compiled with -O3. ........ * Improved the comment. ........ git-svn-id: branches/fixes_3_2@40588 - --- compiler/arm/aoptcpu.pas | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/compiler/arm/aoptcpu.pas b/compiler/arm/aoptcpu.pas index 84234e16a1..16b815159d 100644 --- a/compiler/arm/aoptcpu.pas +++ b/compiler/arm/aoptcpu.pas @@ -433,6 +433,19 @@ Implementation { finally get rid of the mov } taicpu(p).loadreg(0,taicpu(movp).oper[0]^.reg); + { Remove preindexing and postindexing for LDR in some cases. + For example: + ldr reg2,[reg1, xxx]! + mov reg1,reg2 + must be translated to: + ldr reg1,[reg1, xxx] + + Preindexing must be removed there, since the same register is used as the base and as the target. + Such case is not allowed for ARM CPU and produces crash. } + if (taicpu(p).opcode = A_LDR) and (taicpu(p).oper[1]^.typ = top_ref) + and (taicpu(movp).oper[0]^.reg = taicpu(p).oper[1]^.ref^.base) + then + taicpu(p).oper[1]^.ref^.addressmode:=AM_OFFSET; asml.remove(movp); movp.free; end;