[llvm] Reenable JumpTableToSwitch pass by default (PR #83229)

Alexander Shaposhnikov via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 28 21:43:33 PDT 2024


alexander-shaposhnikov wrote:

@nikic - I've looked (just a bit) into what's going on (probably will look more thoroughly when I have time, currently I'm overloaded with other work).
IIRC, the problematic examples contained ~10K+ jump tables, those jump tables got expanded into ~100K+ calls, and from there the compilation time slowed down considerably (in particular, inlining took a significant amount of time), the pass itself was fast.

- It'd be useful to better understand why e.g. this issue does or does not happen with clang + libstdc++,  conceptually the transformation performed by the pass can be done at the source level, and the LLVM IR for the report above (after optimization) should be ~somewhat similar to what one would get from libstdc++'s.
I don't have an answer to this question, one thing that came up - with gcc  flang has been using **common::visit instead of std::visit** and this potentially might explain the difference (I wanted to try to clarify this bit in the comment above, it's still unclear to me).
- if the combination clang + libstdc++ works with **common::visit replaced by std::visit**, this might hint that there might be a better place in the pipeline for this transformation. If it doesn't - then, perhaps, the input is somewhat pathological.
- I guess another way to attack the problem would be to try to change libc++'s std::variant/std::visit. In this case the optimization is still useful (cause the patter occurs outside of libc++ too), but std::variant/std::visit are responsible for a very large portion of it. 


https://github.com/llvm/llvm-project/pull/83229


More information about the llvm-commits mailing list