Doesn't this make the dead clauses return void the function instead of void the value? Not that they ever should run.
On Fri, Apr 25, 2014 at 10:45 AM, <stamo...@racket-lang.org> wrote: > stamourv has updated `master' from b40619ffd5 to ce3033a0c7. > http://git.racket-lang.org/plt/b40619ffd5..ce3033a0c7 > > =====[ One Commit ]===================================================== > Directory summary: > 52.9% pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/ > 47.0% > pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/ > > ~~~~~~~~~~ > > ce3033a Vincent St-Amour <stamo...@racket-lang.org> 2014-04-25 13:40 > : > | Keep dead case-lambda clauses around to avoid changing arity. > | > | Closes PR14468. > : > A > pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/dead-case-lambda.rkt > M .../tests/typed-racket/optimizer/tests/unboxed-for.rkt | 2 +- > M .../typed-racket-lib/typed-racket/optimizer/dead-code.rkt | 10 > +++++++--- > > =====[ Overall Diff ]=================================================== > > pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/dead-code.rkt > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > --- > OLD/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/dead-code.rkt > +++ > NEW/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/dead-code.rkt > @@ -49,9 +49,13 @@ > (begin0 > (case-lambda > #,@(for/list ((formals (in-syntax #'(formals ...))) > - (bodies (in-syntax #'(bodies ...))) > - #:unless (dead-lambda-branch? formals)) > - (cons formals (stx-map (optimize) bodies)))) > + (bodies (in-syntax #'(bodies ...)))) > + (if (dead-lambda-branch? formals) > + ;; keep the clause (to have a case-lambda with the > right arity) > + ;; but not the body (to make the function smaller for > inlining) > + ;; TODO could do better, and keep a single clause per > arity > + (list formals #'(void)) ; return type doesn't matter, > should never run > + (cons formals (stx-map (optimize) bodies))))) > ;; We need to keep the syntax objects around in the generated code > with the correct bindings > ;; so that CheckSyntax displays the arrows correctly > #,@(for/list ((formals (in-syntax #'(formals ...))) > > pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/dead-case-lambda.rkt > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > --- /dev/null > +++ > NEW/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/dead-case-lambda.rkt > @@ -0,0 +1,19 @@ > +#;#; > +#<<END > +TR opt: dead-case-lambda.rkt 4:10 () -- dead case-lambda branch > +TR opt: dead-case-lambda.rkt 6:10 (d . rst) -- dead case-lambda branch > +END > +#<<END > +(arity-at-least 0) > + > +END > + > +#lang typed/racket > +#reader tests/typed-racket/optimizer/reset-port > + > +(procedure-arity > + (ann (case-lambda > + [() (void)] > + [(d) (void)] > + [(d . rst) (void)]) > + (Any -> Any))) > > pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/unboxed-for.rkt > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > --- > OLD/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/unboxed-for.rkt > +++ > NEW/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/unboxed-for.rkt > @@ -2,7 +2,6 @@ > #<<END > TR opt: unboxed-for.rkt 2:0 (for/fold: : Float-Complex ((sum : Float-Complex > 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- > call to fun with unboxed args > TR opt: unboxed-for.rkt 2:0 (for/fold: : Float-Complex ((sum : Float-Complex > 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- > fun -> unboxed fun > -TR opt: unboxed-for.rkt 2:0 (for/fold: : Float-Complex ((sum : Float-Complex > 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- > unbox float-complex > TR opt: unboxed-for.rkt 2:0 (for/fold: : Float-Complex ((sum : Float-Complex > 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- > unboxed call site > TR opt: unboxed-for.rkt 2:0 (for/fold: : Float-Complex ((sum : Float-Complex > 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- > unboxed call site > TR opt: unboxed-for.rkt 2:0 (for/fold: : Float-Complex ((sum : Float-Complex > 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- > unboxed let bindings > @@ -17,6 +16,7 @@ TR opt: unboxed-for.rkt 2:53 0.0+0.0i -- unboxed literal > TR opt: unboxed-for.rkt 3:13 i -- unboxed complex variable > TR opt: unboxed-for.rkt 3:13 i -- unboxed complex variable > TR opt: unboxed-for.rkt 3:33 (quote (1.0+2.0i 2.0+4.0i)) -- in-list > +TR opt: unboxed-for.rkt 3:33 (quote (1.0+2.0i 2.0+4.0i)) -- unbox > float-complex > TR opt: unboxed-for.rkt 4:11 sum -- leave var unboxed > TR opt: unboxed-for.rkt 4:6 (+ i sum) -- unboxed binary float complex > TR opt: unboxed-for.rkt 4:9 i -- leave var unboxed _________________________ Racket Developers list: http://lists.racket-lang.org/dev