Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Dec 1, 2024
1 parent 655ec30 commit c0ebbdd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/analyses/activity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Base.@assume_effects :removable :foldable :nothrow @inline function (c::Merger{s
end
end

Base.@assume_effects :removable :foldable :nothrow @inline forcefold(::Val{RT})::ActivityState where {RT} = RT
@inline forcefold(::Val{RT}) where {RT} = RT

Base.@assume_effects :removable :foldable :nothrow @inline function forcefold(::Val{ty}, ::Val{sty}, C::Vararg{Any,N})::ActivityState where {ty,sty,N}
if sty == AnyState || sty == ty
Expand Down
31 changes: 16 additions & 15 deletions src/compiler/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,23 @@ function set_writing(mri::ModRefInfo)
return mri | MRI_Mod
end

function set_readonly(effect::MemoryEffect)
function set_readonly(effect::MemoryEffect)::MemoryEffect
data = UInt32(0)
for loc in (ArgMem, InaccessibleMem, Other)
data = UInt32(set_readonly(getModRef(effect, loc))) << getLocationPos(loc)
end
return MemoryEffect(data)
end

function is_readonly(mri::ModRefInfo)
function is_readonly(mri::ModRefInfo)::Bool
return mri == MRI_NoModRef || mri == MRI_Ref
end

function is_readnone(mri::ModRefInfo)
function is_readnone(mri::ModRefInfo)::Bool
return mri == MRI_NoModRef
end

function is_writeonly(mri::ModRefInfo)
function is_writeonly(mri::ModRefInfo)::Bool
return mri == MRI_NoModRef || mri == MRI_Mod
end

Expand All @@ -137,7 +137,7 @@ for n in (:is_readonly, :is_readnone, :is_writeonly)
end
end

function is_noreturn(f::LLVM.Function)
Base.@assume_effects :removable :foldable :nothrow function is_noreturn(f::LLVM.Function)::Bool
for attr in collect(function_attributes(f))
if kind(attr) == kind(EnumAttribute("noreturn"))
return true
Expand All @@ -146,7 +146,7 @@ function is_noreturn(f::LLVM.Function)
return false
end

function is_readonly(f::LLVM.Function)
Base.@assume_effects :removable :foldable :nothrow function is_readonly(f::LLVM.Function)::Bool
intr = LLVM.API.LLVMGetIntrinsicID(f)
if intr == LLVM.Intrinsic("llvm.lifetime.start").id
return true
Expand Down Expand Up @@ -179,7 +179,7 @@ function is_readonly(f::LLVM.Function)
return false
end

function is_readnone(f::LLVM.Function)
Base.@assume_effects :removable :foldable :nothrow function is_readnone(f::LLVM.Function)::Bool
intr = LLVM.API.LLVMGetIntrinsicID(f)
if intr == LLVM.Intrinsic("llvm.lifetime.start").id
return true
Expand Down Expand Up @@ -209,7 +209,7 @@ function is_readnone(f::LLVM.Function)
return false
end

function is_writeonly(f::LLVM.Function)
Base.@assume_effects :removable :foldable :nothrow function is_writeonly(f::LLVM.Function)::Bool
intr = LLVM.API.LLVMGetIntrinsicID(f)
if intr == LLVM.Intrinsic("llvm.lifetime.start").id
return true
Expand Down Expand Up @@ -364,7 +364,7 @@ end

const swiftself_kind = enum_attr_kind("swiftself")

function has_swiftself(fn::LLVM.Function)::Bool
Base.@assume_effects :removable :foldable :nothrow function has_swiftself(fn::LLVM.Function)::Bool
for i in 1:length(LLVM.parameters(fn))
for attr in collect(LLVM.parameter_attributes(fn, i))
if attr isa LLVM.EnumAttribute
Expand All @@ -376,7 +376,7 @@ function has_swiftself(fn::LLVM.Function)::Bool
end
return false
end
function has_fn_attr(fn::LLVM.Function, attr::LLVM.EnumAttribute)::Bool
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
Expand All @@ -387,7 +387,8 @@ function has_fn_attr(fn::LLVM.Function, attr::LLVM.EnumAttribute)::Bool
end
return false
end
function has_fn_attr(fn::LLVM.Function, attr::LLVM.StringAttribute)::Bool

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
Expand Down Expand Up @@ -445,14 +446,14 @@ end
NamedTuple{ntuple(Symbol, Val(length(U.parameters))),U}

# recursively compute the eltype type indexed by idx[0], idx[1], ...
function recursive_eltype(@nospecialize(val::LLVM.Value), idxs::Vector{Cuint})
ty = LLVM.value_type(val)
Base.@assume_effects :removable :foldable :nothrow function recursive_eltype(@nospecialize(val::LLVM.Value), idxs::Vector{Cuint})::LLVM.LLVMType
ty = LLVM.value_type(val)::LLVM.LLVMType
for i in idxs
if isa(ty, LLVM.ArrayType)
ty = eltype(ty)
ty = eltype(ty)::LLVM.LLVMType
else
@assert isa(ty, LLVM.StructType)
ty = elements(ty)[i+1]
ty = elements(ty)[i+1]::LLVM.LLVMType
end
end
return ty
Expand Down
2 changes: 1 addition & 1 deletion src/rules/customrules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ end
debug_from_orig!(gutils, res, orig)
callconv!(res, callconv(llvmf))

hasNoRet = has_fn_attribute(llvmf, EnumAttribute("noreturn"))
hasNoRet = has_fn_attr(llvmf, EnumAttribute("noreturn"))

if hasNoRet
return false
Expand Down
10 changes: 5 additions & 5 deletions src/rules/llvmrules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ end
if in(name, ("ijl_f_finalizer", "jl_f_finalizer"))
return common_finalizer_augfwd(2, B, orig, gutils, normalR, shadowR, tapeR)
end
if has_fn_attribute(F, StringAttribute("enzyme_inactive"))
if has_fn_attr(F, StringAttribute("enzyme_inactive"))
return true
end
end
Expand Down Expand Up @@ -307,7 +307,7 @@ end
common_finalizer_rev(2, B, orig, gutils, tape)
return nothing
end
if has_fn_attribute(F, StringAttribute("enzyme_inactive"))
if has_fn_attr(F, StringAttribute("enzyme_inactive"))
return nothing
end
end
Expand All @@ -328,7 +328,7 @@ end
if in(name, ("ijl_invoke", "jl_invoke"))
return common_invoke_fwd(2, B, orig, gutils, normalR, shadowR)
end
if has_fn_attribute(F, StringAttribute("enzyme_inactive"))
if has_fn_attr(F, StringAttribute("enzyme_inactive"))
return true
end
end
Expand All @@ -345,7 +345,7 @@ end
if in(name, ("ijl_invoke", "jl_invoke"))
return common_invoke_augfwd(2, B, orig, gutils, normalR, shadowR, tapeR)
end
if has_fn_attribute(F, StringAttribute("enzyme_inactive"))
if has_fn_attr(F, StringAttribute("enzyme_inactive"))
return true
end
end
Expand All @@ -363,7 +363,7 @@ end
common_invoke_rev(2, B, orig, gutils, tape)
return nothing
end
if has_fn_attribute(F, StringAttribute("enzyme_inactive"))
if has_fn_attr(F, StringAttribute("enzyme_inactive"))
return nothing
end
end
Expand Down

0 comments on commit c0ebbdd

Please sign in to comment.