jit: do not compile methods with different optlevel in the same llvm module - #62034
Open
KristofferC wants to merge 3 commits into
Open
jit: do not compile methods with different optlevel in the same llvm module#62034KristofferC wants to merge 3 commits into
KristofferC wants to merge 3 commits into
Conversation
KristofferC
commented
Jun 8, 2026
| a = rand(100_000) | ||
| expected = OptLevelNoLeakHeavy.ksum1(a) # compiled directly at the default level | ||
| OptLevelNoLeakSlow.call2(a) # ksum2 first reached (co-compiled) via an -O0 module | ||
| @test OptLevelNoLeakHeavy.ksum2(a) === expected |
Member
Author
There was a problem hiding this comment.
Maybe this won't test what it is supposed to test if bounds checking is forced on. Have to check.
Member
Author
There was a problem hiding this comment.
Seems to work even with --check-bounds=yes, but does require O2.
julia +nightly --check-bounds=yes /tmp/test_opt.jl
per-module optlevel does not leak across co-compiled modules: Test Failed at /tmp/test_opt.jl:29
Expression: OptLevelNoLeakHeavy.ksum2(a) === expected
Evaluated: 33348.18205471307 === 33348.18205471279
...
julia +nightly --check-bounds=yes -O0 /tmp/test_opt.jl
Test Summary: | Pass Total Time
per-module optlevel does not leak across co-compiled modules | 1 1 0.1s
julia +nightly --check-bounds=yes -O1 /tmp/test_opt.jl
Test Summary: | Pass Total Time
per-module optlevel does not leak across co-compiled modules | 1 1 0.1s
KristofferC
force-pushed
the
kc/compile_level_sharding
branch
from
June 8, 2026 15:23
54b072e to
6e40a4a
Compare
xal-0
reviewed
Jun 8, 2026
| auto &ES = jl_ExecutionEngine->getExecutionSession(); | ||
| jl_emitted_output_t emitted = | ||
| out.finish(std::move(ctx), std::move(mod), *ES.getSymbolStringPool()); | ||
| jl_ExecutionEngine->addOutput(std::move(emitted)); |
Member
There was a problem hiding this comment.
I believe this reintroduces a more subtle version of the bug #61255 was intended to fix. In the current design, it is important that all of the CodeInfos passed to jl_emit_codeinsts_to_jit_impl be added to the JIT with a single addOutput call.
Member
Author
There was a problem hiding this comment.
Thoughts about the updated revision?
…module Currently, a module running with non-default opt-level could "poison" the opt-level of a method in another module if they happened to get compiled together (due to the optimization level picked for the LLVM module is picked as the minimum of the methods involved).
KristofferC
force-pushed
the
kc/compile_level_sharding
branch
from
July 22, 2026 13:20
bd5c094 to
6e3a918
Compare
Member
Author
|
Bump (@xal-0). I know you are planning on rewriting this, but maybe there is some value in getting this in in the meantime. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, a module running with non-default opt-level could "poison" the opt-level of a method in another module if they happened to get compiled together (due to the optimization level picked for the LLVM module being picked as the minimum of the methods involved).
The test shows a possible interaction where calling a method from a O0 module causes it to get compiled with O0, giving it a different result if it was compiled on its own (simd effect).
Iterated on with Claude