summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-04-28 18:32:48 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-04-28 18:32:48 +0000
commitf726e6e53dde97c760ab23820481cf0f7028395f (patch)
tree2b30a398aa56e51ae475874cb681720fcf4c4046
parent1fbb209d279976ec88ae20a85a923efba5baa97d (diff)
downloadfpc-f726e6e53dde97c760ab23820481cf0f7028395f.tar.gz
* avoid overflow during register allocation
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@49285 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--compiler/rgobj.pas12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rgobj.pas b/compiler/rgobj.pas
index b4ad622ae1..b0d344f5ae 100644
--- a/compiler/rgobj.pas
+++ b/compiler/rgobj.pas
@@ -2846,8 +2846,10 @@ unit rgobj;
set weigth of the newly allocated register higher than the old one,
so it will selected for spilling with a lower priority than
the original one, this prevents an endless spilling loop if orgreg
- is short living, see e.g. tw25164.pp }
- add_reg_instruction(instr,loadreg,reginfo[orgreg].weight+1);
+ is short living, see e.g. tw25164.pp
+
+ the min trick is needed to avoid an overflow in case weight=high(weight which might happen }
+ add_reg_instruction(instr,loadreg,min(high(reginfo[orgreg].weight)-1,reginfo[orgreg].weight)+1);
ungetregisterinline(list,loadreg);
end;
end;
@@ -2878,8 +2880,10 @@ unit rgobj;
set weigth of the newly allocated register higher than the old one,
so it will selected for spilling with a lower priority than
the original one, this prevents an endless spilling loop if orgreg
- is short living, see e.g. tw25164.pp }
- add_reg_instruction(instr,storereg,reginfo[orgreg].weight+1);
+ is short living, see e.g. tw25164.pp
+
+ the min trick is needed to avoid an overflow in case weight=high(weight which might happen }
+ add_reg_instruction(instr,storereg,min(high(reginfo[orgreg].weight)-1,reginfo[orgreg].weight)+1);
end;
end;