./trunk/gcc135/vcs_diff_compiler.patch 2025-10-22-00:31
> uname -a Linux cfarm135 4.18.0-553.69.1.el8_10.ppc64le #1 SMP Mon Aug 11 04:24:05 PDT 2025 ppc64le ppc64le ppc64le GNU/Linux
diff --git a/compiler/aoptobj.pas b/compiler/aoptobj.pas
index ee71bcff0e..bb6eff9b0e 100644
--- a/compiler/aoptobj.pas
+++ b/compiler/aoptobj.pas
@@ -29,7 +29,7 @@
{$i fpcdefs.inc}
-{$if not defined(JVM) and not defined(WASM) and not defined(POWERPC) and not defined (POWERPC64)}
+{$if not defined(JVM) and not defined(WASM)}
{$define CPU_SUPPORTS_OPT_COND_JUMP}
{$endif}
@@ -1261,13 +1261,28 @@ TAOptObj = class(TAoptBaseCpu)
class function TAOptObj.FindLabel(L: TasmLabel; Var hp: Tai): Boolean;
Var TempP: Tai;
+{$ifdef CPU_BC_HAS_SIZE_LIMIT}
+ count: ASizeUInt;
+{$endif CPU_BC_HAS_SIZE_LIMIT}
Begin
TempP := hp;
+{$ifdef CPU_BC_HAS_SIZE_LIMIT}
+ count:=0;
+{$endif CPU_BC_HAS_SIZE_LIMIT}
While Assigned(TempP) and
+{$ifdef CPU_BC_HAS_SIZE_LIMIT}
+ (count < BC_max_distance) and
+{$endif CPU_BC_HAS_SIZE_LIMIT}
(TempP.typ In SkipInstr + [ait_label,ait_align]) Do
If (TempP.typ <> ait_Label) Or
(Tai_label(TempP).labsym <> L)
- Then GetNextInstruction(TempP, TempP)
+ Then
+ begin
+ GetNextInstruction(TempP, TempP);
+{$ifdef CPU_BC_HAS_SIZE_LIMIT}
+ inc(count);
+{$endif CPU_BC_HAS_SIZE_LIMIT}
+ end
Else
Begin
hp := TempP;
diff --git a/compiler/fpcdefs.inc b/compiler/fpcdefs.inc
index aa08b47386..302e1e39bc 100644
--- a/compiler/fpcdefs.inc
+++ b/compiler/fpcdefs.inc
@@ -183,6 +183,7 @@
{$define cpurefshaveindexreg}
{$define SUPPORT_SAFECALL}
{$define SUPPORT_GET_FRAME}
+ {$define CPU_BC_HAS_SIZE_LIMIT}
{$endif powerpc}
{$ifdef powerpc64}
@@ -196,6 +197,7 @@
{$define cpurefshaveindexreg}
{$define cpuno32bitops}
{$define SUPPORT_SAFECALL}
+ {$define CPU_BC_HAS_SIZE_LIMIT}
{$endif powerpc64}
{$ifdef arm}
diff --git a/compiler/globals.pas b/compiler/globals.pas
index 79a34f5c89..2c2ef4fd89 100644
--- a/compiler/globals.pas
+++ b/compiler/globals.pas
@@ -232,6 +232,15 @@ tsettings = record
const
LinkMapWeightDefault = 1000;
+{$ifdef CPU_BC_HAS_SIZE_LIMIT}
+ {$if defined(POWERPC) or defined(POWERPC64)}
+ { instructions are 4-byte long and relative jump distance
+ a signed 16-bit signed integer, code as
+ reduced by a small amount to avoid troubles
+ as distance can be modified by optimizations. }
+ BC_max_distance = ($8000 div 4) - $100;
+ {$endif}
+{$endif CPU_BC_HAS_SIZE_LIMIT}
type
TLinkRec = record