On 7/23/21 7:57 PM, Segher Boessenkool wrote:
Hi!
On Fri, Jul 23, 2021 at 07:47:54AM +0200, Martin Liška wrote:
On 7/12/21 7:20 PM, Segher Boessenkool wrote:
+static __attribute__ ((optimize ("-fno-stack-protector"))) __typeof
(f) *
-fno-stack-protector is default.
Yes, but one needs an optimize attribute in order to trigger
cl_target_option_save/restore
mechanism.
So it behaves differently if you select the default than if you do not
select anything? That is wrong, no?
Sorry, I don't get your example, please explain it.
If -mbork is the default, the coompiler whould behave the same if you
invoke it with -mbork as when you do not. And the optimize attribute
should work exactly the same as command line options.
Ah, got your point. All right, let's use then 'optimize(1)'.
Is it fine with the adjustment?
Cheers,
Martin
Or perhaps you are saying you have this in the testcase only to exercise
the option save/restore code paths? Please document that then, in the
testcase.
Segher
>From 517e32a75aa59b4b538eda30e78de0fa925bb0f9 Mon Sep 17 00:00:00 2001
From: Martin Liska <mli...@suse.cz>
Date: Tue, 1 Jun 2021 15:39:14 +0200
Subject: [PATCH] rs6000: Fix restored rs6000_long_double_type_size
As mentioned in the "Fallout: save/restore target options in handle_optimize_attribute"
thread, we need to support target option restore
of rs6000_long_double_type_size == FLOAT_PRECISION_TFmode.
gcc/ChangeLog:
* config/rs6000/rs6000.c (rs6000_option_override_internal): When
a target option is restored, it can have
rs6000_long_double_type_size set to FLOAT_PRECISION_TFmode
and error should not be emitted.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/pragma-optimize.c: New test.
---
gcc/config/rs6000/rs6000.c | 2 ++
gcc/testsuite/gcc.target/powerpc/pragma-optimize.c | 13 +++++++++++++
2 files changed, 15 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/powerpc/pragma-optimize.c
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 2de5a96e1b6..5b1c06b09fc 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -4189,6 +4189,8 @@ rs6000_option_override_internal (bool global_init_p)
else
rs6000_long_double_type_size = default_long_double_size;
}
+ else if (rs6000_long_double_type_size == FLOAT_PRECISION_TFmode)
+ ; /* The option value can be seen when cl_target_option_restore is called. */
else if (rs6000_long_double_type_size == 128)
rs6000_long_double_type_size = FLOAT_PRECISION_TFmode;
else if (global_options_set.x_rs6000_ieeequad)
diff --git a/gcc/testsuite/gcc.target/powerpc/pragma-optimize.c b/gcc/testsuite/gcc.target/powerpc/pragma-optimize.c
new file mode 100644
index 00000000000..e8ba63a0667
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pragma-optimize.c
@@ -0,0 +1,13 @@
+/* { dg-options "-O2 -mlong-double-128 -mabi=ibmlongdouble" } */
+
+extern unsigned long int x;
+extern float f (float);
+extern __typeof (f) f_power8;
+extern __typeof (f) f_power9;
+extern __typeof (f) f __attribute__ ((ifunc ("f_ifunc")));
+static __attribute__ ((optimize (1))) __typeof (f) *
+f_ifunc (void)
+{
+ __typeof (f) *res = x ? f_power9 : f_power8;
+ return res;
+}
--
2.32.0