Skip to content

refine IR model queries #58661

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

Merged
merged 1 commit into from
Jun 19, 2025
Merged

refine IR model queries #58661

merged 1 commit into from
Jun 19, 2025

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Jun 6, 2025

  • jl_isa_ast_node was missing enter/leave nodes.
  • Core.IR exports mistakenly included a function memoryref.
  • Base.IR, and quoted were not public or documented.
  • Add julia function isa_ast_node to improve accuracy of quoted.
  • Change == on AST nodes to check egal equality of any constants in the IR / AST, and make hashing consistent with that change. This helpfully allows determining that x + 1 and x + 1.0 are not equivalent, exchangeable operations. If you need to compare any two objects for semantic equality, you may need to first wrap them with x = Base.isa_ast_node(x) ? x : QuoteNode(x) to resolve the ambiguity of whether the comparison is of the semantics or value.
  • Handle undef fields in Phi/PhiC node equality and hashing

@vtjnash vtjnash requested a review from JeffBezanson June 6, 2025 19:11
@vtjnash vtjnash force-pushed the jn/IR-model branch 3 times, most recently from 4ecf97f to 4e85692 Compare June 12, 2025 20:46
 - `jl_isa_ast_node` was missing enter/leave nodes.
 - `Core.IR` exports mistakenly included a function `memoryref`.
 - `Base.IR`, and `quoted` were not public or documented.
 - Add julia function `isa_ast_node` to improve accuracy of `quoted`.
 - Change `==` on AST nodes to check egal equality of any constants in
   the IR / AST, and make hashing consistent with that change.
   This helpfully allows determining that `x + 1` and `x + 1.0` are not
   equivalent, exchangeable operations. If you need to compare any two
   objects for semantic equality, you may need to first wrap them with
   some sort of expression object (such as `QuoteNode(x) ==
   QuoteNode(x)`) to resolve the ambiguity of whether the comparison is
   of the semantics or value.
 - Handle `undef` fields in Phi/PhiC node equality and hashing
@vtjnash vtjnash merged commit 098a4f8 into master Jun 19, 2025
5 of 7 checks passed
@vtjnash vtjnash deleted the jn/IR-model branch June 19, 2025 19:17
@odow
Copy link
Contributor

odow commented Jul 3, 2025

This helpfully allows determining that x + 1 and x + 1.0 are not equivalent, exchangeable operations

Is this not a breaking change? It broke various tests in JuMP and MathOptInterface.jl

old

julia> expr = Expr(:call, :+, 2)
:(+2)

julia> expr_dbl = Expr(:call, :+, 2.0)
:(+2.0)

julia> expr == expr_dbl
true

julia> versioninfo()
Julia Version 1.10.9
Commit 5595d20a287 (2025-03-10 12:51 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (x86_64-apple-darwin24.0.0)
  CPU: 8 × Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

new

julia> expr = Expr(:call, :+, 2)
:(+2)

julia> expr_dbl = Expr(:call, :+, 2.0)
:(+2.0)

julia> expr == expr_dbl
false

julia> versioninfo()
Julia Version 1.13.0-DEV.814
Commit ed1fd390b59 (2025-07-03 19:54 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: macOS (x86_64-apple-darwin24.0.0)
  CPU: 8 × Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LLVM: libLLVM-20.1.2 (ORCJIT, skylake)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 8 virtual cores)

@timholy
Copy link
Member

timholy commented Jul 25, 2025

(cross posted from the squash-commit) Also broke https://github.com/JuliaDebug/JuliaInterpreter.jl/blob/e66fa6dff9f053d355bb4729afe012d5c1024ff3/test/interpret.jl#L562. I'll submit a PR to change the test but I'm unsure whether the breakage was intentional.

timholy added a commit to JuliaDebug/JuliaInterpreter.jl that referenced this pull request Jul 25, 2025
Nightly became more strict about equality among `QuoteNode`s
(JuliaLang/julia#58661). This expands the
comparison to circumvent Base's new behavior.
timholy added a commit to JuliaDebug/JuliaInterpreter.jl that referenced this pull request Jul 25, 2025
Nightly became more strict about equality among `QuoteNode`s
(JuliaLang/julia#58661). This expands the
comparison to circumvent Base's new behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants