diff options
author | Andy Wingo <wingo@pobox.com> | 2021-04-27 14:51:38 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2021-04-27 14:51:38 +0200 |
commit | 12fa7d115d24fa97879c5b6cde44e93a25221895 (patch) | |
tree | 995cf83033e472e96fc468039397b17583140719 /module | |
parent | 534dd35a3c3e842d8547e83c38e5b67e99af89b5 (diff) | |
download | guile-12fa7d115d24fa97879c5b6cde44e93a25221895.tar.gz |
Fix closure-conversion bug for SCC with all free vars pruned
* module/language/cps/closure-conversion.scm (convert-one): Fix bug when
getting value of SCC whose free variables have been elided. Thanks to
abcdw for the report!
* test-suite/tests/compiler.test ("cse auxiliary definitions"): Remove
spurious newline.
("closure conversion"): New test.
Diffstat (limited to 'module')
-rw-r--r-- | module/language/cps/closure-conversion.scm | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/module/language/cps/closure-conversion.scm b/module/language/cps/closure-conversion.scm index d1492c155..875552b87 100644 --- a/module/language/cps/closure-conversion.scm +++ b/module/language/cps/closure-conversion.scm @@ -504,11 +504,17 @@ Otherwise @var{var} is bound, so @var{k} is called with @var{var}." ;; A not-well-known function with zero free vars. Copy as a ;; constant, relying on the linker to reify just one copy. => (lambda (kfun) - (with-cps cps - (letv var*) - (let$ body (k var*)) - (letk k* ($kargs (#f) (var*) ,body)) - (build-term ($continue k* #f ($const-fun kfun)))))) + ;; It may well be that "var" is the "self" of another + ;; member of an SCC containing just one not-well-known + ;; function. But here we're asking for the value of the + ;; closure, which is the $const-fun of the non-well-known + ;; member. + (let ((kfun (closure-label kfun shared bound->label))) + (with-cps cps + (letv var*) + (let$ body (k var*)) + (letk k* ($kargs (#f) (var*) ,body)) + (build-term ($continue k* #f ($const-fun kfun))))))) ((intset-ref free var) (if (and self-known? (eqv? 1 nfree)) ;; A reference to the one free var of a well-known function. |