-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[compiler-rt] Add infrastructure for testing cpuid builtins #101927
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
base: main
Are you sure you want to change the base?
[compiler-rt] Add infrastructure for testing cpuid builtins #101927
Conversation
This patch adds infrastructure in compiler-rt to test cpuid related builtins (like __builtin_cpu_supports and __builtin_cpu_is) on X86.
✅ With the latest revision this PR passed the C/C++ code formatter. |
Bump on this when you get a chance @petrhosek. Thanks! |
@petrhosek bump on this when you get a chance. Thanks! |
Bump on this when you have a chance @petrhosek. |
Using OverrideCPUID doesn't look an ideal solution to me. It cannot prevent mistakes from author who wrote both code and test. It also cannot reflect any HW changes or mismatch. I'd like to see run time test from llvm-test-suite. We can leverage SDE to emulate different Intel CPUs, but I don't know how to do with other vendors. |
Right. It can't catch everything, but it should be an improvement over what we have currently (no testing). I'm also not sure there's anything that is clearly better and works across vendors. My plan for this was ideally to take raw cpuid values from real hardware and then assert that we get the expected features and identify the appropriate CPU. That doesn't make it foolproof, but should be a reasonable enough approach.
Can you explicate on the specific scenarios you're describing here?
I would think using SDE would require adding it as a dependency to I think we could write a hook that uses |
It's unlike to happen. I imagine the HW spec might be updated after it's disclosed and compiler may fail to catch it.
There was a bot run with SDE, but seems removed from llvm-zorg now. |
Makes sense. Either way, seems like something that would be hard to detect even with decent testing?
Yeah, this doesn't seem too uncommon for some of the bots with specific configurations, hence my concern about limiting the tests by requiring something like SDE. Are we able to move forward with this given testing a specific processor's CPU values and asserting microarch/features based on manufacturer documentation should alleviate concerns regarding tests being incorrectly based on the implementation? |
I agree the dependency to extra tool is not great, but the method here doesn't look much value to me. In my opinion, a valuable test should serve one or another of below functions:
|
This patch adds infrastructure in compiler-rt to test cpuid related builtins (like __builtin_cpu_supports and __builtin_cpu_is) on X86.