From 2c1158b88e1bbf5aa22e124bb3d213d311058045 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 2 Apr 2018 08:19:55 -0700 Subject: compiler: switch: bugfix: missing mov to oreg. * share/txr/stdlib/compiler.tl (comp-switch): When compiling the shared case of switch (generated by tagbody), we must identify the last fragment's output register and move that to oreg. --- share/txr/stdlib/compiler.tl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index 73258677..c9d9bd05 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -435,10 +435,13 @@ (clabels (mapcar (ret (gensym "l")) cases)) (treg me.(maybe-alloc-treg oreg)) (ifrag me.(compile treg env idx-form)) + last-cfrag (cfrags (collect-each ((cs cases) (lb clabels) (i (range 1))) (let ((cfrag me.(comp-progn oreg env cs))) + (when (eq i ncases) + (set last-cfrag cfrag)) (new (frag oreg ^(,lb ,*cfrag.code @@ -452,6 +455,8 @@ ^(,*ifrag.code (swtch ,ifrag.oreg ,*clabels) ,*(mappend .code cfrags) + ,*(when (and shared last-cfrag) + (maybe-mov oreg last-cfrag.oreg)) ,lend) (uni ifrag.fvars [reduce-left uni cfrags nil .fvars]) (uni ifrag.ffuns [reduce-left uni cfrags nil .ffuns])))))) -- cgit v1.2.3