On Thu, 17 Jul 2025 at 18:05, Pierrick Bouvier <pierrick.bouv...@linaro.org> wrote: > On 7/17/25 9:56 AM, Peter Maydell wrote: > > I'm not really a fan of relying on the compiler to fold stuff > > away -- it's fragile and there's no guarantee the compiler > > will actually do it. In this example it would be really easy > > for somebody coming along to tidy this up later to put the > > nested if()s back into a single if() condition and reintroduce > > the problem, for instance. > > > > There are various places where we already relied on that, including > before the single-binary work ({accel}_allowed). > > For the fragile aspect of it, that's why CI exists. Building all > binaries with clang --enable-debug should ensure no regression can be > introduced.
But our CI can't check all versions of gcc and clang at all optimisation levels. The reason it's fragile is because there's never a guarantee that the compiler does it or what situations it will work vs not work. It's not a feature provided by the language or the compiler that you can fold away references to functions that don't exist; it just happens to work. I know we already rely on constant-folding in various places: I'm not super enthusiastic about those either. -- PMM