[m-dev.] request for opinions about a change to switch detection

Julien Fischer jfischer at opturion.com
Fri Nov 14 12:29:54 AEDT 2025


On Fri, 14 Nov 2025 at 10:50, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:

> I can fix the problem in several ways, and I am looking for opinions
> on which you guys prefer.
>
> The first fix is to modify the code of switch detection to inline
> any nested switches it now generates. This is conceptually simple,
> but it can, in the worst case, greatly increase the workload of
> the passes between switch detection and format call. This is because
> inlining the inner switch in the outer switch creates N copies of
> all the code that follows the inner switch in its arm of the outer
> switch if the inner switch has N cases, and that following code has
> no bound on its size.
>
> The second fix is to modify the code of the format_call pass
> to inline switches. This avoids the potential slowdown described above,
> but requires a new pass as the initial part of format_call. Since most
> procedures do not contain any call to any predicate named "format",
> this prepass would not slow down the compilation of most procedures;
> its impact would mostly by on compiler code complexity.
>
> The third "fix" is to simply declare that the warning is an appropriate
> response to code like the above.

It is not an appropriate response to such code.

> My preference is for the second fix, but would also be ok with the first.
> What do you guys think?

My preference is also for the second fix.

> Also, if we settle on one the first two fixes, would you prefer that
> I commit my diff *without* the chosen fix, and then post that fix for review
> separately?

I don't have a preference, whichever is most convenient for you.
(Although please try to avoid breaking the ROTD builds.)

Julien.


More information about the developers mailing list