[PATCH] D130688: [Driver][Sparc] Default to -mcpu=v9 for SparcV8 on Linux

Rainer Orth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 29 00:39:11 PDT 2022


ro added a comment.

In D130688#3686512 <https://reviews.llvm.org/D130688#3686512>, @MaskRay wrote:

> Making the behavior different for different Linux distributions is not great, but if it matches the practice, I think it is fine.

It's the best we can do in `clang`, I fear, due to the compiler's desire to decide as much as possible at runtime.  GCC is way more static here, and whoever builds it can decide on the default CPU with `--with-cpu=v9` e.g. at configure time.

> I don't know Sparc enough to suggest anything for 32-bit, though...

An alternative would be to just check the host CPU with `getHostCPUName` as updated by D130272 <https://reviews.llvm.org/D130272>.  That CPU name then needs to be checked if it supports the V9 ISA.  That could be done using `getCPUGeneration(CPU) == CG_V9` in `clang/lib/Basic/Targets/Sparc.h`.  However, `SparcTargetInfo` (or `TargetInfo` in general) is not currently used inside the driver code.

Of course, this only works in the native case, but that's true for distro checks, too.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130688/new/

https://reviews.llvm.org/D130688



More information about the cfe-commits mailing list