From 0ee96db260f76f4baba454f50ada3681d194e368 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Tue, 30 Apr 2024 16:19:25 +0800 Subject: [PATCH] IndexAddr: default as ptr --- ssa/expr.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ssa/expr.go b/ssa/expr.go index 1544f242..55803500 100644 --- a/ssa/expr.go +++ b/ssa/expr.go @@ -425,16 +425,15 @@ func (b Builder) IndexAddr(x, idx Expr) Expr { telem := prog.Index(x.Type) pt := prog.Pointer(telem) switch x.t.Underlying().(type) { - case *types.Pointer: - indices := []llvm.Value{idx.impl} - return Expr{llvm.CreateInBoundsGEP(b.impl, telem.ll, x.impl, indices), pt} case *types.Slice: pkg := b.fn.pkg ptr := b.InlineCall(pkg.rtFunc("SliceData"), x) indices := []llvm.Value{idx.impl} return Expr{llvm.CreateInBoundsGEP(b.impl, telem.ll, ptr.impl, indices), pt} } - panic("todo") + // case *types.Pointer: + indices := []llvm.Value{idx.impl} + return Expr{llvm.CreateInBoundsGEP(b.impl, telem.ll, x.impl, indices), pt} } // The Slice instruction yields a slice of an existing string, slice