From patchwork Mon Jun 13 19:08:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 100177 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]) by ozlabs.org (Postfix) with SMTP id 95AE5B6FBA for ; Tue, 14 Jun 2011 05:09:20 +1000 (EST) Received: (qmail 9999 invoked by alias); 13 Jun 2011 19:09:19 -0000 Received: (qmail 9991 invoked by uid 22791); 13 Jun 2011 19:09:18 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Jun 2011 19:09:04 +0000 Received: from wpaz13.hot.corp.google.com (wpaz13.hot.corp.google.com [172.24.198.77]) by smtp-out.google.com with ESMTP id p5DJ91uO030759; Mon, 13 Jun 2011 12:09:02 -0700 Received: from topo.tor.corp.google.com (topo.tor.corp.google.com [172.29.41.2]) by wpaz13.hot.corp.google.com with ESMTP id p5DJ8xqN008872; Mon, 13 Jun 2011 12:08:59 -0700 Received: by topo.tor.corp.google.com (Postfix, from userid 54752) id 4B66E1DA1CC; Mon, 13 Jun 2011 15:08:59 -0400 (EDT) To: reply@codereview.appspotmail.com, crowl@google.com, gchare@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Fix GC ICE in g++.dg/pph/c1eabi.cc (issue4607047) Message-Id: <20110613190859.4B66E1DA1CC@topo.tor.corp.google.com> Date: Mon, 13 Jun 2011 15:08:59 -0400 (EDT) From: dnovillo@google.com (Diego Novillo) X-System-Of-Record: true X-IsSubscribed: yes 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 We were running into a GC ICE because when reading a sorted_fields_type field we were never setting the lenght of the vector. This patch moves the setting of the vector length to the actual allocation function (sorted_fields_type_new). It was being done in finish_struct_1 before, so vectors read from the streamer were getting garbage in the len field. This fixes g++.dg/pph/c1eabi.{cc,h}. Tested on x86_64. Committed to branch. Diego. cp/ChangeLog.pph * class.c (sorted_fields_type_new): Set field LEN in the newly allocated vector. (finish_struct_1): Remove setting of FIELD_VEC->LEN. testsuite/ChangeLog.pph * g++.dg/pph/c1eabi1.h: Remove XFAIL markers. * g++.dg/pph/c1eabi1.cc: Likewise. Add assembly mis-comparison expectation. --- This patch is available for review at http://codereview.appspot.com/4607047 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 86ec04b..70a3668 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5579,8 +5579,12 @@ determine_key_method (tree type) struct sorted_fields_type * sorted_fields_type_new (int n) { - return ggc_alloc_sorted_fields_type (sizeof (struct sorted_fields_type) - + n * sizeof (tree)); + struct sorted_fields_type *sft; + sft = ggc_alloc_sorted_fields_type (sizeof (struct sorted_fields_type) + + n * sizeof (tree)); + sft->len = n; + + return sft; } @@ -5714,7 +5718,6 @@ finish_struct_1 (tree t) if (n_fields > 7) { struct sorted_fields_type *field_vec = sorted_fields_type_new (n_fields); - field_vec->len = n_fields; add_fields_to_record_type (TYPE_FIELDS (t), field_vec, 0); qsort (field_vec->elts, n_fields, sizeof (tree), field_decl_cmp); diff --git a/gcc/testsuite/g++.dg/pph/c1eabi1.cc b/gcc/testsuite/g++.dg/pph/c1eabi1.cc index 6271501..b2e9b11 100644 --- a/gcc/testsuite/g++.dg/pph/c1eabi1.cc +++ b/gcc/testsuite/g++.dg/pph/c1eabi1.cc @@ -1,7 +1,4 @@ -// { dg-xfail-if "ICE" { "*-*-*" } { "-fpph-map=pph.map" } } -// { dg-bogus "mathcalls.h:365:1: internal compiler error: Segmentation fault" "" { xfail *-*-* } 0 } -// { dg-prune-output "In file included from " } -// { dg-prune-output " from " } // { dg-options "-w -fpermissive" } +// pph asm xdiff #include "c1eabi1.h" diff --git a/gcc/testsuite/g++.dg/pph/c1eabi1.h b/gcc/testsuite/g++.dg/pph/c1eabi1.h index 151b768..5f5b593 100644 --- a/gcc/testsuite/g++.dg/pph/c1eabi1.h +++ b/gcc/testsuite/g++.dg/pph/c1eabi1.h @@ -1,7 +1,3 @@ -// { dg-xfail-if "ICE" { "*-*-*" } { "-fpph-map=pph.map" } } -// { dg-bogus "mathcalls.h:365:1: internal compiler error: Segmentation fault" "" { xfail *-*-* } 0 } -// { dg-prune-output "In file included " } -// { dg-prune-output " from " } // { dg-options "-w -fpermissive" } #ifndef __PPH_GUARD_H