From patchwork Mon Feb 29 22:04:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 63262 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1490925lbc; Mon, 29 Feb 2016 14:04:49 -0800 (PST) X-Received: by 10.98.14.149 with SMTP id 21mr25385198pfo.79.1456783489633; Mon, 29 Feb 2016 14:04:49 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id on6si45512736pac.30.2016.02.29.14.04.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Feb 2016 14:04:49 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-422423-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; spf=pass (google.com: domain of gcc-patches-return-422423-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-422423-patch=linaro.org@gcc.gnu.org; dkim=pass header.i=@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Jvgud1TRv/gMBB2HoHYN4Y+3o20Wd86cRcWVPTJSA9hQbvh+qF Qy+XNj8J/PWyEGDKNMlyy9j0rjFmHTE28ncCxY3c1SeWuxBeE5DVwrzRYgVUmb7U ft/j26kaGg4P2c6pjyFCG/xEKKuF7++sw68RW+1H/Q1y0USwvvAodzaUY= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=cZUtEFSPOv8EyvPxY9+BjdMGVHA=; b=OJdEYNqxUpQMopr93Ps6 Xa9Yiohf1X//SQPlyNVN0svWuLFqQA/Cgr+ONifvb5t3oARhDiK4q2i0LQ47Z1yh gJx/HGeCXFAhMcvxgcamvomXrjnH59Sn0Y8T1YWXvM4CB6IxijnsvFHZvmeN9j81 /1wq2zt8OUxDJhnhaVmNRpY= Received: (qmail 9112 invoked by alias); 29 Feb 2016 22:04:37 -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 9100 invoked by uid 89); 29 Feb 2016 22:04:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=20160301, 2016-03-01, DECL_INITIAL, decl_initial X-HELO: mail-pf0-f169.google.com Received: from mail-pf0-f169.google.com (HELO mail-pf0-f169.google.com) (209.85.192.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 29 Feb 2016 22:04:35 +0000 Received: by mail-pf0-f169.google.com with SMTP id 124so37791091pfg.0 for ; Mon, 29 Feb 2016 14:04:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version; bh=8h5tI+LoyblAHZhRpl/MPhIDyBjnUmlrTZy+LRmODqs=; b=lF//S/15Yjmv5QgD18wNe9C0ViGzbB5USMTbb5X8aSa/MvIfn3UOBBi9UoqEu9detk gEoTNuUaqDpqGaH5Ei6Zg7PCE2JyuXrLVzPPaMf14g4xtiLM4pI2UHqam7A5g01o9gl0 7nt3P7+IOBHAcK9crOuunlpG8ggwxPjOypV7tUqhHtiekXR4ngZh3pJzBb+S9ZMCqNRg Gtt2WcsUmp1CxlkHSXM+BCVvvinY4oYk47TAfgZeDtYDtEVls0ZQRYhZs2w/Rp7JTHOi WXlF2ChsfLNtENkbDaqvkIpPPEKZ/KX44Ht9X2IK9n5joJASWA6rl3IIhAgeviFEGFNB 9Vmw== X-Gm-Message-State: AD7BkJKnksUzdmy4yfsyDi9Ju85HT8K58rJU+lTstCB5c6GEkXS1ee4gh2EPHbexcdCjy6WX X-Received: by 10.98.32.150 with SMTP id m22mr25151636pfj.27.1456783473523; Mon, 29 Feb 2016 14:04:33 -0800 (PST) Received: from [10.1.1.5] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.googlemail.com with ESMTPSA id 17sm40284678pfp.96.2016.02.29.14.04.30 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 29 Feb 2016 14:04:32 -0800 (PST) To: "gcc-patches@gcc.gnu.org" Cc: Jan Hubicka , Martin Jambor , Richard Biener From: kugan Subject: [RFC][PR69708] IPA inline not working for function reference in static const struc Message-ID: <56D4C069.8060200@linaro.org> Date: Tue, 1 Mar 2016 09:04:25 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, As discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69708 and corresponding mailing list discussion, IPA CP is not detecting a jump-function with the sq function as value. static int sq(int x) { return x * x; } static const F f = {sq}; ... dosomething (g(f, x)); ... I added a check at determine_locally_known_aggregate_parts to detect this. This fixes the testcase and passes x86-64-linux-gnu lto bootstrap and regression testing with no new regression. Does this look sensible place to fix this? Thanks, Kugan gcc/ChangeLog: 2016-03-01 Kugan Vivekanandarajah * ipa-prop.c (determine_locally_known_aggregate_parts): Determine jump function for static constant initialization. diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 72c2fed..22da097 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -1562,6 +1562,57 @@ determine_locally_known_aggregate_parts (gcall *call, tree arg, jfunc->agg.by_ref = by_ref; build_agg_jump_func_from_list (list, const_count, arg_offset, jfunc); } + else if ((TREE_CODE (arg) == VAR_DECL) + && is_global_var (arg)) + { + /* PR69708: Figure out aggregate jump-function with constant init + value. */ + struct ipa_known_agg_contents_list *n, **p; + HOST_WIDE_INT offset = 0, size, max_size; + varpool_node *node = varpool_node::get (arg); + if (node + && DECL_INITIAL (node->decl) + && TREE_READONLY (node->decl) + && TREE_CODE (DECL_INITIAL (node->decl)) == CONSTRUCTOR) + { + tree exp = DECL_INITIAL (node->decl); + unsigned HOST_WIDE_INT ix; + tree field, val; + bool reverse; + FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (exp), ix, field, val) + { + bool already_there = false; + if (!field) + break; + get_ref_base_and_extent (field, &offset, &size, + &max_size, &reverse); + if (max_size == -1 + || max_size != size) + break; + p = get_place_in_agg_contents_list (&list, offset, size, + &already_there); + if (!p) + break; + n = XALLOCA (struct ipa_known_agg_contents_list); + n->size = size; + n->offset = offset; + if (is_gimple_ip_invariant (val)) + { + n->constant = val; + const_count++; + } + else + n->constant = NULL_TREE; + n->next = *p; + *p = n; + } + } + if (const_count) + { + jfunc->agg.by_ref = by_ref; + build_agg_jump_func_from_list (list, const_count, arg_offset, jfunc); + } + } } static tree