[PATCH] D130273: [clang][Driver] Handle SPARC -mcpu=native etc.
Rainer Orth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 22 01:41:50 PDT 2022
ro added a comment.
In D130273#3670623 <https://reviews.llvm.org/D130273#3670623>, @MaskRay wrote:
> I notice that in gcc, -march/-mtune/-mcpu are handled in gcc/config/* and every port may have somewhat different behaviors. E.g. x86 and aarch64 are different (and I suspect x86 has the weird behavior).
Right: e.g. `gcc` on SPARC doesn't support `-march` at all. I've made no changes to `clang` here, i.e. the option is silently ignored. I believe it's important to keep that compatibility so `clang` command lines can be passed to `gcc` or vice versa.
> Have you checked that whether this matches GCC? We need some clang/test/Driver tests for `"-cc1"{{.*}} "-target-cpu" "..."`
Not in every detail, especially since the `gcc` driver just passes `-mcpu` etc. on to `cc1` which handles them itself, so it's not really easy to see what happens.
I'll add some tests, though.
================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2226
+
+ std::string TuneCPU;
+ if (Name == "native")
----------------
MaskRay wrote:
> ```
> std::string TuneCPU(Name == "native" ? ... : ...)
> if (!TuneCPU.empty()) {
> ...
> ```
I'm not sure about this: I tried that variant, but I don't really think it's clearer than what I have now:
```
std::string TuneCPU(Name == "native"
? std::string(llvm::sys::getHostCPUName()
: std::string(Name)));
```
My code was taken from `AddSystemZTargetArgs` directly below and it would seem a bit weird if they differ in style.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130273/new/
https://reviews.llvm.org/D130273
More information about the cfe-commits
mailing list