From patchwork Thu Jan 8 19:09:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Stump X-Patchwork-Id: 426836 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 4F4C1140140 for ; Fri, 9 Jan 2015 06:10:35 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; q=dns; s=default; b=tetLI2H9eD24XrFrf eBFTLv1Vo35ouPKMh2foumCyvzojqBH+NLxWJ0zvoEhqTSFsr064vluK+fw926SE XFZxm8A5ezH1rXKw0lOUdbebWnft+mTc6cztTkVz48OA8DS/7Pu2fuJKXO7Bbt4N 0xQYFh8+nW222EfV3xF7myFWsA= 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 :content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; s=default; bh=E1wQxWNEa5kYO90QtLzATd+ kySE=; b=UVuMEnRfWMG7czgjXRriqvic5I6tBwuWJg6iGkk7iF0udq2ctd6E2pB B7KtoPNP1S3x2XricEKwB8e9VoYrygaEeCSRJ2LB/ptAwkt+6h6MY3XnUNaZFY0/ wvMicRVj2TWhpQdeAcHM9X8T1rmILc4rLXetwzz7gHitQ6bl0bAw= Received: (qmail 31165 invoked by alias); 8 Jan 2015 19:10:27 -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 31140 invoked by uid 89); 8 Jan 2015 19:10:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: resqmta-po-07v.sys.comcast.net Received: from resqmta-po-07v.sys.comcast.net (HELO resqmta-po-07v.sys.comcast.net) (96.114.154.166) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 08 Jan 2015 19:10:24 +0000 Received: from resomta-po-02v.sys.comcast.net ([96.114.154.226]) by resqmta-po-07v.sys.comcast.net with comcast id dX9P1p0024tLnxL01XAM4H; Thu, 08 Jan 2015 19:10:21 +0000 Received: from [IPv6:2001:558:6045:a4:40c6:7199:cd03:b02d] ([IPv6:2001:558:6045:a4:40c6:7199:cd03:b02d]) by resomta-po-02v.sys.comcast.net with comcast id dXAJ1p0012ztT3H01XALlQ; Thu, 08 Jan 2015 19:10:21 +0000 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: [PATCH] Fix sporadic failure in g++.dg/tsan/aligned_vs_unaligned_race.C From: Mike Stump In-Reply-To: <20150107082339.GN1667@tucnak.redhat.com> Date: Thu, 8 Jan 2015 11:09:46 -0800 Cc: Bernd Edlinger , "H.J. Lu" , "gcc-patches@gcc.gnu.org" , Dmitry Vyukov Message-Id: <047F6317-2B29-407A-A33E-94EBF782598C@comcast.net> References: <20150106091633.GF1667@tucnak.redhat.com> <20150107082339.GN1667@tucnak.redhat.com> To: Jakub Jelinek X-IsSubscribed: yes On Jan 7, 2015, at 12:23 AM, Jakub Jelinek wrote: > > I'm fine with adding the no_sanitize_thread attribute, the patch LGTM Thanks, I checked it in, the doc seemed trivial enough. * tsan.c (pass_tsan::gate): Add no_sanitize_thread support. (pass_tsan_O0::gate): Likewise. * extend.texi (Function Attributes): Add no_sanitize_thread documentation. c-family: * c-common.c (c_common_attribute_table): Add no_sanitize_thread. Index: doc/extend.texi =================================================================== --- doc/extend.texi (revision 219354) +++ doc/extend.texi (revision 219355) @@ -2205,6 +2205,7 @@ attributes are currently defined for fun @code{returns_nonnull}, @code{gnu_inline}, @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial}, @code{no_sanitize_address}, @code{no_address_safety_analysis}, +@code{no_sanitize_thread}, @code{no_sanitize_undefined}, @code{no_reorder}, @code{bnd_legacy}, @code{bnd_instrument}, @code{error} and @code{warning}. @@ -3721,6 +3722,12 @@ The @code{no_address_safety_analysis} is @code{no_sanitize_address} attribute, new code should use @code{no_sanitize_address}. +@item no_sanitize_thread +@cindex @code{no_sanitize_thread} function attribute +The @code{no_sanitize_thread} attribute on functions is used +to inform the compiler that it should not instrument memory accesses +in the function when compiling with the @option{-fsanitize=thread} option. + @item no_sanitize_undefined @cindex @code{no_sanitize_undefined} function attribute The @code{no_sanitize_undefined} attribute on functions is used Index: c-family/c-common.c =================================================================== --- c-family/c-common.c (revision 219354) +++ c-family/c-common.c (revision 219355) @@ -764,6 +764,9 @@ const struct attribute_spec c_common_att { "no_sanitize_address", 0, 0, true, false, false, handle_no_sanitize_address_attribute, false }, + { "no_sanitize_thread", 0, 0, true, false, false, + handle_no_sanitize_address_attribute, + false }, { "no_sanitize_undefined", 0, 0, true, false, false, handle_no_sanitize_undefined_attribute, false }, Index: tsan.c =================================================================== --- tsan.c (revision 219354) +++ tsan.c (revision 219355) @@ -868,7 +868,9 @@ public: opt_pass * clone () { return new pass_tsan (m_ctxt); } virtual bool gate (function *) { - return (flag_sanitize & SANITIZE_THREAD) != 0; + return ((flag_sanitize & SANITIZE_THREAD) != 0 + && !lookup_attribute ("no_sanitize_thread", + DECL_ATTRIBUTES (current_function_decl))); } virtual unsigned int execute (function *) { return tsan_pass (); } @@ -908,7 +910,9 @@ public: /* opt_pass methods: */ virtual bool gate (function *) { - return (flag_sanitize & SANITIZE_THREAD) != 0 && !optimize; + return ((flag_sanitize & SANITIZE_THREAD) != 0 && !optimize + && !lookup_attribute ("no_sanitize_thread", + DECL_ATTRIBUTES (current_function_decl))); } virtual unsigned int execute (function *) { return tsan_pass (); }