From patchwork Fri Jan 25 15:06:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1031146 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-494744-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="pTMSXnDg"; dkim-atps=neutral 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 43mMnT46tSz9s7h for ; Sat, 26 Jan 2019 02:07:09 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=U3eUuhe9fTEK0OUp8lUeqfkGMfOuUG/x81FQwXEyt0rYcXn5Uc crYj97KDjJZUPNbTHTQgqYriNTqRWvfGvmyUGjzpIKkxaz5iXaPxtZYxRQkH91DJ J/IPLmZv5KwV7Z/hutEjvwIUdHZOhmvML/Hc+mizMff1YfchrFM9x+th8= 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 :from:subject:message-id:date:mime-version:content-type; s= default; bh=Cgok/448tORW/NZkbucnXy1mkcQ=; b=pTMSXnDg4gpnefsLRSdM iHoa0qTXfg/KVxS7dCzr5N7czpDw2OTjvzYPzacS+8jYsWdSEcU5zzWeena1M7s8 TxBfkEDaWiT/pI4c2SwBgUfDCQb8RGhK3BC3G5BvO9MhSWb798Pil35Iqj+QK9WO /jk+VkNo+MxyPbRIlON+ALw= Received: (qmail 100627 invoked by alias); 25 Jan 2019 15:06:49 -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 100537 invoked by uid 89); 25 Jan 2019 15:06:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=H*r:sk:19.2019 X-HELO: mail-qt1-f181.google.com Received: from mail-qt1-f181.google.com (HELO mail-qt1-f181.google.com) (209.85.160.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Jan 2019 15:06:46 +0000 Received: by mail-qt1-f181.google.com with SMTP id d19so10970840qtq.9 for ; Fri, 25 Jan 2019 07:06:46 -0800 (PST) Received: from [192.168.1.115] (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id q17sm80215641qtc.19.2019.01.25.07.06.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jan 2019 07:06:44 -0800 (PST) To: gcc-patches List , Jan Hubicka From: Jason Merrill Subject: RFA: PATCH to gimple-fold.c for c++/80916, bogus "static but not defined" warning Message-ID: <3770ed3f-9788-cf4d-5857-e69504f595c7@redhat.com> Date: Fri, 25 Jan 2019 10:06:37 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 X-IsSubscribed: yes Here we warn because i::dispatch has internal linkage (because l does) and is never instantiated (because the vtable is never emitted). The regression happened because devirtualization started adding it to cgraph as a possible target. I think the way to fix this is to avoid adding an undefined internal function to cgraph as a possible target, since it is not, in fact, possible for it to be the actual target. I think that the best place to fix this would be in can_refer_decl_in_current_unit_p, since the same reasoning applies to other possible references. But we could fix it only in gimple_get_virt_method_for_vtable. First patch tested x86_64-pc-linux-gnu. diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 92d3fb4a9e0..8d63d815a5e 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -7146,7 +7146,10 @@ gimple_get_virt_method_for_vtable (HOST_WIDE_INT token, devirtualize. This can happen in WHOPR when the actual method ends up in other partition, because we found devirtualization possibility too late. */ - if (!can_refer_decl_in_current_unit_p (fn, vtable)) + if (!can_refer_decl_in_current_unit_p (fn, vtable) + || (!TREE_PUBLIC (decl) && DECL_EXTERNAL (decl) + && TREE_CODE (decl) == FUNCTION_DECL + && DECL_INITIAL (decl) == NULL_TREE)) { if (can_refer) {