From: Richard Guenther <rguenther@suse.de>
To: Markus Trippelsdorf <markus@trippelsdorf.de>
Cc: gcc-patches@gcc.gnu.org, ebotcazou@adacore.com,
Martin Jambor <mjambor@suse.de>
Subject: Re: [PATCH] Re-work get_object_alignment (again)
Date: Fri, 20 Jul 2012 08:28:00 -0000 [thread overview]
Message-ID: <alpine.LNX.2.00.1207201027300.17088@jbgna.fhfr.qr> (raw)
In-Reply-To: <20120719131205.GA268@x4>
On Thu, 19 Jul 2012, Markus Trippelsdorf wrote:
> On 2012.07.17 at 15:10 +0200, Richard Guenther wrote:
> > Comments welcome, of course.
>
> This patch apparently miscompiles the Linux kernel, which just
> hangs during early boot:
>
> ...
> SLUB: Genslabs=15, HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
> Hierarchical RCU implementation.
> NR_IRQS:4352 nr_irqs:712 16
> Extended CMOS year: 2000
> Console: colour VGA+ 80x25
> console [tty0] enabled
> (hang)
>
> See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54031
The following fixes one issue (but reportedly does not fix the above
issue).
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2012-07-20 Richard Guenther <rguenther@suse.de>
* builtins.c (get_object_alignment_2): Correct offset handling
when using type alignment of a MEM_REF kind base.
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c (revision 189656)
+++ gcc/builtins.c (working copy)
@@ -346,12 +346,10 @@ get_object_alignment_2 (tree exp, unsign
known_alignment
= get_pointer_alignment_1 (addr, &ptr_align, &ptr_bitpos);
- bitpos += ptr_bitpos;
align = MAX (ptr_align, align);
- if (TREE_CODE (exp) == MEM_REF
- || TREE_CODE (exp) == TARGET_MEM_REF)
- bitpos += mem_ref_offset (exp).low * BITS_PER_UNIT;
+ /* The alignment of the pointer operand in a TARGET_MEM_REF
+ has to take the variable offset parts into account. */
if (TREE_CODE (exp) == TARGET_MEM_REF)
{
if (TMR_INDEX (exp))
@@ -369,9 +367,19 @@ get_object_alignment_2 (tree exp, unsign
/* When EXP is an actual memory reference then we can use
TYPE_ALIGN of a pointer indirection to derive alignment.
Do so only if get_pointer_alignment_1 did not reveal absolute
- alignment knowledge. */
- if (!addr_p && !known_alignment)
- align = MAX (TYPE_ALIGN (TREE_TYPE (exp)), align);
+ alignment knowledge and if using that alignment would
+ improve the situation. */
+ if (!addr_p && !known_alignment
+ && TYPE_ALIGN (TREE_TYPE (exp)) > align)
+ align = TYPE_ALIGN (TREE_TYPE (exp));
+ else
+ {
+ /* Else adjust bitpos accordingly. */
+ bitpos += ptr_bitpos;
+ if (TREE_CODE (exp) == MEM_REF
+ || TREE_CODE (exp) == TARGET_MEM_REF)
+ bitpos += mem_ref_offset (exp).low * BITS_PER_UNIT;
+ }
}
else if (TREE_CODE (exp) == STRING_CST)
{
prev parent reply other threads:[~2012-07-20 8:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-17 13:10 Richard Guenther
2012-07-18 8:54 ` Eric Botcazou
2012-07-19 13:12 ` Markus Trippelsdorf
2012-07-20 8:28 ` Richard Guenther [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.00.1207201027300.17088@jbgna.fhfr.qr \
--to=rguenther@suse.de \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=markus@trippelsdorf.de \
--cc=mjambor@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).