git: 9front

Download patch

ref: 40ed531364586bb83d3e11f09f795cee0e8e953d
parent: 3c94f448b4a1813197c261fa8db6dcc642c09eaf
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Mar 31 21:30:16 EDT 2015

vl: prevent stack altering instructions to be hoisted above loads

fixes bug with libmemdraw where the linker would hoist
the final ADD $const, SP at the end over loads from the
stack causing the front to fall off once a interrupt hits.

--- a/sys/src/cmd/vl/sched.c
+++ b/sys/src/cmd/vl/sched.c
@@ -85,7 +85,7 @@
 		for(t=s+1; t<=se; t++) {
 			if(!(t->p.mark & LOAD))
 				continue;
-			if(t->p.mark & BRANCH)
+			if(t->p.mark & BRANCH || t->set.ireg & (1<<REGSP))
 				break;
 			if(conflict(s, t))
 				break;
@@ -102,7 +102,7 @@
 
 		/* put schedule fodder above load */
 		for(t=s+1; t<=se; t++) {
-			if(t->p.mark & BRANCH)
+			if(t->p.mark & BRANCH || t->set.ireg & (1<<REGSP))
 				break;
 			if(s > sch && conflict(s-1, t))
 				continue;
@@ -634,7 +634,6 @@
 int
 conflict(Sch *sa, Sch *sb)
 {
-
 	if(sa->set.ireg & sb->used.ireg)
 		return 1;
 	if(sa->set.freg & sb->used.freg)
--