diff --git a/scheme/cyclone/cps-optimizations.sld b/scheme/cyclone/cps-optimizations.sld index 2131ff8c..089fe0c3 100644 --- a/scheme/cyclone/cps-optimizations.sld +++ b/scheme/cyclone/cps-optimizations.sld @@ -687,7 +687,8 @@ ;; Helper for the next function (define (inline-prim-call? exp ivars args) - (let ((fast-inline #t)) + (let ((fast-inline #t) + (cannot-inline #f)) ;; faster and safer but (at least for now) misses some ;; opportunities for optimization because it takes a global ;; approach rather than considering the specific variables @@ -695,18 +696,23 @@ (for-each (lambda (v) (with-var v (lambda (var) + (if (adbv:mutated-indirectly? var) + (set! cannot-inline #t)) (if (not (adbv:inlinable var)) (set! fast-inline #f))))) ivars) - (if fast-inline - ;; Fast path, no need for more analysis - fast-inline - ;; Fast path failed, see if we can inline anyway - (call/cc - (lambda (return) - ;(trace:error `(inline-ok? ,exp ,ivars ,args)) - (inline-ok? exp ivars args (list #f) return) - (return #t)))))) + (cond + (cannot-inline #f) + (else + (if fast-inline + ;; Fast path, no need for more analysis + fast-inline + ;; Fast path failed, see if we can inline anyway + (call/cc + (lambda (return) + ;(trace:error `(inline-ok? ,exp ,ivars ,args)) + (inline-ok? exp ivars args (list #f) return) + (return #t)))))))) ;; Make sure inlining a primitive call will not cause out-of-order execution ;; exp - expression to search