better "cannot stack allocate" compiler notes
authorNikodemus Siivola <nikodemus@random-state.net>
Fri, 9 Dec 2011 09:53:18 +0000 (11:53 +0200)
committerNikodemus Siivola <nikodemus@random-state.net>
Fri, 9 Dec 2011 11:38:15 +0000 (13:38 +0200)
  When the note refers to failure to allocate an argument,
  say so -- instead of claiming to be unable to stack allocate
  the entire function, which is both silly and wrong.

  Also prettier formatting.

NEWS
src/compiler/ir1util.lisp

diff --git a/NEWS b/NEWS
index f1498bf..f082d0d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,8 @@ changes relative to sbcl-1.0.54:
     (regression since 1.0.53)
   * bug fix: attempts to stack allocate a required argument to a function with
     an external entry point caused compiler-errors.
+  * bug fix: compiler notes for failed stack allocation for a function argument
+    no longer claim to be unable to stack allocate the function.
 
 changes in sbcl-1.0.54 relative to sbcl-1.0.53:
   * minor incompatible changes:
index 5959b9f..964a23f 100644 (file)
 
 ;;;; DYNAMIC-EXTENT related
 
+(defun lambda-var-original-name (leaf)
+  (let* ((home (lambda-var-home leaf)))
+    (if (eq :external (lambda-kind home))
+        (let ((p (1- (position leaf (lambda-vars home)))))
+          (leaf-debug-name
+           (elt (lambda-vars (lambda-entry-fun home)) p)))
+        (leaf-debug-name leaf))))
+
 (defun note-no-stack-allocation (lvar &key flush)
   (do-uses (use (principal-lvar lvar))
     (unless (or
              ;; If we're flushing, don't complain if we can flush the combination.
              (and flush (combination-p use) (flushable-combination-p use)))
       (let ((*compiler-error-context* use))
-        (compiler-notify "could not stack allocate the result of ~S"
-                         (find-original-source (node-source-path use)))))))
+        (if (and (ref-p use) (lambda-var-p (ref-leaf use)))
+            (compiler-notify "~@<could~2:I not stack allocate ~S in: ~S~:@>"
+                             (lambda-var-original-name (ref-leaf use))
+                             (find-original-source (node-source-path use)))
+            (compiler-notify "~@<could~2:I not stack allocate: ~S~:@>"
+                             (find-original-source (node-source-path use))))))))
 
 (defun use-good-for-dx-p (use dx &optional component)
   ;; FIXME: Can casts point to LVARs in other components?