diff mbox series

[21/39] debug: Avoid clang optimize away required function on tst-ssp1.c

Message ID 20241222000509.2205895-22-hjl.tools@gmail.com
State New
Headers show
Series [01/39] conform: Use -dD instead of -dN on compiler invocation | expand

Commit Message

H.J. Lu Dec. 22, 2024, 12:04 a.m. UTC
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>

---
 debug/tst-ssp-1.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Sam James Dec. 22, 2024, 4:40 a.m. UTC | #1
"H.J. Lu" <hjl.tools@gmail.com> writes:

> From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
>
> ---
>  debug/tst-ssp-1.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
> index 27f10edc56..671e9a5007 100644
> --- a/debug/tst-ssp-1.c
> +++ b/debug/tst-ssp-1.c
> @@ -22,6 +22,10 @@
>  
>  static void
>  __attribute__ ((noinline)) __attribute_noclone__
> +#ifdef __clang__
> +/* Avoid clang optimize it away.  */

optimizing

> +__attribute__ ((optnone))
> +#endif

Also, I don't love the inconsistency here (optnone for Clang vs
noinline,noclone for GCC). But at least for GCC, I know SSP depends on
some optimisation of course, and I don't know if Clang is different
there, so OK. We're trying to err on the side of "only changing Clang"
where we can for this, as long as it's clear what should be revisited.

Reviewed-by: Sam James <sam@gentoo.org>

>  test (char *foo)
>  {
>    int i;
H.J. Lu Dec. 22, 2024, 5:21 a.m. UTC | #2
On Sun, Dec 22, 2024 at 12:40 PM Sam James <sam@gentoo.org> wrote:
>
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
> > From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> >
> > ---
> >  debug/tst-ssp-1.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
> > index 27f10edc56..671e9a5007 100644
> > --- a/debug/tst-ssp-1.c
> > +++ b/debug/tst-ssp-1.c
> > @@ -22,6 +22,10 @@
> >
> >  static void
> >  __attribute__ ((noinline)) __attribute_noclone__
> > +#ifdef __clang__
> > +/* Avoid clang optimize it away.  */
>
> optimizing
>
> > +__attribute__ ((optnone))
> > +#endif
>
> Also, I don't love the inconsistency here (optnone for Clang vs
> noinline,noclone for GCC). But at least for GCC, I know SSP depends on
> some optimisation of course, and I don't know if Clang is different

Let me revisit it.

> there, so OK. We're trying to err on the side of "only changing Clang"
> where we can for this, as long as it's clear what should be revisited.
>
> Reviewed-by: Sam James <sam@gentoo.org>
>
> >  test (char *foo)
> >  {
> >    int i;
diff mbox series

Patch

diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index 27f10edc56..671e9a5007 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -22,6 +22,10 @@ 
 
 static void
 __attribute__ ((noinline)) __attribute_noclone__
+#ifdef __clang__
+/* Avoid clang optimize it away.  */
+__attribute__ ((optnone))
+#endif
 test (char *foo)
 {
   int i;