-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SROA confusing new and old nodes
SROA was accidentally treating a pending node as old and thus getting the wrong type when querying the predecessor. As a result it thought one of the paths was unreachable causing undefined data to be introduced on that path (generally the `1.0` that happened to already be in register). Fix #29983 (cherry picked from commit da0179c)
- Loading branch information
1 parent
543cf24
commit ba9d981
Showing
2 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
using Test | ||
|
||
# Issue #29983 | ||
# This one is a bit hard to trigger, but the key is to create a case | ||
# where SROA needs to introduce an intermediate type-unstable phi node | ||
struct Foo29983{T} | ||
x::Tuple{T} | ||
end | ||
struct Bar29983{S} | ||
x::S | ||
end | ||
Base.:+(a::T, b::Bar29983{S}) where {T, S} = Bar29983(a + b.x) | ||
Base.:+(a::Bar29983{S}, b::T) where {T, S} = b + a | ||
Base.:+(a::Bar29983{S}, b::Bar29983{T}) where {T, S} = Bar29983(a.x + b.x) | ||
Base.:+(a::Foo29983, b::Foo29983) = Foo29983((a.x[1] + b.x[1],)) | ||
|
||
function f(x::Vector{T}) where {T} | ||
x1 = Foo29983((x[1],)) | ||
la1 = Foo29983((x[1],)) | ||
f1 = Foo29983((0,)) | ||
for _ in 1:2 | ||
f1 += la1 | ||
end | ||
return f1 | ||
end | ||
|
||
@test f([Bar29983(1.0)]).x[1].x == 2.0 |