From patchwork Wed Jul 3 10:46:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1126830 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-504283-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="QrNzRKjQ"; 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 45dyTk3ctkz9s4Y for ; Wed, 3 Jul 2019 20:46:50 +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=VWTjaouARp7G9QEO 4kOkWOG6Qrl/GZkA0HglAUJTaxArHl8GfNx+OzzqW21HrZGaOfaWoe0ECPe0wgqj iI5O+ysmchK9BlsuQ4ECyA5fSgAV0oid5d757w/LlWRRksI564QswSlvZ1Cm2Jxp YkHqoMBTeHSGdNOKzd5jugxT7uI= 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=1QG70agZHLXRGhnt2ZWLFz 3MpZA=; b=QrNzRKjQpMLHM04UPMg6sU7ssKgLDq5sRUt3yJwUhvz1zgtkitZgNu /+l2nb9Fg5AJC1A9gcPdUaLDrKaYPMaGlbmsUtiBIC/tBMqFYl9jpQ4MSQQXShDn exJuUzzO0JHSppFrxjfoPCBLM3Q4s+vIvUn6DcJ94Dj+s2Pi3rIqc= Received: (qmail 120366 invoked by alias); 3 Jul 2019 10:46:43 -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 120358 invoked by uid 89); 3 Jul 2019 10:46:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.5 required=5.0 tests=AWL, 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, ass 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; Wed, 03 Jul 2019 10:46:42 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id BFF8C814FA for ; Wed, 3 Jul 2019 12:46:39 +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 3y1bmb6fkdpH for ; Wed, 3 Jul 2019 12:46:39 +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 9D88D81399 for ; Wed, 3 Jul 2019 12:46:39 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Small improvements to coverage info (1/n) Date: Wed, 03 Jul 2019 12:46:37 +0200 Message-ID: <4824451.YNsNmM2r07@polaris> MIME-Version: 1.0 Hi, we have collected a number of small improvements to coverage info generated by the compiler over the years. One of the issues is when a new expression or statement is built without source location information and ends up inheriting the source location information of the previous instruction in the debug info, which can be totally unrelated. Tested on x86_64-suse-linux, both GCC and GDB, OK for mainline? 2019-07-03 Eric Botcazou * tree-cfg.c (gimple_make_forwarder_block): Propagate location info on phi nodes if possible. * tree-scalar-evolution.c (final_value_replacement_loop): Propagate location info on the newly created statement. * tree-ssa-loop-manip.c (create_iv): Propagate location info on the newly created increment if needed. Index: tree-cfg.c =================================================================== --- tree-cfg.c (revision 272930) +++ tree-cfg.c (working copy) @@ -5756,6 +5756,7 @@ gimple_make_forwarder_block (edge fallth basic_block dummy, bb; tree var; gphi_iterator gsi; + bool forward_location_p; dummy = fallthru->src; bb = fallthru->dest; @@ -5763,6 +5764,9 @@ gimple_make_forwarder_block (edge fallth if (single_pred_p (bb)) return; + /* We can forward location info if we have only one predecessor. */ + forward_location_p = single_pred_p (dummy); + /* If we redirected a branch we must create new PHI nodes at the start of BB. */ for (gsi = gsi_start_phis (dummy); !gsi_end_p (gsi); gsi_next (&gsi)) @@ -5774,7 +5778,8 @@ gimple_make_forwarder_block (edge fallth new_phi = create_phi_node (var, bb); gimple_phi_set_result (phi, copy_ssa_name (var, phi)); add_phi_arg (new_phi, gimple_phi_result (phi), fallthru, - UNKNOWN_LOCATION); + forward_location_p + ? gimple_phi_arg_location (phi, 0) : UNKNOWN_LOCATION); } /* Add the arguments we have stored on edges. */ Index: tree-scalar-evolution.c =================================================================== --- tree-scalar-evolution.c (revision 272930) +++ tree-scalar-evolution.c (working copy) @@ -3680,6 +3680,8 @@ final_value_replacement_loop (struct loo true, GSI_SAME_STMT); gassign *ass = gimple_build_assign (rslt, def); + gimple_set_location (ass, + gimple_phi_arg_location (phi, exit->dest_idx)); gsi_insert_before (&gsi, ass, GSI_SAME_STMT); if (dump_file) { Index: tree-ssa-loop-manip.c =================================================================== --- tree-ssa-loop-manip.c (revision 272930) +++ tree-ssa-loop-manip.c (working copy) @@ -126,10 +126,22 @@ create_iv (tree base, tree step, tree va gsi_insert_seq_on_edge_immediate (pe, stmts); stmt = gimple_build_assign (va, incr_op, vb, step); + /* Prevent the increment from inheriting a bogus location if it is not put + immediately after a statement whose location is known. */ if (after) - gsi_insert_after (incr_pos, stmt, GSI_NEW_STMT); + { + if (gsi_end_p (*incr_pos)) + { + edge e = single_succ_edge (gsi_bb (*incr_pos)); + gimple_set_location (stmt, e->goto_locus); + } + gsi_insert_after (incr_pos, stmt, GSI_NEW_STMT); + } else - gsi_insert_before (incr_pos, stmt, GSI_NEW_STMT); + { + gimple_set_location (stmt, gimple_location (gsi_stmt (*incr_pos))); + gsi_insert_before (incr_pos, stmt, GSI_NEW_STMT); + } initial = force_gimple_operand (base, &stmts, true, var); if (stmts)