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/4
    CodeGenModule.cpp
  • -
    Driver/ToolChains/
  • -
    ToolChains/
  • -
    Clang.cpp
  • -
    Frontend/
  • -
    CompilerInvocation.cpp
  • -
    test/Misc/
  • -
    Misc/
  • 1/2
    target-invalid-cpu-note.c

[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 Transcript Aug 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?

Revision Contents

PathSize
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
DiffIDBaseDescriptionCreatedLintUnit
Base Base
Diff 1283456 Aug 5 2020, 5:41 PM
Diff 2286409 2f01785 rG4cbceb74bb5676d0181d4d0cab5194d90a42c2ecAug 18 2020, 3:13 PM

Diff 286409

clang/include/clang/Basic/TargetOptions.h

/// When compiling for the device side, contains the triple used to compile /// When compiling for the device side, contains the triple used to compile
/// for the host. /// for the host.
std::string HostTriple; std::string HostTriple;
/// If given, the name of the target CPU to generate code for. /// If given, the name of the target CPU to generate code for.
std::string CPU; std::string CPU;
/// If given, the name of the target CPU to tune code for.
std::string TuneCPU;
/// If given, the unit to use for floating point math. /// If given, the unit to use for floating point math.
std::string FPMath; std::string FPMath;
/// If given, the name of the target ABI to use. /// If given, the name of the target ABI to use.
std::string ABI; std::string ABI;
/// The EABI version to use /// The EABI version to use
llvm::EABI EABIVersion; llvm::EABI EABIVersion;

clang/include/clang/Driver/Options.td

  • This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 LinesShow All 2,709 Lines▼ Show 20 Lines def mno_relax_pic_calls : Flag<["-"], "mno-relax-pic-calls">,
HelpText<"Do not produce relaxation hints for linkers to try optimizing PIC " HelpText<"Do not produce relaxation hints for linkers to try optimizing PIC "
"call sequences into direct calls (MIPS only)">, Flags<[HelpHidden]>; "call sequences into direct calls (MIPS only)">, Flags<[HelpHidden]>;
def mglibc : Flag<["-"], "mglibc">, Group<m_libc_Group>, Flags<[HelpHidden]>; def mglibc : Flag<["-"], "mglibc">, Group<m_libc_Group>, Flags<[HelpHidden]>;
def muclibc : Flag<["-"], "muclibc">, Group<m_libc_Group>, Flags<[HelpHidden]>; def muclibc : Flag<["-"], "muclibc">, Group<m_libc_Group>, Flags<[HelpHidden]>;
def module_file_info : Flag<["-"], "module-file-info">, Flags<[DriverOption,CC1Option]>, Group<Action_Group>, def module_file_info : Flag<["-"], "module-file-info">, Flags<[DriverOption,CC1Option]>, Group<Action_Group>,
HelpText<"Provide information about a particular module file">; HelpText<"Provide information about a particular module file">;
def mthumb : Flag<["-"], "mthumb">, Group<m_Group>; def mthumb : Flag<["-"], "mthumb">, Group<m_Group>;
def mtune_EQ : Joined<["-"], "mtune=">, Group<m_Group>, def mtune_EQ : Joined<["-"], "mtune=">, Group<m_Group>,
HelpText<"Accepted for compatibility with GCC. Currently has no effect.">; HelpText<"Only supported on X86. Otherwise accepted for compatibility with GCC.">;
def multi__module : Flag<["-"], "multi_module">; def multi__module : Flag<["-"], "multi_module">;
def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">; def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
def multiply__defined : Separate<["-"], "multiply_defined">; def multiply__defined : Separate<["-"], "multiply_defined">;
def mwarn_nonportable_cfstrings : Flag<["-"], "mwarn-nonportable-cfstrings">, Group<m_Group>; def mwarn_nonportable_cfstrings : Flag<["-"], "mwarn-nonportable-cfstrings">, Group<m_Group>;
def no_canonical_prefixes : Flag<["-"], "no-canonical-prefixes">, Flags<[HelpHidden, CoreOption]>, def no_canonical_prefixes : Flag<["-"], "no-canonical-prefixes">, Flags<[HelpHidden, CoreOption]>,
HelpText<"Use relative instead of canonical paths">; HelpText<"Use relative instead of canonical paths">;
def no_cpp_precomp : Flag<["-"], "no-cpp-precomp">, Group<clang_ignored_f_Group>; def no_cpp_precomp : Flag<["-"], "no-cpp-precomp">, Group<clang_ignored_f_Group>;
def no_integrated_cpp : Flag<["-", "--"], "no-integrated-cpp">, Flags<[DriverOption]>; def no_integrated_cpp : Flag<["-", "--"], "no-integrated-cpp">, Flags<[DriverOption]>;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Target Options // Target Options
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
def target_cpu : Separate<["-"], "target-cpu">, def target_cpu : Separate<["-"], "target-cpu">,
HelpText<"Target a specific cpu type">; HelpText<"Target a specific cpu type">;
def tune_cpu : Separate<["-"], "tune-cpu">,
HelpText<"Tune for a specific cpu type">;
def target_feature : Separate<["-"], "target-feature">, def target_feature : Separate<["-"], "target-feature">,
HelpText<"Target specific attributes">; HelpText<"Target specific attributes">;
def triple : Separate<["-"], "triple">, def triple : Separate<["-"], "triple">,
HelpText<"Specify target triple (e.g. i686-apple-darwin9)">, HelpText<"Specify target triple (e.g. i686-apple-darwin9)">,
MarshallingInfoString<"TargetOpts->Triple", "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())", "std::string">, MarshallingInfoString<"TargetOpts->Triple", "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())", "std::string">,
AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString; AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString;
def target_abi : Separate<["-"], "target-abi">, def target_abi : Separate<["-"], "target-abi">,
HelpText<"Target a particular ABI type">; HelpText<"Target a particular ABI type">;

clang/lib/Basic/Targets.cpp

Show First 20 LinesShow All 646 Lines▼ Show 20 Lines if (!Opts->CPU.empty() && !Target->setCPU(Opts->CPU)) {
Diags.Report(diag::err_target_unknown_cpu) << Opts->CPU; Diags.Report(diag::err_target_unknown_cpu) << Opts->CPU;
SmallVector<StringRef, 32> ValidList; SmallVector<StringRef, 32> ValidList;
Target->fillValidCPUList(ValidList); Target->fillValidCPUList(ValidList);
if (!ValidList.empty()) if (!ValidList.empty())
Diags.Report(diag::note_valid_options) << llvm::join(ValidList, ", "); Diags.Report(diag::note_valid_options) << llvm::join(ValidList, ", ");
return nullptr; return nullptr;
} }
// Check the TuneCPU name if specified.
if (!Opts->TuneCPU.empty() && !Target->isValidCPUName(Opts->TuneCPU)) {
Diags.Report(diag::err_target_unknown_cpu) << Opts->TuneCPU;
SmallVector<StringRef, 32> ValidList;
Target->fillValidCPUList(ValidList);
if (!ValidList.empty())
Diags.Report(diag::note_valid_options) << llvm::join(ValidList, ", ");
return nullptr;
}
// Set the target ABI if specified. // Set the target ABI if specified.
if (!Opts->ABI.empty() && !Target->setABI(Opts->ABI)) { if (!Opts->ABI.empty() && !Target->setABI(Opts->ABI)) {
Diags.Report(diag::err_target_unknown_abi) << Opts->ABI; Diags.Report(diag::err_target_unknown_abi) << Opts->ABI;
return nullptr; return nullptr;
} }
// Set the fp math unit. // Set the fp math unit.
if (!Opts->FPMath.empty() && !Target->setFPMath(Opts->FPMath)) { if (!Opts->FPMath.empty() && !Target->setFPMath(Opts->FPMath)) {

clang/lib/CodeGen/CodeGenModule.cpp

} }
bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD, bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
llvm::AttrBuilder &Attrs) { llvm::AttrBuilder &Attrs) {
// Add target-cpu and target-features attributes to functions. If // Add target-cpu and target-features attributes to functions. If
// we have a decl for the function and it has a target attribute then // we have a decl for the function and it has a target attribute then
// parse that and add it to the feature set. // parse that and add it to the feature set.
StringRef TargetCPU = getTarget().getTargetOpts().CPU; StringRef TargetCPU = getTarget().getTargetOpts().CPU;
StringRef TuneCPU = getTarget().getTargetOpts().TuneCPU;
erichkeaneUnsubmitted

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?

erichkeane: Does this lead to a situation in 'attribute-target' where we have a 'tune' setting to a...
craig.topperAuthorUnsubmitted

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.

craig.topper: TuneCPU is only supposed to control microarchitectural things like should i prefer an "ADD 1"...
erichkeaneUnsubmitted

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.

erichkeane: My concern is more. Say: TargetCPU == "nahalem" Does it make sense for TuneCPU == "pentium"?
craig.topperAuthorUnsubmitted

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.

craig.topper: From a behavior standpoint, its not any different than what this does today -march=pentium...
std::vector<std::string> Features; std::vector<std::string> Features;
const auto *FD = dyn_cast_or_null<FunctionDecl>(GD.getDecl()); const auto *FD = dyn_cast_or_null<FunctionDecl>(GD.getDecl());
FD = FD ? FD->getMostRecentDecl() : FD; FD = FD ? FD->getMostRecentDecl() : FD;
const auto *TD = FD ? FD->getAttr<TargetAttr>() : nullptr; const auto *TD = FD ? FD->getAttr<TargetAttr>() : nullptr;
const auto *SD = FD ? FD->getAttr<CPUSpecificAttr>() : nullptr; const auto *SD = FD ? FD->getAttr<CPUSpecificAttr>() : nullptr;
bool AddedAttr = false; bool AddedAttr = false;
if (TD || SD) { if (TD || SD) {
llvm::StringMap<bool> FeatureMap; llvm::StringMap<bool> FeatureMap;
Show All 18 Lines if (TD || SD) {
// function. // function.
Features = getTarget().getTargetOpts().Features; Features = getTarget().getTargetOpts().Features;
} }
if (TargetCPU != "") { if (TargetCPU != "") {
Attrs.addAttribute("target-cpu", TargetCPU); Attrs.addAttribute("target-cpu", TargetCPU);
AddedAttr = true; AddedAttr = true;
} }
if (TuneCPU != "") {
Attrs.addAttribute("tune-cpu", TuneCPU);
AddedAttr = true;
}
if (!Features.empty()) { if (!Features.empty()) {
llvm::sort(Features); llvm::sort(Features);
Attrs.addAttribute("target-features", llvm::join(Features, ",")); Attrs.addAttribute("target-features", llvm::join(Features, ","));
AddedAttr = true; AddedAttr = true;
} }
return AddedAttr; return AddedAttr;
} }

clang/lib/Driver/ToolChains/Clang.cpp

  • This file is larger than 256 KB, so syntax highlighting is disabled by default.
#include "clang/Driver/XRayArgs.h" #include "clang/Driver/XRayArgs.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Config/llvm-config.h" #include "llvm/Config/llvm-config.h"
#include "llvm/Option/ArgList.h" #include "llvm/Option/ArgList.h"
#include "llvm/Support/CodeGen.h" #include "llvm/Support/CodeGen.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include "llvm/Support/Compression.h" #include "llvm/Support/Compression.h"
#include "llvm/Support/FileSystem.h" #include "llvm/Support/FileSystem.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Path.h" #include "llvm/Support/Path.h"
#include "llvm/Support/Process.h" #include "llvm/Support/Process.h"
#include "llvm/Support/TargetParser.h" #include "llvm/Support/TargetParser.h"
#include "llvm/Support/YAMLParser.h" #include "llvm/Support/YAMLParser.h"
#ifdef LLVM_ON_UNIX #ifdef LLVM_ON_UNIX
#include <unistd.h> // For getuid(). #include <unistd.h> // For getuid().
#endif #endif
さんかく Show 20 LinesShow All 2,016 Lines▼ Show 20 Lines void Clang::AddX86TargetArgs(const ArgList &Args,
} }
// Set flags to support MCU ABI. // Set flags to support MCU ABI.
if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false)) { if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false)) {
CmdArgs.push_back("-mfloat-abi"); CmdArgs.push_back("-mfloat-abi");
CmdArgs.push_back("soft"); CmdArgs.push_back("soft");
CmdArgs.push_back("-mstack-alignment=4"); CmdArgs.push_back("-mstack-alignment=4");
} }
// Handle -mtune.
// FIXME: We should default to "generic" unless -march is set to match gcc.
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) {
StringRef Name = A->getValue();
if (Name == "native")
Name = llvm::sys::getHostCPUName();
CmdArgs.push_back("-tune-cpu");
CmdArgs.push_back(Args.MakeArgString(Name));
}
} }
void Clang::AddHexagonTargetArgs(const ArgList &Args, void Clang::AddHexagonTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { ArgStringList &CmdArgs) const {
CmdArgs.push_back("-mqdsp6-compat"); CmdArgs.push_back("-mqdsp6-compat");
CmdArgs.push_back("-Wreturn-type"); CmdArgs.push_back("-Wreturn-type");
if (auto G = toolchains::HexagonToolChain::getSmallDataThreshold(Args)) { if (auto G = toolchains::HexagonToolChain::getSmallDataThreshold(Args)) {

clang/lib/Frontend/CompilerInvocation.cpp

Show First 20 LinesShow All 3,652 Lines▼ Show 20 Lines llvm::EABI EABIVersion = llvm::StringSwitch<llvm::EABI>(Value)
.Default(llvm::EABI::Unknown); .Default(llvm::EABI::Unknown);
if (EABIVersion == llvm::EABI::Unknown) if (EABIVersion == llvm::EABI::Unknown)
Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
<< Value; << Value;
else else
Opts.EABIVersion = EABIVersion; Opts.EABIVersion = EABIVersion;
} }
Opts.CPU = std::string(Args.getLastArgValue(OPT_target_cpu)); Opts.CPU = std::string(Args.getLastArgValue(OPT_target_cpu));
Opts.TuneCPU = std::string(Args.getLastArgValue(OPT_tune_cpu));
Opts.FPMath = std::string(Args.getLastArgValue(OPT_mfpmath)); Opts.FPMath = std::string(Args.getLastArgValue(OPT_mfpmath));
Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature); Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature);
Opts.LinkerVersion = Opts.LinkerVersion =
std::string(Args.getLastArgValue(OPT_target_linker_version)); std::string(Args.getLastArgValue(OPT_target_linker_version));
Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ); Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128); Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128);
Opts.NVPTXUseShortPointers = Args.hasFlag( Opts.NVPTXUseShortPointers = Args.hasFlag(
options::OPT_fcuda_short_ptr, options::OPT_fno_cuda_short_ptr, false); options::OPT_fcuda_short_ptr, options::OPT_fno_cuda_short_ptr, false);

clang/test/Misc/target-invalid-cpu-note.c

// RUN: not %clang_cc1 -triple armv5--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix ARM // RUN: not %clang_cc1 -triple armv5--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix ARM
// ARM: error: unknown target CPU 'not-a-cpu' // ARM: error: unknown target CPU 'not-a-cpu'
// ARM: note: valid target CPU values are: // ARM: note: valid target CPU values are:
// ARM-SAME: arm2 // ARM-SAME: arm2
// RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AARCH64 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AARCH64
// AARCH64: error: unknown target CPU 'not-a-cpu' // AARCH64: error: unknown target CPU 'not-a-cpu'
// AARCH64: note: valid target CPU values are: // AARCH64: note: valid target CPU values are:
// AARCH64-SAME: cortex-a35, // AARCH64-SAME: cortex-a35,
// RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
// TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
// TUNE_AARCH64: note: valid target CPU values are:
// TUNE_AARCH64-SAME: cortex-a35,
// RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86 // RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86
// X86: error: unknown target CPU 'not-a-cpu' // X86: error: unknown target CPU 'not-a-cpu'
// X86: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, // X86: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3,
// X86-SAME: i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, // X86-SAME: i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3,
// X86-SAME: pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, // X86-SAME: pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott,
// X86-SAME: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, // X86-SAME: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont,
// X86-SAME: nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, // X86-SAME: nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge,
// X86-SAME: core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, // X86-SAME: core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512,
// X86-SAME: skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, lakemont, k6, k6-2, k6-3, // X86-SAME: skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, lakemont, k6, k6-2, k6-3,
// X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, // X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64,
// X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, // X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10,
// X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, // X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2,
// X86-SAME: x86-64, geode // X86-SAME: x86-64, geode
// RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86_64 // RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86_64
// X86_64: error: unknown target CPU 'not-a-cpu' // X86_64: error: unknown target CPU 'not-a-cpu'
// X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell, // X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell,
// X86_64-SAME: atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, // X86_64-SAME: atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere,
// X86_64-SAME: sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, // X86_64-SAME: sandybridge, corei7-avx, ivybridge, core-avx-i, haswell,
// X86_64-SAME: core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, // X86_64-SAME: core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake,
// X86_64-SAME: icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, // X86_64-SAME: icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3,
// X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, // X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
// X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64 // X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
// RUN: not %clang_cc1 -triple i386--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86
// TUNE_X86: error: unknown target CPU 'not-a-cpu'
// TUNE_X86: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3,
// TUNE_X86-SAME: i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3,
// TUNE_X86-SAME: pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott,
// TUNE_X86-SAME: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont,
// TUNE_X86-SAME: nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge,
// TUNE_X86-SAME: core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512,
// TUNE_X86-SAME: skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, lakemont, k6, k6-2, k6-3,
// TUNE_X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64,
// TUNE_X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10,
// TUNE_X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2,
// TUNE_X86-SAME: x86-64, geode
// RUN: not %clang_cc1 -triple x86_64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86_64
efriedmaUnsubmitted

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?

efriedma: Should we have a test for tune-cpu for some non-x86 target? Or are we happy to just assume...
craig.topperAuthorUnsubmitted

I copied the AARCH64 test above an added a -tune-cpu version of it. That will be included with my commit

craig.topper: I copied the AARCH64 test above an added a -tune-cpu version of it. That will be included with...
// TUNE_X86_64: error: unknown target CPU 'not-a-cpu'
// TUNE_X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell,
// TUNE_X86_64-SAME: atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere,
// TUNE_X86_64-SAME: sandybridge, corei7-avx, ivybridge, core-avx-i, haswell,
// TUNE_X86_64-SAME: core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake,
// TUNE_X86_64-SAME: icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3,
// TUNE_X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
// TUNE_X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
// RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX // RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
// NVPTX: error: unknown target CPU 'not-a-cpu' // NVPTX: error: unknown target CPU 'not-a-cpu'
// NVPTX: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35, // NVPTX: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35,
// NVPTX-SAME: sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72 // NVPTX-SAME: sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72
// RUN: not %clang_cc1 -triple r600--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix R600 // RUN: not %clang_cc1 -triple r600--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix R600
// R600: error: unknown target CPU 'not-a-cpu' // R600: error: unknown target CPU 'not-a-cpu'
// R600: note: valid target CPU values are: r600, rv630, rv635, r630, rs780, // R600: note: valid target CPU values are: r600, rv630, rv635, r630, rs780,

AltStyle によって変換されたページ (->オリジナル) /