[clang] [clang][CodeGen] The linux kernel expects initializers to FULLY initialize variables, structs and unions including padding (PR #97121)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 31 14:56:36 PDT 2024


https://github.com/rjmccall commented:

Is this really all that's required?  It looks like you're just filling in explicit zero padding when emitting constant initializers.  That should steer clear of any possibility that LLVM would treat the padding as `undef` for optimization purposes (surely `undef` bytes are still emitted as zero when rendering the initializer in assembly? it doesn't hurt to be more explicit, of course), so okay, it's good to do.  But I assume that similar code is required in order to explicitly zero out any padding when dynamically initializing a local variable.

Also, is adding constant padding fields retroactively really the best way to handle this instead of just expecting the constant emitter to fill them in itself?

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


More information about the cfe-commits mailing list