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.
Этот коммит содержится в:
родитель
589569fc35
коммит
85108514df
1 изменённых файлов: 1 добавлений и 4 удалений
|
@ -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
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче