From 2f50610433866e1cf04d75614f165188143f3b70 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Mon, 21 Aug 2023 18:38:25 +0900 Subject: [PATCH] OptAnalyzer: ignore reports from const-prop when concrete-evaled already --- Project.toml | 3 ++- src/abstractinterpret/typeinfer.jl | 5 +++++ test/analyzers/test_optanalyzer.jl | 18 +++++++++++------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index 6f6f4cb4a..b5fc8067e 100644 --- a/Project.toml +++ b/Project.toml @@ -30,7 +30,8 @@ Example = "7876af07-990d-54b4-ab0e-23690620f79a" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Aqua", "BenchmarkTools", "Example", "Libdl", "Logging", "Random", "Test"] +test = ["Aqua", "BenchmarkTools", "Example", "Libdl", "Logging", "Random", "StaticArrays", "Test"] diff --git a/src/abstractinterpret/typeinfer.jl b/src/abstractinterpret/typeinfer.jl index 12b28f60e..2e4dd267a 100644 --- a/src/abstractinterpret/typeinfer.jl +++ b/src/abstractinterpret/typeinfer.jl @@ -46,6 +46,11 @@ let # overload `const_prop_call` # successful constant prop', we need to update reports collect_callee_reports!(analyzer, sv) end + @static if VERSION ≥ v"1.11.0-DEV.233" || v"1.11.0-DEV" > VERSION ≥ v"1.10.0-beta1.11" + if concrete_eval_result !== nothing + filter_lineages!(analyzer, sv.result, mi) + end + end return const_result end end diff --git a/test/analyzers/test_optanalyzer.jl b/test/analyzers/test_optanalyzer.jl index a483ab2ae..b02a4c6ae 100644 --- a/test/analyzers/test_optanalyzer.jl +++ b/test/analyzers/test_optanalyzer.jl @@ -295,15 +295,13 @@ let result = @report_opt issue335_callf(issue335_problematic_callee, 42) end end -let result = report_opt() do - issue335_callf(42) do val - if val < 0 - return issue335_problematic_callee(val) - end - return sin(val) +test_opt() do + issue335_callf(42) do val + if val < 0 + return issue335_problematic_callee(val) end + return sin(val) end - @test isempty(get_reports_with_test(result)) end # report runtime dispatches within "noncompileable" but inlineable frames @@ -325,4 +323,10 @@ let result = report_opt((Any,Any)) do a, b end end +using StaticArrays +const Issue560Vec3 = SVector{3, Float64} +const issue560μ = zeros(Issue560Vec3, 2, 3, 4, 5) +issue560f(μ) = reinterpret(reshape, Float64, μ) +@test_opt issue560f(issue560μ) + end # module test_optanalyzer