Skip to content

Commit 53f64a6

Browse files
authored
inactive kwargs (#1539)
* inactive kwargs * only kwargs * fixup * fix * fix
1 parent 82cc451 commit 53f64a6

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

src/compiler.jl

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ end
10871087

10881088

10891089
function get_array_struct()
1090+
@static if VERSION < v"1.11-"
10901091
# JL_EXTENSION typedef struct {
10911092
# JL_DATA_TYPE
10921093
# void *data;
@@ -1117,6 +1118,41 @@ function get_array_struct()
11171118
nrows = LLVM.IntType(8*sizeof(Csize_t))
11181119

11191120
return LLVM.StructType([ptrty, sizeT, arrayFlags, elsz, off, nrows]; packed=true)
1121+
else
1122+
# JL_EXTENSION typedef struct {
1123+
# JL_DATA_TYPE
1124+
# size_t length;
1125+
# void *ptr;
1126+
# // followed by padding and inline data, or owner pointer
1127+
# #ifdef _P64
1128+
# // union {
1129+
# // jl_value_t *owner;
1130+
# // T inl[];
1131+
# // };
1132+
# #else
1133+
# //
1134+
# // jl_value_t *owner;
1135+
# // size_t padding[1];
1136+
# // T inl[];
1137+
# #endif
1138+
# } jl_genericmemory_t;
1139+
#
1140+
# JL_EXTENSION typedef struct {
1141+
# JL_DATA_TYPE
1142+
# void *ptr_or_offset;
1143+
# jl_genericmemory_t *mem;
1144+
# } jl_genericmemoryref_t;
1145+
#
1146+
# JL_EXTENSION typedef struct {
1147+
# JL_DATA_TYPE
1148+
# jl_genericmemoryref_t ref;
1149+
# size_t dimsize[]; // length for 1-D, otherwise length is mem->length
1150+
# } jl_array_t;
1151+
i8 = LLVM.IntType(8)
1152+
ptrty = LLVM.PointerType(i8, 10)
1153+
sizeT = LLVM.IntType(8*sizeof(Csize_t))
1154+
return LLVM.StructType([ptrty, sizeT]; packed=true)
1155+
end
11201156
end
11211157

11221158
function get_array_data(B, array)
@@ -1171,9 +1207,6 @@ function get_array_nrows(B, array)
11711207
return LLVM.load!(B, nrows, v)
11721208
end
11731209

1174-
dedupargs() = ()
1175-
dedupargs(a, da, args...) = (a, dedupargs(args...)...)
1176-
11771210
# Force sret
11781211
struct Return2
11791212
ret1::Any
@@ -5398,11 +5431,11 @@ function GPUCompiler.codegen(output::Symbol, job::CompilerJob{<:EnzymeTarget};
53985431
handleCustom(llvmfn, "enz_noop", [StringAttribute("enzyme_inactive"), EnumAttribute("readonly"), StringAttribute("enzyme_ta_norecur")])
53995432
continue
54005433
end
5401-
if EnzymeRules.is_inactive_from_sig(mi.specTypes; world, method_table, caller)
5434+
if EnzymeRules.is_inactive_from_sig(specTypes; world, method_table, caller) && has_method(Tuple{typeof(EnzymeRules.inactive), specTypes.parameters...}, world, method_table)
54025435
handleCustom(llvmfn, "enz_noop", [StringAttribute("enzyme_inactive"), EnumAttribute("nofree"), StringAttribute("enzyme_no_escaping_allocation"), StringAttribute("enzyme_ta_norecur")])
54035436
continue
54045437
end
5405-
if EnzymeRules.is_inactive_noinl_from_sig(mi.specTypes; world, method_table, caller)
5438+
if EnzymeRules.is_inactive_noinl_from_sig(specTypes; world, method_table, caller) && has_method(Tuple{typeof(EnzymeRules.inactive_noinl), specTypes.parameters...}, world, method_table)
54065439
handleCustom(llvmfn, "enz_noop", [StringAttribute("enzyme_inactive"), EnumAttribute("nofree"), StringAttribute("enzyme_no_escaping_allocation"), StringAttribute("enzyme_ta_norecur")], false, false)
54075440
for bb in blocks(llvmfn)
54085441
for inst in instructions(bb)

src/compiler/validation.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ end
345345
end
346346

347347
@inline function is_inactive(tys, world::UInt, mt)
348+
specTypes = Interpreter.simplify_kw(Tuple{tys...})
348349
if has_method(Tuple{typeof(EnzymeRules.inactive), tys...}, world, mt)
349350
return true
350351
end

src/internal_rules.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ end
1515
function EnzymeRules.inactive(::typeof(Base.fixup_stdlib_path), args...)
1616
return nothing
1717
end
18-
function EnzymeRules.inactive(::typeof(Base.CoreLogging.handle_message), args...)
18+
function EnzymeRules.inactive(::typeof(Base.CoreLogging.handle_message), args...; kwargs...)
1919
return nothing
2020
end
2121
function EnzymeRules.inactive(::typeof(Base.CoreLogging.logging_error), args...)

0 commit comments

Comments
 (0)