Skip to content

return matters in generated function lowering #25678

@Keno

Description

@Keno

Haven't tracked this down fully, but something is up with lowering:

@generated function code_llvm_helper(f, args...)
    NI.code_typed(f.parameters[1], Tuple{args...})[1].first
end
@generated function code_llvm_helper2(f, args...)
    return NI.code_typed(f.parameters[1], Tuple{args...})[1].first
end

julia> typeof(first(methods(code_llvm_helper)).generator.gen(nothing, Val{x->x}, [Bool]))
Expr

julia> typeof(first(methods(code_llvm_helper2)).generator.gen(nothing, Val{x->x}, [Bool]))
CodeInfo

This distinction matters quite a bit of course, since CodeInfo returns get treated specially.
Looks like the extra Expr in the first case is a LineNumberNode.

Metadata

Metadata

Labels

bugIndicates an unexpected problem or unintended behaviorcompiler:loweringSyntax lowering (compiler front end, 2nd stage)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions