[IR] Store original function in the IrInlinedBlock

In Native and JS, there is a special logic where the compiler saves
a copy of inlined function (see `InlineFunctionsSupport`). This copy
is used in the IR inliner. Because of that, we can't really compare
inlined function with other functions directly. We need to
get `originalFunction` first and save it.
This commit is contained in:
Ivan Kylchik
2024-02-23 11:43:19 +01:00
committed by Space Team
parent 800704a130
commit 6ec75a705e
2 changed files with 2 additions and 5 deletions
@@ -57,10 +57,7 @@ abstract class UsefulDeclarationProcessor(
super.visitBlock(expression, data)
if (expression is IrReturnableBlock) {
// We need to extract `originalFunction` here because saved `inlineFunction`
// is actually a copy made in `SaveInlineFunctionsBeforeInlining`.
// Without this, we are not going to find proper intersection in the `saveOnlyIntersectionOfNextDeclarationsFor` method.
expression.inlineFunction?.originalFunction?.addToUsefulPolyfilledDeclarations()
expression.inlineFunction?.addToUsefulPolyfilledDeclarations()
}
}
@@ -162,7 +162,7 @@ class FunctionInlining(
val substituteMap = mutableMapOf<IrValueParameter, IrExpression>()
fun inline() = inlineFunction(callSite, callee, callee, true)
fun inline() = inlineFunction(callSite, callee, callee.originalFunction, true)
private fun <E : IrElement> E.copy(): E {
@Suppress("UNCHECKED_CAST")