Skip to content

[Windows] allow clang to build tailcall vm, use __preserve_none for Call VM if available with msvc#21563

Draft
henderkes wants to merge 2 commits intophp:masterfrom
henderkes:8.5.4
Draft

[Windows] allow clang to build tailcall vm, use __preserve_none for Call VM if available with msvc#21563
henderkes wants to merge 2 commits intophp:masterfrom
henderkes:8.5.4

Conversation

@henderkes
Copy link
Copy Markdown
Contributor

@henderkes henderkes commented Mar 28, 2026

Not the largest improvement (~5-8% in my testing), but msvc's __preserve_none is not stable enough to use the tailcall vm with [[msvc::musttail]].

The tailcall VM for clang is a nice 25-30% improvement, but it still lags far behind msvc.

I'm not 100% sure if switching the call vm to __preserve_none could have any ill effects - Edit: forgot about the JIT... will take a while to track that down. If it's even feasible, I've never looked at the jit code.

PS: removing /GUARD:CF (from PHP_SECURITY_FLAGS) gives a 40% performance uplift in phoronix phpbench. I'm guessing disabling that isn't a good idea?

@henderkes henderkes requested a review from dstogov as a code owner March 28, 2026 13:57
@henderkes henderkes changed the title allow clang to build tailcall vm on windows, use __preserve_none for Call VM if available [Windows] allow clang to build tailcall vm, use __preserve_none for Call VM if available with msvc Mar 28, 2026
@henderkes henderkes force-pushed the 8.5.4 branch 3 times, most recently from 8d8808b to 774082c Compare March 28, 2026 15:50
@henderkes henderkes marked this pull request as draft March 28, 2026 16:27
@henderkes
Copy link
Copy Markdown
Contributor Author

Okay, got a decent idea how the JIT works now. There seem to be two issues: first, jit ir doesn't use the actual calling convention of the handlers but assumes tailcall vm -> preserve_none, else fastcall (IR_FASTCALL_FUNC). Second, msvc's __preserve_none calling convention uses a different register order than clang's.

Second one is easy to fix, first will need touches in various places. Can't just replace it because different registers are getting clobbered and that will destroy fp and ip.

Whether this is worth my time pursuing, I'll leave open for the core team to decide. I'm fairly confident that I could fix the issues with a few days of time if it's seen as beneficial. But perhaps not, because maybe Microsoft starts working on their compiler again after leaving it abandoned for half a decade and we better spend the effort on proper tailcall VM then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant