From 8a211d36aa77d252a22010985c549a98e044669c Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 28 Oct 2018 19:44:39 +0100 Subject: [PATCH] compiler: only produce one bitcast from an alloca This makes passes simpler, by being able to look at the (only) bitcast from an alloca to know the expected type. --- compiler/compiler.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/compiler.go b/compiler/compiler.go index f3fcd618..1a29d5b8 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -3460,9 +3460,10 @@ func (c *Compiler) parseMakeInterface(val llvm.Value, typ types.Type, global str // Allocate on the heap and put a pointer in the interface. // TODO: escape analysis. sizeValue := llvm.ConstInt(c.uintptrType, size, false) - itfValue = c.createRuntimeCall("alloc", []llvm.Value{sizeValue}, "") - itfValueCast := c.builder.CreateBitCast(itfValue, llvm.PointerType(val.Type(), 0), "") + alloc := c.createRuntimeCall("alloc", []llvm.Value{sizeValue}, "") + itfValueCast := c.builder.CreateBitCast(alloc, llvm.PointerType(val.Type(), 0), "") c.builder.CreateStore(val, itfValueCast) + itfValue = c.builder.CreateBitCast(itfValueCast, c.i8ptrType, "") } } else { // Directly place the value in the interface.