[PATCH v3] x86: Don't enable UINTR in 32-bit mode

H.J. Lu hjl.tools@gmail.com
Tue Jul 13 16:35:18 GMT 2021


On Mon, Jul 12, 2021 at 11:56 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Mon, Jul 12, 2021 at 06:51:30PM -0700, H.J. Lu wrote:
> > @@ -404,9 +404,18 @@ const char *host_detect_local_cpu (int argc, const char **argv)
> >    if (argc < 1)
> >      return NULL;
>
> I think it would be simpler to use 2 arguments instead of one.
> So change the above to if (argc < 2)

Fixed.

> >
> > -  arch = !strcmp (argv[0], "arch");
> > +  arch = !strncmp (argv[0], "arch", 4);
> >
> > -  if (!arch && strcmp (argv[0], "tune"))
> > +  if (!arch && strncmp (argv[0], "tune", 4))
> > +    return NULL;
>
> Keep strcmp as is here.

Fixed.

> > +
> > +  bool codegen_x86_64;
> > +
> > +  if (!strcmp (argv[0] + 4, "32"))
> > +    codegen_x86_64 = false;
> > +  else if (!strcmp (argv[0] + 4, "64"))
> > +    codegen_x86_64 = true;
> > +  else
> >      return NULL;
>
> Check argv[1] here instead.

Fixed.

> > @@ -813,7 +826,8 @@ const char *host_detect_local_cpu (int argc, const char **argv)
> >      }
> >
> >  done:
> > -  return concat (cache, "-m", argv[0], "=", cpu, options, NULL);
> > +  const char *moption = arch ? "-march=" : "-mtune=";
> > +  return concat (cache, moption, cpu, options, NULL);
> >  }
> >  #else
>
> You don't need this change.

Fixed.

> > diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
> > index 7a35c468da3..7cba655595e 100644
> > --- a/gcc/config/i386/i386-options.c
> > +++ b/gcc/config/i386/i386-options.c
> > @@ -2109,6 +2109,7 @@ ix86_option_override_internal (bool main_args_p,
> >  #define DEF_PTA(NAME) \
> >       if (((processor_alias_table[i].flags & PTA_ ## NAME) != 0) \
> >           && PTA_ ## NAME != PTA_64BIT \
> > +         && (TARGET_64BIT || PTA_ ## NAME != PTA_UINTR) \
> >           && !TARGET_EXPLICIT_ ## NAME ## _P (opts)) \
> >         SET_TARGET_ ## NAME (opts);
> >  #include "i386-isa.def"
> > diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
> > index 8c3eace56da..ae9f455c48d 100644
> > --- a/gcc/config/i386/i386.h
> > +++ b/gcc/config/i386/i386.h
> > @@ -577,9 +577,12 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
> >  #define CC1_CPU_SPEC CC1_CPU_SPEC_1
> >  #else
> >  #define CC1_CPU_SPEC CC1_CPU_SPEC_1 \
> > -"%{march=native:%>march=native %:local_cpu_detect(arch) \
> > -  %{!mtune=*:%>mtune=native %:local_cpu_detect(tune)}} \
> > -%{mtune=native:%>mtune=native %:local_cpu_detect(tune)}"
> > +"%{" OPT_ARCH32 ":%{march=native:%>march=native %:local_cpu_detect(arch32) \
> > +               %{!mtune=*:%>mtune=native %:local_cpu_detect(tune32)}}}" \
> > +"%{" OPT_ARCH32 ":%{mtune=native:%>mtune=native %:local_cpu_detect(tune32)}}" \
> > +"%{" OPT_ARCH64 ":%{march=native:%>march=native %:local_cpu_detect(arch64) \
> > +               %{!mtune=*:%>mtune=native %:local_cpu_detect(tune64)}}}" \
> > +"%{" OPT_ARCH64 ":%{mtune=native:%>mtune=native %:local_cpu_detect(tune64)}}"
>
> And you can use
> #define ARCH_ARG "%{" OPT_ARCH64 ":64;32}"

I added

#define ARCH_ARG "%{" OPT_ARCH64 ":64;:32}"

> %:local_cpu_detect(arch, " ARCH_ARG ")
> etc.
>
>         Jakub
>

Here is the v3 patch.   OK for master?

Thanks.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v3-0001-x86-Don-t-enable-UINTR-in-32-bit-mode.patch
Type: text/x-patch
Size: 6706 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210713/461115e3/attachment.bin>


More information about the Gcc-patches mailing list