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: 590178 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 56534140773 for ; Tue, 1 Mar 2016 09:04:45 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=NFU/SatN; dkim-atps=neutral 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=N64NK/yajivmgIHTtrULBslDJAZxlMrhj8Xj6gM45Ft6DY1a4s dznJtA3kP6VrsDg878sUzkqbojo/1llGfzHsFS7RkDyayo+YpP7dmLWQK5dbAazJ FoAiQ3Ma0y7KUGG4Wkol/t8hTDTN/Be4VE0FZrOoT6avnYZDl9MO8cnEY= 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=NFU/SatNWznFqk7YPPkP hKgIRMYiiyc06xaQxaUTR4ZYRgeJZtAeLheFgdTVO2OiQXKzIHGlTPK80EuerZKb J0ip/CJLvud2vQQUkhjybG3Plqp8Gz97m2xBa3KCG6h13wZxT273+zI55AyLrBTR RcFnKbKzyP4korgfNA0lbuw= 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