From patchwork Wed Nov 8 15:51:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 163094 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp1003165vqo; Wed, 8 Nov 2023 07:52:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYGr79qhU0BNL2FUUpnWEyR1ovzy49decxpvG4kSGfMKuZd7aYJibI5sZZJMa79ldL7QII X-Received: by 2002:a05:6214:29c6:b0:66d:2785:a2b0 with SMTP id gh6-20020a05621429c600b0066d2785a2b0mr2101706qvb.29.1699458734502; Wed, 08 Nov 2023 07:52:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699458734; cv=pass; d=google.com; s=arc-20160816; b=SXFg/BzHJowJHrgSUSV2cTnLuv0AqbjyPJHDudxKIM8z+3IHkt7uEWM3zNAJDPLVmR 0ftoWQbBW+i/5HRR1Prpwogw5I5/t0jefCvnmKLZI4e4oMGS1EzmZy5JKxZ1vYMWWpUs kJb4OQuQ6k92OAktf55o7iFwY4Nf9vxZvfOn+FWDs5rQDE6wsEzMfVQUUXMPRhVU6Zn9 wgltryS8RV1RgPIpopCgerkQi4RAYBnUJ/fxd6edG7tIJVFsS6eB+a1mL6VgdmqKt1O5 yo8Ju1KQg+zzAUKdzSxFXFTcK+twwA8oBNmbSQP0mLAjzJdW7Ph7fx377iBC6OvtdESC PRXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :message-id:date:organization:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=KlaL/figWYWKfVDWAzvx8c5aQixh+mDwMrQmHlu8RqE=; fh=7tY8rTOuqhHtvd1a8NmdrHFoBheWP/a3QDo585Pw2h0=; b=yVzh2+OTZKo5KruCi5R9MHL5l//MzNbub0NPy6q/XGfzJbP8xGdD/objzfqILO7tm+ 517prO74qGeIgQ7W/cmecn5Q7FIwEbo3q5FjnLQdVWUAYZpPlHMnCifXFD9djuzM6QyL 97SFVxojg4lm3V6FEWOF0aFRCm1pnUSyDV1WmoF4FgqLkvUuFOKi2LX2/AMg+OlTtX9o CbCYodp0+2AVGRtiSWxXo1O6jwLqeX5k7sVO0GLpEaZ6RuQbmavGriAIJMLH3oY5z0S5 c/by33dwzKE89bMoAO4f8WtuD6cJ2LzRM4Q3FftBjrOdMzHXqQg6qWwGiYGZ6Ukdp4Av PFsw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=OVKypkDT; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g15-20020ad4514f000000b0066d20730d39si1508742qvq.356.2023.11.08.07.52.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 07:52:14 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=OVKypkDT; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1BEBD3875DE8 for ; Wed, 8 Nov 2023 15:52:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by sourceware.org (Postfix) with ESMTPS id 93DAC3858D37 for ; Wed, 8 Nov 2023 15:51:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 93DAC3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 93DAC3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699458695; cv=none; b=jt90YkEUTGmRJ3lTPT0BCTfO8ek4jZXh5Wy8wt5wTPpQOW/mu4endedWi+u3UR1svNmGbtZcIZsUh06LSdbiqJSwm0I7AGgEx1K4m8bHdJ/H04uC8Im4XetcwDVQNGt7IuJzZhmWgObfpba62nwxuSGkWDuo8JmDRzsCXWAkbko= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699458695; c=relaxed/simple; bh=k33hdNFcBO94uvYYbOeSX1PpXMLKae7z0SMAoNdNFlo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=TypvwtyfwqnhJE7Hd3Xyf86TC/4KljPyfPl1U7rgr769ZZpU9enuJmX9IdqI8XFpIhKIh2VKkFvyPYiPrXVIT2UXzi/mmd/fJ+kLBP+sd8Ywefadbmk9cBEzCf29iLPfgMkkqvjOhx4jZDFGjRo9EfqI5pPyR+cafeGLBR0rF+k= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-5a86b6391e9so85284447b3.0 for ; Wed, 08 Nov 2023 07:51:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1699458693; x=1700063493; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:date:organization:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=KlaL/figWYWKfVDWAzvx8c5aQixh+mDwMrQmHlu8RqE=; b=OVKypkDTauaE7VZL3xIEe9FNFE5bTCPDYowBdG0uUjwZ3swUpAdxyRGiAcJNJ8DVVH Eq96PtcBBUBCmV5JIGk3txiyhZBDBS1VqkJfIAtDgtDs+vqQUjNJT+0D9clobm9e75Iy 2R11UaY+9xoowopwKCGfUnOEy86FEa2tA50chcva6GwPXt7Jw/1DJXWhkgfoMMtJC2v+ c3GLQ9XmvQ/8Pa0tlnKPG3dWRnLwApZXM0dJ+k7GIgbZEmqsVFWxIC6j4GTBKgK9Z6BG +VU1LsI1Dad2TmX8rVLh3uzGYzUK3mODePORSy1k/vZf7ZlvTzHoNFZjifU7Rznf6FIP s5sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699458693; x=1700063493; h=mime-version:user-agent:message-id:date:organization:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KlaL/figWYWKfVDWAzvx8c5aQixh+mDwMrQmHlu8RqE=; b=rDbi17kPsn4e7R7B+evt2dk6VGOR7uRXNeMO+gM7dzEaZoxO8cPrLEp/WIZBCLsJhO uGynQjOsfiI9etwIkt3Rn9qljkQ9tmct0bMfvLe8c7mvbKjHukdnVZ7AsaK9Z6OBpasV W5A9TYjLtWj+PM8+wgxrzPJN7iMg8a/dGgE57GE1TtIzaGQGBtk91/ja6V3EURF6x4uV qpyPIUU+CnCsOvXwntx75NaL2KRu0rKf5sois1fWfMyVO07bZbtx1P7cbvdHfYcu2+Lv vvPvwUANuUkMzX+1jX8N0VjIm8onX9VYe4bt3iyq6RaTKbHG/vGsdSjoBeoNoGojrxPL kRjA== X-Gm-Message-State: AOJu0Yz/0ivSrOR71W3s4pDmp2weXZdJxNvku2SRPkowCBfQmxEHvyTS QXRlXIXaeOp6y8vHXldq1XxCZVx1e9nEQ+9OnyjzUw== X-Received: by 2002:a0d:e042:0:b0:5a9:117d:ddbc with SMTP id j63-20020a0de042000000b005a9117dddbcmr1912603ywe.15.1699458692991; Wed, 08 Nov 2023 07:51:32 -0800 (PST) Received: from free.home ([2804:7f1:2080:e9c8:ff5e:88e8:a900:d7b4]) by smtp.gmail.com with ESMTPSA id u198-20020a0debcf000000b005a42740fcd4sm7083167ywe.94.2023.11.08.07.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 07:51:32 -0800 (PST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 3A8FpNRu2214717 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 8 Nov 2023 12:51:24 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Cc: Eugene Rozenfeld Subject: [PATCH] skip debug stmts when assigning locus discriminators Organization: Free thinker, does not speak for AdaCore Date: Wed, 08 Nov 2023 12:51:23 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782011641637947967 X-GMAIL-MSGID: 1782011641637947967 c-c++-common/goacc/kernels-loop-g.c has been failing (compare-debug) on i686-linux-gnu since r13-3172, because the implementation enabled debug stmts to cause discriminators to be assigned differently, and the discriminators are printed in the .gkd dumps that -fcompare-debug compares. This patch prevents debug stmts from affecting the discriminators in nondebug stmts, but enables debug stmts to get discriminators just as nondebug stmts would if their line numbers match. I suppose we could arrange for discriminators to be omitted from the -fcompare-debug dumps, but keeping discriminators in sync is probably good to avoid other potential sources of divergence between debug and nondebug. Regstrapped on x86_64-linux-gnu, also tested with gcc-13 on i686- and x86_64-. Ok to install? (Eugene, I suppose what's special about this testcase, that may not apply to most other uses of assign_discriminators, is that goacc creates new functions out of already optimized code. I think assign_discriminators may not be suitable for new functions, with code that isn't exactly pristinely in-order. WDYT?) for gcc/ChangeLog * tree-cfg.cc (assign_discriminators): Handle debug stmts. --- gcc/tree-cfg.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index 40a6f2a3b529f..a30a2de33a106 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -1214,6 +1214,22 @@ assign_discriminators (void) { gimple *stmt = gsi_stmt (gsi); + /* Don't allow debug stmts to affect discriminators, but + allow them to take discriminators when they're on the + same line as the preceding nondebug stmt. */ + if (is_gimple_debug (stmt)) + { + if (curr_locus != UNKNOWN_LOCATION + && same_line_p (curr_locus, &curr_locus_e, + gimple_location (stmt))) + { + location_t loc = gimple_location (stmt); + location_t dloc = location_with_discriminator (loc, + curr_discr); + gimple_set_location (stmt, dloc); + } + continue; + } if (curr_locus == UNKNOWN_LOCATION) { curr_locus = gimple_location (stmt);