Fix allocate-slots for $kreceive with multiple predecessors
authorAndy Wingo <wingo@pobox.com>
Mon, 21 Jul 2014 09:47:43 +0000 (11:47 +0200)
committerAndy Wingo <wingo@pobox.com>
Mon, 21 Jul 2014 09:47:43 +0000 (11:47 +0200)
* module/language/cps/slot-allocation.scm (allocate-slots): For
  continuations of $call, $callk, and $values with multiple
  predecessors, recalculate the set of live slots.  Fixes miscompilation
  of ice-9/futures.scm:process-future!, broken since the previous patch,
  now that $kreceive continuations can have multiple predecessors.

module/language/cps/slot-allocation.scm

index 92b6e02..d9d53f5 100644 (file)
@@ -635,13 +635,17 @@ are comparable with eqv?.  A tmp slot may be used."
               (match (lookup-cont (idx->label n) dfg)
                 (($ $kclause) n)
                 (($ $kargs names syms body)
+                 (define (compute-k-live k)
+                   (match (lookup-predecessors k dfg)
+                     ((_) post-live)
+                     (_ (recompute-live-slots k nargs))))
                  (let ((uses (vector-ref usev n)))
                    (match (find-call body)
                      (($ $continue k src (or ($ $call) ($ $callk)))
-                      (allocate-call label k uses live post-live))
+                      (allocate-call label k uses live (compute-k-live k)))
                      (($ $continue k src ($ $primcall)) #t)
                      (($ $continue k src ($ $values))
-                      (allocate-values label k uses live post-live))
+                      (allocate-values label k uses live (compute-k-live k)))
                      (($ $continue k src ($ $prompt escape? tag handler))
                       (allocate-prompt label k handler nargs))
                      (_ #f)))