Open LukeSTM opened 2 months ago
@llvm/issue-subscribers-clang-codegen
Author: Luke (LukeSTM)
attribute ((packed)) has a higher priority than fpack-struct=4
It seem like llvm prefer a small alignment. If attribute ((align (4))) and fpack-struct=8, alignment = 4. If attribute ((align (4))) and fpack-struct, alignment = 1. https://godbolt.org/z/ddeMvzEGE
Is this an expected behavior? CC @AaronBallman @zygoloid
I understand that the alignment rules of the structures of gcc and llvm should be the same, but the default alignment rules are different. gcc arm struct alignment default 4byte,and could not less than 4byte。llvm does not have this restriction.
compile with only one option:-fpack-struct=4
gcc could pass this testcase, but clang could not. https://godbolt.org/z/h5T5rdYWb
The code can be simplified as follows:
https://godbolt.org/z/EbGsEz6eP
if compile without -fpack-struct=4, the alignment of struct is 8, as same as attribue. But if compile with -fpack-struct=4, the alignment of struct is 4. Why fpack-struct=4 has a higher priority than attribute? I think attribute should has a higher priority than Compilation options