From patchwork Sun Nov 13 17:29:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 81961 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp677697qge; Sun, 13 Nov 2016 09:30:17 -0800 (PST) X-Received: by 10.99.159.26 with SMTP id g26mr22278185pge.62.1479058217659; Sun, 13 Nov 2016 09:30:17 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id t184si19161034pgd.119.2016.11.13.09.30.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Nov 2016 09:30:17 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-441250-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-441250-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-441250-patch=linaro.org@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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=DkY5amhbjx6VHBM/ c9XenPuC73QcY8AfP2alJ2CSBHsZ28nF0AWahlh6rdi0ijvkMMnRRFjGJClQmCAi ZWodfuXgbnp2kMWhNB8zdiJWPe+KhbwlX+e3qbh2jeTqtEguonclg/j0DoPEV7pQ AXc2vWuf9qxlRuVIZ7i5H+sbaSo= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=wDQKwLLcDw1+s80JtsRK0y PWmxc=; b=f0E51smHj2PqR5iiXs0BsulGKvJxai66ktuRwboJzRNnh9hui9NDAK aK+5nMDgaCBZ46pUCw+WN0D8kVxpz/JpMtpdXi2jJxr1v85mvDuVX+szKsSrr91L UmV9CCAzfbVDjAF9d3GJzxDWqmsGiWENBqaRgDlL1/1yNq6ORFv7k= Received: (qmail 62277 invoked by alias); 13 Nov 2016 17:29:58 -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 62255 invoked by uid 89); 13 Nov 2016 17:29:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:decl_st, thunk, sk:DECL_ST, Natural X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 13 Nov 2016 17:29:46 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 19DFF812EC for ; Sun, 13 Nov 2016 18:29:44 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PxxaWN8WP6UM for ; Sun, 13 Nov 2016 18:29:43 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id DE9D3812EB for ; Sun, 13 Nov 2016 18:29:43 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix ICE in initialize_inlined_parameters with LTO Date: Sun, 13 Nov 2016 18:29:43 +0100 Message-ID: <1708227.BH4S3ROK0u@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-48-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 This is a regression present on the mainline and 6 branch: for the attached Ada testcase compiled in LTO mode, the following assertion triggers in initialize_inlined_parameters during inlining: if (p) { /* No static chain? Seems like a bug in tree-nested.c. */ gcc_assert (static_chain); setup_one_parameter (id, p, static_chain, fn, bb, &vars); } So we have a callee expecting a static chain but the caller doesn't pass one. It turns out that the caller is a thunk created by the ICF pass (as a wrapper in ICF's terminology) so it definitely cannot pass a static chain. Now ICF already makes sure that it doesn't create a wrapper in the opposite situation (alias expecting a static chain instead of original function) so the fixlet simply makes the test symmetric. Tested on x86_64-suse-linux, applied on the mainline and 6 branch as obvious. 2016-11-13 Eric Botcazou * ipa-icf.c (sem_function::merge): Do not create a wrapper also if the original function needs a static chain. 2016-11-13 Eric Botcazou * gnat.dg/lto21.adb: New test. * gnat.dg/lto21_pkg1.ads: New helper. * gnat.dg/lto21_pkg2.ad[sb]: Likewise. -- Eric Botcazou Index: ipa-icf.c =================================================================== --- ipa-icf.c (revision 242334) +++ ipa-icf.c (working copy) @@ -1186,11 +1186,12 @@ sem_function::merge (sem_item *alias_ite fprintf (dump_file, "Wrapper cannot be created because of COMDAT\n"); } - else if (DECL_STATIC_CHAIN (alias->decl)) + else if (DECL_STATIC_CHAIN (alias->decl) + || DECL_STATIC_CHAIN (original->decl)) { if (dump_file) fprintf (dump_file, - "Can not create wrapper of nested functions.\n"); + "Cannot create wrapper of nested function.\n"); } /* TODO: We can also deal with variadic functions never calling VA_START. */