From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76283 invoked by alias); 6 Mar 2018 12:01:06 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 76121 invoked by uid 89); 6 Mar 2018 12:00:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS,TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=H*r:10.223.157 X-HELO: mail-wr0-f169.google.com Received: from mail-wr0-f169.google.com (HELO mail-wr0-f169.google.com) (209.85.128.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Mar 2018 12:00:36 +0000 Received: by mail-wr0-f169.google.com with SMTP id m12so20621641wrm.13 for ; Tue, 06 Mar 2018 04:00:34 -0800 (PST) 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=vlPBI7fHNazFXpiR11DRqVHfSgaGe0O8aFctpIpseFs=; b=MWqF0PN0QeKhm/SHL59qzYBBS5XdBBI5Dqt+jnzyX9fmo6SDvLOPNvdrBH9M17dgPn 9p3iSAHmg9PiiXBv7M9mfdIkz1739FoNF4KLKIqXJT92/ftd1SQG42f1PJs8iK0sxNsh CZFIFas9NXnro/qEECAr6LWlEnBiaLcjZH9zySOJiBoleoGQCWeNU1k5SF/DM0K9rwYn 6pcYWrA8wa6DO9cDC0g9M7DRY3zTbKFrwLgjAA3stbgHNRFuoriXaeRYYsUc0LeK1Snp 3tdmhem6LtNrzvwuFHd5DTirtWBMbC8S5hxMiHlfbh9wWO2KDDW0JwFU9vnxnOhSz9SN Wnqw== X-Gm-Message-State: APf1xPC8vTTEQ7OrZZ/QB7rjDABlMSqRQRS+m6zDU7jzdmpoa3z0R4d/ ZyvQOBsmL/XabX41kS3qdpcPrz/QeifFncElvBOK+lQFHHg= X-Google-Smtp-Source: AG47ELtbmrLfKAc+rFRJtIZPe1Rik4Q7P88IF+l9oOHjng/5pHAbskT9nbiut5B55wDdj5QQph8jwmY7zwV8GF60VZY= X-Received: by 10.223.135.136 with SMTP id b8mr15482863wrb.72.1520337632950; Tue, 06 Mar 2018 04:00:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.157.73 with HTTP; Tue, 6 Mar 2018 04:00:32 -0800 (PST) From: Prathamesh Kulkarni Date: Tue, 06 Mar 2018 12:01:00 -0000 Message-ID: Subject: eliminate dead stores across functions To: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00059.txt.bz2 Hi, For the following test-case, int a; __attribute__((noinline)) static void foo() { a = 3; } int main() { a = 4; foo (); return a; } I assume it's safe to remove "a = 4" since 'a' would be overwritten by call to foo ? IIUC, ipa-reference pass does mod/ref analysis to compute side-effects of function call, so could we perhaps use ipa_reference_get_not_written_global() in dse pass to check if a global variable will be killed on call to a function ? If not, I suppose we could write a similar ipa pass that computes the set of killed global variables per function but I am not sure if that's the correct approach. Thanks, Prathamesh