Opened 5 years ago

Closed 5 years ago

#1280 closed defect (fixed)

Cannot INLINE functions created by MACROLET

Reported by: rsmith Owned by:
Priority: major Milestone:
Component: Compiler Version: trunk
Keywords: inline Cc: gb

Description

A function defined with MACROLET that is declaimed as INLINE doesn't seem to actually inline at the call site.

If you manually write the definition out without the MACROLET, inlining works as expected.

I have tried locally declaring the function as INLINE at the call site, and I have also tried doing a DECLAIM INLINE outside of the MACROLET, all to no avail.

See the interactions below to reproduce.

File def.lisp

(defpackage :foo
  (:use :cl)
  (:export fun))

(in-package :foo)

(macrolet ((def (name op)
             `(progn
                (declaim (inline ,name))
                (defun ,name (a b)
                  (,op a b)))))
  (def fun +))

File use.lisp

(in-package :cl-user)

(defun bar (a b)
  (declare (optimize speed (safety 0) (debug 0) (space 0)))
  (foo:fun a (* a b)))

REPL interaction (note the line marked with !!!!...!!)

CL-USER> (lisp-implementation-type)
"Clozure Common Lisp"
CL-USER> (lisp-implementation-version)
"Version 1.11-dev-r16361M-trunk  (LinuxARM32)"
CL-USER> (load (compile-file "def.lisp"))
#P"def.lafsl"
CL-USER> (load (compile-file "use.lisp"))
#P"use.lafsl"
CL-USER> (disassemble #'bar)
;; Source: "use.lisp.newest":23-122
  (mov imm0 (:$ 19))
  (stmdb (:! sp) (imm0 vsp fn lr))
  (mov fn temp2)
  (stmdb (:! vsp) (arg_z arg_y))        ;[12]

;;; (* a b)
  (sploadlr .SPbuiltin-times)           ;[16]
  (blx lr)

;;; (foo:fun a (* a b))
  (ldr arg_y (:@ vsp (:$ 4)))           ;[24]
  (mov nargs (:$ 8))
  (ldr temp1 (:@ fn 'FOO:FUN))          ; *** !!!!!!!!!!!!!!
  (ldmia (:! sp) (imm0 vsp fn lr))
  (ldr temp2 (:@ temp1 (:$ 6)))         ;[40]
  (ldr pc (:@ temp2 (:$ -2)))

;;; #<no source text>
NIL

Change History (1)

comment:1 Changed 5 years ago by gb

  • Resolution set to fixed
  • Status changed from new to closed

(In [16362]) Defun: don't insist on a null lexical environment to retain lambda for inlining.

(We still insist on an environment that's free of function and variable bindings, but macros/symbol-macros don't raise the same set of issues.

fixes ticket:1280 in the trunk.

Note: See TracTickets for help on using tickets.