| 
79 | 79 |     @test occursin("air.max.s.v2i64", ir)  | 
80 | 80 | end  | 
81 | 81 | 
 
  | 
 | 82 | +@testset "unsupported type detection" begin  | 
 | 83 | +    function kernel1(ptr)  | 
 | 84 | +        buf = reinterpret(Ptr{Float32}, ptr)  | 
 | 85 | +        val = unsafe_load(buf)  | 
 | 86 | +        dval = Cdouble(val)  | 
 | 87 | +        # ccall("extern metal_os_log", llvmcall, Nothing, (Float64,), dval)  | 
 | 88 | +        Base.llvmcall(("""  | 
 | 89 | +        declare void @llvm.va_start(i8*)  | 
 | 90 | +        declare void @llvm.va_end(i8*)  | 
 | 91 | +        declare void @air.os_log(i8*, i64)  | 
 | 92 | +          | 
 | 93 | +        define void @metal_os_log(...) {  | 
 | 94 | +            %1 = alloca i8*  | 
 | 95 | +            %2 = bitcast i8** %1 to i8*  | 
 | 96 | +            call void @llvm.va_start(i8* %2)  | 
 | 97 | +            %3 = load i8*, i8** %1  | 
 | 98 | +            call void @air.os_log(i8* %3, i64 8)  | 
 | 99 | +            call void @llvm.va_end(i8* %2)  | 
 | 100 | +            ret void  | 
 | 101 | +        }  | 
 | 102 | +
  | 
 | 103 | +        define void @entry(double %val) #0 {  | 
 | 104 | +            call void (...) @metal_os_log(double %val)  | 
 | 105 | +            ret void  | 
 | 106 | +        }  | 
 | 107 | +
  | 
 | 108 | +        attributes #0 = { alwaysinline }""", "entry"),  | 
 | 109 | +        Nothing, Tuple{Float64}, dval)  | 
 | 110 | +        return  | 
 | 111 | +    end  | 
 | 112 | + | 
 | 113 | + | 
 | 114 | +    ir = sprint(io->Metal.code_llvm(io, kernel1, Tuple{Core.LLVMPtr{Float32,1}}; validate=true))  | 
 | 115 | +    @test occursin("@metal_os_log", ir)  | 
 | 116 | + | 
 | 117 | +    function kernel2(ptr)  | 
 | 118 | +        val = unsafe_load(ptr)  | 
 | 119 | +        res = val * val  | 
 | 120 | +        unsafe_store!(ptr, res)  | 
 | 121 | +        return  | 
 | 122 | +    end  | 
 | 123 | + | 
 | 124 | +    @test_throws_message(InvalidIRError, Metal.code_llvm(devnull, kernel2, Tuple{Core.LLVMPtr{Float64,1}}; validate=true)) do msg  | 
 | 125 | +        occursin("unsupported use of double value", msg)  | 
 | 126 | +    end  | 
 | 127 | +end  | 
 | 128 | + | 
82 | 129 | end  | 
83 | 130 | 
 
  | 
84 | 131 | end  | 
 | 
0 commit comments