From patchwork Thu Oct 27 10:25:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Glisse X-Patchwork-Id: 687528 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 3t4NMT2qFBz9sfH for ; Thu, 27 Oct 2016 21:25:57 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=AjNjQSH3; 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:mime-version:content-type; q=dns; s= default; b=FPNbZ064VFXPneWmgnjEkrag5fgoh1YDYunEGSMSj63U3SFytJh7Q NcweUmqHfwt1Yin/8KOG4gw/z/kKB0Vr9CjlFX4OKa+wEJJKr+Y+vFkJsUVuHbx2 N4hnRegOnNOPgvOt3Za6ItVEOLdAt6Rc5OGjREl9SfVu+BGOExnaGc= 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:mime-version:content-type; s= default; bh=4bwS+Oe0KfMT4cRaQcSf3CuEj9c=; b=AjNjQSH3mZ3ypNOXNPke f3YQYfiJuDuSYCD5/fNF75oh5tN47AjFIl31bKfeCdOp2BfKT66eIiF3DVlWnx0l bGFq5sl6g3mHTsw67qouVDEbqBlG1hRWhl98kG/DqvfGUBadz9G5qjAdgzNsn2Sr U4dOi6o6kGboGopjRTX2y5M= Received: (qmail 53857 invoked by alias); 27 Oct 2016 10:25:49 -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 53839 invoked by uid 89); 27 Oct 2016 10:25:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Protect, hide, H*c:HHHH, protect X-HELO: mail3-relais-sop.national.inria.fr Received: from mail3-relais-sop.national.inria.fr (HELO mail3-relais-sop.national.inria.fr) (192.134.164.104) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Oct 2016 10:25:38 +0000 Received: from ip-118.net-89-2-234.rev.numericable.fr (HELO laptop-mg.local) ([89.2.234.118]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 27 Oct 2016 12:25:36 +0200 Date: Thu, 27 Oct 2016 12:25:31 +0200 (CEST) From: Marc Glisse To: gcc-patches@gcc.gnu.org Subject: [libgcc] Protect __TMC_END__ - __TMC_LIST__ == 0 Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Hello, some optimization patch I was working on simplified __TMC_END__ - __TMC_LIST__ == 0 to false, which is not wanted (I assume that's why it wasn't written __TMC_END__ == __TMC_LIST__ in the first place). Bootstrap+regtest on powerpc64le-unknown-linux-gnu. 2016-10-27 Marc Glisse PR libgcc/77813 * crtstuff.c (deregister_tm_clones, register_tm_clones): Hide __TMC_END__ behind a passthrough asm. Index: libgcc/crtstuff.c =================================================================== --- libgcc/crtstuff.c (revision 241611) +++ libgcc/crtstuff.c (working copy) @@ -273,41 +273,47 @@ STATIC func_ptr __TMC_LIST__[] # ifdef HAVE_GAS_HIDDEN extern func_ptr __TMC_END__[] __attribute__((__visibility__ ("hidden"))); # endif static inline void deregister_tm_clones (void) { void (*fn) (void *); #ifdef HAVE_GAS_HIDDEN - if (__TMC_END__ - __TMC_LIST__ == 0) + func_ptr *end = __TMC_END__; + // Do not optimize the comparison to false. + __asm ("" : "+g" (end)); + if (__TMC_LIST__ == end) return; #else if (__TMC_LIST__[0] == NULL) return; #endif fn = _ITM_deregisterTMCloneTable; __asm ("" : "+r" (fn)); if (fn) fn (__TMC_LIST__); } static inline void register_tm_clones (void) { void (*fn) (void *, size_t); size_t size; #ifdef HAVE_GAS_HIDDEN - size = (__TMC_END__ - __TMC_LIST__) / 2; + func_ptr *end = __TMC_END__; + // Do not optimize the comparison to false. + __asm ("" : "+g" (end)); + size = (end - __TMC_LIST__) / 2; #else for (size = 0; __TMC_LIST__[size * 2] != NULL; size++) continue; #endif if (size == 0) return; fn = _ITM_registerTMCloneTable; __asm ("" : "+r" (fn)); if (fn)