fix(library/init/lean/compiler): bug fixes
This commit is contained in:
parent
81d11db5d2
commit
db30a23055
3 changed files with 8 additions and 1 deletions
|
|
@ -32,12 +32,13 @@ reshapeWithoutDeadAux bs term term.freeVars
|
|||
partial def FnBody.elimDead : FnBody → FnBody
|
||||
| b :=
|
||||
let (bs, term) := b.flatten in
|
||||
let bs := modifyJPVals bs FnBody.elimDead in
|
||||
let term := match term with
|
||||
| FnBody.case tid x alts :=
|
||||
let alts := alts.hmap $ λ alt, alt.modifyBody $ λ b, FnBody.elimDead b in
|
||||
FnBody.case tid x alts
|
||||
| other := other in
|
||||
reshape bs term
|
||||
reshapeWithoutDead bs term
|
||||
|
||||
/-- Eliminate dead let-declarations and join points -/
|
||||
@[export lean.ir.decl_elim_dead_core]
|
||||
|
|
|
|||
|
|
@ -281,6 +281,11 @@ partial def reshapeAux : Array FnBody → Nat → FnBody → FnBody
|
|||
def reshape (bs : Array FnBody) (term : FnBody) : FnBody :=
|
||||
reshapeAux bs bs.size term
|
||||
|
||||
@[inline] def modifyJPVals (bs : Array FnBody) (f : FnBody → FnBody) : Array FnBody :=
|
||||
bs.hmap $ λ b, match b with
|
||||
| FnBody.jdecl j xs t v k := FnBody.jdecl j xs t (f v) k
|
||||
| other := other
|
||||
|
||||
@[export lean.ir.mk_alt_core] def mkAlt (n : Name) (cidx : Nat) (size : Nat) (usize : Nat) (ssize : Nat) (b : FnBody) : Alt := Alt.ctor ⟨n, cidx, size, usize, ssize⟩ b
|
||||
|
||||
inductive Decl
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ partial def pushProjs : Array FnBody → Array Alt → Array IndexSet → Array
|
|||
partial def FnBody.pushProj : FnBody → FnBody
|
||||
| b :=
|
||||
let (bs, term) := b.flatten in
|
||||
let bs := modifyJPVals bs FnBody.pushProj in
|
||||
match term with
|
||||
| FnBody.case tid x alts :=
|
||||
let afvs := alts.map $ λ alt, alt.body.freeVars in
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue