From patchwork Fri Nov 25 09:11:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 84064 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp26712obn; Fri, 25 Nov 2016 01:12:11 -0800 (PST) X-Received: by 10.99.171.10 with SMTP id p10mr12276427pgf.36.1480065131804; Fri, 25 Nov 2016 01:12:11 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id d10si15177569plj.180.2016.11.25.01.12.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Nov 2016 01:12:11 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-442622-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-442622-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-442622-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=Onov9fGQcxHB1FS UZD7mP5vjEM24vLxY1TeaWi7cxa4hiKT2fjQES/QxaeW9o6M+y2o+JYw6oDQQ0K/ L18UI0QmqxnA20vL/OZCCexv8qFP95u9YAL7DIhEs+ZxPbCRpixhNrjnJCS2etty EAM8xOUpwLBBVmNAV2c+fRFaT19M= 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 :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=7BgBjEJBdDQSPc+IrFwzQ 4cjJ2o=; b=fDiVE9bYwqptGfVTYorwVsFwzI9FEOiaVNeMeDaO4HPPzuhQpf1gf bHV7APnEYRMizhgC60WkA5nk9jV1meg7wBUsvMB1IPB0denViKtvJa/neZ6Mwzsa IqTkggjy3vInZXXaZerWRvgHDemiR72LBojphFg8ryHDhbVfPN1pME= Received: (qmail 74717 invoked by alias); 25 Nov 2016 09:11:57 -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 74692 invoked by uid 89); 25 Nov 2016 09:11:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:GET_MOD, sk:get_mod, 60066, sk:a5f04ba X-HELO: mail-io0-f178.google.com Received: from mail-io0-f178.google.com (HELO mail-io0-f178.google.com) (209.85.223.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Nov 2016 09:11:45 +0000 Received: by mail-io0-f178.google.com with SMTP id x94so115967331ioi.3 for ; Fri, 25 Nov 2016 01:11:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=xbW4LF+vOY8lJhedhVfF9OvwC3M2ol9DykVXYHIzsfM=; b=Iqxq8H8TEYP2WtG/xv64Fn0iDedPAGhxURbCLXZAWEcziD8Mil0mklhoS3TimtP9BB Dd30TEG88/GNOWcRAx+jxORTMjfPvykRMzM/G6Cy3ppdHRFec6DjF5KYJ1QvqgeA/YOe D/VAMliyToqx+/7bRhMB5yedPpZtbnI0WCwGsUoxxhIyJsa3m834XkdA4O2fdUxuhjqS hjuQ6NklpNFEECu5x3EcPuH5tpb6/qxbpzArcfRaRxm1LT5cOrWVoZZ8o0CqYcT2eFSV RIDJ9wtUUg5gMts+2HgSPG1W4pefDm25+EbN9L8gaNhBoY2N/YKiRTA3wyi48CkpdErA KGIQ== X-Gm-Message-State: AKaTC03lM8bQ2fIrlNp6iwG3gP3I+58Ha41yFNdQYa4fKLONifgTvX0dzqo51hB0DwCqY7wvL+PA6qULP8OBUWIc X-Received: by 10.107.57.193 with SMTP id g184mr6160958ioa.183.1480065104246; Fri, 25 Nov 2016 01:11:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.136.156 with HTTP; Fri, 25 Nov 2016 01:11:43 -0800 (PST) In-Reply-To: References: <20161125080511.GG3541@tucnak.redhat.com> From: Prathamesh Kulkarni Date: Fri, 25 Nov 2016 14:41:43 +0530 Message-ID: Subject: Re: change initialization of ptrdiff_type_node To: Richard Biener Cc: Jakub Jelinek , gcc Patches X-IsSubscribed: yes On 25 November 2016 at 13:43, Richard Biener wrote: > On Fri, 25 Nov 2016, Jakub Jelinek wrote: > >> On Fri, Nov 25, 2016 at 01:28:06PM +0530, Prathamesh Kulkarni wrote: >> > --- a/gcc/lto/lto-lang.c >> > +++ b/gcc/lto/lto-lang.c >> > @@ -1271,8 +1271,30 @@ lto_init (void) >> > gcc_assert (TYPE_MAIN_VARIANT (const_tm_ptr_type_node) >> > == const_ptr_type_node); >> > >> > - ptrdiff_type_node = integer_type_node; >> > + if (strcmp (PTRDIFF_TYPE, "int") == 0) >> > + ptrdiff_type_node = integer_type_node; >> > + else if (strcmp (PTRDIFF_TYPE, "long int") == 0) >> > + ptrdiff_type_node = long_integer_type_node; >> > + else if (strcmp (PTRDIFF_TYPE, "long long int") == 0) >> > + ptrdiff_type_node = long_long_integer_type_node; >> > + else if (strcmp (PTRDIFF_TYPE, "short int") == 0) >> > + ptrdiff_type_node = short_integer_type_node; >> > + else >> > + { >> > + ptrdiff_type_node = NULL_TREE; >> > + for (int i = 0; i < NUM_INT_N_ENTS; i++) >> > + if (int_n_enabled_p[i]) >> > + { >> > + char name[50]; >> > + sprintf (name, "__int%d", int_n_data[i].bitsize); >> > + if (strcmp (name, PTRDIFF_TYPE) == 0) >> > + ptrdiff_type_node = int_n_trees[i].signed_type; >> > + } >> > + if (ptrdiff_type_node == NULL_TREE) >> > + gcc_unreachable (); >> > + } >> >> This looks ok to me. > > But I'd like to see this in build_common_tree_nodes alongside > the initialization of size_type_node (and thus removed from > c_common_nodes_and_builtins). This way you can simply remove > the lto-lang.c code as well. > > Please then also remove the ptrdiff_type_node re-set from > free_lang_data (). Hi Richard, Does this version look OK ? Validation in progress. Thanks, Prathamesh > >> > >> > + unsigned_ptrdiff_type_node = unsigned_type_for (ptrdiff_type_node); >> > lto_build_c_type_nodes (); >> > gcc_assert (va_list_type_node); >> >> But why this and the remaining hunks? Nothing in the middle-end >> needs it, IMHO it should be kept in c-family/. > > Yeah, this change looks unnecessary to me. > >> > diff --git a/gcc/tree-core.h b/gcc/tree-core.h >> > index eec2d4f..6c52387 100644 >> > --- a/gcc/tree-core.h >> > +++ b/gcc/tree-core.h >> > @@ -617,6 +617,7 @@ enum tree_index { >> > TI_SIZE_TYPE, >> > TI_PID_TYPE, >> > TI_PTRDIFF_TYPE, >> > + TI_UNSIGNED_PTRDIFF_TYPE, >> > TI_VA_LIST_TYPE, >> > TI_VA_LIST_GPR_COUNTER_FIELD, >> > TI_VA_LIST_FPR_COUNTER_FIELD, >> > diff --git a/gcc/tree.h b/gcc/tree.h >> > index 62cd7bb..ae69d0d 100644 >> > --- a/gcc/tree.h >> > +++ b/gcc/tree.h >> > @@ -3667,6 +3667,7 @@ tree_operand_check_code (const_tree __t, enum tree_code __code, int __i, >> > #define size_type_node global_trees[TI_SIZE_TYPE] >> > #define pid_type_node global_trees[TI_PID_TYPE] >> > #define ptrdiff_type_node global_trees[TI_PTRDIFF_TYPE] >> > +#define unsigned_ptrdiff_type_node global_trees[TI_UNSIGNED_PTRDIFF_TYPE] >> > #define va_list_type_node global_trees[TI_VA_LIST_TYPE] >> > #define va_list_gpr_counter_field global_trees[TI_VA_LIST_GPR_COUNTER_FIELD] >> > #define va_list_fpr_counter_field global_trees[TI_VA_LIST_FPR_COUNTER_FIELD] >> >> >> Jakub >> >> > > -- > Richard Biener > SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg) 2016-11-25 Prathamesh Kulkarni * tree.c (build_common_tree_nodes): Initialize ptrdiff_type_node. (free_lang_data): Remove assignment to ptrdiff_type_node. c-family/ * c-common.c (c_common_nodes_and_builtins): Remove initialization of ptrdiff_type_node. lto/ * lto-lang.c (lto_init): Remove initialization of ptrdiff_type_node. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 62174a9..0749361 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -4475,8 +4475,6 @@ c_common_nodes_and_builtins (void) default_function_type = build_varargs_function_type_list (integer_type_node, NULL_TREE); - ptrdiff_type_node - = TREE_TYPE (identifier_global_value (get_identifier (PTRDIFF_TYPE))); unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node); lang_hooks.decls.pushdecl diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index a5f04ba..58f6e0c 100644 --- a/gcc/lto/lto-lang.c +++ b/gcc/lto/lto-lang.c @@ -1271,8 +1271,6 @@ lto_init (void) gcc_assert (TYPE_MAIN_VARIANT (const_tm_ptr_type_node) == const_ptr_type_node); - ptrdiff_type_node = integer_type_node; - lto_build_c_type_nodes (); gcc_assert (va_list_type_node); diff --git a/gcc/tree.c b/gcc/tree.c index 11e0abc..57f2e9a 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -6006,7 +6006,6 @@ free_lang_data (void) free_lang_data_in_cgraph (); /* Create gimple variants for common types. */ - ptrdiff_type_node = integer_type_node; fileptr_type_node = ptr_type_node; const_tm_ptr_type_node = const_ptr_type_node; @@ -10314,6 +10313,30 @@ build_common_tree_nodes (bool signed_char) gcc_unreachable (); } + /* Define what type to use for ptrdiff_t. */ + if (strcmp (PTRDIFF_TYPE, "int") == 0) + ptrdiff_type_node = integer_type_node; + else if (strcmp (PTRDIFF_TYPE, "long int") == 0) + ptrdiff_type_node = long_integer_type_node; + else if (strcmp (PTRDIFF_TYPE, "long long int") == 0) + ptrdiff_type_node = long_long_integer_type_node; + else if (strcmp (PTRDIFF_TYPE, "short int") == 0) + ptrdiff_type_node = short_integer_type_node; + else + { + ptrdiff_type_node = NULL_TREE; + for (int i = 0; i < NUM_INT_N_ENTS; i++) + if (int_n_enabled_p[i]) + { + char name[50]; + sprintf (name, "__int%d", int_n_data[i].bitsize); + if (strcmp (name, PTRDIFF_TYPE) == 0) + ptrdiff_type_node = int_n_trees[i].signed_type; + } + if (ptrdiff_type_node == NULL_TREE) + gcc_unreachable (); + } + /* Fill in the rest of the sized types. Reuse existing type nodes when possible. */ intQI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (QImode), 0);