public inbox for gcc-regression@sourceware.org
help / color / mirror / Atom feed
* [TCWG CI] Regression caused by gcc: Append target/optimize attr to the current cmdline.
@ 2021-10-01 19:41 ci_notify
  0 siblings, 0 replies; 3+ messages in thread
From: ci_notify @ 2021-10-01 19:41 UTC (permalink / raw)
  To: Martin Liska; +Cc: gcc-regression

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 17807 bytes --]

[TCWG CI] Regression caused by gcc: Append target/optimize attr to the current cmdline.:
commit 6de9f0c13b27c34336587da19d03200f8cc6bcd5
Author: Martin Liska <mliska@suse.cz>

    Append target/optimize attr to the current cmdline.

Results regressed to
# reset_artifacts:
-10
# true:
0
# build_abe binutils:
1
# First few build errors in logs:
# 00:06:37 make[3]: [Makefile:1770: armv8l-unknown-linux-gnueabihf/bits/largefile-config.h] Error 1 (ignored)
# 00:24:14 /home/tcwg-buildslave/workspace/tcwg_gnu_4/abe/snapshots/gcc.git~master/libgomp/oacc-init.c:876:1: error: optimization attribute on ‘acc_on_device’ follows definition but the attribute doesn’t match [-Werror=attributes]
# 00:24:14 /home/tcwg-buildslave/workspace/tcwg_gnu_4/abe/snapshots/gcc.git~master/libgomp/oacc-init.c:954:1: internal compiler error: in dwarf2out_register_main_translation_unit, at dwarf2out.c:28328
# 00:24:15 make[5]: *** [Makefile:799: oacc-init.lo] Error 1
# 00:24:19 make[4]: *** [Makefile:1022: all-recursive] Error 1
# 00:24:19 make[3]: *** [Makefile:622: all] Error 2
# 00:24:19 make[2]: *** [Makefile:22819: all-stage2-target-libgomp] Error 2
# 00:25:02 make[3]: [Makefile:1770: armv8l-unknown-linux-gnueabihf/bits/largefile-config.h] Error 1 (ignored)
# 00:25:02 make[1]: *** [Makefile:24679: stage2-bubble] Error 2
# 00:25:02 make: *** [Makefile:1013: all] Error 2

from
# reset_artifacts:
-10
# true:
0
# build_abe binutils:
1
# build_abe bootstrap_lto:
2

THIS IS THE END OF INTERESTING STUFF.  BELOW ARE LINKS TO BUILDS, REPRODUCTION INSTRUCTIONS, AND THE RAW COMMIT.

This commit has regressed these CI configurations:
 - tcwg_gcc_bootstrap/master-arm-bootstrap_lto

First_bad build: https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_lto/4/artifact/artifacts/build-6de9f0c13b27c34336587da19d03200f8cc6bcd5/
Last_good build: https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_lto/4/artifact/artifacts/build-97909f80fde6c4ce2a2fa1e11b325a80c4741b8c/
Baseline build: https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_lto/4/artifact/artifacts/build-baseline/
Even more details: https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_lto/4/artifact/artifacts/

Reproduce builds:
<cut>
mkdir investigate-gcc-6de9f0c13b27c34336587da19d03200f8cc6bcd5
cd investigate-gcc-6de9f0c13b27c34336587da19d03200f8cc6bcd5

# Fetch scripts
git clone https://git.linaro.org/toolchain/jenkins-scripts

# Fetch manifests and test.sh script
mkdir -p artifacts/manifests
curl -o artifacts/manifests/build-baseline.sh https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_lto/4/artifact/artifacts/manifests/build-baseline.sh --fail
curl -o artifacts/manifests/build-parameters.sh https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_lto/4/artifact/artifacts/manifests/build-parameters.sh --fail
curl -o artifacts/test.sh https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_lto/4/artifact/artifacts/test.sh --fail
chmod +x artifacts/test.sh

# Reproduce the baseline build (build all pre-requisites)
./jenkins-scripts/tcwg_gnu-build.sh @@ artifacts/manifests/build-baseline.sh

# Save baseline build state (which is then restored in artifacts/test.sh)
mkdir -p ./bisect
rsync -a --del --delete-excluded --exclude /bisect/ --exclude /artifacts/ --exclude /gcc/ ./ ./bisect/baseline/

cd gcc

# Reproduce first_bad build
git checkout --detach 6de9f0c13b27c34336587da19d03200f8cc6bcd5
../artifacts/test.sh

# Reproduce last_good build
git checkout --detach 97909f80fde6c4ce2a2fa1e11b325a80c4741b8c
../artifacts/test.sh

cd ..
</cut>

Full commit (up to 1000 lines):
<cut>
commit 6de9f0c13b27c34336587da19d03200f8cc6bcd5
Author: Martin Liska <mliska@suse.cz>
Date:   Wed Jun 2 08:44:37 2021 +0200

    Append target/optimize attr to the current cmdline.
    
    gcc/c-family/ChangeLog:
    
            * c-common.c (parse_optimize_options): Combine optimize
            options with what was provided on the command line.
    
    gcc/ChangeLog:
    
            * toplev.c (toplev::main): Save decoded optimization options.
            * toplev.h (save_opt_decoded_options): New.
            * doc/extend.texi: Be more clear about optimize and target
            attributes.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/i386/avx512er-vrsqrt28ps-3.c: Disable fast math.
            * gcc.target/i386/avx512er-vrsqrt28ps-5.c: Likewise.
            * gcc.target/i386/attr-optimize.c: New test.
---
 gcc/c-family/c-common.c                            | 17 +++++++++++++--
 gcc/doc/extend.texi                                |  8 ++++++--
 gcc/testsuite/gcc.target/i386/attr-optimize.c      | 24 ++++++++++++++++++++++
 .../gcc.target/i386/avx512er-vrsqrt28ps-3.c        |  2 +-
 .../gcc.target/i386/avx512er-vrsqrt28ps-5.c        |  2 +-
 gcc/toplev.c                                       |  8 ++++++++
 gcc/toplev.h                                       |  1 +
 7 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index c6757f093ac..7b99a5546ea 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -5904,9 +5904,22 @@ parse_optimize_options (tree args, bool attr_p)
       j++;
     }
   decoded_options_count = j;
-  /* And apply them.  */
+
+  /* Merge the decoded options with save_decoded_options.  */
+  unsigned save_opt_count = save_opt_decoded_options.length ();
+  unsigned merged_decoded_options_count
+    = save_opt_count + decoded_options_count;
+  cl_decoded_option *merged_decoded_options
+    = XNEWVEC (cl_decoded_option, merged_decoded_options_count);
+
+  for (unsigned i = 0; i < save_opt_count; ++i)
+    merged_decoded_options[i] = save_opt_decoded_options[i];
+  for (unsigned i = 0; i < decoded_options_count; ++i)
+    merged_decoded_options[save_opt_count + i] = decoded_options[i];
+
+   /* And apply them.  */
   decode_options (&global_options, &global_options_set,
-		  decoded_options, decoded_options_count,
+		  merged_decoded_options, merged_decoded_options_count,
 		  input_location, global_dc, NULL);
   free (decoded_options);
 
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index b4c5376223a..133b82eef38 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -3663,7 +3663,10 @@ take function pointer arguments.
 @cindex @code{optimize} function attribute
 The @code{optimize} attribute is used to specify that a function is to
 be compiled with different optimization options than specified on the
-command line.  Valid arguments are constant non-negative integers and
+command line.  The optimize attribute arguments of a function behave
+behave as if appended to the command-line.
+
+Valid arguments are constant non-negative integers and
 strings.  Each numeric argument specifies an optimization @var{level}.
 Each @var{string} argument consists of one or more comma-separated
 substrings.  Each substring that begins with the letter @code{O} refers
@@ -3867,7 +3870,8 @@ This attribute prevents stack protection code for the function.
 Multiple target back ends implement the @code{target} attribute
 to specify that a function is to
 be compiled with different target options than specified on the
-command line.  One or more strings can be provided as arguments.
+command line.  The original target command-line options are ignored.
+One or more strings can be provided as arguments.
 Each string consists of one or more comma-separated suffixes to
 the @code{-m} prefix jointly forming the name of a machine-dependent
 option.  @xref{Submodel Options,,Machine-Dependent Options}.
diff --git a/gcc/testsuite/gcc.target/i386/attr-optimize.c b/gcc/testsuite/gcc.target/i386/attr-optimize.c
new file mode 100644
index 00000000000..f5db028f1fd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/attr-optimize.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O1 -ftree-slp-vectorize -march=znver1 -fdump-tree-optimized" } */
+
+/* Use -O2, but -ftree-slp-vectorize option should be preserved and used.  */
+#pragma GCC optimize "-O2"
+
+typedef struct {
+  long n[4];
+} secp256k1_fe;
+
+void *a;
+int c;
+static void
+fn1(secp256k1_fe *p1, int p2)
+{
+  p1->n[0] = p1->n[1] = p2;
+}
+void
+fn2()
+{
+  fn1(a, !c);
+}
+
+/* { dg-final { scan-tree-dump { MEM <vector\(2\) long int> \[[^]]*\] = } "optimized" } } */
diff --git a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c
index 1ba8172d6e3..40aefb50844 100644
--- a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c
+++ b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c
@@ -8,7 +8,7 @@
 #define MAX 1000
 #define EPS 0.00001
 
-__attribute__ ((noinline, optimize (1)))
+__attribute__ ((noinline, optimize (1, "-fno-fast-math")))
 void static
 compute_rsqrt_ref (float *a, float *r)
 {
diff --git a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c
index e067a81e562..498f4d50aa5 100644
--- a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c
+++ b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c
@@ -8,7 +8,7 @@
 #define MAX 1000
 #define EPS 0.00001
 
-__attribute__ ((noinline, optimize (1)))
+__attribute__ ((noinline, optimize (1, "-fno-fast-math")))
 void static
 compute_sqrt_ref (float *a, float *r)
 {
diff --git a/gcc/toplev.c b/gcc/toplev.c
index e1688aae724..78bb7e9749b 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -121,6 +121,9 @@ static bool no_backend;
 struct cl_decoded_option *save_decoded_options;
 unsigned int save_decoded_options_count;
 
+/* Vector of saved Optimization decoded command line options.  */
+auto_vec<cl_decoded_option> save_opt_decoded_options;
+
 /* Used to enable -fvar-tracking, -fweb and -frename-registers according
    to optimize in process_options ().  */
 #define AUTODETECT_VALUE 2
@@ -2334,6 +2337,11 @@ toplev::main (int argc, char **argv)
 						&save_decoded_options,
 						&save_decoded_options_count);
 
+  /* Save Optimization decoded options.  */
+  for (unsigned i = 0; i < save_decoded_options_count; ++i)
+    if (cl_options[save_decoded_options[i].opt_index].flags & CL_OPTIMIZATION)
+      save_opt_decoded_options.safe_push (save_decoded_options[i]);
+
   /* Perform language-specific options initialization.  */
   lang_hooks.init_options (save_decoded_options_count, save_decoded_options);
 
diff --git a/gcc/toplev.h b/gcc/toplev.h
index f543554b15f..c44c5ff926a 100644
--- a/gcc/toplev.h
+++ b/gcc/toplev.h
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 /* Decoded options, and number of such options.  */
 extern struct cl_decoded_option *save_decoded_options;
 extern unsigned int save_decoded_options_count;
+extern auto_vec<cl_decoded_option> save_opt_decoded_options;
 
 class timer;
 
</cut>
>From hjl@sc.intel.com  Fri Oct  1 21:39:40 2021
Return-Path: <hjl@sc.intel.com>
X-Original-To: gcc-regression@gcc.gnu.org
Delivered-To: gcc-regression@gcc.gnu.org
Received: from mga05.intel.com (mga05.intel.com [192.55.52.43])
 by sourceware.org (Postfix) with ESMTPS id 2C0D13858410
 for <gcc-regression@gcc.gnu.org>; Fri,  1 Oct 2021 21:39:39 +0000 (GMT)
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2C0D13858410
X-IronPort-AV: E=McAfee;i="6200,9189,10124"; a="311138322"
X-IronPort-AV: E=Sophos;i="5.85,340,1624345200"; d="scan'208";a="311138322"
Received: from fmsmga002.fm.intel.com ([10.253.24.26])
 by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 01 Oct 2021 14:39:37 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.85,340,1624345200"; d="scan'208";a="565287043"
Received: from scymds01.sc.intel.com ([10.148.94.138])
 by fmsmga002.fm.intel.com with ESMTP; 01 Oct 2021 14:39:37 -0700
Received: from gnu-clx-1.sc.intel.com (gnu-clx-1.sc.intel.com [172.25.70.216])
 by scymds01.sc.intel.com with ESMTP id 191LdbLb027487;
 Fri, 1 Oct 2021 14:39:37 -0700
Received: by gnu-clx-1.sc.intel.com (Postfix, from userid 1000)
 id 8E8C23E001F; Fri,  1 Oct 2021 14:39:37 -0700 (PDT)
Date: Fri, 01 Oct 2021 14:39:37 -0700
To: skpgkp2@gmail.com, hjl.tools@gmail.com, gcc-regression@gcc.gnu.org
Subject: Regressions on native/master at commit r12-4083 vs commit
 r12-4058 on Linux/x86_64
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20211001213937.8E8C23E001F@gnu-clx-1.sc.intel.com>
From: "H. J. Lu" <hjl@sc.intel.com>
X-Spam-Status: No, score=-3470.6 required=5.0 testsºYES_00, KAM_DMARC_STATUS,
 KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_NONE,
 TXREP autolearn=no autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
 server2.sourceware.org
X-BeenThere: gcc-regression@gcc.gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Gcc-regression mailing list <gcc-regression.gcc.gnu.org>
List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-regression>,
 <mailto:gcc-regression-request@gcc.gnu.org?subject=unsubscribe>
List-Archive: <https://gcc.gnu.org/pipermail/gcc-regression/>
List-Post: <mailto:gcc-regression@gcc.gnu.org>
List-Help: <mailto:gcc-regression-request@gcc.gnu.org?subject=help>
List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-regression>,
 <mailto:gcc-regression-request@gcc.gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 01 Oct 2021 21:39:41 -0000

New failures:
FAIL: g++.dg/modules/xtreme-header-2_b.C -std=c++2b (internal compiler error)
FAIL: g++.dg/modules/xtreme-header-2_b.C -std=c++2b (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_a.H module-cmi  (gcm.cache/$srcdir/g++.dg/modules/xtreme-header-3_a.H.gcm)
FAIL: g++.dg/modules/xtreme-header-3_a.H module-cmi  (gcm.cache/$srcdir/g++.dg/modules/xtreme-header-3_a.H.gcm)
FAIL: g++.dg/modules/xtreme-header-3_a.H module-cmi  (gcm.cache/$srcdir/g++.dg/modules/xtreme-header-3_a.H.gcm)
FAIL: g++.dg/modules/xtreme-header-3_a.H module-cmi  (gcm.cache/$srcdir/g++.dg/modules/xtreme-header-3_a.H.gcm)
FAIL: g++.dg/modules/xtreme-header-3_a.H module-cmi  (gcm.cache/$srcdir/g++.dg/modules/xtreme-header-3_a.H.gcm)
FAIL: g++.dg/modules/xtreme-header-3_a.H module-cmi  (gcm.cache/$srcdir/g++.dg/modules/xtreme-header-3_a.H.gcm)
FAIL: g++.dg/modules/xtreme-header-3_a.H module-cmi  (gcm.cache/$srcdir/g++.dg/modules/xtreme-header-3_a.H.gcm)
FAIL: g++.dg/modules/xtreme-header-3_a.H module-cmi  (gcm.cache/$srcdir/g++.dg/modules/xtreme-header-3_a.H.gcm)
FAIL: g++.dg/modules/xtreme-header-3_a.H module-cmi  (gcm.cache/$srcdir/g++.dg/modules/xtreme-header-3_a.H.gcm)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++17 (internal compiler error)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++17 (internal compiler error)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++17 (internal compiler error)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++17 (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++17 (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++17 (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++2a (internal compiler error)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++2a (internal compiler error)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++2a (internal compiler error)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++2a (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++2a (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++2a (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++2b (internal compiler error)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++2b (internal compiler error)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++2b (internal compiler error)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++2b (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++2b (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++2b (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_b.C -std=c++17 (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_b.C -std=c++17 (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_b.C -std=c++17 (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_b.C -std=c++2a (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_b.C -std=c++2a (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_b.C -std=c++2a (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_b.C -std=c++2b (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_b.C -std=c++2b (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_b.C -std=c++2b (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_c.C -std=c++17 (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_c.C -std=c++17 (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_c.C -std=c++17 (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_c.C -std=c++2a (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_c.C -std=c++2a (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_c.C -std=c++2a (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_c.C -std=c++2b (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_c.C -std=c++2b (test for excess errors)
FAIL: g++.dg/modules/xtreme-header-3_c.C -std=c++2b (test for excess errors)

New passes:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [TCWG CI] Regression caused by gcc: Append target/optimize attr to the current cmdline.
       [not found] ` <3433895F-7734-4EFF-9F63-AAF29DC27D24@linaro.org>
@ 2021-10-01 15:23   ` Martin Liška
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liška @ 2021-10-01 15:23 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: gcc-regression

On 10/1/21 17:20, Maxim Kuvyrkov wrote:
> Hi Martin,
> 
> This patch appears to break GCC build on aarch64-linux-gnu.  Would you please take a look?
> 
> Thanks!

Hello.

Should be fixed now with 5051fad8582fcbdd0844232b5a8c4e856be5e5a4.

Cheers,
Martin


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [TCWG CI] Regression caused by gcc: Append target/optimize attr to the current cmdline.
@ 2021-10-01 15:02 ci_notify
       [not found] ` <3433895F-7734-4EFF-9F63-AAF29DC27D24@linaro.org>
  0 siblings, 1 reply; 3+ messages in thread
From: ci_notify @ 2021-10-01 15:02 UTC (permalink / raw)
  To: Martin Liska; +Cc: gcc-regression

[TCWG CI] Regression caused by gcc: Append target/optimize attr to the current cmdline.:
commit 6de9f0c13b27c34336587da19d03200f8cc6bcd5
Author: Martin Liska <mliska@suse.cz>

    Append target/optimize attr to the current cmdline.

Results regressed to
# reset_artifacts:
-10
# true:
0
# build_abe binutils:
1
# First few build errors in logs:
# 00:02:04 /home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/snapshots/gcc.git~master/libgcc/unwind.inc:87:1: internal compiler error: Segmentation fault
# 00:02:04 /home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/snapshots/gcc.git~master/libgcc/unwind.inc:87:1: internal compiler error: Segmentation fault
# 00:02:04 make[2]: *** [/home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/snapshots/gcc.git~master/libgcc/shared-object.mk:14: unwind-dw2.o] Error 1
# 00:02:04 make[2]: *** [/home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/snapshots/gcc.git~master/libgcc/shared-object.mk:17: unwind-dw2_s.o] Error 1
# 00:02:05 make[1]: *** [Makefile:13896: all-target-libgcc] Error 2
# 00:02:05 make: *** [Makefile:975: all] Error 2

from
# reset_artifacts:
-10
# true:
0
# build_abe binutils:
1
# build_abe gcc:
2
# build_abe linux:
4
# build_abe glibc:
5
# build_abe gdb:
6

THIS IS THE END OF INTERESTING STUFF.  BELOW ARE LINKS TO BUILDS, REPRODUCTION INSTRUCTIONS, AND THE RAW COMMIT.

This commit has regressed these CI configurations:
 - tcwg_gnu_native_build/master-aarch64

First_bad build: https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/artifact/artifacts/build-6de9f0c13b27c34336587da19d03200f8cc6bcd5/
Last_good build: https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/artifact/artifacts/build-97909f80fde6c4ce2a2fa1e11b325a80c4741b8c/
Baseline build: https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/artifact/artifacts/build-baseline/
Even more details: https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/artifact/artifacts/

Reproduce builds:
<cut>
mkdir investigate-gcc-6de9f0c13b27c34336587da19d03200f8cc6bcd5
cd investigate-gcc-6de9f0c13b27c34336587da19d03200f8cc6bcd5

# Fetch scripts
git clone https://git.linaro.org/toolchain/jenkins-scripts

# Fetch manifests and test.sh script
mkdir -p artifacts/manifests
curl -o artifacts/manifests/build-baseline.sh https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/artifact/artifacts/manifests/build-baseline.sh --fail
curl -o artifacts/manifests/build-parameters.sh https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/artifact/artifacts/manifests/build-parameters.sh --fail
curl -o artifacts/test.sh https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/artifact/artifacts/test.sh --fail
chmod +x artifacts/test.sh

# Reproduce the baseline build (build all pre-requisites)
./jenkins-scripts/tcwg_gnu-build.sh @@ artifacts/manifests/build-baseline.sh

# Save baseline build state (which is then restored in artifacts/test.sh)
mkdir -p ./bisect
rsync -a --del --delete-excluded --exclude /bisect/ --exclude /artifacts/ --exclude /gcc/ ./ ./bisect/baseline/

cd gcc

# Reproduce first_bad build
git checkout --detach 6de9f0c13b27c34336587da19d03200f8cc6bcd5
../artifacts/test.sh

# Reproduce last_good build
git checkout --detach 97909f80fde6c4ce2a2fa1e11b325a80c4741b8c
../artifacts/test.sh

cd ..
</cut>

Full commit (up to 1000 lines):
<cut>
commit 6de9f0c13b27c34336587da19d03200f8cc6bcd5
Author: Martin Liska <mliska@suse.cz>
Date:   Wed Jun 2 08:44:37 2021 +0200

    Append target/optimize attr to the current cmdline.
    
    gcc/c-family/ChangeLog:
    
            * c-common.c (parse_optimize_options): Combine optimize
            options with what was provided on the command line.
    
    gcc/ChangeLog:
    
            * toplev.c (toplev::main): Save decoded optimization options.
            * toplev.h (save_opt_decoded_options): New.
            * doc/extend.texi: Be more clear about optimize and target
            attributes.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/i386/avx512er-vrsqrt28ps-3.c: Disable fast math.
            * gcc.target/i386/avx512er-vrsqrt28ps-5.c: Likewise.
            * gcc.target/i386/attr-optimize.c: New test.
---
 gcc/c-family/c-common.c                            | 17 +++++++++++++--
 gcc/doc/extend.texi                                |  8 ++++++--
 gcc/testsuite/gcc.target/i386/attr-optimize.c      | 24 ++++++++++++++++++++++
 .../gcc.target/i386/avx512er-vrsqrt28ps-3.c        |  2 +-
 .../gcc.target/i386/avx512er-vrsqrt28ps-5.c        |  2 +-
 gcc/toplev.c                                       |  8 ++++++++
 gcc/toplev.h                                       |  1 +
 7 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index c6757f093ac..7b99a5546ea 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -5904,9 +5904,22 @@ parse_optimize_options (tree args, bool attr_p)
       j++;
     }
   decoded_options_count = j;
-  /* And apply them.  */
+
+  /* Merge the decoded options with save_decoded_options.  */
+  unsigned save_opt_count = save_opt_decoded_options.length ();
+  unsigned merged_decoded_options_count
+    = save_opt_count + decoded_options_count;
+  cl_decoded_option *merged_decoded_options
+    = XNEWVEC (cl_decoded_option, merged_decoded_options_count);
+
+  for (unsigned i = 0; i < save_opt_count; ++i)
+    merged_decoded_options[i] = save_opt_decoded_options[i];
+  for (unsigned i = 0; i < decoded_options_count; ++i)
+    merged_decoded_options[save_opt_count + i] = decoded_options[i];
+
+   /* And apply them.  */
   decode_options (&global_options, &global_options_set,
-		  decoded_options, decoded_options_count,
+		  merged_decoded_options, merged_decoded_options_count,
 		  input_location, global_dc, NULL);
   free (decoded_options);
 
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index b4c5376223a..133b82eef38 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -3663,7 +3663,10 @@ take function pointer arguments.
 @cindex @code{optimize} function attribute
 The @code{optimize} attribute is used to specify that a function is to
 be compiled with different optimization options than specified on the
-command line.  Valid arguments are constant non-negative integers and
+command line.  The optimize attribute arguments of a function behave
+behave as if appended to the command-line.
+
+Valid arguments are constant non-negative integers and
 strings.  Each numeric argument specifies an optimization @var{level}.
 Each @var{string} argument consists of one or more comma-separated
 substrings.  Each substring that begins with the letter @code{O} refers
@@ -3867,7 +3870,8 @@ This attribute prevents stack protection code for the function.
 Multiple target back ends implement the @code{target} attribute
 to specify that a function is to
 be compiled with different target options than specified on the
-command line.  One or more strings can be provided as arguments.
+command line.  The original target command-line options are ignored.
+One or more strings can be provided as arguments.
 Each string consists of one or more comma-separated suffixes to
 the @code{-m} prefix jointly forming the name of a machine-dependent
 option.  @xref{Submodel Options,,Machine-Dependent Options}.
diff --git a/gcc/testsuite/gcc.target/i386/attr-optimize.c b/gcc/testsuite/gcc.target/i386/attr-optimize.c
new file mode 100644
index 00000000000..f5db028f1fd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/attr-optimize.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O1 -ftree-slp-vectorize -march=znver1 -fdump-tree-optimized" } */
+
+/* Use -O2, but -ftree-slp-vectorize option should be preserved and used.  */
+#pragma GCC optimize "-O2"
+
+typedef struct {
+  long n[4];
+} secp256k1_fe;
+
+void *a;
+int c;
+static void
+fn1(secp256k1_fe *p1, int p2)
+{
+  p1->n[0] = p1->n[1] = p2;
+}
+void
+fn2()
+{
+  fn1(a, !c);
+}
+
+/* { dg-final { scan-tree-dump { MEM <vector\(2\) long int> \[[^]]*\] = } "optimized" } } */
diff --git a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c
index 1ba8172d6e3..40aefb50844 100644
--- a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c
+++ b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c
@@ -8,7 +8,7 @@
 #define MAX 1000
 #define EPS 0.00001
 
-__attribute__ ((noinline, optimize (1)))
+__attribute__ ((noinline, optimize (1, "-fno-fast-math")))
 void static
 compute_rsqrt_ref (float *a, float *r)
 {
diff --git a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c
index e067a81e562..498f4d50aa5 100644
--- a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c
+++ b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c
@@ -8,7 +8,7 @@
 #define MAX 1000
 #define EPS 0.00001
 
-__attribute__ ((noinline, optimize (1)))
+__attribute__ ((noinline, optimize (1, "-fno-fast-math")))
 void static
 compute_sqrt_ref (float *a, float *r)
 {
diff --git a/gcc/toplev.c b/gcc/toplev.c
index e1688aae724..78bb7e9749b 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -121,6 +121,9 @@ static bool no_backend;
 struct cl_decoded_option *save_decoded_options;
 unsigned int save_decoded_options_count;
 
+/* Vector of saved Optimization decoded command line options.  */
+auto_vec<cl_decoded_option> save_opt_decoded_options;
+
 /* Used to enable -fvar-tracking, -fweb and -frename-registers according
    to optimize in process_options ().  */
 #define AUTODETECT_VALUE 2
@@ -2334,6 +2337,11 @@ toplev::main (int argc, char **argv)
 						&save_decoded_options,
 						&save_decoded_options_count);
 
+  /* Save Optimization decoded options.  */
+  for (unsigned i = 0; i < save_decoded_options_count; ++i)
+    if (cl_options[save_decoded_options[i].opt_index].flags & CL_OPTIMIZATION)
+      save_opt_decoded_options.safe_push (save_decoded_options[i]);
+
   /* Perform language-specific options initialization.  */
   lang_hooks.init_options (save_decoded_options_count, save_decoded_options);
 
diff --git a/gcc/toplev.h b/gcc/toplev.h
index f543554b15f..c44c5ff926a 100644
--- a/gcc/toplev.h
+++ b/gcc/toplev.h
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 /* Decoded options, and number of such options.  */
 extern struct cl_decoded_option *save_decoded_options;
 extern unsigned int save_decoded_options_count;
+extern auto_vec<cl_decoded_option> save_opt_decoded_options;
 
 class timer;
 
</cut>
>From maxim.kuvyrkov@linaro.org  Fri Oct  1 15:21:01 2021
Return-Path: <maxim.kuvyrkov@linaro.org>
X-Original-To: gcc-regression@gcc.gnu.org
Delivered-To: gcc-regression@gcc.gnu.org
Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com
 [IPv6:2a00:1450:4864:20::12f])
 by sourceware.org (Postfix) with ESMTPS id D38FE3858406
 for <gcc-regression@gcc.gnu.org>; Fri,  1 Oct 2021 15:20:58 +0000 (GMT)
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D38FE3858406
Received: by mail-lf1-x12f.google.com with SMTP id e15so40155114lfr.10
 for <gcc-regression@gcc.gnu.org>; Fri, 01 Oct 2021 08:20:58 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc
 :content-transfer-encoding:message-id:references:to;
 bh=t0h8D9S7C0iw37qDdSRsmLecQqBJH0eJ2RWRLkOWUd8=;
 b=4j0/CaSE2/fUqKEy49Lvm32QRuQLmM/YqwxpdMVpVwNiqjFf924/XQlhIc+ZTR1R4p
 okBYiDBzWuwZ0vf22dnSxXygEHuWmexwKgSprJAs1C5aNG28AcuV7r51G4+qkb2G1n+E
 IRHZmqe3NXqsLiM/FILM5F+/Nn7M7OD/ISzKa156iSUlabSU0AYQSkTUJFaFIbSV1K/D
 JH97TePPKxhklAC52aM614GUZj0wCS15Fw91IPuzNngp+VSrwplm6RvPsV1tSc7UyCWr
 bOacqKleh00myq6R/IfybjeOAN4jpUAFZiG3iQUxMwnhyrzllDvhqcWgbaQHdsU2569s
 ORJw==
X-Gm-Message-State: AOAM530pyFLUI6Q0Ef9J11Nu7K+ZUxuyzeVqt/gyj6xGhfgFqNF+kWW+
 aSsxStacdKYuTsXpHCpRAKQN
X-Google-Smtp-Source: ABdhPJzCWRkh8rn9O9PL2WXMvgTis6GBNMAQtlcsRimDh2a8h4z15pKFvBna9A9kEgec3vkcNG3H3Q==
X-Received: by 2002:ac2:46c4:: with SMTP id p4mr4610290lfo.689.1633101657323; 
 Fri, 01 Oct 2021 08:20:57 -0700 (PDT)
Received: from [192.168.0.218] ([185.30.228.145])
 by smtp.gmail.com with ESMTPSA id x14sm761504lfc.308.2021.10.01.08.20.56
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Fri, 01 Oct 2021 08:20:56 -0700 (PDT)
Content-Type: text/plain;
	charset=us-ascii
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\))
Subject: Re: [TCWG CI] Regression caused by gcc: Append target/optimize attr
 to the current cmdline.
From: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
In-Reply-To: <1003651381.7878.1633100577355@localhost>
Date: Fri, 1 Oct 2021 18:20:56 +0300
Cc: gcc-regression@gcc.gnu.org
Content-Transfer-Encoding: quoted-printable
Message-Id: <3433895F-7734-4EFF-9F63-AAF29DC27D24@linaro.org>
References: <1003651381.7878.1633100577355@localhost>
To: Martin Liska <mliska@suse.cz>
X-Mailer: Apple Mail (2.3608.120.23.2.7)
X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_LOTSOFHASH,
 KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS,
 TXREP autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
 server2.sourceware.org
X-BeenThere: gcc-regression@gcc.gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Gcc-regression mailing list <gcc-regression.gcc.gnu.org>
List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-regression>,
 <mailto:gcc-regression-request@gcc.gnu.org?subject=unsubscribe>
List-Archive: <https://gcc.gnu.org/pipermail/gcc-regression/>
List-Post: <mailto:gcc-regression@gcc.gnu.org>
List-Help: <mailto:gcc-regression-request@gcc.gnu.org?subject=help>
List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-regression>,
 <mailto:gcc-regression-request@gcc.gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 01 Oct 2021 15:21:01 -0000

Hi Martin,

This patch appears to break GCC build on aarch64-linux-gnu.  Would you =
please take a look?

Thanks!

--
Maxim Kuvyrkov
https://www.linaro.org

> On 1 Oct 2021, at 18:02, ci_notify--- via Gcc-regression =
<gcc-regression@gcc.gnu.org> wrote:
>=20
> [TCWG CI] Regression caused by gcc: Append target/optimize attr to the =
current cmdline.:
> commit 6de9f0c13b27c34336587da19d03200f8cc6bcd5
> Author: Martin Liska <mliska@suse.cz>
>=20
>    Append target/optimize attr to the current cmdline.
>=20
> Results regressed to
> # reset_artifacts:
> -10
> # true:
> 0
> # build_abe binutils:
> 1
> # First few build errors in logs:
> # 00:02:04 =
/home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/snapshots/gcc.git~master/li=
bgcc/unwind.inc:87:1: internal compiler error: Segmentation fault
> # 00:02:04 =
/home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/snapshots/gcc.git~master/li=
bgcc/unwind.inc:87:1: internal compiler error: Segmentation fault
> # 00:02:04 make[2]: *** =
[/home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/snapshots/gcc.git~master/l=
ibgcc/shared-object.mk:14: unwind-dw2.o] Error 1
> # 00:02:04 make[2]: *** =
[/home/tcwg-buildslave/workspace/tcwg_gnu_1/abe/snapshots/gcc.git~master/l=
ibgcc/shared-object.mk:17: unwind-dw2_s.o] Error 1
> # 00:02:05 make[1]: *** [Makefile:13896: all-target-libgcc] Error 2
> # 00:02:05 make: *** [Makefile:975: all] Error 2
>=20
> from
> # reset_artifacts:
> -10
> # true:
> 0
> # build_abe binutils:
> 1
> # build_abe gcc:
> 2
> # build_abe linux:
> 4
> # build_abe glibc:
> 5
> # build_abe gdb:
> 6
>=20
> THIS IS THE END OF INTERESTING STUFF.  BELOW ARE LINKS TO BUILDS, =
REPRODUCTION INSTRUCTIONS, AND THE RAW COMMIT.
>=20
> This commit has regressed these CI configurations:
> - tcwg_gnu_native_build/master-aarch64
>=20
> First_bad build: =
https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/ar=
tifact/artifacts/build-6de9f0c13b27c34336587da19d03200f8cc6bcd5/
> Last_good build: =
https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/ar=
tifact/artifacts/build-97909f80fde6c4ce2a2fa1e11b325a80c4741b8c/
> Baseline build: =
https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/ar=
tifact/artifacts/build-baseline/
> Even more details: =
https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/ar=
tifact/artifacts/
>=20
> Reproduce builds:
> <cut>
> mkdir investigate-gcc-6de9f0c13b27c34336587da19d03200f8cc6bcd5
> cd investigate-gcc-6de9f0c13b27c34336587da19d03200f8cc6bcd5
>=20
> # Fetch scripts
> git clone https://git.linaro.org/toolchain/jenkins-scripts
>=20
> # Fetch manifests and test.sh script
> mkdir -p artifacts/manifests
> curl -o artifacts/manifests/build-baseline.sh =
https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/ar=
tifact/artifacts/manifests/build-baseline.sh --fail
> curl -o artifacts/manifests/build-parameters.sh =
https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/ar=
tifact/artifacts/manifests/build-parameters.sh --fail
> curl -o artifacts/test.sh =
https://ci.linaro.org/job/tcwg_gnu_native_build-bisect-master-aarch64/3/ar=
tifact/artifacts/test.sh --fail
> chmod +x artifacts/test.sh
>=20
> # Reproduce the baseline build (build all pre-requisites)
> ./jenkins-scripts/tcwg_gnu-build.sh @@ =
artifacts/manifests/build-baseline.sh
>=20
> # Save baseline build state (which is then restored in =
artifacts/test.sh)
> mkdir -p ./bisect
> rsync -a --del --delete-excluded --exclude /bisect/ --exclude =
/artifacts/ --exclude /gcc/ ./ ./bisect/baseline/
>=20
> cd gcc
>=20
> # Reproduce first_bad build
> git checkout --detach 6de9f0c13b27c34336587da19d03200f8cc6bcd5
> ../artifacts/test.sh
>=20
> # Reproduce last_good build
> git checkout --detach 97909f80fde6c4ce2a2fa1e11b325a80c4741b8c
> ../artifacts/test.sh
>=20
> cd ..
> </cut>
>=20
> Full commit (up to 1000 lines):
> <cut>
> commit 6de9f0c13b27c34336587da19d03200f8cc6bcd5
> Author: Martin Liska <mliska@suse.cz>
> Date:   Wed Jun 2 08:44:37 2021 +0200
>=20
>    Append target/optimize attr to the current cmdline.
>=20
>    gcc/c-family/ChangeLog:
>=20
>            * c-common.c (parse_optimize_options): Combine optimize
>            options with what was provided on the command line.
>=20
>    gcc/ChangeLog:
>=20
>            * toplev.c (toplev::main): Save decoded optimization =
options.
>            * toplev.h (save_opt_decoded_options): New.
>            * doc/extend.texi: Be more clear about optimize and target
>            attributes.
>=20
>    gcc/testsuite/ChangeLog:
>=20
>            * gcc.target/i386/avx512er-vrsqrt28ps-3.c: Disable fast =
math.
>            * gcc.target/i386/avx512er-vrsqrt28ps-5.c: Likewise.
>            * gcc.target/i386/attr-optimize.c: New test.
> ---
> gcc/c-family/c-common.c                            | 17 =
+++++++++++++--
> gcc/doc/extend.texi                                |  8 ++++++--
> gcc/testsuite/gcc.target/i386/attr-optimize.c      | 24 =
++++++++++++++++++++++
> .../gcc.target/i386/avx512er-vrsqrt28ps-3.c        |  2 +-
> .../gcc.target/i386/avx512er-vrsqrt28ps-5.c        |  2 +-
> gcc/toplev.c                                       |  8 ++++++++
> gcc/toplev.h                                       |  1 +
> 7 files changed, 56 insertions(+), 6 deletions(-)
>=20
> diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
> index c6757f093ac..7b99a5546ea 100644
> --- a/gcc/c-family/c-common.c
> +++ b/gcc/c-family/c-common.c
> @@ -5904,9 +5904,22 @@ parse_optimize_options (tree args, bool attr_p)
>       j++;
>     }
>   decoded_options_count =3D j;
> -  /* And apply them.  */
> +
> +  /* Merge the decoded options with save_decoded_options.  */
> +  unsigned save_opt_count =3D save_opt_decoded_options.length ();
> +  unsigned merged_decoded_options_count
> +    =3D save_opt_count + decoded_options_count;
> +  cl_decoded_option *merged_decoded_options
> +    =3D XNEWVEC (cl_decoded_option, merged_decoded_options_count);
> +
> +  for (unsigned i =3D 0; i < save_opt_count; ++i)
> +    merged_decoded_options[i] =3D save_opt_decoded_options[i];
> +  for (unsigned i =3D 0; i < decoded_options_count; ++i)
> +    merged_decoded_options[save_opt_count + i] =3D =
decoded_options[i];
> +
> +   /* And apply them.  */
>   decode_options (&global_options, &global_options_set,
> -		  decoded_options, decoded_options_count,
> +		  merged_decoded_options, merged_decoded_options_count,
> 		  input_location, global_dc, NULL);
>   free (decoded_options);
>=20
> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
> index b4c5376223a..133b82eef38 100644
> --- a/gcc/doc/extend.texi
> +++ b/gcc/doc/extend.texi
> @@ -3663,7 +3663,10 @@ take function pointer arguments.
> @cindex @code{optimize} function attribute
> The @code{optimize} attribute is used to specify that a function is to
> be compiled with different optimization options than specified on the
> -command line.  Valid arguments are constant non-negative integers and
> +command line.  The optimize attribute arguments of a function behave
> +behave as if appended to the command-line.
> +
> +Valid arguments are constant non-negative integers and
> strings.  Each numeric argument specifies an optimization @var{level}.
> Each @var{string} argument consists of one or more comma-separated
> substrings.  Each substring that begins with the letter @code{O} =
refers
> @@ -3867,7 +3870,8 @@ This attribute prevents stack protection code =
for the function.
> Multiple target back ends implement the @code{target} attribute
> to specify that a function is to
> be compiled with different target options than specified on the
> -command line.  One or more strings can be provided as arguments.
> +command line.  The original target command-line options are ignored.
> +One or more strings can be provided as arguments.
> Each string consists of one or more comma-separated suffixes to
> the @code{-m} prefix jointly forming the name of a machine-dependent
> option.  @xref{Submodel Options,,Machine-Dependent Options}.
> diff --git a/gcc/testsuite/gcc.target/i386/attr-optimize.c =
b/gcc/testsuite/gcc.target/i386/attr-optimize.c
> new file mode 100644
> index 00000000000..f5db028f1fd
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/attr-optimize.c
> @@ -0,0 +1,24 @@
> +/* { dg-do compile } */
> +/* { dg-additional-options "-O1 -ftree-slp-vectorize -march=3Dznver1 =
-fdump-tree-optimized" } */
> +
> +/* Use -O2, but -ftree-slp-vectorize option should be preserved and =
used.  */
> +#pragma GCC optimize "-O2"
> +
> +typedef struct {
> +  long n[4];
> +} secp256k1_fe;
> +
> +void *a;
> +int c;
> +static void
> +fn1(secp256k1_fe *p1, int p2)
> +{
> +  p1->n[0] =3D p1->n[1] =3D p2;
> +}
> +void
> +fn2()
> +{
> +  fn1(a, !c);
> +}
> +
> +/* { dg-final { scan-tree-dump { MEM <vector\(2\) long int> \[[^]]*\] =
=3D } "optimized" } } */
> diff --git a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c =
b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c
> index 1ba8172d6e3..40aefb50844 100644
> --- a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c
> +++ b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c
> @@ -8,7 +8,7 @@
> #define MAX 1000
> #define EPS 0.00001
>=20
> -__attribute__ ((noinline, optimize (1)))
> +__attribute__ ((noinline, optimize (1, "-fno-fast-math")))
> void static
> compute_rsqrt_ref (float *a, float *r)
> {
> diff --git a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c =
b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c
> index e067a81e562..498f4d50aa5 100644
> --- a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c
> +++ b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c
> @@ -8,7 +8,7 @@
> #define MAX 1000
> #define EPS 0.00001
>=20
> -__attribute__ ((noinline, optimize (1)))
> +__attribute__ ((noinline, optimize (1, "-fno-fast-math")))
> void static
> compute_sqrt_ref (float *a, float *r)
> {
> diff --git a/gcc/toplev.c b/gcc/toplev.c
> index e1688aae724..78bb7e9749b 100644
> --- a/gcc/toplev.c
> +++ b/gcc/toplev.c
> @@ -121,6 +121,9 @@ static bool no_backend;
> struct cl_decoded_option *save_decoded_options;
> unsigned int save_decoded_options_count;
>=20
> +/* Vector of saved Optimization decoded command line options.  */
> +auto_vec<cl_decoded_option> save_opt_decoded_options;
> +
> /* Used to enable -fvar-tracking, -fweb and -frename-registers =
according
>    to optimize in process_options ().  */
> #define AUTODETECT_VALUE 2
> @@ -2334,6 +2337,11 @@ toplev::main (int argc, char **argv)
> 						&save_decoded_options,
> 						=
&save_decoded_options_count);
>=20
> +  /* Save Optimization decoded options.  */
> +  for (unsigned i =3D 0; i < save_decoded_options_count; ++i)
> +    if (cl_options[save_decoded_options[i].opt_index].flags & =
CL_OPTIMIZATION)
> +      save_opt_decoded_options.safe_push (save_decoded_options[i]);
> +
>   /* Perform language-specific options initialization.  */
>   lang_hooks.init_options (save_decoded_options_count, =
save_decoded_options);
>=20
> diff --git a/gcc/toplev.h b/gcc/toplev.h
> index f543554b15f..c44c5ff926a 100644
> --- a/gcc/toplev.h
> +++ b/gcc/toplev.h
> @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
> /* Decoded options, and number of such options.  */
> extern struct cl_decoded_option *save_decoded_options;
> extern unsigned int save_decoded_options_count;
> +extern auto_vec<cl_decoded_option> save_opt_decoded_options;
>=20
> class timer;
>=20
> </cut>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-01 19:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 19:41 [TCWG CI] Regression caused by gcc: Append target/optimize attr to the current cmdline ci_notify
  -- strict thread matches above, loose matches on Subject: below --
2021-10-01 15:02 ci_notify
     [not found] ` <3433895F-7734-4EFF-9F63-AAF29DC27D24@linaro.org>
2021-10-01 15:23   ` Martin Liška

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).