Hello,

I’m doing an optimization problem and trying to work on CUDA. I can run my program in Julia v1.8.2 and v1.8.5. However, I get some errors when running on the GPU in Julia v1.9.0 and v1.9.1.

Here is a minimum example:

```
using CUDA, Distributions, Optim
x = rand(truncated(Normal(0, 1); lower=0.0), 100)
logL(x, p1, p2) = logpdf(truncated(Normal(p1, exp(p2)); lower=0.0), x)
obj(x, p1, p2) = -mean(logL.(CuArray(x), p1, p2))
init = ones(2)
H = TwiceDifferentiable(vars -> obj(x, vars[1], vars[2]), init)
opt = optimize(H, init, Optim.Options(iterations = 10, show_trace=true))
```

And here are errors when running the last line of the above example in Julia v1.9.0 and v1.9.1:

```
ERROR: InvalidIRError: compiling MethodInstance for (::GPUArrays.var"#broadcast_kernel#26")(::CUDA.CuKernelContext, ::CuDeviceVector{Float64, 1}, ::Base.Broadcast.Broadcasted{CUDA.CuArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(logL), Tuple{Base.Broadcast.Extruded{CuDeviceVector{Float64, 1}, Tuple{Bool}, Tuple{Int64}}, Float64, Float64}}, ::Int64) resulted in invalid LLVM IR
Reason: unsupported dynamic function invocation (call to var"#setprecision#25"(kws::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}}, ::typeof(setprecision), f::Function, ::Type{T}, prec::Integer) where T @ Base.MPFR mpfr.jl:969)
```

The above errors point out `Reason: unsupported dynamic function`

. I’m not sure whether it is a bug of Julia v1.9.x or not. How can I solve the problem?