From patchwork Wed Mar 22 18:48:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 742289 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 3vpJcM6659z9s3s for ; Thu, 23 Mar 2017 05:48:51 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="QHVut03z"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=nFh9vxuMtf/Jj7ln8pjtaAoggcHNedM2mOaHXdUiyJe 3MQT03Ao4zrAavElg/PIB76L4yDqIox7Xa+nRaFXDFtf+PRlDUu1rIiNyifXUIcw lFAaOCQYdopmxkg7JgoYlk3TlASiM+5mjdrubmm9ifcrdV4SK39i/hBu/Yky05Ek = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=ytBLAkNrryty8nOBG5og/zVjVNY=; b=QHVut03zuhCncjPSk BwDX1ONpmXwfPDeN7/QUwnCYtXR6cFARnXVxGmhY3vbPLZ/gK9+1yu/h9LIBV1n+ M44U9isJFhmu9/Km3GA3GFfeBLOtvkxvM81SQC4pBo7xNV3xt5iacqtcL+GD6rgp WYsxqGXtqaniUc/zf9Q825PusY= Received: (qmail 49331 invoked by alias); 22 Mar 2017 18:48:37 -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 49207 invoked by uid 89); 22 Mar 2017 18:48:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*MI:20170322184813 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Mar 2017 18:48:22 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30FC0C054929 for ; Wed, 22 Mar 2017 18:48:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 30FC0C054929 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 30FC0C054929 Received: from tucnak.zalov.cz (ovpn-116-72.ams2.redhat.com [10.36.116.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCC3D7E634 for ; Wed, 22 Mar 2017 18:48:18 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v2MImEUH014594 for ; Wed, 22 Mar 2017 19:48:15 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v2MImDOe014593 for gcc-patches@gcc.gnu.org; Wed, 22 Mar 2017 19:48:13 +0100 Date: Wed, 22 Mar 2017 19:48:13 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Cherry-pick libtsan atomic fix (PR sanitizer/78158) Message-ID: <20170322184813.GH11094@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi! I've committed the following cherry-pick of upstream change for tsan atomics after bootstrapping/regtesting it on x86_64-linux and i686-linux. 2017-03-22 Jakub Jelinek PR sanitizer/78158 * tsan/tsan_interface_atomic.cc: Cherry-pick upstream r298378. Jakub --- libsanitizer/tsan/tsan_interface_atomic.cc (revision 298377) +++ libsanitizer/tsan/tsan_interface_atomic.cc (revision 298378) @@ -448,10 +448,27 @@ static void AtomicFence(ThreadState *thr // C/C++ +static morder covert_morder(morder mo) { + if (flags()->force_seq_cst_atomics) + return (morder)mo_seq_cst; + + // Filter out additional memory order flags: + // MEMMODEL_SYNC = 1 << 15 + // __ATOMIC_HLE_ACQUIRE = 1 << 16 + // __ATOMIC_HLE_RELEASE = 1 << 17 + // + // HLE is an optimization, and we pretend that elision always fails. + // MEMMODEL_SYNC is used when lowering __sync_ atomics, + // since we use __sync_ atomics for actual atomic operations, + // we can safely ignore it as well. It also subtly affects semantics, + // but we don't model the difference. + return (morder)(mo & 0x7fff); +} + #define SCOPED_ATOMIC(func, ...) \ const uptr callpc = (uptr)__builtin_return_address(0); \ uptr pc = StackTrace::GetCurrentPc(); \ - mo = flags()->force_seq_cst_atomics ? (morder)mo_seq_cst : mo; \ + mo = covert_morder(mo); \ ThreadState *const thr = cur_thread(); \ if (thr->ignore_interceptors) \ return NoTsanAtomic##func(__VA_ARGS__); \