{"id":2230371,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2230371/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/bmm.hi2c8on426.gcc.gcc-TEST.chris.bazley.151.1.1@forge-stage.sourceware.org/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<bmm.hi2c8on426.gcc.gcc-TEST.chris.bazley.151.1.1@forge-stage.sourceware.org>","date":"2026-04-29T17:10:14","name":"[v1,1/1] aarch64: Handle opts_set parameter properly in aarch64_option_restore","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"d8fb130bee8d77c9cff876114bf71c2cdbdac391","submitter":{"id":92535,"url":"http://patchwork.ozlabs.org/api/1.1/people/92535/?format=json","name":"Christopher Bazley via Sourceware Forge","email":"forge-bot+chris.bazley@forge-stage.sourceware.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/bmm.hi2c8on426.gcc.gcc-TEST.chris.bazley.151.1.1@forge-stage.sourceware.org/mbox/","series":[{"id":502114,"url":"http://patchwork.ozlabs.org/api/1.1/series/502114/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=502114","date":"2026-04-29T17:10:13","name":"aarch64: Handle opts_set parameter properly in aarch64_option_restore","version":1,"mbox":"http://patchwork.ozlabs.org/series/502114/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2230371/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2230371/checks/","tags":{},"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org; dmarc=none (p=none dis=none)\n header.from=forge-stage.sourceware.org","sourceware.org;\n spf=pass smtp.mailfrom=forge-stage.sourceware.org","server2.sourceware.org;\n arc=none smtp.remote-ip=38.145.34.39"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5P481VqNz1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 03:12:08 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 4ECB04BB8F4D\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 17:12:06 +0000 (GMT)","from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id 28BA84BB1C28\n for <gcc-patches@gcc.gnu.org>; Wed, 29 Apr 2026 17:11:36 +0000 (GMT)","from forge-stage.sourceware.org (localhost [IPv6:::1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256)\n (No client certificate requested)\n by forge-stage.sourceware.org (Postfix) with ESMTPS id F13FA43648\n for <gcc-patches@gcc.gnu.org>; Wed, 29 Apr 2026 17:11:35 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 4ECB04BB8F4D","OpenDKIM Filter v2.11.0 sourceware.org 28BA84BB1C28"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 28BA84BB1C28","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 28BA84BB1C28","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777482696; cv=none;\n b=jkI+XHi9sArxOL9yFo24A98DIzg1HAa1jfMaS+aS5sB2CDx0OuIRuW+/gzSVZDJkxw9NJ+hln1svJl76XOOD1YZs8LpSHqyDJIR0jxK4IGJ3FVi/b/r4yPVYrLnJ7iOsPVc8zMSRQzTCyPmBKENvVJYJwhjIUzL9tSdxdwAt/lU=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777482696; c=relaxed/simple;\n bh=KYhOUiXtKDtqRXp5Epg6kwhZq6WiyFcxpqH6xEefeuM=;\n h=From:Date:Subject:To:Message-ID;\n b=Zl+G04QBShHD50awMJoGnFOhCvFIpSGy+2Sng2rdUMJOMYlKaAFKT14wNZGU0S+kpd7e3w6HQSPPhscYzAurlTCf0ioXPRXHUgZbJ2tQUeitb3nZmmWnyXWcJ49AI3RacQdy0g1aWBYEhzuLpVxQCGHRaOWHBAybIA2mPrFaOwc=","ARC-Authentication-Results":"i=1; server2.sourceware.org","From":"Christopher Bazley via Sourceware Forge\n <forge-bot+chris.bazley@forge-stage.sourceware.org>","Date":"Wed, 29 Apr 2026 17:10:14 +0000","Subject":"[PATCH v1 1/1] aarch64: Handle opts_set parameter properly in\n aarch64_option_restore","To":"gcc-patches mailing list <gcc-patches@gcc.gnu.org>","Message-ID":"\n <bmm.hi2c8on426.gcc.gcc-TEST.chris.bazley.151.1.1@forge-stage.sourceware.org>","X-Mailer":"batrachomyomachia","X-Pull-Request-Organization":"gcc","X-Pull-Request-Repository":"gcc-TEST","X-Pull-Request":"https://forge.sourceware.org/gcc/gcc-TEST/pulls/151","References":"\n <bmm.hi2c8on426.gcc.gcc-TEST.chris.bazley.151.1.0@forge-stage.sourceware.org>","In-Reply-To":"\n <bmm.hi2c8on426.gcc.gcc-TEST.chris.bazley.151.1.0@forge-stage.sourceware.org>","X-Patch-URL":"\n https://forge.sourceware.org/chris.bazley/gcc/commit/266c39219d59821d57166bd149d3f54048b5cf9c","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Reply-To":"gcc-patches mailing list <gcc-patches@gcc.gnu.org>,\n chris.bazley@arm.com","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"From: Christopher Bazley <chris.bazley@arm.com>\n\nPreviously, the AArch64 implementation of TARGET_OPTION_RESTORE ignored\nthe opts_set parameter and its callee, aarch64_override_options_internal,\ninvoked SET_OPTION_IF_UNSET with &global_options_set instead of with\nopts_set.\n\nThat was bad for maintainability, because it was based on an assumption\nthat cl_target_option_restore would only be called with &global_options_set.\nOtherwise, if an option were set in *opts_set but not in global_options_set,\nthe corresponding value would have been wrongly overridden; conversely, if\nan option were set in global_options_set but not in *opts_set then its\nvalue would not have been overridden as expected.\n\nIt looks as though cl_target_option_restore is not currently called with\nan argument expression other than &global_options_set except by the arm,\ni386 and s390 backends. However, ascertaining that and ensuring it will\nalways be true wastes more time than simply doing the right thing.\n\ngcc/ChangeLog:\n\n\t* config/aarch64/aarch64-c.cc (aarch64_pragma_target_parse):\n\tPass &global_options_set as an argument to\n\taarch64_override_options_internal.\n\t* config/aarch64/aarch64-protos.h (aarch64_override_options_internal):\n\tAdd a parameter declaration for opts_set.\n\t* config/aarch64/aarch64.cc (aarch64_override_options_internal):\n\tAdd a parameter declaration for opts_set and use the argument\n\twhen invoking SET_OPTION_IF_UNSET.\n\t(aarch64_override_options): Pass &global_options_set as an argument to\n\taarch64_override_options_internal.\n\t(aarch64_option_restore): As above.\n\t(aarch64_set_current_function): As above.\n\t(aarch64_option_valid_attribute_p): As above.\n\t(aarch64_option_valid_version_attribute_p): As above.\n---\n gcc/config/aarch64/aarch64-c.cc     |  2 +-\n gcc/config/aarch64/aarch64-protos.h |  3 +-\n gcc/config/aarch64/aarch64.cc       | 58 +++++++++++++++--------------\n 3 files changed, 33 insertions(+), 30 deletions(-)","diff":"diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc\nindex b2cc3e67f6da..21a3f3b1237e 100644\n--- a/gcc/config/aarch64/aarch64-c.cc\n+++ b/gcc/config/aarch64/aarch64-c.cc\n@@ -358,7 +358,7 @@ aarch64_pragma_target_parse (tree args, tree pop_target)\n       if (!aarch64_process_target_attr (args))\n \treturn false;\n \n-      aarch64_override_options_internal (&global_options);\n+      aarch64_override_options_internal (&global_options, &global_options_set);\n     }\n \n   /* args is NULL, restore to the state described in pop_target.  */\ndiff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h\nindex afacc004cb90..16b58f39a97e 100644\n--- a/gcc/config/aarch64/aarch64-protos.h\n+++ b/gcc/config/aarch64/aarch64-protos.h\n@@ -1140,7 +1140,8 @@ void aarch64_expand_tag_memory (rtx, rtx, rtx);\n #endif /* RTX_CODE */\n \n bool aarch64_process_target_attr (tree);\n-void aarch64_override_options_internal (struct gcc_options *);\n+void aarch64_override_options_internal (struct gcc_options *,\n+\t\t\t\t\tstruct gcc_options *);\n \n const char *aarch64_general_mangle_builtin_type (const_tree);\n void aarch64_general_init_builtins (void);\ndiff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc\nindex 37c28c8f2f8f..fb4c46ce04df 100644\n--- a/gcc/config/aarch64/aarch64.cc\n+++ b/gcc/config/aarch64/aarch64.cc\n@@ -19599,12 +19599,15 @@ aarch64_override_options_after_change_1 (struct gcc_options *opts)\n }\n \n /* 'Unpack' up the internal tuning structs and update the options\n-    in OPTS.  The caller must have set up selected_tune and selected_arch\n+    in OPTS.  OPTS_SET can be used to avoid overriding values that\n+    were explicitly set on the command line.\n+    The caller must have set up selected_tune and selected_arch\n     as all the other target-specific codegen decisions are\n     derived from them.  */\n \n void\n-aarch64_override_options_internal (struct gcc_options *opts)\n+aarch64_override_options_internal (struct gcc_options *opts,\n+\t\t\t\t   struct gcc_options *opts_set)\n {\n   const struct processor *tune = aarch64_get_tune_cpu (opts->x_selected_tune);\n   aarch64_tune = tune->sched_core;\n@@ -19736,33 +19739,31 @@ aarch64_override_options_internal (struct gcc_options *opts)\n \tgcc_unreachable ();\n     }\n \n-  /* We don't mind passing in global_options_set here as we don't use\n-     the *options_set structs anyway.  */\n-  SET_OPTION_IF_UNSET (opts, &global_options_set,\n+  SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t       param_sched_autopref_queue_depth, queue_depth);\n \n   /* Set up parameters to be used in prefetching algorithm.  Do not\n      override the defaults unless we are tuning for a core we have\n      researched values for.  */\n   if (aarch64_tune_params.prefetch->num_slots > 0)\n-    SET_OPTION_IF_UNSET (opts, &global_options_set,\n+    SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t\t param_simultaneous_prefetches,\n \t\t\t aarch64_tune_params.prefetch->num_slots);\n   if (aarch64_tune_params.prefetch->l1_cache_size >= 0)\n-    SET_OPTION_IF_UNSET (opts, &global_options_set,\n+    SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t\t param_l1_cache_size,\n \t\t\t aarch64_tune_params.prefetch->l1_cache_size);\n   if (aarch64_tune_params.prefetch->l1_cache_line_size >= 0)\n-    SET_OPTION_IF_UNSET (opts, &global_options_set,\n+    SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t\t param_l1_cache_line_size,\n \t\t\t aarch64_tune_params.prefetch->l1_cache_line_size);\n \n   if (aarch64_tune_params.prefetch->l1_cache_line_size >= 0)\n     {\n-      SET_OPTION_IF_UNSET (opts, &global_options_set,\n+      SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t\t   param_destruct_interfere_size,\n \t\t\t   aarch64_tune_params.prefetch->l1_cache_line_size);\n-      SET_OPTION_IF_UNSET (opts, &global_options_set,\n+      SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t\t   param_construct_interfere_size,\n \t\t\t   aarch64_tune_params.prefetch->l1_cache_line_size);\n     }\n@@ -19770,28 +19771,28 @@ aarch64_override_options_internal (struct gcc_options *opts)\n     {\n       /* For a generic AArch64 target, cover the current range of cache line\n \t sizes.  */\n-      SET_OPTION_IF_UNSET (opts, &global_options_set,\n+      SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t\t   param_destruct_interfere_size,\n \t\t\t   256);\n-      SET_OPTION_IF_UNSET (opts, &global_options_set,\n+      SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t\t   param_construct_interfere_size,\n \t\t\t   64);\n     }\n \n   if (aarch64_tune_params.prefetch->l2_cache_size >= 0)\n-    SET_OPTION_IF_UNSET (opts, &global_options_set,\n+    SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t\t param_l2_cache_size,\n \t\t\t aarch64_tune_params.prefetch->l2_cache_size);\n   if (!aarch64_tune_params.prefetch->prefetch_dynamic_strides)\n-    SET_OPTION_IF_UNSET (opts, &global_options_set,\n+    SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t\t param_prefetch_dynamic_strides, 0);\n   if (aarch64_tune_params.prefetch->minimum_stride >= 0)\n-    SET_OPTION_IF_UNSET (opts, &global_options_set,\n+    SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t\t param_prefetch_minimum_stride,\n \t\t\t aarch64_tune_params.prefetch->minimum_stride);\n \n   /* Use the alternative scheduling-pressure algorithm by default.  */\n-  SET_OPTION_IF_UNSET (opts, &global_options_set,\n+  SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t       param_sched_pressure_algorithm,\n \t\t       SCHED_PRESSURE_MODEL);\n \n@@ -19805,7 +19806,7 @@ aarch64_override_options_internal (struct gcc_options *opts)\n \n   /* Enforce that interval is the same size as size so the mid-end does the\n      right thing.  */\n-  SET_OPTION_IF_UNSET (opts, &global_options_set,\n+  SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t       param_stack_clash_protection_probe_interval,\n \t\t       guard_size);\n \n@@ -19830,13 +19831,13 @@ aarch64_override_options_internal (struct gcc_options *opts)\n   /* Avoid loop-dependant FMA chains.  */\n   if (aarch64_tune_params.extra_tuning_flags\n       & AARCH64_EXTRA_TUNE_AVOID_CROSS_LOOP_FMA)\n-    SET_OPTION_IF_UNSET (opts, &global_options_set, param_avoid_fma_max_bits,\n+    SET_OPTION_IF_UNSET (opts, opts_set, param_avoid_fma_max_bits,\n \t\t\t 512);\n \n   /* Consider fully pipelined FMA in reassociation.  */\n   if (aarch64_tune_params.extra_tuning_flags\n       & AARCH64_EXTRA_TUNE_FULLY_PIPELINED_FMA)\n-    SET_OPTION_IF_UNSET (opts, &global_options_set, param_fully_pipelined_fma,\n+    SET_OPTION_IF_UNSET (opts, opts_set, param_fully_pipelined_fma,\n \t\t\t 1);\n \n   /* If dispatch scheduling is enabled, the dispatch_constraints in the\n@@ -19847,7 +19848,7 @@ aarch64_override_options_internal (struct gcc_options *opts)\n \n   /* Enable possible unprofitable vectorization.  */\n   if (opts->x_flag_aarch64_max_vectorization)\n-    SET_OPTION_IF_UNSET (opts, &global_options_set,\n+    SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t\t param_vect_allow_possibly_not_worthwhile_vectorizations,\n \t\t\t 1);\n \n@@ -19855,7 +19856,7 @@ aarch64_override_options_internal (struct gcc_options *opts)\n      whichever one is not default.  If both are set then prefer the param flag\n      over the parameters.  */\n   if (opts->x_autovec_preference != AARCH64_AUTOVEC_DEFAULT)\n-    SET_OPTION_IF_UNSET (opts, &global_options_set,\n+    SET_OPTION_IF_UNSET (opts, opts_set,\n \t\t\t aarch64_autovec_preference,\n \t\t\t opts->x_autovec_preference);\n \n@@ -20166,7 +20167,7 @@ aarch64_override_options (void)\n   if (aarch64_track_speculation)\n     flag_shrink_wrap = 0;\n \n-  aarch64_override_options_internal (&global_options);\n+  aarch64_override_options_internal (&global_options, &global_options_set);\n \n   /* Save these options as the default ones in case we push and pop them later\n      while processing functions with potential target attributes.  */\n@@ -20245,14 +20246,15 @@ initialize_aarch64_code_model (struct gcc_options *opts)\n }\n \n /* Implements TARGET_OPTION_RESTORE.  Restore the backend codegen decisions\n-   using the information saved in PTR.  */\n+   using the information saved in PTR.  OPTS_SET can be used to avoid\n+   overriding values that were explicitly set on the command line.  */\n \n static void\n aarch64_option_restore (struct gcc_options *opts,\n-\t\t\tstruct gcc_options * /* opts_set */,\n+\t\t\tstruct gcc_options *opts_set,\n \t\t\tstruct cl_target_option * /* ptr */)\n {\n-  aarch64_override_options_internal (opts);\n+  aarch64_override_options_internal (opts, opts_set);\n }\n \n /* Implement TARGET_OPTION_PRINT.  */\n@@ -20372,7 +20374,7 @@ aarch64_set_current_function (tree fndecl)\n       aarch64_set_asm_isa_flags (base_flags\n \t\t\t\t | aarch64_feature_flags (new_isa_mode));\n \n-      aarch64_override_options_internal (&global_options);\n+      aarch64_override_options_internal (&global_options, &global_options_set);\n       new_tree = build_target_option_node (&global_options,\n \t\t\t\t\t   &global_options_set);\n       DECL_FUNCTION_SPECIFIC_TARGET (fndecl) = new_tree;\n@@ -20928,7 +20930,7 @@ aarch64_option_valid_attribute_p (tree fndecl, tree, tree args, int)\n   /* Set up any additional state.  */\n   if (ret)\n     {\n-      aarch64_override_options_internal (&global_options);\n+      aarch64_override_options_internal (&global_options, &global_options_set);\n       new_target = build_target_option_node (&global_options,\n \t\t\t\t\t     &global_options_set);\n     }\n@@ -21205,7 +21207,7 @@ aarch64_option_valid_version_attribute_p (tree fndecl, tree, tree args, int)\n   /* Set up any additional state.  */\n   if (ret)\n     {\n-      aarch64_override_options_internal (&global_options);\n+      aarch64_override_options_internal (&global_options, &global_options_set);\n       new_target = build_target_option_node (&global_options,\n \t\t\t\t\t     &global_options_set);\n     }\n","prefixes":["v1","1/1"]}