From patchwork Thu Jan 26 17:44:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Richard Earnshaw \(lists\)" X-Patchwork-Id: 92544 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp313818obz; Thu, 26 Jan 2017 09:45:00 -0800 (PST) X-Received: by 10.99.176.14 with SMTP id h14mr4533599pgf.22.1485452700295; Thu, 26 Jan 2017 09:45:00 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id v10si204pge.382.2017.01.26.09.45.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jan 2017 09:45:00 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-447220-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-447220-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-447220-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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=sXfLoRH31mFtb3S2OEjBV4XT7LxMkTD8qh+o8benPURAEHsHes nUuEqOfN0sqWLJK9n5U6+LuWadaZVY+n4kD98mhc3A7Z75dg2agyYFCX4q2wnHyp k4y1r/ztw72RTQH7Oe1RRbonikCZwtPGVAfnfxbhcaqUjcHP/K6KvGeRA= 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:message-id:date:mime-version:content-type; s= default; bh=uFAhFxGPks719CeIFXuWJyddiZc=; b=BVIo4kzjOmWQJZBDJt3d A3VcbFOJnuqqKcEucrC2Se/VXmqhRC0OGGi8bsTIgR3BB5uuDkfvQbJvoYWhaafh /31E9Dy2PMkfkNVLQmeDJMoTWu2xWOI7k8CD/CjiYQ9okjETf9NWaRKnAeTlBCI7 YDfE5fND9s/WS0dfaxBZxGM= Received: (qmail 113761 invoked by alias); 26 Jan 2017 17:44:47 -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 113752 invoked by uid 89); 26 Jan 2017 17:44:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=xxx X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Jan 2017 17:44:45 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ECEFBC14; Thu, 26 Jan 2017 09:44:43 -0800 (PST) Received: from e105689-lin.cambridge.arm.com (e105689-lin.cambridge.arm.com [10.2.207.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7E1A83F242; Thu, 26 Jan 2017 09:44:43 -0800 (PST) To: gcc-patches From: "Richard Earnshaw (lists)" Subject: [PATCH][ARM] Fix PR79239 - unrecognized insn after pragma gcc pop_options Message-ID: <3bbac626-8417-d6f0-5470-6b2eff5a6856@arm.com> Date: Thu, 26 Jan 2017 17:44:42 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 It turns out that because the compiler uses a hash table to save the cl_target_option structures it is unsafe to modify the result of build_target_option_node() (doing so will cause the hash lookup to fail). This PR was due to not properly understanding this limitation. The fix is to create temporary copies of the cl_target_option nodes for use during target option processing and then only creating the tree node once the options have been suitably modified. gcc: PR target/79239 * arm.c (arm_option_override): Don't call build_target_option_node until after doing all option overrides. (arm_valid_target_attribute_tree): Likewise. gcc/testsuite: * gcc.target/arm/pr79239.c: New test. This has passed cross-testing, but I'm currently waiting for a native bootstrap to complete before committing. R. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 96777f0..5ca9e00 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3256,6 +3256,7 @@ arm_option_override (void) { static const enum isa_feature fpu_bitlist[] = { ISA_ALL_FPU, isa_nobit }; static const enum isa_feature quirk_bitlist[] = { ISA_ALL_QUIRKS, isa_nobit}; + cl_target_option opts; isa_quirkbits = sbitmap_alloc (isa_num_bits); arm_initialize_isa (isa_quirkbits, quirk_bitlist); @@ -3283,14 +3284,9 @@ arm_option_override (void) arm_fpu_index = (enum fpu_type) fpu_index; } - /* Create the default target_options structure. We need this early - to configure the overall build target. */ - target_option_default_node = target_option_current_node - = build_target_option_node (&global_options); - - arm_configure_build_target (&arm_active_target, - TREE_TARGET_OPTION (target_option_default_node), - &global_options_set, true); + cl_target_option_save (&opts, &global_options); + arm_configure_build_target (&arm_active_target, &opts, &global_options_set, + true); #ifdef SUBTARGET_OVERRIDE_OPTIONS SUBTARGET_OVERRIDE_OPTIONS; @@ -3646,9 +3642,10 @@ arm_option_override (void) arm_option_check_internal (&global_options); arm_option_params_internal (); - /* Resynchronize the saved target options. */ - cl_target_option_save (TREE_TARGET_OPTION (target_option_default_node), - &global_options); + /* Create the default target_options structure. */ + target_option_default_node = target_option_current_node + = build_target_option_node (&global_options); + /* Register global variables with the garbage collector. */ arm_add_gc_roots (); @@ -30333,22 +30330,18 @@ tree arm_valid_target_attribute_tree (tree args, struct gcc_options *opts, struct gcc_options *opts_set) { - tree t; + struct cl_target_option cl_opts; if (!arm_valid_target_attribute_rec (args, opts)) return NULL_TREE; - t = build_target_option_node (opts); - arm_configure_build_target (&arm_active_target, TREE_TARGET_OPTION (t), - opts_set, false); + cl_target_option_save (&cl_opts, opts); + arm_configure_build_target (&arm_active_target, &cl_opts, opts_set, false); arm_option_check_internal (opts); /* Do any overrides, such as global options arch=xxx. */ arm_option_override_internal (opts, opts_set); - /* Resynchronize the saved target options. */ - cl_target_option_save (TREE_TARGET_OPTION (t), opts); - - return t; + return build_target_option_node (opts); } static void diff --git a/gcc/testsuite/gcc.target/arm/pr79239.c b/gcc/testsuite/gcc.target/arm/pr79239.c new file mode 100644 index 0000000..d1f1b28 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr79239.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_fp_ok } */ +/* { dg-add-options arm_fp } */ + +#pragma GCC push_options +#pragma GCC target "fpu=crypto-neon-fp-armv8" +int a, b; +extern __inline __attribute__((__gnu_inline__)) int fn1() {} + +#pragma GCC pop_options +void +fn2() { + if (b * 0.77 + 0.5) + a = 0; +}