-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
typename
is not fully optimized away
#30430
Comments
|
Has nothing to do with |
Remarkably julia> Core.Compiler.getfield_tfunc(Core.Compiler.Const(Int64, false), Core.Compiler.Const(:name, false))
Core.Compiler.Const(Int64, false) So why is the
After unsuccessfully looking for a tfunc in julia/base/compiler/abstractinterpretation.jl Lines 764 to 765 in 59314a9
|
OTOH: julia> f1() = Base.typename(Int)
f1 (generic function with 1 method)
julia> f2() = Int.name
f2 (generic function with 1 method)
julia> g1() = f1().wrapper
g1 (generic function with 1 method)
julia> g2() = f2().wrapper
g2 (generic function with 1 method)
julia> @code_typed f1()
CodeInfo(
1 ─ %1 = Base.typename::Const(typename, false)
│ %2 = invoke %1(Main.Int::DataType)::Const(Int64, false)
└── return %2
) => TypeName
julia> @code_typed f2()
CodeInfo(
1 ─ %1 = Main.Int::Const(Int64, false)
│ %2 = (Base.getfield)(%1, :name)::TypeName
└── return %2
) => TypeName
julia> @code_typed g1()
CodeInfo(
1 ─ %1 = Base.typename::typeof(typename)
│ invoke %1(Main.Int::DataType)::TypeName
└── return Int64
) => Type{Int64}
julia> @code_typed g2()
CodeInfo(
1 ─ return Int64
) => Type{Int64} So maybe the |
Apparently fixed on master:
|
see #30420
For example
The called method is just
so it should be inlineable, and we know accessing DataType's
name
is nothrow and constant, so it's not clear why this call isn't removed.The text was updated successfully, but these errors were encountered: