I understand, due to halting problem, we can not compute exact stack size usage.

However, is there a tool that can compute a **upper bound** for how much stack a function will consume in the **worst case over all inputs** ?

For example, a function that does not call any other function, in the worst case, uses O(1) stack space.

The motivation behind this is: for rust/wasm32, I'm somewhat concerned my functions might be "too recursive", so I'd like to have some tool that tells me which functions are O(1), and which functions are not. (If it can't distinguish O(log n) vs O(n), that is fine -- just knowing which functions are not O(1) would be useful enough.)