Repository navigation
Compiler crash on MSVC when building with JIT and PGO #125217
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Oct 9, 2024 Perhaps this is the same root cause as the crash with the free-threading build as well (just extra complexity in
_PyEval_EvalFrameDefault#123153.This problem is proving tricky to solve. In the past when we've seen this crash, it has been enough to disable speed optimizations on the single
_PyEval_EvalFrameDefaultfunction using#pragma optimize("t", off), but that's not working in this case. I have also tried turning off all optimizations on that function to no avail.Just to confirm why PGO is so important, I measured its effect on the last known-working commit (04c837d) and PGO improves speed by about 14% on the pyperformance suite. So "just not using PGO on Windows" isn't a viable option.
git bisecttells me that the first commit to cause the compiler to crash with the JIT/PGO combination is da071fa #124392, which at least seems plausible. Maybe there is something we can do with those changes to workaround the compiler crash (Cc: @markshannon) as a stopgap solution.In the meantime, now that I have a set of changes to point to, I can file a bug against MSVC.
Here is the bug I filed against MSVC: https://developercommunity.visualstudio.com/t/C1001-when-compiling-very-large-function/10767031
Leaving a few possible alternatives just in case:
_PyEval_EvalFrameDefault(...) { ... - uint8_t opcode; /* Current opcode */ + uint16_t opcode; /* Current opcode */ ... #if USE_COMPUTED_GOTOS _unknown_opcode: #else - EXTRA_CASES // From pycore_opcode_metadata.h, ... + default: #endifAdding an extra
opcodecase more than 299, which loses the advantage ofEXTRA_CASES:_PyEval_EvalFrameDefault(...) { ... #if USE_COMPUTED_GOTOS _unknown_opcode: #else EXTRA_CASES // From pycore_opcode_metadata.h, ... + case 500: #endifI guess MSVC might want to merge the jump tables.
Bug report
Bug description:
Building with the JIT and PGO simultaneously causes MSVC 1941 to crash:
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs