From ec3a2c96712aa1296db52233823fea13fd3cbff3 Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Thu, 13 Jan 2022 16:18:55 +0300 Subject: [PATCH] Native: remove cleanup landingpad if it is unused Useful for ObjCExport, because most of its bridges don't use it. --- .../org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt index 980395a1057..088b859bd92 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt @@ -1510,7 +1510,10 @@ internal abstract class FunctionGenerationContext( processReturns() - if (!needCleanupLandingpadAndLeaveFrame) { + // If cleanup landingpad is trivial or unused, remove it. + // It would be great not to generate it in the first place in this case, + // but this would be complicated without a major refactoring. + if (!needCleanupLandingpadAndLeaveFrame || invokeInstructions.isEmpty()) { // Replace invokes with calls and branches. invokeInstructions.forEach { functionInvokeInfo -> positionBefore(functionInvokeInfo.invokeInstruction)