From patchwork Mon Jul 8 09:32:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1128974 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-504591-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="U21WSPkJ"; 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 45j0bs4vdJz9sNf for ; Mon, 8 Jul 2019 19:32:33 +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=hjpAT0CWDvhnq+s6 C93pGx7xX+z9H6kyDb/Q8U1OE4nhpm6DvnbdG2T0yi4qfaAooFjL+LDqbfvi9sSc aGC6VWSaNnsWt3HdKZ1WZmvxYpADz/IMSaOVNkeakdnAW76JTdGTxdNtPKKX2FUS Kt8b5pL+lR95fkxiXLlXe7J0WSo= 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=4dWvYl8c0b/HFO6P7tXKBk f5ldM=; b=U21WSPkJxqZqukhzd97G2dnQ7HQ6I04kFIN7m0am+iIKA8re4EicxJ FLxVynxVH8TU6X9hEcvfxIRky5FalDM0Mz4/qCl8+xwqG1L9LivZ228IdBIkZtWX bm+V5FsuOxuCYvgwKtenDu+sOAp+wMzxQr9x0DzWHyf3ESXGHJUH0= Received: (qmail 43677 invoked by alias); 8 Jul 2019 09:32:26 -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 43669 invoked by uid 89); 8 Jul 2019 09:32:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=inheriting 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; Mon, 08 Jul 2019 09:32:24 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id E3F0681386 for ; Mon, 8 Jul 2019 11:32:21 +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 IZeDJK0ufVyQ for ; Mon, 8 Jul 2019 11:32:21 +0200 (CEST) Received: from polaris.localnet (unknown [IPv6:2a01:e35:8a16:3850:1a03:73ff:fe45:373a]) (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 BE16E81368 for ; Mon, 8 Jul 2019 11:32:21 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Small improvements to coverage info (3/n) Date: Mon, 08 Jul 2019 11:32:19 +0200 Message-ID: <7409263.WKbt3tlcc9@polaris> MIME-Version: 1.0 Hi, a couple of fixes for the RTL middle-end this time, with the same goal of preventing instructions from inheriting random source location information in the debug info generated by the compiler. Tested on x86_64-suse-linux, both GCC and GDB, OK for mainline? 2019-07-08 Eric Botcazou * emit-rtl.c (set_insn_locations): New function moved from... * function.c (set_insn_locations): ...here. * ira-emit.c (emit_moves): Propagate location of the first instruction to the inserted move instructions. * reg-stack.c (compensate_edge): Set the location if the sequence is inserted on the edge. * rtl.h (set_insn_locations): Declare. Index: emit-rtl.c =================================================================== --- emit-rtl.c (revision 273133) +++ emit-rtl.c (working copy) @@ -6582,6 +6582,18 @@ curr_insn_location (void) return curr_location; } +/* Set the location of the insn chain starting at INSN to LOC. */ +void +set_insn_locations (rtx_insn *insn, location_t loc) +{ + while (insn) + { + if (INSN_P (insn)) + INSN_LOCATION (insn) = loc; + insn = NEXT_INSN (insn); + } +} + /* Return lexical scope block insn belongs to. */ tree insn_scope (const rtx_insn *insn) Index: function.c =================================================================== --- function.c (revision 273133) +++ function.c (working copy) @@ -5244,19 +5244,6 @@ use_return_register (void) diddle_return_value (do_use_return_reg, NULL); } -/* Set the location of the insn chain starting at INSN to LOC. */ - -static void -set_insn_locations (rtx_insn *insn, int loc) -{ - while (insn != NULL) - { - if (INSN_P (insn)) - INSN_LOCATION (insn) = loc; - insn = NEXT_INSN (insn); - } -} - /* Generate RTL for the end of the current function. */ void Index: ira-emit.c =================================================================== --- ira-emit.c (revision 273133) +++ ira-emit.c (working copy) @@ -1011,6 +1011,10 @@ emit_moves (void) tmp = NEXT_INSN (tmp); if (NOTE_INSN_BASIC_BLOCK_P (tmp)) tmp = NEXT_INSN (tmp); + /* Propagate the location of the current first instruction to the + moves so that they don't inherit a random location. */ + if (tmp != NULL_RTX && INSN_P (tmp)) + set_insn_locations (insns, INSN_LOCATION (tmp)); if (tmp == BB_HEAD (bb)) emit_insn_before (insns, tmp); else if (tmp != NULL_RTX) Index: reg-stack.c =================================================================== --- reg-stack.c (revision 273133) +++ reg-stack.c (working copy) @@ -2929,6 +2929,7 @@ compensate_edge (edge e) seq = get_insns (); end_sequence (); + set_insn_locations (seq, e->goto_locus); insert_insn_on_edge (seq, e); return true; } Index: rtl.h =================================================================== --- rtl.h (revision 273133) +++ rtl.h (working copy) @@ -4338,6 +4338,7 @@ extern void insn_locations_init (void); extern void insn_locations_finalize (void); extern void set_curr_insn_location (location_t); extern location_t curr_insn_location (void); +extern void set_insn_locations (rtx_insn *, location_t); /* rtl-error.c */ extern void _fatal_insn_not_found (const_rtx, const char *, int, const char *)