@@ -107,7 +107,7 @@ function unsafe_to_llvm(B::LLVM.IRBuilder, @nospecialize(val); insert_name_if_no
107107 end
108108 end
109109
110- function setup_global (k, v)
110+ function setup_global (k, v, force_inactive = false )
111111 mod = LLVM. parent (LLVM. parent (LLVM. position (B)))
112112 globs = LLVM. globals (mod)
113113 if Base. haskey (globs, " ejl_" * k)
@@ -116,7 +116,7 @@ function unsafe_to_llvm(B::LLVM.IRBuilder, @nospecialize(val); insert_name_if_no
116116 gv = LLVM. GlobalVariable (mod, T_jlvalue, " ejl_" * k, Tracked)
117117
118118 API. SetMD (gv, " enzyme_ta_norecur" , LLVM. MDNode (LLVM. Metadata[]))
119- inactive = Enzyme. Compiler. is_memory_instance (v)
119+ inactive = force_inactive && Enzyme. Compiler. is_memory_instance (v)
120120 if ! inactive && v isa Core. SimpleVector && length (v) == 0
121121 inactive = true
122122 end
@@ -150,7 +150,9 @@ function unsafe_to_llvm(B::LLVM.IRBuilder, @nospecialize(val); insert_name_if_no
150150 if insert_name_if_not_exists != = nothing
151151 insert_name_if_not_exists = " inserted\$ " * string (Base. reinterpret (UInt, Compiler. unsafe_to_ptr (val)))* " \$ " * insert_name_if_not_exists
152152 Compiler. JuliaEnzymeNameMap[insert_name_if_not_exists] = val
153- return setup_global (insert_name_if_not_exists, val)
153+ # Since the legacy behavior was to force inactive for global constants, we retain that here (for now)
154+ force_inactive = true
155+ return setup_global (insert_name_if_not_exists, val, force_inactive)
154156 end
155157
156158 # XXX : This prevents code from being runtime relocatable
0 commit comments