Skip to content
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

missing nospecialize on some macro arguments #39902

Open
vtjnash opened this issue Mar 3, 2021 · 1 comment
Open

missing nospecialize on some macro arguments #39902

vtjnash opened this issue Mar 3, 2021 · 1 comment
Labels
compiler:latency Compiler latency compiler:lowering Syntax lowering (compiler front end, 2nd stage) kind:bug Indicates an unexpected problem or unintended behavior

Comments

@vtjnash
Copy link
Sponsor Member

vtjnash commented Mar 3, 2021

Notice how b is missing nospecialize where it exists in the second body, since it has a default value in the first body. I noticed this when I was testing some precompile statements and surprised to see some failing.

julia> Meta.@lower macro foo(a, b=2) nothing end
:($(Expr(:thunk, CodeInfo(
    @ none within `top-level scope'
1 ─       $(Expr(:thunk, CodeInfo(
    @ none within `top-level scope'
1 ─     return $(Expr(:method, Symbol("@foo")))
)))
$(Expr(:method, Symbol("@foo")))
│   %3  = Core.Typeof(var"@foo")
│   %4  = Core.svec(%3, Core.LineNumberNode, Core.Module, Core.Any)
│   %5  = Core.svec()
│   %6  = Core.svec(%4, %5, $(QuoteNode(:(#= REPL[5]:1 =#))))
$(Expr(:method, Symbol("@foo"), :(%6), CodeInfo(
    @ REPL[5]:1 within none
1$(Expr(:meta, :nospecialize, :(a)))
%2 = (#self#)(__source__, __module__, a, 2)
└──      return %2
)))
$(Expr(:method, Symbol("@foo")))
%9  = Core.Typeof(var"@foo")
%10 = Core.svec(%9, Core.LineNumberNode, Core.Module, Core.Any, Core.Any)
%11 = Core.svec()
%12 = Core.svec(%10, %11, $(QuoteNode(:(#= REPL[5]:1 =#))))
$(Expr(:method, Symbol("@foo"), :(%12), CodeInfo(
    @ REPL[5]:1 within none
1$(Expr(:meta, :nospecialize, :(a)))
└──     return nothing
)))
└──       return var"@foo"
))))
@vtjnash vtjnash added the compiler:lowering Syntax lowering (compiler front end, 2nd stage) label Mar 3, 2021
@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Mar 3, 2021

Relatedly, also missing on args...:

julia> Meta.@lower macro ncall(N::Int, f, args...) nothing end
:($(Expr(:thunk, CodeInfo(
    @ none within `top-level scope'
1 ─      $(Expr(:thunk, CodeInfo(
    @ none within `top-level scope'
1 ─     return $(Expr(:method, Symbol("@ncall")))
)))
$(Expr(:method, Symbol("@ncall")))
│   %3 = Core.Typeof(var"@ncall")
│   %4 = Core.apply_type(Vararg, Core.Any)
│   %5 = Core.svec(%3, Core.LineNumberNode, Core.Module, Int, Core.Any, %4)
│   %6 = Core.svec()
│   %7 = Core.svec(%5, %6, $(QuoteNode(:(#= REPL[5]:1 =#))))
$(Expr(:method, Symbol("@ncall"), :(%7), CodeInfo(
    @ REPL[5]:1 within `none'
1 ─     $(Expr(:meta, :nospecialize, :(f)))
└──     return nothing
)))
└──      return var"@ncall"
))))

@vtjnash vtjnash added kind:bug Indicates an unexpected problem or unintended behavior compiler:latency Compiler latency labels Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:latency Compiler latency compiler:lowering Syntax lowering (compiler front end, 2nd stage) kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant