From patchwork Fri Nov 25 07:58:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 84030 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp22121qgi; Thu, 24 Nov 2016 23:58:36 -0800 (PST) X-Received: by 10.98.4.134 with SMTP id 128mr6475437pfe.156.1480060716238; Thu, 24 Nov 2016 23:58:36 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id f22si14948390pli.271.2016.11.24.23.58.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Nov 2016 23:58:36 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-442604-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-442604-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-442604-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:from:date:message-id:subject:to:content-type; q= dns; s=default; b=eUTdDABZK2Bu7Cu+dTcSgwFgK2111ULpDbLSWWXxeXcZ6T MfeoZ5e/x8NHDnluufH+/C3McIfEY+r73HeOt6GX4UYsBgoQ6KJMpQ+zGFpan5qq o9T75mLbXqNMokFKPXEW+gyM+A0OJSjB4OLBkBMEyGy/hvI7yVPIOzrcGW0fs= 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:from:date:message-id:subject:to:content-type; s= default; bh=HyflS6uBJl54tfG06boGSZFIaK0=; b=WaYHLo7p/nDOEDnHHBbO P7url6nKk+VUeBL0wuaqDa5dX4vEYq+6WH/G4Fbd4UmJ1Sdqd4jVcJ25zeYHduUy SjH95Ax5rSIxANjiJwPvKHHWHoZyk/Mx5WX9TdL2klhKFgRQjkf06LCu++GjlZIR wHHnvbD1f8Yb3U8rVzewnxw= Received: (qmail 50132 invoked by alias); 25 Nov 2016 07:58:19 -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 50102 invoked by uid 89); 25 Nov 2016 07:58:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=6177, 2896, PR78501, pr78501 X-HELO: mail-io0-f182.google.com Received: from mail-io0-f182.google.com (HELO mail-io0-f182.google.com) (209.85.223.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Nov 2016 07:58:08 +0000 Received: by mail-io0-f182.google.com with SMTP id a124so113419458ioe.2 for ; Thu, 24 Nov 2016 23:58:08 -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:from:date:message-id:subject:to; bh=pFkBlURJwOR+QQH4WsElo1axurqkR1H+v10j+pbgEqQ=; b=HEeD5wfwUrtgVlr3aUSddsL7c+7YZEYvBN6ABItJ36A+E2xlkGj6R7aQkodfbC34hd VL5ozA3G17uVCieXwyLr6C8jIo43CgxfRKNVj5F2opdayQN6e9bi51ZFK8BHQKwZ5du/ tGKNe/TRajj9Zl3DNDpOmzCSik6e0XDw8EbbPBt12Zdtamcg8q+s7Qa/+RSYQWjMjg5S fSl/2/71oxs9R+XN9U6MbJW8Hc/EgJ8F7/U3FQBw8wDGIrDEfxG7mN20i2VuL9D0prx1 0JKJx7v1+7rEoA5vPW2koEtD/jWg/pMDpYiI99rpC4cLhlaXeObZ6rRDJ78NcK7zvEwv RSqA== X-Gm-Message-State: AKaTC02QrcT76bHGRCBCnQzEscv+dO82nP0rBgVASmuxjM/Xs2JGTDeTbU5ZW7O6QurebAUBCQtQLIr7DUhDw6Mx X-Received: by 10.36.58.85 with SMTP id m82mr5606217itm.29.1480060686749; Thu, 24 Nov 2016 23:58:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.136.156 with HTTP; Thu, 24 Nov 2016 23:58:06 -0800 (PST) From: Prathamesh Kulkarni Date: Fri, 25 Nov 2016 13:28:06 +0530 Message-ID: Subject: change initialization of ptrdiff_type_node To: gcc Patches , Richard Biener , Jakub Jelinek X-IsSubscribed: yes Hi, This patch changes initialization of ptrdiff_type_node in lto-lang.c, based on Jakub's suggestion in PR78501 comment 12: "The other uses of ptrdiff_type_node in the middle-end, which need fixing anyway, would need something like your patch, but not sure if it is not a waste of time to compute it if the C/C++ FE will immediately override it anyway. So perhaps just compute it that way in the LTO FE? I mean, for the *printf warning/length stuff, those calls shouldn't appear in Ada/Go/Fortran code, they can in LTO or C-family." For unsigned_ptrdiff_type_node, I removed it's definition from c-common.h and moved it to tree.h. Is that OK ? Thanks, Prathamesh 2016-11-25 Prathamesh Kulkarni * tree-core.h (TI_UNSIGNED_PTRDIFF_TYPE): New enum value. * tree.h (unsigned_ptrdiff_type_node): New macro. c-family/ * c-common.h (CTI_UNSIGNED_PTRDIFF_TYPE): Remove. (unsigned_ptrdiff_type_node): Likewise. lto/ * lto-lang.c (lto_init): Change initialization of ptrdiff_type_node. Initialize unsigned_ptrdiff_type_node. diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index a23193e..e93a65a 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -289,7 +289,6 @@ enum c_tree_index CTI_UNDERLYING_WCHAR_TYPE, CTI_WINT_TYPE, CTI_SIGNED_SIZE_TYPE, /* For format checking only. */ - CTI_UNSIGNED_PTRDIFF_TYPE, /* For format checking only. */ CTI_INTMAX_TYPE, CTI_UINTMAX_TYPE, CTI_WIDEST_INT_LIT_TYPE, @@ -432,7 +431,6 @@ extern const unsigned int num_c_common_reswords; #define underlying_wchar_type_node c_global_trees[CTI_UNDERLYING_WCHAR_TYPE] #define wint_type_node c_global_trees[CTI_WINT_TYPE] #define signed_size_type_node c_global_trees[CTI_SIGNED_SIZE_TYPE] -#define unsigned_ptrdiff_type_node c_global_trees[CTI_UNSIGNED_PTRDIFF_TYPE] #define intmax_type_node c_global_trees[CTI_INTMAX_TYPE] #define uintmax_type_node c_global_trees[CTI_UINTMAX_TYPE] #define widest_integer_literal_type_node c_global_trees[CTI_WIDEST_INT_LIT_TYPE] diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index a5f04ba..09b6d18 100644 --- 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 (); + } + unsigned_ptrdiff_type_node = unsigned_type_for (ptrdiff_type_node); lto_build_c_type_nodes (); gcc_assert (va_list_type_node); 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]