Loosen tail-call optimization check for functions returning Unit
Do not check, that all Unit predecessors are POPs. This is safe for the same reason, as it is safe to allow some of ARETURN sources not be suspension point results. To elaborate, before Unit, the stack is empty. This is because if there are multiple paths to Unit and at least one of them comes from POP after suspension point (we are interested in this case only - otherwise, the call is not tail-call), in path from said POP the stack is empty, since after suspension point the stack contains only one element. Thus, the stack in other paths leading to Unit has to be empty, otherwise, merge operation is not possible and ASM will report error during analysis. Since the stack is empty in all paths, we can hoist Unit and following ARETURN to predecessors, effectively turning path from suspension point to tail-call.
This commit is contained in:
+5
@@ -9683,6 +9683,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/functionReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inline.kt")
|
||||
public void testInline() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/inline.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("override.kt")
|
||||
public void testOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/override.kt");
|
||||
|
||||
Reference in New Issue
Block a user