From patchwork Mon Jul 24 08:42:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu X-Patchwork-Id: 792682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-458750-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="VGiVrR/D"; dkim-atps=neutral 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 3xGFPN1yy6z9s74 for ; Mon, 24 Jul 2017 18:47:35 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=uJ+5+yt9sy1UTZhA 2pHY8nxT6rVBYJN5T2hvZ87V1cBvbrdA+iOQtQFtcOZ1l/KZ6P08mOY+lgV1BAlD k0mWTb7Ad5LG1DvcIS+Q+bAOZMNXRLkHEPubByEEZjHCElCykUtKGi/BqGEoFRCR qsE79jSA3PTxyiexZVs2ZAddI60= 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:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=P09++m29guXQxSYzJDOZ9O RnHKs=; b=VGiVrR/DCSG6q/QlXYuwnFrGVkamJYPg53J0eiPdM83r77C7SP/WaR rKJ7j47HLTNGkRhdaaRInJaZAh17VmI2RJYc5pNNeI1TArXThTMWF/y0L3zkIwEQ FlcXAFxkFE7qJ65//GPomQX8xjthBKUmkn5fF5Yr3Jd7R+ZEcXU+Y= Received: (qmail 54657 invoked by alias); 24 Jul 2017 08:46:40 -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 53745 invoked by uid 89); 24 Jul 2017 08:46:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=studies, anchors, fc, Hx-languages-length:2424 X-HELO: smtprelay.synopsys.com Received: from smtprelay.synopsys.com (HELO smtprelay.synopsys.com) (198.182.60.111) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Jul 2017 08:46:26 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id EC82510C1581; Mon, 24 Jul 2017 01:46:24 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id D50F8445; Mon, 24 Jul 2017 01:46:24 -0700 (PDT) Received: from US01WXQAHTC1.internal.synopsys.com (us01wxqahtc1.internal.synopsys.com [10.12.238.230]) by mailhost.synopsys.com (Postfix) with ESMTP id C55D3442; Mon, 24 Jul 2017 01:46:24 -0700 (PDT) Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.106) by US01WXQAHTC1.internal.synopsys.com (10.12.238.230) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 24 Jul 2017 01:46:24 -0700 Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.104) by IN01WEHTCB.internal.synopsys.com (10.144.199.105) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 24 Jul 2017 14:16:21 +0530 Received: from nl20droid1.internal.synopsys.com (10.100.24.228) by IN01WEHTCA.internal.synopsys.com (10.144.199.243) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 24 Jul 2017 14:16:21 +0530 From: Claudiu Zissulescu To: CC: , , , , Claudiu Zissulescu Subject: [PATCH 4/7] [ARC] Use TARGET_USE_ANCHORS_FOR_SYMBOL_P. Date: Mon, 24 Jul 2017 10:42:56 +0200 Message-ID: <1500885779-12930-5-git-send-email-claziss@synopsys.com> In-Reply-To: <1500885779-12930-1-git-send-email-claziss@synopsys.com> References: <1500885779-12930-1-git-send-email-claziss@synopsys.com> MIME-Version: 1.0 From: Claudiu Zissulescu We don't want to use anchors for small data: the GP register acts as an anchor in that case. We also don't want to use them for PC-relative accesses, where the PC acts as an anchor. TLS symbols require special accesses as well, don't use anchors for such symbols. gcc/ 2017-04-28 Claudiu Zissulescu * config/arc/arc.c (arc_use_anchors_for_symbol_p): New function. (TARGET_USE_ANCHORS_FOR_SYMBOL_P): Define. gcc/testsuite 2017-04-28 Claudiu Zissulescu * gcc.target/arc/pr9001184797.c: New test. --- gcc/config/arc/arc.c | 24 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/arc/pr9001184797.c | 19 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 gcc/testsuite/gcc.target/arc/pr9001184797.c diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 3980a0f..c94b187 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -10687,6 +10687,30 @@ arc_builtin_setjmp_frame_value (void) return gen_raw_REG (Pmode, FRAME_POINTER_REGNUM); } +/* Implement TARGET_USE_ANCHORS_FOR_SYMBOL_P. We don't want to use + anchors for small data: the GP register acts as an anchor in that + case. We also don't want to use them for PC-relative accesses, + where the PC acts as an anchor. Prohibit also TLS symbols to use + anchors. */ + +static bool +arc_use_anchors_for_symbol_p (const_rtx symbol) +{ + if (SYMBOL_REF_TLS_MODEL (symbol)) + return false; + + if (flag_pic) + return false; + + if (SYMBOL_REF_SMALL_P (symbol)) + return false; + + return default_use_anchors_for_symbol_p (symbol); +} + +#undef TARGET_USE_ANCHORS_FOR_SYMBOL_P +#define TARGET_USE_ANCHORS_FOR_SYMBOL_P arc_use_anchors_for_symbol_p + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-arc.h" diff --git a/gcc/testsuite/gcc.target/arc/pr9001184797.c b/gcc/testsuite/gcc.target/arc/pr9001184797.c new file mode 100644 index 0000000..e76c676 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/pr9001184797.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target tls } */ +/* { dg-options "-Os -w -mno-ll64" } */ + +/* This test studies the use of anchors and tls symbols. */ + +struct a b; +struct a { + long c; + long d +} e() { + static __thread struct a f; + static __thread g; + g = 5; + h(); + if (f.c) + g = g & 5; + f = b; +}