-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[MC] Add support for -mcpu=native. #159414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# RUN: llvm-mc -filetype=obj -mcpu=native %s 2>&1 | FileCheck %s | ||
|
||
# CHECK-NOT: 'native' is not a recognized processor for this target (ignoring processor) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -467,6 +467,10 @@ int main(int argc, char **argv) { | |
FeaturesStr = Features.getString(); | ||
} | ||
|
||
// Replace -mcpu=native with Host CPU. | ||
jurahul marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
if (MCPU == "native") | ||
MCPU = std::string(llvm::sys::getHostCPUName()); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to pass call getHostCPUFeatures too and pass that information to MAttr? I know on X86, getHostCPUName can return "haswell" on Pentium CPUs that don't support AVX2, but use the haswell microarchitecture. "haswell" implies AVX2. getHostCPUFeatures will return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, that's a good point. It doesn't look like X86 supports I do see that clang/lib/Driver/ToolChains/Arch/X86.cpp:
I don't have a strong opinion here, but do have a strong opinion that MC needs to support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clang does use getHostCPUFeatures with -mcpu=native. I wrote the code originally. It's here.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think that fixme is maybe saying we shouldn't call getHostCPU if you explicitly pass --target=x86_64 on a non-x86 machine? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry I meant -march=native. For all intents and purpose -march on X86 is -mcpu. I've been on RISC-V for too long now so I my brain thinks -mcpu. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Latest patch addresses this. I think it's best to allow the command line -mattr's to override the default with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree. |
||
std::unique_ptr<MCSubtargetInfo> STI( | ||
TheTarget->createMCSubtargetInfo(TheTriple, MCPU, FeaturesStr)); | ||
assert(STI && "Unable to create subtarget info!"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too specific for a not check. Better to verify the output is empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like FileCheck doesn't like an empty input file (really stderr piped to stdout):
I could make the CHECK-NOT more narrow. Maybe something like:
Does that seem acceptable, @arsenm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know there's some trick to do this. I ran into this recently but forget what I did
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess checking native works though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--allow-empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in latest patch.