Enable prompt analysis
authorAndy Wingo <wingo@pobox.com>
Thu, 9 Jan 2014 18:23:03 +0000 (19:23 +0100)
committerAndy Wingo <wingo@pobox.com>
Sat, 11 Jan 2014 15:01:11 +0000 (16:01 +0100)
* module/language/cps/dfg.scm (compute-live-variables, visit-fun):
  Use the new prompt analysis pass in analyze-control-flow instead of
  always adding a link in the DFG.  Avoids problems if there are
  parts of the prompt body that have no path to the pop.

module/language/cps/dfg.scm

index 722e325..661bbfe 100644 (file)
@@ -708,7 +708,8 @@ BODY for each body continuation in the prompt."
       (values mapping n)))
   (call-with-values (lambda () (make-variable-mapping (dfg-use-maps dfg)))
     (lambda (var-map nvars)
-      (let* ((cfa (analyze-control-flow fun dfg #:reverse? #t))
+      (let* ((cfa (analyze-control-flow fun dfg #:reverse? #t
+                                        #:add-handler-preds? #t))
              (syms (make-vector nvars #f))
              (names (make-vector nvars #f))
              (usev (make-vector (cfa-k-count cfa) '()))
@@ -846,18 +847,7 @@ BODY for each body continuation in the prompt."
 
          (($ $prompt escape? tag handler pop)
           (use! tag)
-          (use-k! handler)
-          ;; Any continuation in the prompt body could cause an abort to
-          ;; the handler, so in theory we could register the handler as
-          ;; a successor of any block in the prompt body.  That would be
-          ;; inefficient, though, besides being a hack.  Instead we take
-          ;; advantage of the fact that pop continuation post-dominates
-          ;; the prompt body, so we add a link from there to the
-          ;; handler.  This creates a primcall node with multiple
-          ;; successors, which is not quite correct, but it does reflect
-          ;; control flow.  It is necessary to ensure that the live
-          ;; variables in the handler are seen as live in the body.
-          (link-blocks! pop handler))
+          (use-k! handler))
 
          (($ $fun)
           (when global?