From patchwork Fri Nov 20 14:31:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 546934 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 00B30140323 for ; Sat, 21 Nov 2015 01:31:49 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ykQEAHgV; 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:to :from:subject:cc:message-id:date:mime-version:content-type; q= dns; s=default; b=ran3toWPmMGxpTutqk0Pphhr+eaVtDaCeOXOXxP48LxGWC 6TuqTL9FEEl2SN0mKyNvX1sT52EfuGYg1khdYtiZDGzr1RuWgYtFW8CC3Tz97JLx E2E3B5y8bU2zEMdyMCre0iR4gpaJcN9kFjLNLCzFnRGxEJmO9m2eFo4X4oF9A= 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:to :from:subject:cc:message-id:date:mime-version:content-type; s= default; bh=/ksQjTzNXBmK9Wno+91kXXjYo08=; b=ykQEAHgVwCH+194JBNLK CHk0UUQIAf5hKYVZddvFJaG6wCQ4Wd8vy8XKVMaBwxvVVI9bNgobvJxk1bqrbEIn nP9wUa285KEzJ80fT34kvDruBPlLEU/aZV/vhgyNG91bS0MW7ESgj0Mwi8V+cjub 5t9A8dsORFs6WZNHpX0Ayms= Received: (qmail 38079 invoked by alias); 20 Nov 2015 14:31:42 -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 38065 invoked by uid 89); 20 Nov 2015 14:31:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f176.google.com Received: from mail-yk0-f176.google.com (HELO mail-yk0-f176.google.com) (209.85.160.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 20 Nov 2015 14:31:31 +0000 Received: by ykba77 with SMTP id a77so163775989ykb.2 for ; Fri, 20 Nov 2015 06:31:29 -0800 (PST) X-Received: by 10.129.82.145 with SMTP id g139mr1550472ywb.335.1448029889364; Fri, 20 Nov 2015 06:31:29 -0800 (PST) Received: from ?IPv6:2601:181:c000:c497:a2a8:cdff:fe3e:b48? ([2601:181:c000:c497:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id w1sm14661224ywe.5.2015.11.20.06.31.28 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 20 Nov 2015 06:31:28 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: [ptx] overrride anchor hook Cc: Jakub Jelinek Message-ID: <564F2EC0.5060109@acm.org> Date: Fri, 20 Nov 2015 09:31:28 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Jim discovered that he needed to override the anchoring hook when using a PPC host-side compiler, but didn't figure out why this was needed. Digging into it, I discovered that flag_section_anchors is cleared in toplev.c by the command line option machinery, if there are no anchor target hooks. However, that's done in the host compiler and the LTO machinery simply copies the value over into the LTO compiler. Usually that's fine, as the LTO compiler's for the same target architecture. Except when it's an offload compiler. The flags are not resanitized (perhaps that should be done?) Anyway, that led to the PTX accelerator compiler trying to do section anchory things. Fixed by overriding TARGET_USE_ANCHORS_FOR_SYMBOL_P to say 'no'. I guess at the next instance of an offload compiler seeing a 'surprising' combination of optimization flags, we'll need a resanitize hook? Jakub? nathan 2015-11-20 Nathan Sidwell James Norris * config/nvptx/nvptx.c (nvptx_use_anchors_for_symbol_p): New. (TARGET_USE_ANCHORS_FOR_SYMBOL_P): Override. Index: config/nvptx/nvptx.c =================================================================== --- config/nvptx/nvptx.c (revision 230657) +++ config/nvptx/nvptx.c (working copy) @@ -3895,6 +3895,19 @@ nvptx_cannot_copy_insn_p (rtx_insn *insn return false; } } + +/* Section anchors do not work. Initialization for flag_section_anchor + probes the existence of the anchoring target hooks and prevents + anchoring if they don't exist. However, we may be being used with + a host-side compiler that does support anchoring, and hence see + the anchor flag set (as it's not recalculated). So provide an + implementation denying anchoring. */ + +static bool +nvptx_use_anchors_for_symbol_p (const_rtx ARG_UNUSED (a)) +{ + return false; +} /* Record a symbol for mkoffload to enter into the mapping table. */ @@ -4914,6 +4927,9 @@ nvptx_goacc_reduction (gcall *call) #undef TARGET_CANNOT_COPY_INSN_P #define TARGET_CANNOT_COPY_INSN_P nvptx_cannot_copy_insn_p +#undef TARGET_USE_ANCHORS_FOR_SYMBOL_P +#define TARGET_USE_ANCHORS_FOR_SYMBOL_P nvptx_use_anchors_for_symbol_p + #undef TARGET_INIT_BUILTINS #define TARGET_INIT_BUILTINS nvptx_init_builtins #undef TARGET_EXPAND_BUILTIN