Browse files

Copy propagation of local procedure names may re-introduce references…

… to contracted procedures, and thus breaks the invariant that contracted procedures are only referenced once. With certain code patterns (for example in srfi-14-tests.scm as reported by Mario) this could cause the compiler to contract infinitely (if the contracted code contains propagated references to other contractions).

Now contraction is disabled for variables that are "replacing" (i.e.
propagated). Once the propagation has taken place a later optimization
pass will do the contraction.

This fixes #874 (

Signed-off-by: Mario Domenech Goulart <>
  • Loading branch information...
1 parent 1b7b630 commit 285f53dbca729cffb4c4d9ee84e4ba893c882546 @bunny351 bunny351 committed with mario-goulart Jul 6, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 optimizer.scm
@@ -249,7 +249,8 @@
(let ((var (first params)))
(cond ((or (test var 'removable)
- (and (test var 'contractable) (not (test var 'replacing))) )
+ (and (test var 'contractable)
+ (not (test var 'replacing))))
(set! removed-lets (add1 removed-lets))
(walk (second subs) fids gae) )
@@ -312,7 +313,10 @@
(or (test var 'value)
(test var 'local-value))))
(args (cdr subs)) )
- (cond ((test var 'contractable)
+ (cond ((and (test var 'contractable)
+ (not (test var 'replacing))
+ ;; inlinable procedure has changed
+ (not (test (first (node-parameters lval)) 'inline-target)))
;; only called once
(let* ([lparams (node-parameters lval)]
[llist (third lparams)] )

0 comments on commit 285f53d

Please sign in to comment.