From d6ad7721e67801a0737b38c066e5ae91ff0e2c4f Mon Sep 17 00:00:00 2001 From: florian Date: Tue, 16 Aug 2011 22:43:30 +0000 Subject: [PATCH] * patch by Jeppe Johansen to avoid corruption of frame/stack pointer by pre/post indexed operations, resolves #19679 git-svn-id: trunk@18234 - --- compiler/arm/rgcpu.pas | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/compiler/arm/rgcpu.pas b/compiler/arm/rgcpu.pas index 20879447f2..bad81c5e7f 100644 --- a/compiler/arm/rgcpu.pas +++ b/compiler/arm/rgcpu.pas @@ -62,6 +62,8 @@ unit rgcpu; procinfo; procedure trgintcputhumb2.add_cpu_interferences(p: tai); + var + r : tregister; begin if p.typ=ait_instruction then begin @@ -95,6 +97,27 @@ unit rgcpu; end; end; end; + A_LDRB, + A_STRB, + A_STR, + A_LDR, + A_LDRH, + A_STRH, + A_LDRSB, + A_LDRSH, + A_LDRD, + A_STRD: + { don't mix up the framepointer and stackpointer with pre/post indexed operations } + if (taicpu(p).oper[1]^.typ=top_ref) and + (taicpu(p).oper[1]^.ref^.addressmode in [AM_PREINDEXED,AM_POSTINDEXED]) then + begin + add_edge(getsupreg(taicpu(p).oper[1]^.ref^.base),getsupreg(current_procinfo.framepointer)); + { FIXME: temp variable r is needed here to avoid Internal error 20060521 } + { while compiling the compiler. } + r:=NR_STACK_POINTER_REG; + if current_procinfo.framepointer<>r then + add_edge(getsupreg(taicpu(p).oper[1]^.ref^.base),getsupreg(r)); + end; end; end; end;