From patchwork Wed Jun 13 02:02:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 928578 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-479605-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="P56SABU0"; 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 41595Z1pYRz9s1R for ; Wed, 13 Jun 2018 12:03:30 +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; q=dns; s= default; b=SlQE0sFIYQc2IwnmyFWxb0o6zYkOszBTslwlAJRDSAUX/PgJj3+/a gMLYld4GLlUK92byuPlSSuQOHgl6npkhaVLjDxmbktMlU2+JD+WNwzCBxeRUYF/S 40WiqXZJRA6ivWcVVsnSQ3sYIVLQXGIzBbkQr5Tc6RnwQDFFQHDFEQ= 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; s= default; bh=FUe9Bcagih6xyQseWT6vHsjt9BQ=; b=P56SABU0mIvOjOejS+dy XXhMjG54+o04jcm+2+nEGSA5z8eQwCTcISNoknccVT7DtmDy6DJ/Ep5h7tJssNJ5 gba0rJniZkkc364yA4AHji456vo1zzWfXDllPTsAaYUIkXtQ3CihzX1NeKlnqS3j yqiwFIjzz3e/PCvmaWRouYM= Received: (qmail 121285 invoked by alias); 13 Jun 2018 02:03:21 -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 120651 invoked by uid 89); 13 Jun 2018 02:03:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=assignments, partition, america, America X-HELO: linux-libre.fsfla.org Received: from linux-libre.fsfla.org (HELO linux-libre.fsfla.org) (208.118.235.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Jun 2018 02:03:09 +0000 Received: from free.home (home.lxoliva.fsfla.org [172.31.160.164]) by linux-libre.fsfla.org (8.15.2/8.15.2/Debian-3) with ESMTP id w5D2331Y010688 for ; Wed, 13 Jun 2018 02:03:05 GMT Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTP id w5D22vf0122231; Tue, 12 Jun 2018 23:02:57 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: [PATCH] [PR86064] split single cross-partition range with nonzero locviews Date: Tue, 12 Jun 2018 23:02:57 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes We didn't split cross-partition ranges in loclists to output a whole-function location expression, but with nonzero locviews, we force loclists, and then we have to split to avoid cross-partition list entries. From: Alexandre Oliva for gcc/ChangeLog PR debug/86064 * dwarf2out.c (loc_list_has_views): Adjust comments. (dw_loc_list): Split single cross-partition range with nonzero locview. for gcc/testsuite/ChangeLog PR debug/86064 * gcc.dg/pr86064.c: New. --- gcc/dwarf2out.c | 18 ++++++++++++++++-- gcc/testsuite/gcc.dg/pr86064.c | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr86064.c diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 620e66986be6..0c5d7e0e0357 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -9982,7 +9982,15 @@ new_loc_list (dw_loc_descr_ref expr, const char *begin, var_loc_view vbegin, return retlist; } -/* Return true iff there's any nonzero view number in the loc list. */ +/* Return true iff there's any nonzero view number in the loc list. + + ??? When views are not enabled, we'll often extend a single range + to the entire function, so that we emit a single location + expression rather than a location list. With views, even with a + single range, we'll output a list if start or end have a nonzero + view. If we change this, we may want to stop splitting a single + range in dw_loc_list just because of a nonzero view, even if it + straddles across hot/cold partitions. */ static bool loc_list_has_views (dw_loc_list_ref list) @@ -17090,7 +17098,13 @@ dw_loc_list (var_loc_list *loc_list, tree decl, int want_address) of first partition and second one starting at the beginning of second partition. */ if (node == loc_list->last_before_switch - && (node != loc_list->first || loc_list->first->next) + && (node != loc_list->first || loc_list->first->next + /* If we are to emit a view number, we will emit + a loclist rather than a single location + expression for the entire function (see + loc_list_has_views), so we have to split the + range that straddles across partitions. */ + || !ZERO_VIEW_P (node->view)) && current_function_decl) { endname = cfun->fde->dw_fde_end; diff --git a/gcc/testsuite/gcc.dg/pr86064.c b/gcc/testsuite/gcc.dg/pr86064.c new file mode 100644 index 000000000000..5be820c78f84 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr86064.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-g -O2 -fno-var-tracking-assignments -gsplit-dwarf" } */ + +/* This used to fail with location views (implicitly) enabled, because + var-tracking (not at assignments) creates a range for d starting at + the load after the first call, and we did not split the range, + despite its crossing between hot and cold partitions, because it's + a single range, that we normally extend to the entire function. + However, because the range starts at a (presumed) nonzero view, we + end up outputting a loclist instead of a single location entry. + But then, -gsplit-dwarf selects (startx,length) loclist entries, + and the length ends up computing the difference between symbols in + different subsections. */ + +int a; +__attribute__((__cold__)) void b(); + +void e(int *); +int f(); + +void c() { + int d; + e(&d); + a = d; + if (f()) + b(); +}