This is an archive of the discontinued LLVM Phabricator instance.

[X86] Add basic support for -mtune command line option in clang
ClosedPublic

Authored by craig.topper on Aug 5 2020, 5:45 PM.

Details

Summary

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

Event Timeline

craig.topper created this revision.Aug 5 2020, 5:45 PM
craig.topper requested review of this revision.Aug 5 2020, 5:45 PM

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?

craig.topper added inline comments.Aug 17 2020, 12:30 PM
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.

erichkeane added inline comments.Aug 17 2020, 12:32 PM
clang/lib/CodeGen/CodeGenModule.cpp
1752

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.

craig.topper added inline comments.Aug 18 2020, 12:26 PM
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.

efriedma accepted this revision.Aug 18 2020, 12:36 PM

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?

This revision is now accepted and ready to land.Aug 18 2020, 12:36 PM
craig.topper added inline comments.Aug 18 2020, 2:54 PM
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

Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2020, 3:13 PM
phosek added a subscriber: phosek.Aug 18 2020, 9:45 PM

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           :     2

Specifically, the tune-cpu attribute seems to be missing on Darwin. Would it be possible to take a look?

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           :     2

Specifically, 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.

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.

aeubanks added a subscriber: aeubanks.EditedAug 19 2020, 11:57 AM

This doesn't work with -mtune=generic (https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html), can gcc compatibility be added?

(https://crbug.com/1119448)

$ 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

This doesn't work with -mtune=generic (https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html), can gcc compatibility be added?

(https://crbug.com/1119448)

$ 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.

This doesn't work with -mtune=generic (https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html), can gcc compatibility be added?

(https://crbug.com/1119448)

$ 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.

Thanks!
There may be codebases trying to compile under both gcc and clang. Or remnants from gcc days?