Skip to content

Commit 1ca9e1e

Browse files
committed
compiler: use GEP to index array
1 parent 790f5cd commit 1ca9e1e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

compiler/map.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,8 @@ func (b *builder) zeroUndefBytes(typ types.Type, ptr llvm.Value) error {
303303

304304
for i := 0; i < llvmArrayType.ArrayLength(); i++ {
305305
// for each element, first clear any undef bytes in the element itself
306-
offset := b.targetData.ElementOffset(llvmArrayType, i)
307-
llvmOffset := llvm.ConstInt(b.uintptrType, offset, false)
308-
ptr := b.CreateGEP(b.ctx.Int8Type(), base, []llvm.Value{llvmOffset}, "")
306+
idx := llvm.ConstInt(b.uintptrType, uint64(i), false)
307+
ptr := b.CreateGEP(llvmArrayType, base, []llvm.Value{idx}, "")
309308

310309
// recursively zero any padding bytes in this element
311310
b.zeroUndefBytes(typ.Elem(), ptr)

0 commit comments

Comments
 (0)