From 85108514df5ccc80cffb6409503b1d10bdb05b4d Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Fri, 25 Jan 2019 13:15:08 +0100 Subject: [PATCH] compiler: fix indexing of strings on AVR Extract directly from the string instead of calling the len() builtin. This is both cleaner and avoids a zero-extension to an integer on AVR, which led to a LLVM verification error. --- compiler/compiler.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/compiler/compiler.go b/compiler/compiler.go index a7aa6d433..cddc81787 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -1995,10 +1995,7 @@ func (c *Compiler) parseExpr(frame *Frame, expr ssa.Value) (llvm.Value, error) { // Bounds check. // LLVM optimizes this away in most cases. - length, err := c.parseBuiltin(frame, []ssa.Value{expr.X}, "len", expr.Pos()) - if err != nil { - return llvm.Value{}, err // shouldn't happen - } + length := c.builder.CreateExtractValue(value, 1, "len") c.emitBoundsCheck(frame, length, index, expr.Index.Type()) // Lookup byte