clangir icon indicating copy to clipboard operation
clangir copied to clipboard

Revise usage of `const_struct` and `const_array` to enhance codegen parity

Open sitio-couto opened this issue 1 year ago • 0 comments

https://github.com/llvm/clangir/blob/d5f6e2b5ac86f32848e23d1c0b79d0612b87cb64/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp#L694-L712

Note: This is indeed an interesting difference, if we forget about LLVM and think only about CIR for a moment, we're also not being uniform right now (my fault), given that const_struct attrs are used inline within cir.const and others are going through globals, at some point we need to migrate more.

Originally posted by @bcardosolopes in https://github.com/llvm/clangir/pull/171#pullrequestreview-1530826198

I wonder if this approach is actually better than what clang does, given the lack of memcopy/globals being involved - OTOH we might be loosing uniquing from unnamed address tagged globals. Any thoughts @htyu ?

Originally posted by @bcardosolopes in https://github.com/llvm/clangir/pull/171#discussion_r1264048755

An explicit assignment better supports later optimization passes than a memcpy does, which always requires an additional step of analysis. However from performance point of view an explicit assignment would be as less efficient as memcpy does, but I guess we can always push the conversion to memcpy to llvm.

Originally posted by @htyu in https://github.com/llvm/clangir/pull/171#discussion_r1264161101

sitio-couto avatar Jul 17 '23 18:07 sitio-couto