From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6263 invoked by alias); 13 Sep 2009 14:07:18 -0000 Received: (qmail 6225 invoked by uid 48); 13 Sep 2009 14:07:03 -0000 Date: Sun, 13 Sep 2009 14:07:00 -0000 Message-ID: <20090913140703.6224.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug rtl-optimization/40838] gcc shouldn't assume that the stack is aligned In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mikulas at artax dot karlin dot mff dot cuni dot cz" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-09/txt/msg01264.txt.bz2 ------- Comment #34 from mikulas at artax dot karlin dot mff dot cuni dot cz 2009-09-13 14:07 ------- So I posted these two examples that show that the patch is insufficient: 1) if the array is embedded in a structure and that structure is on the stack, the stack is not aligned. (if the array were out of structure, it would be) 2) gcc sometimes spills xmm registers over function calls (spilling zero this way is suboptimal, but that's only a performance issue) and the stack is not aligned in this case. Note, in align-counterexample2.c, there is another bug! Gcc shouldn't assume that arrays "x" and "y" are 16-byte aligned. Arrays "x" and "y" are in common section, that means that they can be declared in any other module and the linker joins these declarations. So, for example, if in another module someone declared int x[100] = { 1, 2, 3, 4 } and the module were compiled with different compiler that doesn't align the array (the ABI allows it) , the linker is forced to use the declaration with the initialization and the array would be misaligned. We can only assume alignment on the variables that are not in common section, i.e. with -fno-common or explicitly initialized. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838