-;;; Convert a call to a local function. If the function has already
-;;; been LET converted, then throw FUN to LOCAL-CALL-LOSSAGE. This
-;;; should only happen when we are converting inline expansions for
-;;; local functions during optimization.
-(defun ir1-convert-local-combination (start cont form fun)
- (if (functional-kind fun)
- (throw 'local-call-lossage fun)
- (ir1-convert-combination start cont form
- (maybe-reanalyze-fun fun))))
+;;; Convert a call to a local function, or if the function has already
+;;; been LET converted, then throw FUNCTIONAL to
+;;; LOCALL-ALREADY-LET-CONVERTED. The THROW should only happen when we
+;;; are converting inline expansions for local functions during
+;;; optimization.
+(defun ir1-convert-local-combination (start cont form functional)
+
+ ;; The test here is for "when LET converted", as a translation of
+ ;; the old CMU CL comments into code. Unfortunately, the old CMU CL
+ ;; comments aren't specific enough to tell whether the correct
+ ;; translation is FUNCTIONAL-SOMEWHAT-LETLIKE-P or
+ ;; FUNCTIONAL-LETLIKE-P or what. The old CMU CL code assumed that
+ ;; any non-null FUNCTIONAL-KIND meant that the function "had been
+ ;; LET converted", which might even be right, but seems fragile, so
+ ;; we try to be pickier.
+ (when (or
+ ;; looks LET-converted
+ (functional-somewhat-letlike-p functional)
+ ;; It's possible for a LET-converted function to end up
+ ;; deleted later. In that case, for the purposes of this
+ ;; analysis, it is LET-converted: LET-converted functionals
+ ;; are too badly trashed to expand them inline, and deleted
+ ;; LET-converted functionals are even worse.
+ (eql (functional-kind functional) :deleted))
+ (throw 'locall-already-let-converted functional))
+ ;; Any other non-NIL KIND value is a case we haven't found a
+ ;; justification for, and at least some such values (e.g. :EXTERNAL
+ ;; and :TOPLEVEL) seem obviously wrong.
+ (aver (null (functional-kind functional)))
+
+ (ir1-convert-combination start
+ cont
+ form
+ (maybe-reanalyze-functional functional)))