This is an archive of the discontinued LLVM Phabricator instance.

[C-API] Add LLVMGetHostCPU{Name,Features}.
ClosedPublic

Authored by anarazel on Mar 23 2018, 7:30 PM.

Details

Summary

Without these functions it's hard to create a TargetMachine for Orc JIT that creates efficient native code.

It's not sufficient to just expose LLVMGetHostCPUName(), because for some CPUs there's fewer features
actually available than the CPU name indicates (e.g. AVX might be missing on some CPUs identified as skylake).

Diff Detail

Repository
rL LLVM

Event Timeline

anarazel created this revision.Mar 23 2018, 7:30 PM

Ping? This is a trivial change and makes it much easier to use Orc via the C API, as otherwise suboptimal code is generated. If anybody has suggestions for further reviewers I'd also be happy.

whitequark accepted this revision.Apr 11 2018, 3:36 PM

LGTM. Ideally we would have a test for this code but given that it involves host CPU and features this seems quite tricky and not worth the benefit.

This revision is now accepted and ready to land.Apr 11 2018, 3:36 PM

Ideally we would have a test for this code but given that it involves host CPU and features this seems quite tricky and not worth the benefit.

Yea, I was wondering about that, but the only test that seemed possible with reasonable would be to just call the functions and throw the results away, which didn't seem like it'd add much.

Thanks!

This revision was automatically updated to reflect the committed changes.