https://llvm.org/bugs/show_bug.cgi?id=28410
Bug ID: 28410 Summary: Optimized code contains illegal movaps instruction when using aligned attribute in typedef Product: clang Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: C++ Assignee: unassignedclangb...@nondot.org Reporter: lukasz.c...@intel.com CC: dgre...@apple.com, llvm-bugs@lists.llvm.org Classification: Unclassified clang generates MOVAPS instruction with wrongly aligned operand (resulting in SEGFAULT) when compiling following code with optimizations enabled (-O2): #include <stdint.h> struct Foo { uint32_t data[ 13 ]; }; typedef __attribute__((aligned(16))) Foo FooDef; int counter; struct Bar { FooDef array[4]; }; __attribute__ ((noinline)) void do_sth(FooDef* foo) { counter += ((char*)foo)[0]; } int main() { Bar* bar = new Bar(); FooDef tmp = {{0}}; for (int i = 0; i < 4; i++) { FooDef *foo = &bar->array[i]; *foo = tmp; do_sth(foo); } return 0; } Explanation: aligned(16) attribute is ignored when determining sizeof(FooDef) (so sizeof(FooDef) == 52, not 64). At the other hand optimizer assumes that the given alignment holds for all elements of bar->array which is not true due to sizeof(FooDef) not aligned to 16 bytes. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs