From patchwork Fri Oct 30 12:44:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 538298 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 64BF8140DB1 for ; Fri, 30 Oct 2015 23:44:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=yo92p9v2; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=DtVI8wvXp4D3BPwu+YCQHHoEKceTVTBcSDBtlbM7uuQbzJnaFs0FR D1O2KgaduJaBC36MYldvcn2tSzBYoD1If771AxKBhJZaDLWSBWEcc20QPW3gdvSz Nub8YFduVLgecN6rXPZ3pkJv3cRQvjZUtvVQsfRp9RvVWqBrLNYB1U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=rlHg5d3/C//+XusKKjpiKObgo8Q=; b=yo92p9v24GuA9P4IIII1 jXUwr0duzRHh4l9zQ95qHNScAslpTy56MAVIxbLnh9voEUfcNiW7vF8aJzV5UnGA JIEuSliDM0n7DwmoBJlv4Cns+hqwZi4YuundQDq4HP6AN3xFaKqI8DPzTJWkKNHx a/z5e/oBlYVvkh18PdZlPCM= Received: (qmail 30155 invoked by alias); 30 Oct 2015 12:44:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 30127 invoked by uid 89); 30 Oct 2015 12:44:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 30 Oct 2015 12:44:12 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 83801AC09 for ; Fri, 30 Oct 2015 12:44:31 +0000 (UTC) Date: Fri, 30 Oct 2015 13:44:09 +0100 From: Martin Jambor To: GCC Patches Subject: [PR 68064] Do not create jump functions with zero alignment Message-ID: <20151030124408.GB2460@virgil.suse.cz> Mail-Followup-To: GCC Patches MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi, in PR 68064, IPA-CP hits an assert upon encountering a jump function claiming that a pointer has known alignment of zero. That is actually what get_pointer_alignment_1 returns when asked what is the alignment of iftmp.0_1 in: : # iftmp.0_1 = PHI <0B(2), 2147483648B(3)> {anonymous}::fn1 (iftmp.0_1); I suppose that given the circumstances, it is more-or-less reasonable answer, even if very weird, so we should check for that possibility. That is what the patch below does. Bootstrapped and tested on x86_64-linux. OK for trunk? Thanks, Martin 2015-10-29 Martin Jambor PR ipa/68064 * ipa-prop.c (ipa_compute_jump_functions_for_edge): Check that alignment iz not zero. testsuite/ * g++.dg/torture/pr68064.C: New. diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 19846a8..f36e2fd 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -1651,6 +1651,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, unsigned align; if (get_pointer_alignment_1 (arg, &align, &hwi_bitpos) + && align != 0 && align % BITS_PER_UNIT == 0 && hwi_bitpos % BITS_PER_UNIT == 0) { diff --git a/gcc/testsuite/g++.dg/torture/pr68064.C b/gcc/testsuite/g++.dg/torture/pr68064.C new file mode 100644 index 0000000..59b6897 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr68064.C @@ -0,0 +1,35 @@ +// { dg-do compile } + +template class A { +public: + class B; + typedef typename Config::template D::type TypeHandle; + static A *Tagged() { return B::New(B::kTagged); } + static TypeHandle Union(TypeHandle); + static TypeHandle Representation(TypeHandle, typename Config::Region *); + bool Is(); +}; + +template class A::B { + friend A; + enum { kTaggedPointer = 1 << 31, kTagged = kTaggedPointer }; + static A *New(int p1) { return Config::from_bitset(p1); } +}; + +struct C { + typedef int Region; + template struct D { typedef A *type; }; + static A *from_bitset(unsigned); +}; +A *C::from_bitset(unsigned p1) { return reinterpret_cast *>(p1); } + +namespace { +int *a; +void fn1(A *p1) { A::Union(A::Representation(p1, a)); } +} + +void fn2() { + A b; + A *c = b.Is() ? 0 : A::Tagged(); + fn1(c); +}