ssa: fix type of unsafe.SliceData

This commit is contained in:
Li Jie
2024-10-21 17:32:42 +08:00
parent 834e8c64c5
commit 7ecd98b0a0

View File

@@ -124,7 +124,9 @@ func (b Builder) SliceData(x Expr) Expr {
log.Printf("SliceData %v\n", x.impl)
}
ptr := llvm.CreateExtractValue(b.impl, x.impl, 0)
return Expr{ptr, b.Prog.VoidPtr()}
ty := x.Type.RawType()
tySlice := ty.Underlying().(*types.Slice)
return Expr{ptr, b.Prog.Pointer(b.Prog.rawType(tySlice.Elem()))}
}
// SliceLen returns the length of a slice.