This is an archive of the discontinued LLVM Phabricator instance.

[X86] Default to -mtune=generic unless -march is passed to the driver. Add TuneCPU to the AST serialization
ClosedPublic

Authored by craig.topper on Aug 24 2020, 2:25 PM.

Details

Summary

This patch defaults to -mtune=generic unless -march is present. If -march is present we'll use the empty string unless its overridden by mtune. The back should use the target cpu if the tune-cpu isn't present.

It also adds AST serialization support to fix some tests that emit AST and parse it back. These tests diff the IR against the output from not going through AST. So if we don't serialize the tune CPU we fail the diff.

Diff Detail

Event Timeline

erichkeane added inline comments.Aug 26 2020, 11:30 AM
clang/lib/Serialization/ASTReader.cpp
395

What does this string do? Does there have to be a test for it?

craig.topper added inline comments.Aug 26 2020, 11:59 AM
clang/lib/Serialization/ASTReader.cpp
395

It seems to be used by a diagnostic. But I couldn't find any tests for the diagnostic for "target CPU" that I could copy from.

erichkeane accepted this revision.Aug 26 2020, 12:02 PM
This revision is now accepted and ready to land.Aug 26 2020, 12:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 26 2020, 2:54 PM

No it wasnt expected. There was already a comment on the commit about it. The settings it’s selecting should match the default we get with no -march on Linux. The only thing I’ve found so far is extra time to read the function attribute from getSubtargetImpl which happen every time getTTI is called. And extra time to add the function attribute in clang. The strange thing is it seems to have regressed O0 even so that rules out a lot of optimization related code. Any information you can provide would be helpful.