This is an archive of the discontinued LLVM Phabricator instance.

[Clang][Driver] Add -mcpu=help to clang
ClosedPublic

Authored by michaelmaitland on Feb 27 2023, 1:59 PM.

Details

Summary

Clang currently uses -mcpu=?. The ? causes errors on some shells such as zsh
since it is a special character. In order for it to work on shells such as zsh,
the option must be passed in quotes or escaped. This patch adds -mcpu=help as
another alias for --print-supported-cpus. In llc, -mcpu=help an alias to
print supported cpus.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2023, 1:59 PM
michaelmaitland requested review of this revision.Feb 27 2023, 1:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2023, 1:59 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Code and description appear out of sync. (help != list) Personally, I like the help naming a lot better.

Change list -> help.

Code and description appear out of sync. (help != list) Personally, I like the help naming a lot better.

Thanks for catching this. I meant to write help instead of list.

reames accepted this revision.Feb 27 2023, 2:12 PM

LGTM

This revision is now accepted and ready to land.Feb 27 2023, 2:12 PM

Sorry I just saw this but I am not sure this is a good idea. Why can't the user use --print-supported-cpus instead? The additional alias doesn't seem useful. If you can make GCC add this as well, it will be different.

FWIW I think this should be reverted.

Sorry I just saw this but I am not sure this is a good idea. Why can't the user use --print-supported-cpus instead? The additional alias doesn't seem useful. If you can make GCC add this as well, it will be different.

According to https://reviews.llvm.org/D63105, I believe the reason mcpu=? and mtune=? were added was:

This option is useful but may be hard to discover. Will something like -march=? and -mtune=? make the feature more discoverable?

I would then say this option is being made available for the same reason: discoverability. Since llc uses help instead of ?, I think that this clang option is easier to discover since it exists in other parts of llvm. Additionally, it comes with the added benefit that help does not contain special characters that require escaping. Maybe we revert this patch and remove the ? and only support help?

Since llc has -mcpu=help, it seems fine to have clang -mcpu=help. I made a bad suggestion there about -mcpu=?. Perhaps I should revert de94ac9357750fdba45e09eefa8f67a650ae6a64 . This -mcpu=help patch is good.