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: 194812 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1960813dyb; Wed, 31 Jan 2024 07:20:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+ntW+0nRBPmY3NsXN/F/7LDxSduBo9wK1lN+9D8+f97svt6vTdR9gs6E7A0htuOqOqLmP X-Received: by 2002:a9d:5f15:0:b0:6e0:fd9d:69e9 with SMTP id f21-20020a9d5f15000000b006e0fd9d69e9mr1799963oti.1.1706714457343; Wed, 31 Jan 2024 07:20:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706714457; cv=pass; d=google.com; s=arc-20160816; b=TDHa8PJh2+ZOsz/vqTZ1gtHHut24XeQUq6DNIjbHfaEk43GFK5QFP4SWrIxkYLR603 2EOnskj9hsC2+IoYq79j4wTGRhu26J1aZafFTblm27E/arLLlai3YDMSO+mGGyE5LS3l PhFGJXVGxU4jEe99yBfRKxlqpNvnuBP5q9Ar285JS6VtfHhTSipUiZoYxCDCVH2qsGp8 Vlo73b4pgly37uOL5KvO5HHC3uapm4YhvtpIT9g7OfUH/+i+S3R3acbbQdXwmtylj6Ru ysUzXyLA+mQw59YY8JtGgonlDyX21FqGXn12pbTKBe6wHRT4KHOOerI81d0Co/9FI/ep EpjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition:in-reply-to :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=RAP9NUCYRI1ncbB7USyoLXZFuU7M/lnFPH3GH/XtrOQ=; fh=UR9LlEV5WTvVCUisL1KdTp8+Xt/e1FSEMuhe2I01HcU=; b=T5On5zbo7kSsVQmaUF8Yur6OuuNf7Q0o1De/HY3zN4S8Shx3H8B9fVCDU5GMypUsix BRCD5x5hBgy2Cd+FPFgZIRRQnqCsJ9Mra/Fjq3HlJ9QElJNRyzapz2J5MJXf2WDT7oeD eeQX7+zBGf+61Ei9huU6dOwG0eI9FzQe5g/zvdXA9HcVEmzHpfF4y8HItbBKwRd9Myu0 8ORwzYKaDAFfAbbtMxm8FG/QBfTEQPaZ/90NkTOusMT/F8DPykjGsjWZKk4buxgzfJSk I65xOntSuHMe2lx6n+NjdR57txAZS3WMjDSXXPmxC8BYaarNG3HRAS3GXVEbeuTYXuyi Vdqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XO24zUde; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCWJDsff0gYbfCJ2GaYpn9fJDTEVN1FRKdj2vC5/9tBwYFBPdkZA/s6Duxjb+pGHUutQ+dOmDEHaFtATcgVyEkkfrAqpFw== Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l17-20020a05622a051100b00429bcc06f6asi12278471qtx.352.2024.01.31.07.20.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 07:20:57 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XO24zUde; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 114AA3858401 for ; Wed, 31 Jan 2024 15:20:57 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789619818919282169 X-GMAIL-MSGID: 1789619818919282169 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(); +}