diff --git a/src/compiler.jl b/src/compiler.jl index e2fdcc36fd..0c3e82d032 100644 --- a/src/compiler.jl +++ b/src/compiler.jl @@ -1446,7 +1446,23 @@ function julia_sanitize( bad = BasicBlock(fn, "bad") position!(builder, entry) inp, sval = collect(parameters(fn)) - cmp = fcmp!(builder, LLVM.API.LLVMRealUNO, inp, inp) + cmp = nothing + @show value_type(inp), isa(value_type(inp), LLVM.ArrayType) + + if isa(value_type(inp), LLVM.ArrayType) + nelem = length(value_type(inp)) + for i in 1:nelem + e0 = extract_value!(builder, inp, i - 1) + cmp0 = fcmp!(builder, LLVM.API.LLVMRealUNO, e0, e0) + if cmp == nothing + cmp = cmp0 + else + cmp = or!(builder, cmp, cmp0) + end + end + else + cmp = fcmp!(builder, LLVM.API.LLVMRealUNO, inp, inp) + end br!(builder, cmp, bad, good) @@ -1459,6 +1475,17 @@ function julia_sanitize( unreachable!(builder) dispose(builder) end + if LLVM.API.LLVMVerifyFunction(fn, LLVM.API.LLVMReturnStatusAction) != 0 + msg = sprint() do io + println( + io, + LLVM.API.LLVMVerifyFunction(fn, LLVM.API.LLVMPrintMessageAction), + ) + println(io, string(fn)) + println(io, "Broken julia.sanitize") + end + throw(LLVM.LLVMException(msg)) + end end # val = call!(B, FT, fn, LLVM.Value[val, globalstring_ptr!(B, stringv)]) diff --git a/test/integration/Comrade/runtests.jl b/test/integration/Comrade/runtests.jl index b7798f21b5..53f1d470d3 100644 --- a/test/integration/Comrade/runtests.jl +++ b/test/integration/Comrade/runtests.jl @@ -8,6 +8,7 @@ using LinearAlgebra using Test +Enzyme.Compiler.CheckNan[] = true const ComradePATH = joinpath(dirname(pathof(Comrade)), "..", "examples", "Data") const dataurl = "https://de.cyverse.org/anon-files/iplant/home/shared/commons_repo/curated/EHTC_M87pol2017_Nov2023/hops_data/April11/SR2_M87_2017_101_lo_hops_ALMArot.uvfits"