mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-15 00:13:43 +00:00
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:
@@ -1995,10 +1995,7 @@ func (c *Compiler) parseExpr(frame *Frame, expr ssa.Value) (llvm.Value, error) {
|
|||||||
|
|
||||||
// Bounds check.
|
// Bounds check.
|
||||||
// LLVM optimizes this away in most cases.
|
// LLVM optimizes this away in most cases.
|
||||||
length, err := c.parseBuiltin(frame, []ssa.Value{expr.X}, "len", expr.Pos())
|
length := c.builder.CreateExtractValue(value, 1, "len")
|
||||||
if err != nil {
|
|
||||||
return llvm.Value{}, err // shouldn't happen
|
|
||||||
}
|
|
||||||
c.emitBoundsCheck(frame, length, index, expr.Index.Type())
|
c.emitBoundsCheck(frame, length, index, expr.Index.Type())
|
||||||
|
|
||||||
// Lookup byte
|
// Lookup byte
|
||||||
|
|||||||
Reference in New Issue
Block a user