From patchwork Mon Jun 14 10:29:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 55516 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 5F6B9B7D6D for ; Mon, 14 Jun 2010 20:29:22 +1000 (EST) Received: (qmail 2720 invoked by alias); 14 Jun 2010 10:29:20 -0000 Received: (qmail 2711 invoked by uid 22791); 14 Jun 2010 10:29:19 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_BJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Jun 2010 10:29:14 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5EAT3l8013784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 14 Jun 2010 06:29:03 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5EAT2jl008226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 14 Jun 2010 06:29:03 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o5EAT9k7004488; Mon, 14 Jun 2010 12:29:09 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o5EAT8C6004486; Mon, 14 Jun 2010 12:29:08 +0200 Date: Mon, 14 Jun 2010 12:29:08 +0200 From: Jakub Jelinek To: "Joseph S. Myers" Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Register lazy_hex_fp_values with GC (PR bootstrap/44509) Message-ID: <20100614102908.GI7811@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) 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 Hi! I've misread libcpp, thought values.macro is allocated using libcpp buffers, but apparently that's not the case - it is allocated using ggc_alloc. The following patch fixes it by registering the array with GC. Bootstrapped/regtested on x86_64-linux and i686-linux. Ok for trunk? 2010-06-14 Jakub Jelinek PR bootstrap/44509 * c-config-lang.in (gtfiles): Add c-family/c-cppbuiltin.c. * c-family/c-cppbuiltin.c: Include gt-c-family-c-cppbuiltin.h. (lazy_hex_fp_values, lazy_hex_fp_value_count): Add GTY(()) markers. (lazy_hex_fp_value, builtin_define_with_hex_fp_value): Use ggc_strdup instead of xstrdup. * gcc.dg/pr44509.c: New test. Jakub --- gcc/c-config-lang.in.jj 2010-06-07 11:25:05.000000000 +0200 +++ gcc/c-config-lang.in 2010-06-14 08:04:54.000000000 +0200 @@ -22,4 +22,4 @@ # files used by C that have garbage collection GTY macros in them # which therefore need to be scanned by gengtype.c. -gtfiles="\$(srcdir)/c-lang.c \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c \$(srcdir)/c-objc-common.c \$(srcdir)/c-parser.c \$(srcdir)/c-lang.h" +gtfiles="\$(srcdir)/c-lang.c \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-cppbuiltin.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c \$(srcdir)/c-objc-common.c \$(srcdir)/c-parser.c \$(srcdir)/c-lang.h" --- gcc/c-family/c-cppbuiltin.c.jj 2010-06-12 10:38:08.000000000 +0200 +++ gcc/c-family/c-cppbuiltin.c 2010-06-14 08:16:40.000000000 +0200 @@ -951,15 +951,16 @@ builtin_define_with_int_value (const cha array and function allows it to be done lazily when __DBL_MAX__ etc. is first used. */ -static struct +struct GTY(()) lazy_hex_fp_value_struct { const char *hex_str; cpp_macro *macro; enum machine_mode mode; int digits; const char *fp_suffix; -} lazy_hex_fp_values[12]; -static int lazy_hex_fp_value_count; +}; +static GTY(()) struct lazy_hex_fp_value_struct lazy_hex_fp_values[12]; +static GTY(()) int lazy_hex_fp_value_count; static bool lazy_hex_fp_value (cpp_reader *pfile ATTRIBUTE_UNUSED, @@ -987,7 +988,7 @@ lazy_hex_fp_value (cpp_reader *pfile ATT gcc_assert (idx < node->value.macro->count); node->value.macro->exp.tokens[idx].val.str.len = strlen (buf1); node->value.macro->exp.tokens[idx].val.str.text - = (const unsigned char *) xstrdup (buf1); + = (const unsigned char *) ggc_strdup (buf1); return true; } @@ -1014,7 +1015,8 @@ builtin_define_with_hex_fp_value (const sprintf (buf1, "%s=%s", macro, buf2); cpp_define (parse_in, buf1); node = C_CPP_HASHNODE (get_identifier (macro)); - lazy_hex_fp_values[lazy_hex_fp_value_count].hex_str = xstrdup (hex_str); + lazy_hex_fp_values[lazy_hex_fp_value_count].hex_str + = ggc_strdup (hex_str); lazy_hex_fp_values[lazy_hex_fp_value_count].mode = TYPE_MODE (type); lazy_hex_fp_values[lazy_hex_fp_value_count].digits = digits; lazy_hex_fp_values[lazy_hex_fp_value_count].fp_suffix = fp_suffix; @@ -1173,3 +1175,5 @@ builtin_define_type_minmax (const char * cpp_define (parse_in, buf); } } + +#include "gt-c-family-c-cppbuiltin.h" --- gcc/testsuite/gcc.dg/pr44509.c.jj 2010-06-14 08:28:14.000000000 +0200 +++ gcc/testsuite/gcc.dg/pr44509.c 2010-06-14 08:28:10.000000000 +0200 @@ -0,0 +1,9 @@ +/* PR bootstrap/44509 */ +/* { dg-do compile } */ +/* { dg-options "--param ggc-min-expand=0 --param ggc-min-heapsize=0" } */ + +double +foo (void) +{ + return __DBL_MAX__ - __FLT_MAX__; +}