FEXCore: Pass host type that changes codegen to FEXCore#5610
Conversation
Because these compile options change codegen, we need to make sure these are runtime selected rather than compile-time selected. Will reduce code-cache variance.
|
Does this require corresponding changes in FEXOfflineCompiler on WoA and have you ensured code cache validation is still clean after this change? |
|
It will need one yes. Nothing changed there, it'll continue generating broken code in this instance as expected. |
How has it been generating broken code and why are you bringing this up just now? Anyway, are you going to submit a followup PR for it? |
There were basically three compile time code paths
Depending on which OfflineCodeCompiler build flags and target platform, the tool would never be unable to generate the correct syscall code for all targets. Or the other way of thinking about it, the tool would generate code for a different platforms needs. These are fairly uncommon instructions so it's likely that it wasn't encountered before. There needs to be a flag passed to either the OfflineCodeCompiler or a flag saved in to the code map to determine what the original target was. I assume codemap is going to be the primary path, considering on win32 we have no way to know if a process is wow64 or arm64ec after the fact. |
Am I missing something? A 32-bit binary is wow64 and a 64-bit one is arm64ec, isn't it? So the information is right there. Also note that trying to compile for ARM64EC with FEXOfflineCompiler32 isn't intended to happen, just that it isn't enforced (yet). Either way this seems unrelated to the PR though. Why didn't you update FEXOfflineCompiler along the other changes? Relying on me to catch this stuff when it was submitted + merged over a weekend isn't exactly good team play. |
Glad to see that you concur then that the original code was broken and the new code is equally broken in that environment. The OfflineCompiler needs to be patched up to fetch host CPU features and set the host type the same as the original Linux/wow64/arm64ec code paths if it wants to produce identical output. |
Looks like I might have misread this but I'll make it a bit more clear. Before this change, depending on build flags of FEXOfflineCompiler (Linux, wow64 Windows, arm64ec Windows), the syscall instruction was emitting different code incorrectly depending on case on the Windows side. Primarily boiling down to the behaviour of How regular wow64/arm64.dll code emits:
What FEXOfflineCompiler emits, depending on build flag:
This is why the flag must be passed in from the frontend, because it was already broken. I think because the frontend isn't currently passing the operating mode to the backend, there is now just some additional breakage that FEXOfflineCompiler.exe is currently claiming it is HostType of Linux because it's using the wrong The wrong HostFeatures just means that some features are also incorrectly enabled or disabled which changes codegen as well. But I didn't change that in this particular PR, as it should be changed independently. |
Because these compile options change codegen, we need to make sure these are runtime selected rather than compile-time selected. Will reduce code-cache variance.