Skip to content

Tail-Call optimization #7647

Open
Open
@HerrCai0907

Description

@HerrCai0907

I'm curious as to why binaryen doesn't implement an optimization pass for tailcall feature. Is the optimization itself not feasible?

If it is feasible, I would like to implement it.

The basic idea is we can convert

(func ...
   (call $f)
)

to

(func ...
   (return_call $f)
)
(func ...
   (return (call $f))
)

to

(func ...
   (return_call $f)
)
(func ...
   (if
      (condition)
      (call $f)
   )
)

to

(func ...
   (if
      (condition)
      (return_call $f)
   )
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions