From patchwork Mon May 14 09:07:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 135699 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1494608lji; Mon, 14 May 2018 02:08:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo3jMZvLbA69+USw9LJPjpXPZa49JyvFzusioLCvn34fuoQZuwwHnK2F2PaGbn/ZCr+zKQr X-Received: by 2002:a17:902:8685:: with SMTP id g5-v6mr8792173plo.302.1526288896460; Mon, 14 May 2018 02:08:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526288896; cv=none; d=google.com; s=arc-20160816; b=C5gjpnSC3dkmd6JmC7wCXVswV7+ow+vmRRJYy3AEubDbKoPu8bcOKHN3STpbh7qADO zljoCskfwmIkpcGvvuHYP5b89FkOCfyy9jC1MS7p8TmB3Ii/6j5C3+jxges9QPv3VnIU sJ2Kk2M7lTqewzuwFbLnNiT10/3SyPST08sb0soHbsNh/5Qp7bDICnl0rGWkz50/6wDU ya6Qsrt+IObltWc120Tbhnf3+F+vYOLuvMmGf4Dwxk4jt4zE9MRWPHo7o8mHhAcneyXU f184Kjkl/j56Lt2l/nc2i9B6JX75pDwZMjDXYZYte3AVS1fzwRRJu3JsndF31BJr9Im0 unCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:delivered-to:sender :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=xEKpL0wQiJmPIvFT2dyB+0567PTQpXAZF0uoLCykYYk=; b=z8pZ65ymOWX9pcuNzOC6hFniUbf2S0JSsXF48W+xRrRYfu6c2UxS2FBywOoT0AkI3L 2hdvZR4LpaNlYyBP+uc3eqPtwLUFksVlDmsgaa20aMS+/H0qN/ZUGh5FfZQ7fmoHpE9F YYU+AZ+9ivcQr3Fv7IU6/YUI51iV5jSTwh0P02eCVkzSfS68eE9WF4AFqj6g31qKqNO0 X1o5RbbLh8yjnfdc8QBI+edT23J2zMEzSWnM3yb4zGc8Wn7FVF/5vUYEt5+gsB1qgQfc OTpJnn7YWaAtEiMgC+QOc20N4w/Z8jGIRF9IOlmm7fhEYdVfs53zvw3+oYNJwl2+zmZ9 dSeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ARhnXYaW; spf=pass (google.com: domain of gcc-patches-return-477622-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-477622-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 1-v6si8720927plj.122.2018.05.14.02.08.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 May 2018 02:08:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-477622-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 header.s=default header.b=ARhnXYaW; spf=pass (google.com: domain of gcc-patches-return-477622-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-477622-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=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=JfZ3ihCuZVLISJ/dFm+QnDC/1LLU3mykykkoAxIBolbfDX t2QkilinnuaGoSm7zlkoI3LPzG9kzCx8bqSFmJoya5acU7N8f6tOMd6OAFL3yRy9 3K6MG/b6zPfaU5oQov/Ia/yHwIUTPvX8lHiUBRPjRrOm0/Nt6X54u3wg5XxqM= 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=m9w/A5QtzioU3TKiEJnmHmNTHf8=; b=ARhnXYaWdMMp8j6OQ5/e t6jjIqRguolxyvAhrQAWzFVQyDif/+Tp9cvdQYvtRfmAZZ76ssnGjOBT7BCIvZoS RvLIUENzoDQUGHmbxQ77YAAZiJaCNj6FD5qDCsrJ7O+Icm94jxjRKb++dO+xLqSO 6ZQ5mP0I9C5ZrxNYjb5cQ/8= Received: (qmail 81077 invoked by alias); 14 May 2018 09:08:05 -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 81061 invoked by uid 89); 14 May 2018 09:08:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=85734, H*Ad:D*cz X-HELO: mail-wr0-f176.google.com Received: from mail-wr0-f176.google.com (HELO mail-wr0-f176.google.com) (209.85.128.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 May 2018 09:08:01 +0000 Received: by mail-wr0-f176.google.com with SMTP id 94-v6so11445771wrf.5 for ; Mon, 14 May 2018 02:08:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Il2KiuKPRDvnirfQjO7h+9Eig3YLGY9/pX5o9aa+p7g=; b=KxtVsBi0MzniHSR7H/+J/ixuKX6SrvhAAd7M7viunX0K2+Jl4pw7fNFqVXBRNgXqV2 TwKy8cAXtYpR4LJkK+a7AVD+Nowwq4dzbCIEQR2naHS7oSptHONJPqeIJLkLPt2U7WIh cpMEHpwO8bzjCOKVitWaOMTakjzIv+4rRROjfWuSBuRRQGvwiSAdosH5J+ftIdoiRnCJ Jfm5wV4vFEYBoubB60V1TWKdstcMz4f8fdA0+Sph6WCKfcjdnmyGD/0pZoI1fvrBndoI DgDNSye+Ed7pIfzfHYnUFfESWcjnAy3Meqoa5yytG5keSFxW/HLUa/ddOA13BGUifEtP NvxQ== X-Gm-Message-State: ALKqPwd4Bk+0ZcHKL+4apZdPkeEOcPKiitVU9mbzPGKZ0PM3Xn+q3q3o mvxPzD6SdsWRL/BokQtl+fEXmoUNh4BXF2C+TjmJx623 X-Received: by 2002:adf:ba4a:: with SMTP id t10-v6mr5952462wrg.219.1526288878988; Mon, 14 May 2018 02:07:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.222.16 with HTTP; Mon, 14 May 2018 02:07:57 -0700 (PDT) From: Prathamesh Kulkarni Date: Mon, 14 May 2018 14:37:57 +0530 Message-ID: Subject: PR85734 To: gcc Patches , Jan Hubicka , Richard Biener X-IsSubscribed: yes Hi, The attached patch tries to fix PR85734, by gating on !function_always_visible_to_compiler_p. Bootstrap+test in progress on x86_64. OK to commit if passes ? Thanks, Prathamesh 2018-05-14 Prathamesh Kulkarni PR ipa/85734 * ipa-pure-const.c (propagate_malloc): Gate call towarn_function_malloc on !funcion_always_visible_to_compiler_p. (pass_local_pure_const::execute): Likewise. testsuite/ * gcc.dg/ipa/pr85734.c: New test. diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index a80b6845633..ce8028c1639 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -1987,7 +1987,8 @@ propagate_malloc (void) bool malloc_decl_p = DECL_IS_MALLOC (node->decl); node->set_malloc_flag (true); - if (!malloc_decl_p && warn_suggest_attribute_malloc) + if (!malloc_decl_p && !function_always_visible_to_compiler_p (node->decl) + && warn_suggest_attribute_malloc) warn_function_malloc (node->decl); } } @@ -2221,7 +2222,8 @@ pass_local_pure_const::execute (function *fun) && !DECL_IS_MALLOC (current_function_decl)) { node->set_malloc_flag (true); - if (warn_suggest_attribute_malloc) + if (warn_suggest_attribute_malloc + && !function_always_visible_to_compiler_p (current_function_decl)) warn_function_malloc (node->decl); changed = true; if (dump_file) diff --git a/gcc/testsuite/gcc.dg/ipa/pr85734.c b/gcc/testsuite/gcc.dg/ipa/pr85734.c new file mode 100644 index 00000000000..e5fa21f0548 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr85734.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wsuggest-attribute=malloc" } */ + +__attribute__((noinline)) +static void *f1(__SIZE_TYPE__ sz) /* { dg-bogus "function might be candidate for attribute 'malloc'" } */ +{ + return __builtin_malloc (sz); +} + +__attribute__((noinline)) +static void *f2(__SIZE_TYPE__ sz) /* { dg-bogus "function might be candidate for attribute 'malloc'" } */ +{ + return f1 (sz); +} + +void *f3(__SIZE_TYPE__ sz) /* { dg-warning "function might be candidate for attribute 'malloc'" } */ +{ + return f2(sz); +}