From patchwork Fri Dec 11 11:16:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 555672 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 C53F514031B for ; Fri, 11 Dec 2015 22:16: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=Xi9LlkEJ; 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=nHRVNOeyfOrsTvQSD1TVyej4ZzQsCWa/s1BDFVuV/rDwjjqZcybKY mEXZAJFZoZ2vZU/cYPnTPKBShwxPUnhbpY2l/m4KpZ1SL+oLRySoytwM0KSy61CT T+2Zxw2lbN6GzNXO+51EAMaaUThLSRvGnB/Ht/eQ6S6eUgClh5HRJU= 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=ar9F3UbtgdEy94XK8pKyOSC0Yvw=; b=Xi9LlkEJLDwNtP+W/zVy 4ya3fqdgHOaFeLL4vT+CJKvAaXAYoNtXj5r/sId1vqWWokWZwwmeGGeSq3+uJasI ZXAFgfQ9sf0Z5rFmWNpufK7TYRLw/b8PCnDpkUW4bqxVJv6xO9xMitfvGtUoCMnu ELxAIIvFHO5YmaR+Z6DIazA= Received: (qmail 109638 invoked by alias); 11 Dec 2015 11:16:16 -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 109600 invoked by uid 89); 11 Dec 2015 11:16:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, 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, 11 Dec 2015 11:16:13 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E3484AC08 for ; Fri, 11 Dec 2015 11:16:10 +0000 (UTC) Date: Fri, 11 Dec 2015 12:16:10 +0100 From: Martin Jambor To: GCC Patches Subject: [PR 68064] Testcase and an assert for an already fixed bug Message-ID: <20151211111610.GC3956@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, PR 68064 has been fixed by Richi's revision 231246. I would still like to add the testcase to the testsuite and add a checking assert so that if ever get zero alignment again, we catch it in the analysis part of IPA-CP (which with LTO means in compilation and not linking phase which makes a big difference for debugging). I have tossed this into a bootstrap and test run on an x86_64-linux and found no issues. I believe the patch is quite obvious and so will go ahead and commit it to trunk. Thanks, Martin Add asssert and testcase for PR 68064 2015-12-09 Martin Jambor * ipa-prop.c (ipa_compute_jump_functions_for_edge): Add checking assert that align is nonzero. testsuite/ * g++.dg/torture/pr68064.C: New test. --- gcc/ipa-prop.c | 1 + gcc/testsuite/g++.dg/torture/pr68064.C | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 gcc/testsuite/g++.dg/torture/pr68064.C diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index f379ea7..d0a3501 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -1646,6 +1646,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, && align % BITS_PER_UNIT == 0 && hwi_bitpos % BITS_PER_UNIT == 0) { + gcc_checking_assert (align != 0); jfunc->alignment.known = true; jfunc->alignment.align = align / BITS_PER_UNIT; jfunc->alignment.misalign = hwi_bitpos / BITS_PER_UNIT; 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); +}