-
-
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 use counts for mutable struct SROA
PR #28478 moved the computation of the use counts before the finish call. to fix #28444. However, the early parts of the finish call fixes up phi node arguments, which fail to get counted if we look at use counts before that fixup is performed. This causes #30594 where the only non-trivial use is on the backedge of the phi and would thus incorrectly fail to get accounted for. Fix that by taking the use count after phi fixup but before dce. (cherry picked from commit f8f2045)
- Loading branch information
1 parent
cfc91ed
commit a64ec20
Showing
2 changed files
with
32 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,25 @@ | ||
# Tests for SROA | ||
|
||
mutable struct Foo30594; x::Float64; end | ||
Base.copy(x::Foo30594) = Foo30594(x.x) | ||
function add!(p::Foo30594, off::Foo30594) | ||
p.x += off.x | ||
return p | ||
end | ||
Base.:(+)(a::Foo30594, b::Foo30594) = add!(copy(a), b) | ||
|
||
let results = Float64[] | ||
@noinline use30594(x) = push!(results, x.x); nothing | ||
function foo30594(cnt::Int, dx::Int) | ||
step = Foo30594(dx) | ||
curr = step + Foo30594(1) | ||
for i in 1:cnt | ||
use30594(curr) | ||
curr = curr + step | ||
end | ||
nothing | ||
end | ||
|
||
foo30594(4, -1) | ||
@test results == [0.0, -1.0, -2.0, -3.0] | ||
end |