Don't coerce intrisic value, it's already coerced
This commit is contained in:
+3
-2
@@ -329,7 +329,7 @@ class ExpressionCodegen(
|
|||||||
|
|
||||||
override fun visitFunctionAccess(expression: IrFunctionAccessExpression, data: BlockInfo): PromisedValue {
|
override fun visitFunctionAccess(expression: IrFunctionAccessExpression, data: BlockInfo): PromisedValue {
|
||||||
classCodegen.context.irIntrinsics.getIntrinsic(expression.symbol)
|
classCodegen.context.irIntrinsics.getIntrinsic(expression.symbol)
|
||||||
?.invoke(expression, this, data)?.let { return it.coerce(expression.type) }
|
?.invoke(expression, this, data)?.let { return it }
|
||||||
|
|
||||||
val callable = methodSignatureMapper.mapToCallableMethod(expression)
|
val callable = methodSignatureMapper.mapToCallableMethod(expression)
|
||||||
val callee = expression.symbol.owner
|
val callee = expression.symbol.owner
|
||||||
@@ -409,7 +409,8 @@ class ExpressionCodegen(
|
|||||||
}
|
}
|
||||||
expression is IrConstructorCall ->
|
expression is IrConstructorCall ->
|
||||||
MaterialValue(this, asmType, expression.type)
|
MaterialValue(this, asmType, expression.type)
|
||||||
expression is IrDelegatingConstructorCall ->
|
expression.type.isUnit() && callable.asmMethod.returnType == Type.VOID_TYPE ->
|
||||||
|
//don't generate redundant UNIT/pop instructions
|
||||||
immaterialUnitValue
|
immaterialUnitValue
|
||||||
expression.type.isUnit() ->
|
expression.type.isUnit() ->
|
||||||
// NewInference allows casting `() -> T` to `() -> Unit`. A CHECKCAST here will fail.
|
// NewInference allows casting `() -> T` to `() -> Unit`. A CHECKCAST here will fail.
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
// KOTLIN_CONFIGURATION_FLAGS: +JVM.DISABLE_OPTIMIZATION
|
||||||
|
|
||||||
|
fun foo(s: String = "123") {}
|
||||||
|
|
||||||
|
// 1 IF
|
||||||
|
// 0 Unit\.INSTANCE
|
||||||
|
// 0 POP
|
||||||
Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
// KOTLIN_CONFIGURATION_FLAGS: +JVM.DISABLE_OPTIMIZATION
|
||||||
|
|
||||||
|
fun bar() {}
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
bar()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0 Unit\.INSTANCE
|
||||||
|
// 0 POP
|
||||||
@@ -1635,6 +1635,16 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
|||||||
public void testNoJumpInSingleBranch() throws Exception {
|
public void testNoJumpInSingleBranch() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeText/disabledOptimizations/noJumpInSingleBranch.kt");
|
runTest("compiler/testData/codegen/bytecodeText/disabledOptimizations/noJumpInSingleBranch.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noUnitInstanceInDefaultParameterInitialization.kt")
|
||||||
|
public void testNoUnitInstanceInDefaultParameterInitialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/disabledOptimizations/noUnitInstanceInDefaultParameterInitialization.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noUnitInstanceOnVoidFunctionCall.kt")
|
||||||
|
public void testNoUnitInstanceOnVoidFunctionCall() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/disabledOptimizations/noUnitInstanceOnVoidFunctionCall.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/bytecodeText/enum")
|
@TestMetadata("compiler/testData/codegen/bytecodeText/enum")
|
||||||
|
|||||||
+10
@@ -1590,6 +1590,16 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
|||||||
public void testNoJumpInSingleBranch() throws Exception {
|
public void testNoJumpInSingleBranch() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeText/disabledOptimizations/noJumpInSingleBranch.kt");
|
runTest("compiler/testData/codegen/bytecodeText/disabledOptimizations/noJumpInSingleBranch.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noUnitInstanceInDefaultParameterInitialization.kt")
|
||||||
|
public void testNoUnitInstanceInDefaultParameterInitialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/disabledOptimizations/noUnitInstanceInDefaultParameterInitialization.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noUnitInstanceOnVoidFunctionCall.kt")
|
||||||
|
public void testNoUnitInstanceOnVoidFunctionCall() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/disabledOptimizations/noUnitInstanceOnVoidFunctionCall.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/bytecodeText/enum")
|
@TestMetadata("compiler/testData/codegen/bytecodeText/enum")
|
||||||
|
|||||||
Reference in New Issue
Block a user