Skip to content

DCE bug: unsafe elimination of dead statement, which might not terminate #52991

@aviatesk

Description

@aviatesk

Upon further investigation, it appears that modifying this single line is enough to remove the call to the dead PersistentDict constructor. But, this seems to stem from an inference bug, where we're deleting statements without actually proving terminates.

julia> @noinline Base.@assume_effects :effect_free :nothrow function foo(n)
           s = 0
           while true
               if n - rand(1:10) > 0
                   s += 1
               else
                   break
               end
           end
           return s
       end^C

julia> code_typed((Int,)) do n
           foo(n)
           nothing
       end
1-element Vector{Any}:
 CodeInfo(
1return Main.nothing
) => Nothing

So, I'd like to address this bug first and then revisit this PR.

Originally posted by @aviatesk in #52954 (comment)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions