Skip to content

Commit 49830fd

Browse files
committed
Fixed argument register re-use in presence of THROW
1 parent 7418945 commit 49830fd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Version 7.0.4
22
- Fixed an issue with casting to different size in nucode
33
- Fixed incorrect line info in some DEBUG statements
4+
- Fixed incorrect re-use of parameter registers near functions that have an ABORT or THROW
45

56
Version 7.0.3
67
- Fixed .fpide search so file names are relative to the .fpide file

backends/asm/optimize_ir.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ static bool FuncUsesArgEx(Operand *func, Operand *arg, bool actually)
980980
return !actually;
981981
} else if (func && func->val) {
982982
Function *funcObj = (Function *)func->val;
983-
if ((/*func->kind == IMM_COG_LABEL ||*/ func->kind == IMM_HUB_LABEL) && (actually || funcObj->is_leaf || FuncData(funcObj)->effectivelyLeaf)) {
983+
if ((/*func->kind == IMM_COG_LABEL ||*/ func->kind == IMM_HUB_LABEL) && (actually || funcObj->is_leaf || FuncData(funcObj)->effectivelyLeaf) && !funcObj->has_throw) {
984984
if (arg->kind != REG_ARG) return true; // subreg or smth
985985
if (arg->val < funcObj->numparams) return true; // Arg used;
986986
if (!actually && arg->val < FuncData(funcObj)->maxInlineArg) return true; // Arg clobbered
@@ -2915,6 +2915,7 @@ int OptimizeShortBranches(IRList *irl)
29152915
// Special case of remapping a local to resultN for when general ReplaceBack fails to do the job
29162916
int OptimizeReturnValues(IRList *irl) {
29172917
if (!curfunc->is_leaf) return 0; // Leaf functions only for now
2918+
if (curfunc->has_throw) return 0; // THROW make it non-leaf
29182919
int change = 0;
29192920

29202921

@@ -5602,7 +5603,7 @@ ExpandInlines(IRList *irl)
56025603
ir = ir_next;
56035604
}
56045605
// If inlining (or previous dead-code optimization...) removed all external calls, mark as leaf.
5605-
if (non_inline_calls==0 && !curfunc->is_leaf && !FuncData(curfunc)->effectivelyLeaf) {
5606+
if (non_inline_calls==0 && !curfunc->is_leaf && !FuncData(curfunc)->effectivelyLeaf && !curfunc->has_throw) {
56065607
FuncData(curfunc)->effectivelyLeaf = true;
56075608
change = true;
56085609
}

0 commit comments

Comments
 (0)