ssa: index check take address

This commit is contained in:
visualfc
2024-07-03 13:21:18 +08:00
parent 28d8c56534
commit 490a16a8df
8 changed files with 1154 additions and 548 deletions

View File

@@ -493,10 +493,12 @@ 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() (r llssa.Expr) {
ret = b.Index(x, idx, func() (addr llssa.Expr, zero bool) {
switch n := v.X.(type) {
case *ssa.Const:
zero = true
case *ssa.UnOp:
return p.compileValue(b, n.X)
addr = p.compileValue(b, n.X)
}
return
})