[cfe-dev] why does clang(llvm) do not optimize static throw/catch constructs?

David Chisnall David.Chisnall at cl.cam.ac.uk
Wed Mar 18 01:17:37 PDT 2015


On 18 Mar 2015, at 06:44, Dennis Luehring <dl.soluz at gmx.net> wrote:
> 
> isn't there any exception-flow analysis in clang/llvm (even detecting this stupid case)
> or is there a C++ standard limitation that forbits such optimizations - or does it overall
> not make sense trying to optimize try/catch-flow in any way

Doing this optimisation in the IR requires knowing what the personality function will do.  This is nontrivial in the general case for C++, but would be relatively easy for simple cases like this.

The real question is whether it's worth it.  How much C++ code in the real world actually does this?  I'd imagine that only machine-generated code would, as C++ programmers know that this is a really slow way of writing goto.  It's more likely to occur after inlining, but some analysis of how common it is would be useful for deciding whether it's worth doing.

David





More information about the cfe-dev mailing list