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

Fewer anonymous funcs and despecialize inference #2131

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/compiler/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,46 @@ function reinsert_gcmarker!(func::LLVM.Function, @nospecialize(PB::Union{Nothing
end
end

@inline enum_attr_kind(kind::String) = LLVM.API.LLVMGetEnumAttributeKindForName(kind, Csize_t(length(kind)))

const swiftself_kind = enum_attr_kind("swiftself")

Base.@assume_effects :removable :foldable :nothrow function has_swiftself(fn::LLVM.Function)::Bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why those effects? We shouldn't add them to every function, and I kinda doubt they apply here or are useful?

for i in 1:length(LLVM.parameters(fn))
for attr in collect(LLVM.parameter_attributes(fn, i))
if attr isa LLVM.EnumAttribute
if kind(attr) == swiftself_kind
return true
end
end
end
end
return false
end
Base.@assume_effects :removable :foldable :nothrow function has_fn_attr(fn::LLVM.Function, attr::LLVM.EnumAttribute)::Bool
ekind = LLVM.kind(attr)
for attr in collect(function_attributes(fn))
if attr isa LLVM.EnumAttribute
if kind(attr) == ekind
return true
end
end
end
return false
end

Base.@assume_effects :removable :foldable :nothrow function has_fn_attr(fn::LLVM.Function, attr::LLVM.StringAttribute)::Bool
ekind = LLVM.kind(attr)
for attr in collect(function_attributes(fn))
if attr isa LLVM.StringAttribute
if kind(attr) == ekind
return true
end
end
end
return false
end

Base.@nospecializeinfer function eraseInst(bb::LLVM.BasicBlock, @nospecialize(inst::LLVM.Instruction))
@static if isdefined(LLVM, Symbol("erase!"))
LLVM.erase!(inst)
Expand Down
Loading