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: 79633 Delivered-To: patch@linaro.org Received: by 10.80.142.83 with SMTP id 19csp558805edx; Thu, 27 Oct 2016 03:26:02 -0700 (PDT) X-Received: by 10.99.117.71 with SMTP id f7mr10621869pgn.75.1477563962708; Thu, 27 Oct 2016 03:26:02 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s1si7197210pfb.29.2016.10.27.03.26.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Oct 2016 03:26:02 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-439701-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-439701-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-439701-patch=linaro.org@gcc.gnu.org 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=EkzAPxj41KNbnN5Urzm2/EYLlmuGCF8NnaVKYo41ljjm/VA+SuCxs 7sgdCr2tSQHeb/7hEaUR8hpLJ97pOQDjNohJInIbjhTdDQCDIJejI2t5ucZlK0Nz HnJq16Z3HCxN8Src44cBeR/4UIOr+R6jw7w9BvYIARkAkyZxR9hFjQ= 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=L0Dw8sQ2bzpGGHXkY69a GqAhd5P8Fh+QGXtG+PHIuLhtRwIlAkA/3ZO2qZBO8W2eWC85RpBXAxmBNWjqb8hY MbhbQNzXouGe38Vjq4FH+DanzylgxKeD5GxNGLuISGKWVdAQXwOJEGad4dCq5j2W WFT4ksNqTSAmtKR1WOy/J18= 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. -- Marc Glisse 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)