Hello,

If I move GIMPLE_SWITCH lowering from stmt.c to somewhere in the
GIMPLE pass pipeline, I run into an issue with SJLJ exceptions. The
problem is that except.c:sjlj_emit_dispatch_table() builts a
GIMPLE_SWITCH and calls expand_case on it. If I move all non-casesi,
non-tablejump code out of stmt.c and make it a GIMPLE lowering pass
(currently I have the code in tree-switch-conversion.c) then two
things happen:

1. SJLJ exception dispatch tables can only be expanded as casesi or
tablejump. This may not be optimal.

2. If the target asks for SJLJ exceptions but it has no casesi and no
tablejump insns or expanders, then the compilation will fail.

I don't think (1) is a big problem, because exceptions should be,
well, exceptions after all so optimizing them shouldn't be terribly
important. For (2), I had hoped it would be a requirement to have
either casesi or tablejump, but that doesn't seem to be the case. But
I could put in some code to expand it as a series of test-and-branch
insns instead, in case there is only a small number of num_dispatches.

What is the reason why lowering for SJLJ exceptions is not done in GIMPLE?

Would it be a problem for anyone if SJLJ exception handling will be
less efficient, if I move GIMPLE_SWITCH lowering earlier in the pass
pipeline?

Ciao!
Steven

Reply via email to