ssa: fix ssa.Index and indexType

This commit is contained in:
visualfc
2024-06-16 22:18:02 +08:00
parent 3ff5caef94
commit f7cddb81df
5 changed files with 156 additions and 101 deletions

View File

@@ -775,10 +775,14 @@ func (p *context) compileInstrOrValue(b llssa.Builder, iv instrOrValue, asValue
case *ssa.Index:
x := p.compileValue(b, v.X)
idx := p.compileValue(b, v.Index)
ret = b.Index(x, idx, func(e llssa.Expr) (ret llssa.Expr) {
ret = b.Index(x, idx, func(e llssa.Expr) (ret llssa.Expr, zero bool) {
if e == x {
if n, ok := v.X.(*ssa.UnOp); ok {
return p.compileValue(b, n.X)
switch n := v.X.(type) {
case *ssa.Const:
zero = true
return
case *ssa.UnOp:
return p.compileValue(b, n.X), false
}
}
panic(fmt.Errorf("todo: addr of %v", e))