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: 912771 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-477622-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="GC4pOFpd"; 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 40kvxT75JXz9ryk for ; Mon, 14 May 2018 19:08:12 +1000 (AEST) 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=oRUucyNaQssC2yfbG4uHzst5ifr7tvgHa1QgbRcIA+G1ZQ GyfUQewMWJeuEd9qaGZ/N1lH9n5s4uCrGPQzeVY1F/3j9NV5V4/2whQv+MLD4W6o 4kE4r1SEpPTcraIAkAcLi0V/TIVGMjICGntKZKNXGDhN6PXmhMRFKR/foAo3A= 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=GC4pOFpdnwg1TeouKgrz +rOQkaHwy+nDL/d+7P9qk8UQxFaTW/XiBWqnND4ZsmGuzxQdXlmXrHyVJF9096Uo 0H9/gMHT2I6CpKfXF92Ot4nSXRmcH21h8nuNNmub2aNknK3qfwIghnnurts+3eqV NWljAtdKgOULASsRd5l91OQ= 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-Google-Smtp-Source: AB8JxZo7KrA72ZTKZWQV8h0OEwZ4ArYKE6l2qKQdWR+J+rW4+kTZhfCCuPzwRXKZ9sPZaWL/K14hzMihyNm6s4PWtuw= 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); +}