From b4904deea8d766473e2d1a56eaf39fb98849d0d4 Mon Sep 17 00:00:00 2001 From: sergei Date: Tue, 15 Nov 2016 20:04:27 +0000 Subject: [PATCH] * MIPS: Fixed code generation for PIC global symbols with large offset, resolves #30552. git-svn-id: trunk@34902 - --- .gitattributes | 1 + compiler/mips/cgcpu.pas | 1 + tests/webtbs/tw30552.pp | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 tests/webtbs/tw30552.pp diff --git a/.gitattributes b/.gitattributes index 2c87ee8da1..c759f73659 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15241,6 +15241,7 @@ tests/webtbs/tw30522.pp svneol=native#text/plain tests/webtbs/tw30530.pp svneol=native#text/pascal tests/webtbs/tw30534.pp svneol=native#text/pascal tests/webtbs/tw30537.pp svneol=native#text/pascal +tests/webtbs/tw30552.pp svneol=native#text/pascal tests/webtbs/tw30570.pp svneol=native#text/plain tests/webtbs/tw30572.pp svneol=native#text/plain tests/webtbs/tw3063.pp svneol=native#text/plain diff --git a/compiler/mips/cgcpu.pas b/compiler/mips/cgcpu.pas index ca99ce8880..8365957615 100644 --- a/compiler/mips/cgcpu.pas +++ b/compiler/mips/cgcpu.pas @@ -207,6 +207,7 @@ begin ref.base:=tmpreg1 { offset alone, weird but possible } else begin + tmpreg:=ref.base; if (not base_replaced) then ref.base:=getintregister(list,OS_ADDR); list.concat(taicpu.op_reg_reg_reg(A_ADDU,ref.base,tmpreg,tmpreg1)) diff --git a/tests/webtbs/tw30552.pp b/tests/webtbs/tw30552.pp new file mode 100644 index 0000000000..1e8f8eb557 --- /dev/null +++ b/tests/webtbs/tw30552.pp @@ -0,0 +1,29 @@ +{ %TARGET=linux,android } +{ %OPT=-Cg } +{ This test uncovered code generation bug on MIPS when addressing a large global record + in position-independent way, but of course it cannot hurt to test other CPUs. } +unit Test; + +interface + +type + TMyInnerRecord = packed record + end; + PMyInnerRecord = ^TMyInnerRecord; + TMyRecord = record + ALotOfData: array[0..10000] of Cardinal; + MyPointer: PMyInnerRecord; + end; +var + MyGlobalVariable: TMyRecord; + +implementation + +procedure TestProcedure; +begin + with MyGlobalVariable.MyPointer^ do begin + end; +end; + +begin {main} +end.