Skip to content

Conversation

@Keno
Copy link
Member

@Keno Keno commented Dec 22, 2023

This fixes #52610. The underlying issue is a left over OldSSAValue after the adce_pass! (introduced by compaction, it being during adce is incidental). Compaction introduces OldSSAValue when it compacts in PhiNodes that reference later SSAValues and adds them to a list to revisit at the end of compaction to fill in the actual renamed result. There are two separate fixes here:

  1. If the result of the final revisit is yet another OldSSAValue, rename it again. I don't this ordinarily happens at all, but I suppose it is possible in theory during sroa beacuse of the rename-shortcut optimization [1]. However, this is not not what happened here. Instead compaction incorrectly used an OldSSAValue for an already-inserted node, which then ends up in the rename list because we deleted one of the predecessor edges [2]. To fix that we:

  2. Fix an issue where we weren't accounting for the possibility of previously pending nodes (which have SSAValues beyond the numbering range of the ordinary statements) in the special already_inserted query in phinode value processing. To fix this, unify the logic with the ordinary already_inserted query, which handles this case correctly.

[1]

compact.ssa_rename[old_idx] = lifted_val === nothing ? nothing : lifted_val.val

[2]
ssa_rename[idx] = v

This fixes #52610. The underlying issue is a left over OldSSAValue
after the adce_pass! (introduced by compaction, it being during adce
is incidental). Compaction introduces `OldSSAValue` when it compacts
in PhiNodes that reference later SSAValues and adds them to a list
to revisit at the end of compaction to fill in the actual renamed
result. There are two separate fixes here:

1. If the result of the final revisit is yet another `OldSSAValue`,
   rename it again. I don't this ordinarily happens at all, but I
   suppose it is possible in theory during sroa beacuse of the
   rename-shortcut optimization [1]. However, this is not not what
   happened here. Instead compaction incorrectly used an OldSSAValue
   for an already-inserted node, which then ends up in the rename
   list because we deleted one of the predecessor edges [2]. To fix
   that we:

2. Fix an issue where we weren't accounting for the possibility of
   previously pending nodes (which have SSAValues beyond the numbering
   range of the ordinary statements) in the special already_inserted
   query in phinode value processing. To fix this, unify the logic
   with the ordinary `already_inserted` query, which handles this
   case correctly.

[1] https://github.com/JuliaLang/julia/blob/master/base/compiler/ssair/passes.jl#L1385
[2] https://github.com/JuliaLang/julia/blob/9443c761871c4db9c3213a1e01804286292c3f4d/base/compiler/ssair/ir.jl#L1556

Co-authored-by: Tim Besard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiler bounds error during testing of Krotov.jl; caused by exct modeling changes

1 participant