[PATCH 02/10] compiler.h: add is_const() as a replacement of __is_constexpr()
Linus Torvalds
torvalds at linux-foundation.org
Sat Dec 7 10:26:01 PST 2024
On Sat, 7 Dec 2024 at 05:07, Martin Uecker <muecker at gwdg.de> wrote:
>
> VLA use *less* stack than a fixed size arrays with fixed bound.
Not really. You end up with tons of problems, not the least of which
is how to actually analyze the stack size. It also gets *very* nasty
to have code that declares the VLA size using an argument that is then
checked afterwards - and if you have a strong preference for
"declarations before code", you end up with *horrific* issues.
And even if you are super-careful, and you solved the analysis
problem, in practice VLAs will cause huge stack issues simply due to
code generation issues. The compiler will end up doing extra
alignment and extra frame handling and saving, to the point where any
advantages the VLA would bring is completely dwarfed by all the
disadvantages.
We went through this. We are so *much* better off without VLAs that
it's not even funny.
Now when the compiler says "your stack size is big", you just look
"Oh, that struct should be allocated with kmalloc, not on the stack".
Boom. Done.
Linus
More information about the linux-arm-kernel
mailing list