From patchwork Tue Jun 26 08:54:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 934728 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-480477-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vOfopq7T"; 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 41FKd34Sdqz9s0W for ; Tue, 26 Jun 2018 18:55:34 +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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=JqwJx37/dzdFHXY3 zaA/uLwrbp3MGn8PHCvW98rbDuB4bRxPFCcn1Z2mYs3o49C7t2iJhyJKKtfwZ79j H4f/DV3vUrKFwWddtRQzyzUa0fp7SrCpM4WEi902sJz5KJqGaNZf06LlvRPkcTDv LrLqmUqRMHcGVYIhW2QlIWNHxMI= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=xWOwymqR71cq3HngJ9z3Kd x4XqE=; b=vOfopq7T5QiI00zT0YuIjxnzPXLlsx3a2W2l78+bF48dZU/zkw1nwk 59MjpO/eRFbV96TmjkTaCfRSiZURdkBvvEnLTPgirtU1nnrXp+sXs57LG83cBhUw tSGJlq8hYbJiOxgfTXTrd+iN6MOpf5FxV14VsYZrWXeYxB++KSRJE= Received: (qmail 36920 invoked by alias); 26 Jun 2018 08:55:27 -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 36899 invoked by uid 89); 26 Jun 2018 08:55:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=profi, Hx-languages-length:3371 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Jun 2018 08:55:25 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 2E47F818D7 for ; Tue, 26 Jun 2018 10:55:22 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Lae9xOEccbLz for ; Tue, 26 Jun 2018 10:55:22 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 05CA081549 for ; Tue, 26 Jun 2018 10:55:21 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Remap goto_locus on edges during inlining Date: Tue, 26 Jun 2018 10:54:59 +0200 Message-ID: <1959532.xT2u3vGzl1@polaris> MIME-Version: 1.0 Hi, this makes sure the goto_locus present (or not) on edges is properly remapped during inlining. Tested on x86-64/Linux, OK for the mainline? 2018-06-26 Eric Botcazou * tree-inline.c (remap_location): New function extracted from... (copy_edges_for_bb): Add ID parameter. Remap goto_locus. (copy_phis_for_bb): ...here. Call remap_location. (copy_cfg_body): Adjust call to copy_edges_for_bb. Index: tree-inline.c =================================================================== --- tree-inline.c (revision 262129) +++ tree-inline.c (working copy) @@ -718,6 +718,7 @@ remap_block (tree *block, copy_body_data } /* Copy the whole block tree and root it in id->block. */ + static tree remap_blocks (tree block, copy_body_data *id) { @@ -738,6 +739,7 @@ remap_blocks (tree block, copy_body_data } /* Remap the block tree rooted at BLOCK to nothing. */ + static void remap_blocks_to_null (tree block, copy_body_data *id) { @@ -747,6 +749,27 @@ remap_blocks_to_null (tree block, copy_b remap_blocks_to_null (t, id); } +/* Remap the location info pointed to by LOCUS. */ + +static location_t +remap_location (location_t locus, copy_body_data *id) +{ + if (LOCATION_BLOCK (locus)) + { + tree *n = id->decl_map->get (LOCATION_BLOCK (locus)); + gcc_assert (n); + if (*n) + return set_block (locus, *n); + } + + locus = LOCATION_LOCUS (locus); + + if (locus != UNKNOWN_LOCATION && id->block) + return set_block (locus, id->block); + + return locus; +} + static void copy_statement_list (tree *tp) { @@ -2145,7 +2168,8 @@ update_ssa_across_abnormal_edges (basic_ static bool copy_edges_for_bb (basic_block bb, profile_count num, profile_count den, - basic_block ret_bb, basic_block abnormal_goto_dest) + basic_block ret_bb, basic_block abnormal_goto_dest, + copy_body_data *id) { basic_block new_bb = (basic_block) bb->aux; edge_iterator ei; @@ -2160,6 +2184,7 @@ copy_edges_for_bb (basic_block bb, profi { edge new_edge; int flags = old_edge->flags; + location_t locus = old_edge->goto_locus; /* Return edges do get a FALLTHRU flag when they get inlined. */ if (old_edge->dest->index == EXIT_BLOCK @@ -2167,8 +2192,10 @@ copy_edges_for_bb (basic_block bb, profi && old_edge->dest->aux != EXIT_BLOCK_PTR_FOR_FN (cfun)) flags |= EDGE_FALLTHRU; - new_edge = make_edge (new_bb, (basic_block) old_edge->dest->aux, flags); + new_edge + = make_edge (new_bb, (basic_block) old_edge->dest->aux, flags); new_edge->probability = old_edge->probability; + new_edge->goto_locus = remap_location (locus, id); } if (bb->index == ENTRY_BLOCK || bb->index == EXIT_BLOCK) @@ -2365,16 +2392,7 @@ copy_phis_for_bb (basic_block bb, copy_b inserted = true; } locus = gimple_phi_arg_location_from_edge (phi, old_edge); - if (LOCATION_BLOCK (locus)) - { - tree *n; - n = id->decl_map->get (LOCATION_BLOCK (locus)); - gcc_assert (n); - locus = set_block (locus, *n); - } - else - locus = LOCATION_LOCUS (locus); - + locus = remap_location (locus, id); add_phi_arg (new_phi, new_arg, new_edge, locus); } } @@ -2705,7 +2723,7 @@ copy_cfg_body (copy_body_data * id, if (!id->blocks_to_copy || (bb->index > 0 && bitmap_bit_p (id->blocks_to_copy, bb->index))) need_debug_cleanup |= copy_edges_for_bb (bb, num, den, exit_block_map, - abnormal_goto_dest); + abnormal_goto_dest, id); if (new_entry) {