code: plan9front

Download patch

ref: fc412aef3d073e9228f1179d597e33a9f7132a29
parent: 3473fa237ca0a639e82a589a9192244684cdc9a6
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Nov 16 20:23:57 EST 2021

6c: extern registers must be considered used on return

the peephole optimizer would remove stores to extern
register before a return statement as it would think
they are only set, but not used.

--- a/sys/src/cmd/6c/peep.c
+++ b/sys/src/cmd/6c/peep.c
@@ -890,6 +890,8 @@
 		return 0;
 
 	case ARET:	/* funny */
+		if(REGEXT && v->type <= REGEXT && v->type > exregoffset)
+			return 2;
 		if(v->type == REGRET || v->type == FREGRET)
 			return 2;
 		if(s != A)