@@ -25,6 +25,10 @@ precompile_test_harness("Inference caching") do load_path
2525 return x* x
2626 end
2727
28+ function checked_convert (x)
29+ return Int (x)
30+ end
31+
2832 let
2933 job, _ = NativeCompiler. Native. create_job (kernel, (Vector{Int}, Int))
3034 precompile (job)
@@ -48,6 +52,13 @@ precompile_test_harness("Inference caching") do load_path
4852 precompile (job)
4953 end
5054 end
55+
56+ @setup_workload begin
57+ job, _ = NativeCompiler. Native. create_job (checked_convert, (UInt,); validate= false )
58+ @compile_workload begin
59+ precompile (job)
60+ end
61+ end
5162 end ) |> string)
5263
5364 Base. compilecache (Base. PkgId (" NativeBackend" ), stderr , stdout )
@@ -78,6 +89,21 @@ precompile_test_harness("Inference caching") do load_path
7889 # check that identity survived
7990 @test check_presence (identity_mi, token) broken= (v " 1.12.0-DEV.1268" <= VERSION < v " 1.12.5" || v " 1.13.0-" <= VERSION < v " 1.13.0-beta3" || v " 1.14.0-" <= VERSION < v " 1.14.0-DEV.1843" )
8091
92+ # Recompiling a foreign method after loading precompiled owner-token CIs
93+ # may also surface a native owner-less CI for the same MethodInstance.
94+ # GPUCompiler should prefer the owner-token CI instead of recording both.
95+ job, _ = NativeCompiler. Native. create_job (identity, (Int,))
96+ JuliaContext () do ctx
97+ _, meta = GPUCompiler. compile (:llvm , job)
98+ @test haskey (meta. compiled, job. source)
99+ end
100+
101+ job, _ = NativeCompiler. Native. create_job (NativeBackend. checked_convert, (UInt,); validate= false )
102+ JuliaContext () do ctx
103+ _, meta = GPUCompiler. compile (:llvm , job)
104+ @test haskey (meta. compiled, job. source)
105+ end
106+
81107 GPUCompiler. clear_disk_cache! ()
82108 @test GPUCompiler. disk_cache_enabled () == false
83109
0 commit comments