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.
This commit is contained in:
Ayke van Laethem
2019-01-25 13:15:08 +01:00
parent 589569fc35
commit 85108514df
+1 -4
View File
@@ -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