From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AGHT+IHaotkiZrRLs6W1o/N2H0XZtUjWeJ88JNmP0GKMwQK9G7YQGT0gKn97rAEhSNKNLc+ntVMBkQ== 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 Content-Type: text/plain 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 List-Id: 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); -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer More tolerance and less prejudice are key for inclusion and diversity Excluding neuro-others for not behaving ""normal"" is *not* inclusive