This is an archive of the discontinued LLVM Phabricator instance.
- -clang/
- -include/clang/
- -clang/
- -Basic/
- -TargetOptions.h
- -Driver/
- -Options.td
- -lib/
- -Basic/
- -Targets.cpp
- -CodeGen/
- 2/4CodeGenModule.cpp
- -Driver/ToolChains/
- -ToolChains/
- -Clang.cpp
- -Frontend/
- -CompilerInvocation.cpp
- -test/Misc/
- -Misc/
- 1/2target-invalid-cpu-note.c
[X86] Add basic support for -mtune command line option in clangClosedPublic
Details
Building on the backend support from D85165. This parses the command line option in the driver, passes it on to CC1 and adds a function attribute.
Still need to support tune on the target attribute.
Need to use "generic" as the tuning by default. But need to change generic in the backend first.
Need to set tune if march is specified and mtune isn't.
May need to disable getHostCPUName's ability to guess CPU name from features when it doesn't have a family/model match for mtune=native. That's what gcc appears to do.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
1 comment, otherwise seems alright to me.
| clang/lib/CodeGen/CodeGenModule.cpp | ||
|---|---|---|
| 1752 | Does this lead to a situation in 'attribute-target' where we have a 'tune' setting to a processor that is 'before' the 'TargetCPU'? Should this enforce some sort of hierarchy to make sure we only do it if it is 'newer' (read, more feature rich) than the target? | |
| clang/lib/CodeGen/CodeGenModule.cpp | ||
|---|---|---|
| 1752 | TuneCPU is only supposed to control microarchitectural things like should i prefer an "ADD 1" over "INC" instruction. Or should I use more immediate controlled shuffles over a single variable controlled shuffle. As such that things we get from tune don't have a straightforward relationship with architectural features. | |
| clang/lib/CodeGen/CodeGenModule.cpp | ||
|---|---|---|
| 1752 | My concern is more. Say: TargetCPU == "nahalem" Does it make sense for It would seem to me that is pretty nonsensical. I've definitely seen the reverse (in within x86_64 at least, where Tune is newer than Target), but tuning for an older CPU seems like nonsense. | |
| clang/lib/CodeGen/CodeGenModule.cpp | ||
|---|---|---|
| 1752 | From a behavior standpoint, its not any different than what this does today -march=pentium -msse4.2 -mpopcnt -mfxsr <other nehalem features> I don't think gcc enforces any ordering. | |
LGTM with one minor comment
| clang/test/Misc/target-invalid-cpu-note.c | ||
|---|---|---|
| 54 | Should we have a test for tune-cpu for some non-x86 target? Or are we happy to just assume this works correctly because we already have coverage for target-cpu? | |
| clang/test/Misc/target-invalid-cpu-note.c | ||
|---|---|---|
| 54 | I copied the AARCH64 test above an added a -tune-cpu version of it. That will be included with my commit | |
This seems to have broken our Mac builders with the following error:
-- Testing: 25226 tests, 24 workers --
Testing: 0.. 10.. 20.
FAIL: Clang :: Frontend/ast-main.c (6834 of 25226)
******************** TEST 'Clang :: Frontend/ast-main.c' FAILED ********************
Script:
--
: 'RUN: at line 1'; env SDKROOT="/" /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp1.ll -x c - < /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.c
: 'RUN: at line 2'; env SDKROOT="/" /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-ast -o /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp.ast /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.c
: 'RUN: at line 3'; env SDKROOT="/" /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp2.ll -x ast - < /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp.ast
: 'RUN: at line 4'; diff /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp1.ll /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp2.ll
--
Exit Code: 1
Command Output (stdout):
--
14c14
< attributes #0 = { noinline nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }
---
> attributes #0 = { noinline nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
--
********************
Testing: 0.. 10.. 20.
FAIL: Clang :: Frontend/ast-main.cpp (6835 of 25226)
******************** TEST 'Clang :: Frontend/ast-main.cpp' FAILED ********************
Script:
--
: 'RUN: at line 1'; env SDKROOT="/" /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp1.ll -x c++ - < /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp
: 'RUN: at line 2'; env SDKROOT="/" /b/s/w/ir/k/staging/llvm_build/bin/clang -fno-delayed-template-parsing -emit-ast -o /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp.ast /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp
: 'RUN: at line 3'; env SDKROOT="/" /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp2.ll -x ast - < /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp.ast
: 'RUN: at line 4'; diff /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp1.ll /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp2.ll
--
Exit Code: 1
Command Output (stdout):
--
37,39c37,39
< attributes #0 = { noinline optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }
< attributes #1 = { noinline nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }
< attributes #2 = { noinline norecurse nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }
---
> attributes #0 = { noinline optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
> attributes #1 = { noinline nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
> attributes #2 = { noinline norecurse nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
--
Command Output (stderr):
--
<stdin>:14:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
<stdin>:17:14: note: in instantiation of member function 'S<int>::mf' requested here
S<int>().mf();
^
1 warning generated.
/b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp:14:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
/b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp:17:14: note: in instantiation of member function 'S<int>::mf' requested here
S<int>().mf();
^
1 warning generated.
--
********************
Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
********************
Failed Tests (2):
Clang :: Frontend/ast-main.c
Clang :: Frontend/ast-main.cpp
Testing Time: 225.68s
Unsupported : 564
Passed : 24636
Expectedly Failed: 24
Failed : 2Specifically, the tune-cpu attribute seems to be missing on Darwin. Would it be possible to take a look?
In D85384#2225434, @phosek wrote:This seems to have broken our Mac builders with the following error:
-- Testing: 25226 tests, 24 workers -- Testing: 0.. 10.. 20. FAIL: Clang :: Frontend/ast-main.c (6834 of 25226) ******************** TEST 'Clang :: Frontend/ast-main.c' FAILED ******************** Script: -- : 'RUN: at line 1'; env SDKROOT="/" /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp1.ll -x c - < /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.c : 'RUN: at line 2'; env SDKROOT="/" /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-ast -o /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp.ast /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.c : 'RUN: at line 3'; env SDKROOT="/" /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp2.ll -x ast - < /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp.ast : 'RUN: at line 4'; diff /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp1.ll /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp2.ll -- Exit Code: 1 Command Output (stdout): -- 14c14 < attributes #0 = { noinline nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" } --- > attributes #0 = { noinline nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -- ******************** Testing: 0.. 10.. 20. FAIL: Clang :: Frontend/ast-main.cpp (6835 of 25226) ******************** TEST 'Clang :: Frontend/ast-main.cpp' FAILED ******************** Script: -- : 'RUN: at line 1'; env SDKROOT="/" /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp1.ll -x c++ - < /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp : 'RUN: at line 2'; env SDKROOT="/" /b/s/w/ir/k/staging/llvm_build/bin/clang -fno-delayed-template-parsing -emit-ast -o /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp.ast /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp : 'RUN: at line 3'; env SDKROOT="/" /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp2.ll -x ast - < /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp.ast : 'RUN: at line 4'; diff /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp1.ll /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp2.ll -- Exit Code: 1 Command Output (stdout): -- 37,39c37,39 < attributes #0 = { noinline optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" } < attributes #1 = { noinline nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" } < attributes #2 = { noinline norecurse nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" } --- > attributes #0 = { noinline optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } > attributes #1 = { noinline nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } > attributes #2 = { noinline norecurse nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -- Command Output (stderr): -- <stdin>:14:1: warning: non-void function does not return a value [-Wreturn-type] } ^ <stdin>:17:14: note: in instantiation of member function 'S<int>::mf' requested here S<int>().mf(); ^ 1 warning generated. /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp:14:1: warning: non-void function does not return a value [-Wreturn-type] } ^ /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp:17:14: note: in instantiation of member function 'S<int>::mf' requested here S<int>().mf(); ^ 1 warning generated. -- ******************** Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. ******************** Failed Tests (2): Clang :: Frontend/ast-main.c Clang :: Frontend/ast-main.cpp Testing Time: 225.68s Unsupported : 564 Passed : 24636 Expectedly Failed: 24 Failed : 2Specifically, the tune-cpu attribute seems to be missing on Darwin. Would it be possible to take a look?
I suspect this is somehow related to the very old code in lib/Driver/ToolChains/Darwin.cpp that forces a -mtune=core2 into the command line. But I'm not clear yet why that code is there. @ddunbar looks like you added that code in 2009? Can you shed any light on what its for?
This would be because at that point the default cpu was that and it
probably had something to do with fallbacks.
At this point it can be changed I imagine to whatever makes sense.
In D85384#2225459, @echristo wrote:This would be because at that point the default cpu was that and it
probably had something to do with fallbacks.At this point it can be changed I imagine to whatever makes sense.
The issue seems to be that its somehow only being applied to one set of command lines. And the IR from the two sets of command lines are being differed. So I don't think there's any value that makes sense. Its existence is causing the diff somehow.
This doesn't work with -mtune=generic (https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html), can gcc compatibility be added?
$ cat /tmp/a.c int main(){} $ ./build/bin/clang /tmp/a.c -o /dev/null -mtune=generic error: unknown target CPU 'generic' note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
In D85384#2226842, @aeubanks wrote:This doesn't work with -mtune=generic (https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html), can gcc compatibility be added?
$ cat /tmp/a.c int main(){} $ ./build/bin/clang /tmp/a.c -o /dev/null -mtune=generic error: unknown target CPU 'generic' note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
I was planning to do work supporting that as one of my next patches. But didn't think about the fact that people would already doing it since the option was being ignored. I'll put in a quick fix.
In D85384#2226866, @craig.topper wrote:In D85384#2226842, @aeubanks wrote:This doesn't work with -mtune=generic (https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html), can gcc compatibility be added?
$ cat /tmp/a.c int main(){} $ ./build/bin/clang /tmp/a.c -o /dev/null -mtune=generic error: unknown target CPU 'generic' note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64I was planning to do work supporting that as one of my next patches. But didn't think about the fact that people would already doing it since the option was being ignored. I'll put in a quick fix.
Thanks!
There may be codebases trying to compile under both gcc and clang. Or remnants from gcc days?
Revision Contents
| Path | Size |
|---|---|
clang/ | |
include/ clang/ | |
Basic/ | |
| 3 lines | |
Driver/ | |
| 4 lines | |
lib/ | |
Basic/ | |
| 10 lines | |
CodeGen/ | |
| 5 lines | |
Driver/ ToolChains/ | |
| 13 lines | |
Frontend/ | |
| 1 line | |
test/ Misc/ | |
| 29 lines |
- ·Reviewers: luismarques, shiva0217, asb, jrtc27, craig.topper, khchen, zixuan-wu
- Mon, Dec 18, 5:37 AM
Author: wangpc
Diff 286409
clang/include/clang/Basic/TargetOptions.h
clang/include/clang/Driver/Options.td
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
clang/lib/Basic/Targets.cpp
clang/lib/CodeGen/CodeGenModule.cpp
Does this lead to a situation in 'attribute-target' where we have a 'tune' setting to a processor that is 'before' the 'TargetCPU'? Should this enforce some sort of hierarchy to make sure we only do it if it is 'newer' (read, more feature rich) than the target?
TuneCPU is only supposed to control microarchitectural things like should i prefer an "ADD 1" over "INC" instruction. Or should I use more immediate controlled shuffles over a single variable controlled shuffle. As such that things we get from tune don't have a straightforward relationship with architectural features.
My concern is more. Say:
TargetCPU == "nahalem"
Does it make sense for
TuneCPU == "pentium"?
It would seem to me that is pretty nonsensical. I've definitely seen the reverse (in within x86_64 at least, where Tune is newer than Target), but tuning for an older CPU seems like nonsense.
From a behavior standpoint, its not any different than what this does today
-march=pentium -msse4.2 -mpopcnt -mfxsr <other nehalem features>
I don't think gcc enforces any ordering.
clang/lib/Driver/ToolChains/Clang.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Misc/target-invalid-cpu-note.c
Should we have a test for tune-cpu for some non-x86 target? Or are we happy to just assume this works correctly because we already have coverage for target-cpu?
I copied the AARCH64 test above an added a -tune-cpu version of it. That will be included with my commit