[Wasm] Enable for loops optimization

This commit is contained in:
Svyatoslav Kuzmich
2020-11-09 17:18:03 +03:00
committed by Svyatoslav Kuzmich
parent 233bb47b99
commit 7f26deb5e6
2 changed files with 13 additions and 1 deletions
@@ -382,7 +382,9 @@ internal class IndexedGetLoopHeader(
with(builder) {
// loopVariable = objectVariable[inductionVariable]
val indexedGetFun = with(headerInfo.expressionHandler) { headerInfo.objectVariable.type.getFunction }
val get = irCall(indexedGetFun.symbol).apply {
// Making sure that expression type has type of the variable when it exists.
// Return type of get function can be a type parameter (for example Array<T>::get) which is not a subtype of loopVariable type.
val get = irCall(indexedGetFun.symbol, type = loopVariable?.type ?: indexedGetFun.returnType).apply {
dispatchReceiver = irGet(headerInfo.objectVariable)
putValueArgument(0, irGet(inductionVariable))
}