From patchwork Wed Jan 31 15:20:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1893559 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XO24zUde; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TQ5MY0qfLz23dQ for ; Thu, 1 Feb 2024 02:20:39 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 51C7538582AA for ; Wed, 31 Jan 2024 15:20:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id D153C3858C29 for ; Wed, 31 Jan 2024 15:20:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D153C3858C29 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D153C3858C29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706714419; cv=none; b=VPjCRoc4aaZZvFjtV5uciVFI/Yj+TYVjehB8IEm1GvbVVUifu5+7pA6rMbFDjMqnmNsvUrxTC4rVvMTx+XPFfCuH0nXU/GmmcungyW18tmjmk9EXqveg5Mty5SomFpqKRoIZU7VzXYU1Iau1e9luK3TeWx2hXhR33GN1MYU7rX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706714419; c=relaxed/simple; bh=SHLdf2Km8oHbeffu1INJ+s4RR95X2FDfWCPGJzGFwjU=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=b0ifH26SZCelFsQ4nlaC8PpXiwTsBdgNBMi6sWuW5VeKPKrm1BynVRtJEy8GtjdZCTqkBO/Mht8Hl7xuqQOJfLo6tF9xCyCpByXWDoBtyPOx2UQL4Ms3YQSTYvPxOzPxQQcDDuB8x9J7ozadzle0s6pK0O1D3e4FmhDTTina4H4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706714417; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=RAP9NUCYRI1ncbB7USyoLXZFuU7M/lnFPH3GH/XtrOQ=; b=XO24zUdeqKBv5HFaZDZSmvmLv8HmIvomt93vAXvl5Ev6LWZakYv6JrAU/G2SLZIHcmaVTc gCeOgmLG/+H1M0xlCROtWvKKYQN2fNt5Vn68Z42aAGetldtS/MoKlipjeIff1kJYKZDYfx MKH9+Dc3sn+JWhyDdPncAbzOGq1QRGw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-_YH7rTtGNlyLABmC-v_xUg-1; Wed, 31 Jan 2024 10:20:15 -0500 X-MC-Unique: _YH7rTtGNlyLABmC-v_xUg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CF3E93804085; Wed, 31 Jan 2024 15:20:13 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 91C433C2E; Wed, 31 Jan 2024 15:20:13 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 40VFKBxE291114 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 16:20:11 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 40VFKAjk291113; Wed, 31 Jan 2024 16:20:10 +0100 Date: Wed, 31 Jan 2024 16:20:10 +0100 From: Jakub Jelinek To: Richard Biener , Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] gimple-low: Remove .ASAN_MARK calls on TREE_STATIC variables [PR113531] Message-ID: References: <20240131033759.2236614-1-jason@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org On Wed, Jan 31, 2024 at 01:04:22PM +0100, Richard Biener wrote: > > Like this, so far just tested on the testcase. Ok for trunk if it passes > > bootstrap/regtest on top of Jason's patch? > > Note we fold all - well, all builtin - calls during gimple lowering. Internal calls aren't builtin, so those aren't folded. > Maybe we can put this special-casing there instead? (gimple-low.cc:797, > you possibly have to replace with a GIMPLE_NOP) But sure, we can do it there as well. In that case I think we don't need it in asan.cc though, because gimple-low.cc is guaranteed to be performed on all statements from gimplification that survive in the IL. So like this? 2024-01-31 Jakub Jelinek Jason Merrill PR c++/113531 * gimple-low.cc (lower_stmt): Remove .ASAN_MARK calls on variables which were promoted to TREE_STATIC. * g++.dg/asan/initlist1.C: New test. Jakub --- gcc/gimple-low.cc.jj 2024-01-03 11:51:22.133861623 +0100 +++ gcc/gimple-low.cc 2024-01-31 16:16:21.326927572 +0100 @@ -790,6 +790,21 @@ lower_stmt (gimple_stmt_iterator *gsi, s return; } + if (gimple_call_internal_p (stmt, IFN_ASAN_MARK)) + { + tree base = gimple_call_arg (stmt, 1); + gcc_checking_assert (TREE_CODE (base) == ADDR_EXPR); + tree decl = TREE_OPERAND (base, 0); + if (VAR_P (decl) && TREE_STATIC (decl)) + { + /* Don't poison a variable with static storage; it might have + gotten marked before gimplify_init_constructor promoted it + to static. */ + gsi_remove (gsi, true); + return; + } + } + /* We delay folding of built calls from gimplification to here so the IL is in consistent state for the diagnostic machineries job. */ --- gcc/testsuite/g++.dg/asan/initlist1.C.jj 2024-01-31 16:09:58.071289511 +0100 +++ gcc/testsuite/g++.dg/asan/initlist1.C 2024-01-31 16:09:58.071289511 +0100 @@ -0,0 +1,20 @@ +// PR c++/113531 +// { dg-do run { target c++11 } } +// { dg-additional-options "-fsanitize=address" } + +#include + +void f(int) { } + +void g() +{ + for (auto i : { 1, 2, 3 }) + f (i); + f(42); +} + +int main() +{ + g(); + g(); +}