From b6c5a9007a69d9b7dd2b86d69c06134011f6d004 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Sat, 13 Mar 2021 22:54:39 -0500 Subject: [PATCH] Experimental change to only emit assignments for used args Having other compilation issues but want to get this checked in since we need this functionality --- scheme/cyclone/cgen.sld | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/scheme/cyclone/cgen.sld b/scheme/cyclone/cgen.sld index c26fd872..b99ee217 100644 --- a/scheme/cyclone/cgen.sld +++ b/scheme/cyclone/cgen.sld @@ -1824,6 +1824,7 @@ (cps? (let ((i 0) (cstr "") + ;;;(scm-args (ast:lambda-formals->list exp)) (args formals-as-list)) ;; Strip off extra varargs since we will load them ;; up using a different technique @@ -1834,14 +1835,22 @@ ;; Generate code to unpack args into locals w/expected names (for-each (lambda (arg) - (set! cstr (string-append - cstr - arg - " = args[" - (number->string i) - "];" - )) + ;;;(lambda (scm-arg arg) + ;;;(trace:error `(DEBUG ,scm-arg ARG ,arg)) + ;;;(let ((var (adb:get scm-arg))) + ;;; (when (and (> (adbv:ref-count var) 0) + ;;; (not (null? (adbv:ref-by var)))) + (set! cstr (string-append + cstr + arg + " = args[" + (number->string i) + "];" + ) ;)) (set! i (+ i 1))) + ;;;(if has-closure? + ;;; (cdr scm-args) + ;;; scm-args)) (if has-closure? (cdr args) args))