Summary
define-inline does not respect inline-limit
Metadata
- Id: 75cef43f4af84dc0746307cc77f8656b6ff26198
- Trac id: 1094
- Type: defect
- Reporter: johnwcowan
- Owner: evhan
- Cc:
- Status: closed
- Component: compiler
- Estimated difficulty:
- Resolution: fixed
- Priority: major
- Milestone: 4.10.0
- Version: 4.8.x
- Changetime: 2015-01-29 07:19:40 UTC
- Created: 2014-01-23 22:16:04 UTC
- Keywords:
Description
If you define a recursive procedure with `define-inline`, csc 4.8.0.4 loops.
(define-inline (foo x) (if (= x 0) 0 (+ (foo (- x 1)) 1))) (foo 32)
Compile with `csc -t`, wait forever. This is not the case with
(declare (inline foo)) (define (foo x) (if (= x 0) 0 (+ (foo (- x 1)) 1))) (foo 32)
which suppresses the inlining.
Changes and comments
[2014-07-02 08:49:14 UTC] sjamaan changed milestone from someday to 4.10.0
[2014-07-02 08:49:14 UTC] sjamaan wrote:
A bit silly, but if we can easily fix it, that should probably go into 4.10.0
[2014-11-03 01:50:00 UTC] evhan changed status from new to assigned
[2014-11-03 01:50:00 UTC] evhan set owner to evhan
[2014-11-03 01:50:00 UTC] evhan wrote:
The define-inline feature is pretty much totally distinct from procedure inlining (to which (declare (inline ...)) and inline-limit apply) -- the former is strictly mechanical and takes place during canonicalization, whereas the latter happens later on when the optimizer decides whether or not to inline a predefined procedure or not. Also, inline-limit is a threshold of procedure size, which can't be easily applied to define-inline forms.
To prevent loops, we could add a depth limit for nested define-inline expansions. Or, this may just be a documentation bug that we fix by making clear that define-inline is a naive transformation and if you're not careful, recursive inlines may loop forever. I'd prefer the latter.
Thoughts?
[2015-01-29 07:19:40 UTC] evhan changed status from assigned to closed
[2015-01-29 07:19:40 UTC] evhan set resolution to fixed
[2015-01-29 07:19:40 UTC] evhan wrote:
I've added a note to define-inline's documentation that inline-limit doesn't apply to it in 5d102c31cef490e6e3d3bd8f0044801ed4e50d0e.
A cutoff for nested define-inline expansion should really be a separate feature request, as described above. For now, I'm going to call this a documentation bug and mark it resolved. Please open a new enhancement request if such a feature would be valuable to you.