bc: fix optimizer bug

Fix inlining problem when inlining has been explicitly disabled.

Closes #3309
This commit is contained in:
Matthew Flatt 2020-07-28 12:43:39 -06:00
parent ec0ec8e970
commit 89831c01f6
2 changed files with 23 additions and 1 deletions

View File

@ -6619,6 +6619,28 @@
n)]) n)])
(lambda (x) (h x))))) (lambda (x) (h x)))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Regression test related to single-use variables
;; and disabled inlining
(parameterize ([compile-context-preservation-enabled #t]
[current-namespace (make-base-namespace)])
(void
(compile
'(module m racket/base
(letrec ([f (lambda () 0)]
[g (let ([g2
(lambda ()
(let ([x (f)])
(list (lambda () x) h)))])
g2)]
[h (letrec ([loop
(lambda ()
(let ([y (g)])
(list y loop)))])
loop)])
h)))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs) (report-errs)

View File

@ -9622,7 +9622,7 @@ Scheme_Object *optimize_expr(Scheme_Object *expr, Optimize_Info *info, int conte
int save_fuel = info->inline_fuel, save_no_types = info->no_types; int save_fuel = info->inline_fuel, save_no_types = info->no_types;
int save_vclock, save_aclock, save_kclock, save_sclock; int save_vclock, save_aclock, save_kclock, save_sclock;
info->size -= 1; info->size -= 1;
info->inline_fuel = 0; /* no more inlining; o->expr was already optimized */ info->inline_fuel = -1; /* no more inlining; o->expr was already optimized */
info->no_types = 1; /* cannot used inferred types, in case `val' inferred them */ info->no_types = 1; /* cannot used inferred types, in case `val' inferred them */
save_vclock = info->vclock; /* allowed to move => no change to clocks */ save_vclock = info->vclock; /* allowed to move => no change to clocks */
save_aclock = info->aclock; save_aclock = info->aclock;