From patchwork Fri Aug 26 13:00:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 663086 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3sLLlB0d9Vz9sXR for ; Fri, 26 Aug 2016 23:01:06 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Yhgz4p26; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=TeZb/HL/8Ae2pd30JCbzhbsUUdBl4GtORaZH56Ai9KK81NTzmE iGCaAFLYdn08CS31WUDPostnR4sTQz1oZcls9VsjcnpebGN0N5x6X26ETsLTNAU8 AplsLehSrBKmLII4b/uflA+AmVqEyT8lBc9p6PXKt2KExaDTgxbSgdgRo= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=VgU9Ctb6iUXvj/zaKuoFOZUv3qg=; b=Yhgz4p26B/ALNbhKLjIn 4w+TRoPgZjiLttqD0QWy1gqZWJhj71spbf2905pGUpTUBOi1zrReFynjrSdzmvCc i2m4W1c049Qr8jxwCVxEopuv5K/6bNX8ovX5WlShn0kn0jJiGiMi0VWVHyOsn+Df ZRsZMmVIsZI1SV6ekOlK+4o= Received: (qmail 114071 invoked by alias); 26 Aug 2016 13:00: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 114056 invoked by uid 89); 26 Aug 2016 13:00:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=encoder, sk:streame, U*nathan, output_block X-HELO: mail-qk0-f180.google.com Received: from mail-qk0-f180.google.com (HELO mail-qk0-f180.google.com) (209.85.220.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 Aug 2016 13:00:47 +0000 Received: by mail-qk0-f180.google.com with SMTP id z190so75225216qkc.0 for ; Fri, 26 Aug 2016 06:00:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:to:cc:from:subject:message-id:date :user-agent:mime-version; bh=2SOfrfC66RRYULmywpJ7NZSJCxlGEsrKz7rnlmLVgNI=; b=isRYpzILfWviv126LraAaTFoMXXsWm4l/AsKqRvFFDj68erikf8Xoqo6pnzpmAiYCB Jhb4C9hBNx1AlSdeRmsVlBhFUvx+yVDvf/4yRdLwVt1PLk3RLx3zkKFFxL3QU5HKs8Aa lmER+slziqc10bH+DLv+9AneN7eewAvdaTE56ogerfqjwbYEh2ZFq/ksFmpPk7F747I0 n2920C8JP13VRoyyxl6rXJFmNDN7917FqEa8KUve/YeL6Xo29PDcjetO8dvLtticKM4+ 3ZH2Y2K2Q/GnSWKmajaN3ZNxH00PNEQiocTDl9W4SfCyIGuQN+CqofL3AuijpacMsXDt I1GA== X-Gm-Message-State: AE9vXwPwNUjofcpXWak8dORBOaUct3s1SMrt4PzCa15yjmb58/BYlNfEvQ3jp3LqGSgXtA== X-Received: by 10.55.26.36 with SMTP id a36mr3096434qka.273.1472216446288; Fri, 26 Aug 2016 06:00:46 -0700 (PDT) Received: from ?IPv6:2601:181:c003:1930:3fe6:c217:b86a:6e86? ([2601:181:c003:1930:3fe6:c217:b86a:6e86]) by smtp.googlemail.com with ESMTPSA id k20sm10303510qkl.2.2016.08.26.06.00.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Aug 2016 06:00:45 -0700 (PDT) To: GCC Patches Cc: Richard Guenther From: Nathan Sidwell Subject: [lto] remove unnecessary assignment Message-ID: <6c43c6bf-8fd7-cf68-e0ef-4b2d6e9542e7@acm.org> Date: Fri, 26 Aug 2016 09:00:44 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In chasing down an LTO read/write bug I came across some 'interesting' code in inline_write_summaries: if (cnode && (node = cnode)->definition && !node->alias) that in-test assignment isn't needed -- cnode is not modified until the next loop iteration. Fixed as obvious by removing the 'node' variable. nathan 2016-08-26 Nathan Sidwell * ipa-inline-analysis.c (inline_write_summary): Remove unnecessary assignment inside if condition. Index: ipa-inline-analysis.c =================================================================== --- ipa-inline-analysis.c (revision 239778) +++ ipa-inline-analysis.c (working copy) @@ -4430,7 +4430,6 @@ write_inline_edge_summary (struct output void inline_write_summary (void) { - struct cgraph_node *node; struct output_block *ob = create_output_block (LTO_section_inline_summary); lto_symtab_encoder_t encoder = ob->decl_state->symtab_node_encoder; unsigned int count = 0; @@ -4449,19 +4448,16 @@ inline_write_summary (void) { symtab_node *snode = lto_symtab_encoder_deref (encoder, i); cgraph_node *cnode = dyn_cast (snode); - if (cnode && (node = cnode)->definition && !node->alias) + if (cnode && cnode->definition && !cnode->alias) { - struct inline_summary *info = inline_summaries->get (node); + struct inline_summary *info = inline_summaries->get (cnode); struct bitpack_d bp; struct cgraph_edge *edge; int i; size_time_entry *e; struct condition *c; - streamer_write_uhwi (ob, - lto_symtab_encoder_encode (encoder, - - node)); + streamer_write_uhwi (ob, lto_symtab_encoder_encode (encoder, cnode)); streamer_write_hwi (ob, info->estimated_self_stack_size); streamer_write_hwi (ob, info->self_size); streamer_write_hwi (ob, info->self_time); @@ -4494,9 +4490,9 @@ inline_write_summary (void) write_predicate (ob, info->loop_iterations); write_predicate (ob, info->loop_stride); write_predicate (ob, info->array_index); - for (edge = node->callees; edge; edge = edge->next_callee) + for (edge = cnode->callees; edge; edge = edge->next_callee) write_inline_edge_summary (ob, edge); - for (edge = node->indirect_calls; edge; edge = edge->next_callee) + for (edge = cnode->indirect_calls; edge; edge = edge->next_callee) write_inline_edge_summary (ob, edge); } }