Early inline FLET transform causes bad assembly.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
(defun inner (x fn)
(declare (fixnum x) (function fn))
(funcall fn x))
(declaim (inline inner))
(defun outer (x)
(flet ((fn (x) (1+ x)))
(declare (inline fn))
(inner x #'fn)))
(disassemble 'outer)
; disassembly for OUTER
; Size: 32 bytes. Origin: #x1137796
; 96: 4883EC10 SUB RSP, 16 ; no-arg-parsing entry point
; 9A: 488B05AFFFFFFF MOV RAX, [RIP-81] ; #<FUNCTION (FLET FN :IN OUTER) {11376EB}>
; A1: B902000000 MOV ECX, 2
; A6: 48892C24 MOV [RSP], RBP
; AA: 488BEC MOV RBP, RSP
; AD: FF50FD CALL QWORD PTR [RAX-3]
; B0: 488BE5 MOV RSP, RBP
; B3: F8 CLC
; B4: 5D POP RBP
; B5: C3 RET
;; On the contrary:
(defun outer2 (x y)
(declare (fixnum x y))
(flet ((fn (x) (+ x y)))
(declare (inline fn))
(inner x #'fn)))
(disassemble 'outer2)
; disassembly for OUTER2
; Size: 12 bytes. Origin: #x1137B76
; 76: 4801D7 ADD RDI, RDX ; no-arg-parsing entry point
; 79: 488BD7 MOV RDX, RDI
; 7C: 488BE5 MOV RSP, RBP
; 7F: F8 CLC
; 80: 5D POP RBP
; 81: C3 RET
Seems to be no longer the case.