Skip to content

MIPS tail calls are disabled by default at all optimization levels #107730

Open
@InBetweenNames

Description

@InBetweenNames

Hello, I noticed that tail call optimization is disabled on MIPS at all optimization levels by default. This is causing issues with the musttail attribute in C and C++ programs, where tail calls that otherwise would be eligible are not being treated as such.

The relevant flag is defined here:

static cl::opt<bool>
UseMipsTailCalls("mips-tail-calls", cl::Hidden,
cl::desc("MIPS: permit tail calls."), cl::init(false));

When building with -mllvm -mips-tail-calls=1, tail calls appear to be optimized accordingly (in the few tests I've done). I noticed that there are test cases for this flag throughout the backend (just search for mips-tail-calls=1).

Here are a few issues that are affected by this behaviour:
#47971
#51709
#57795

Is it possible we could make the MIPS backend behave like the others in this respect? It seems to me that if a call site is marked musttail, the backend should make every effort towards performing the tail call regardless of the current optimization level. I would be willing to submit a PR for this change if there's interest.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions