From ea2ba1ed1d5494ac89eaf92323463c20e9f36590 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Tue, 23 Jan 2024 19:53:12 +0900 Subject: [PATCH] fix up broken test --- base/dict.jl | 33 ++++++++++++--------------------- test/compiler/irpasses.jl | 2 +- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/base/dict.jl b/base/dict.jl index 2b6fd41d8d075..5526e592dfe31 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -906,34 +906,25 @@ struct PersistentDict{K,V} <: AbstractDict{K,V} @noinline function KeyValue.set(::Type{PersistentDict{K, V}}, ::Nothing, key, val) where {K, V} new{K, V}(HAMT.HAMT{K, V}(key => val)) end - @noinline @Base.assume_effects :effect_free function KeyValue.set(dict::PersistentDict{K, V}, key, val) where {K, V} + @noinline Base.@assume_effects :effect_free :terminates_globally KeyValue.set( + dict::PersistentDict{K, V}, key, val) where {K, V} = @inline _keyvalueset(dict, key, val) + @noinline Base.@assume_effects :nothrow :effect_free :terminates_globally KeyValue.set( + dict::PersistentDict{K, V}, key::K, val::V) where {K, V} = @inline _keyvalueset(dict, key, val) + global function _keyvalueset(dict::PersistentDict{K, V}, key, val) where {K, V} trie = dict.trie h = HAMT.HashState(key) - found, present, trie, i, bi, top, hs = HAMT.path(trie, key, h, #=persistent=# true) + found, present, trie, i, bi, top, hs = HAMT.path(trie, key, h, #=persistent=#true) HAMT.insert!(found, present, trie, i, bi, hs, val) return new{K, V}(top) end - @noinline @Base.assume_effects :nothrow :effect_free function KeyValue.set(dict::PersistentDict{K, V}, key::K, val::V) where {K, V} + @noinline Base.@assume_effects :effect_free :terminates_globally KeyValue.set( + dict::PersistentDict{K, V}, key) where {K, V} = @inline _keyvalueset(dict, key) + @noinline Base.@assume_effects :nothrow :effect_free :terminates_globally KeyValue.set( + dict::PersistentDict{K, V}, key::K) where {K, V} = @inline _keyvalueset(dict, key) + global function _keyvalueset(dict::PersistentDict{K, V}, key) where {K, V} trie = dict.trie h = HAMT.HashState(key) - found, present, trie, i, bi, top, hs = HAMT.path(trie, key, h, #=persistent=# true) - HAMT.insert!(found, present, trie, i, bi, hs, val) - return new{K, V}(top) - end - @noinline @Base.assume_effects :effect_free function KeyValue.set(dict::PersistentDict{K, V}, key) where {K, V} - trie = dict.trie - h = HAMT.HashState(key) - found, present, trie, i, bi, top, _ = HAMT.path(trie, key, h, #=persistent=# true) - if found && present - deleteat!(trie.data, i) - HAMT.unset!(trie, bi) - end - return new{K, V}(top) - end - @noinline @Base.assume_effects :nothrow :effect_free function KeyValue.set(dict::PersistentDict{K, V}, key::K) where {K, V} - trie = dict.trie - h = HAMT.HashState(key) - found, present, trie, i, bi, top, _ = HAMT.path(trie, key, h, #=persistent=# true) + found, present, trie, i, bi, top, _ = HAMT.path(trie, key, h, #=persistent=#true) if found && present deleteat!(trie.data, i) HAMT.unset!(trie, bi) diff --git a/test/compiler/irpasses.jl b/test/compiler/irpasses.jl index b0c3a57c1b6ea..70b8560c6ee7a 100644 --- a/test/compiler/irpasses.jl +++ b/test/compiler/irpasses.jl @@ -1562,7 +1562,7 @@ function persistent_dict_elim_multiple() end @test_broken fully_eliminated(persistent_dict_elim_multiple) let code = code_typed(persistent_dict_elim_multiple)[1][1].code - @test_broken count(x->isexpr(x, :invoke), code) == 0 + @test count(x->isexpr(x, :invoke), code) == 0 @test code[end] == Core.ReturnNode(1) end