Is there a way to see the expansion of an inline function call?

58 views Asked by At

Let's take an example :

(declaim (inline myinlinefunc))

(defun myinlinefunc (a)
  (* a 2))

(defun myglobalfunc (z)
  (+ (myinlinefunc z) 3))

CL-USER> (trace myinlinefunc myglobalfunc)
(MYINLINEFUNC MYGLOBALFUNC)
CL-USER> (myglobalfunc 2)
  0: (MYGLOBALFUNC 2)
  0: MYGLOBALFUNC returned 7
7 (3 bits, #x7, #o7, #b111)

Is tracing the only way to be sure the compiler has inlined the function myinlinefunc into myglobalfunc ?

Is there a way to see the "expanded" myglobalfunc showing inline function calls effectively replaced by there definition, like a macroexpand ?

1

There are 1 answers

0
Rainer Joswig On

I would expect that the compiler might show you that. Typically an optimizing file compiler.

Example of a compiler note about code inlining using SBCL:

Take SBCL and compile the file with the right settings (speed = 3, ...). SBCL then prints a huge amount of compilation information. Among the huge amounts of output the compiler says:

;     (MYINLINEFUNC Z)
; --> BLOCK 
; ==>
;   (* A 2)
; 

This probably tells us about the expansion it uses.