defmacro compiler notes for List* and Append
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Somewhere between version 2.3.1 and 2.3.4 I think ... Backquote expressions in macro definitions started producing compiler notes when the macro function is compiled with higher than normal speed. For instance, this form:
(defmacro define-foobar (finalization-
(declare (optimize (debug 2) (safety 0) (speed 3)))
(let ((finalize (make-list finalization-rounds :initial-element '(sip-round v0 v1 v2 v3))))
`(defun foobar ()
(let ()
,@finalize
,(if (not double)
`(let ()
Generates notes when compiled with SBCL 2.3.11.
bob> (compile-file "bug.lisp")
; compiling file "/home/
; file: /home/brown/
; in: defmacro define-foobar => defun foobar
; `(LET ()
; ,@BOB::FINALIZE
; (VALUES BOB::H0 BOB::H1))
; --> SB-IMPL::|Append|
; ==>
; 1
;
; note: unable to optimize due to type uncertainty: The first argument is a list, not a null.
; in: defmacro define-foobar
; `(DEFUN BOB::FOOBAR ()
; (LET ()
; ,@BOB::FINALIZE
; ,(IF (NOT BOB::DOUBLE)
; '(LOGXOR BOB::V0 BOB::V1 BOB::V2 BOB::V3)
; `(LET ()
; ,@BOB::FINALIZE
; (VALUES BOB::H0 BOB::H1)))))
; --> SB-IMPL::|List*| SB-IMPL::|Append|
; ==>
; 1
;
; note: unable to optimize due to type uncertainty: The first argument is a list, not a null.
;
; compilation unit finished
; printed 2 notes
; wrote /home/brown/
; compilation finished in 0:00:00.036
Changed in sbcl: | |
status: | New → Fix Committed |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
FWIW
This can be reproduced (at least partly) with a smaller example:
(defun foo (list)
(declare (optimize speed))
`(,@list tail))
Generated note:
; in: defun foo
; `(,@LIST TAIL)
; ==>
; 1
;
; note: unable to
; optimize
; due to type uncertainty:
; The first argument is a list, not a null.
;
; compilation unit finished
; printed 1 note
This behavior started in sbcl-2.3.7.
There is a possibly related section in NEWS:
> * optimization: the compiler removes known-NIL arguments from calls to
> APPEND and NCONC, and empty sequences from calls to CONCATENATE.
And it can be reproduced by using APPEND instead of the backquote:
(defun foo (list)
(declare (optimize speed))
(append list '(tail)))
Generated note:
; in: defun foo
; (APPEND LIST '(TAIL))
;
; note: unable to
; optimize
; due to type uncertainty:
; The first argument is a list, not a null.
;
; compilation unit finished
; printed 1 note