Browse files

Defer contraction pass for variables that are copy-propagated (#874)

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 <>

(cherry picked from commit 285f53d)

Backport conflicts: optimizer.scm, mostly due to ( vs [ braces.
  • Loading branch information...
1 parent 8fc103a commit 20f39f81576c6225b747c9557864366ab9b9ec96 @bunny351 bunny351 committed with Jul 6, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 optimizer.scm
8 optimizer.scm
@@ -231,7 +231,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) ]
@@ -282,7 +283,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)))
(let* ([lparams (node-parameters lval)]
[llist (third lparams)] )
(check-signature var args llist)

0 comments on commit 20f39f8

Please sign in to comment.