From f316c42396ce20a3718928b412ebe08faebd9383 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Sun, 11 Nov 2012 01:49:20 +0100 Subject: [PATCH] Add functions referenced by children to their parent. --- src/cmp/cmpflet.lsp | 3 +-- src/cmp/cmplam.lsp | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cmp/cmpflet.lsp b/src/cmp/cmpflet.lsp index 5e97b3b63..6e944e771 100644 --- a/src/cmp/cmpflet.lsp +++ b/src/cmp/cmpflet.lsp @@ -89,8 +89,7 @@ body-c1form))) (defun child-function-p (presumed-parent fun) - (declare (si::c-local) - (optimize speed)) + (declare (optimize speed)) (loop for real-parent = (fun-parent fun) while real-parent do (if (eq real-parent presumed-parent) diff --git a/src/cmp/cmplam.lsp b/src/cmp/cmplam.lsp index c92cc6a69..31527ad88 100644 --- a/src/cmp/cmplam.lsp +++ b/src/cmp/cmplam.lsp @@ -131,7 +131,15 @@ The function thus belongs to the type of functions that ecl_make_cfun accepts." (reduce #'add-referred-variables-to-function (mapcar #'fun-referenced-vars (fun-referenced-funs fun)) :initial-value fun) - (update-fun-closure-type-many (fun-child-funs fun)) + ;; Add all non-global functions which are referenced by children + ;; excluding those created inside this function. + (loop with children = (fun-child-funs fun) + for child in children + do (loop for f in (fun-referenced-funs child) + unless (or (fun-global f) + (child-function-p fun f)) + do (pushnew f (fun-referenced-funs fun))) + finally (update-fun-closure-type-many children)) (update-fun-closure-type fun) (when global (if (fun-closure fun)