[PATCH] D106503: MCSubtargetInfo: Add debugging 'features' that dump current CPU bit state

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 26 18:23:51 PDT 2021


craig.topper added a comment.

In D106503#2906075 <https://reviews.llvm.org/D106503#2906075>, @george.burgess.iv wrote:

>> I'm curious, as X86 is probably one of the more complicated targets, does rust make use of llvm::X86::updateImpliedFeatures and llvm::X86::getFeaturesForCPU from llvm/lib/Support/X86TargetParser.cpp? That's a large chunk of the code clang uses for feature interactions.
>
> `ripgrep` says Rust never tries to directly invoke either of these. Should it? I'm not personally an expert in backend features, but it seems slightly odd to me that frontends should need to query this info when LLVM already infers much about backend features on its own.
>
> FWIW, I noticed that the inference of SGX is missing from a few `rustc` invocations for certain X86 target CPUs (well, missing compared to clang, at least). Seems like that could be because Rust doesn't call the functions you mentioned. Do you think that should be a bug against `rustc`, or against LLVM for not realizing that SGX is a feature of some CPUs except through these `llvm::X86::{updateImpliedFeatures,getFeaturesForCPU}` interfaces?

SGX is a weird because there are no backend intrinsics for it. The frontend provides some inline assembly wrappers, but that's it. There are odd gaps in which CPUs support it. We intentionally didn't infer it for CPUs in the backend because it made the code in X86.td even harder to maintain than it already is do to the non-linear inheritance.

Clang needs its own copy of the inheritance logic because clang can't depend on a target library in LLVM since the library might not be listed in LLVM_TARGETS_TO_BUILD. The features for the C builtins used by the intrinsic header files needs to be checked by the frontend. The backend will crash on unsupported intrinsics. There are also preprocessor defines the clang creates based on which features are enabled. Not sure if those clang requirements apply to rustc.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106503/new/

https://reviews.llvm.org/D106503



More information about the llvm-commits mailing list