[K/N] All bridges should have cleanup landingpad block (BB with return can be called before setting terminated function used as reason to add Enter/Leave frame functions)
This commit is contained in:
+4
-5
@@ -475,7 +475,7 @@ internal abstract class FunctionGenerationContext(
|
||||
private val entryBb = basicBlockInFunction("entry", startLocation)
|
||||
protected val cleanupLandingpad = basicBlockInFunction("cleanup_landingpad", endLocation)
|
||||
|
||||
private val needLeaveFrameInUnwindEpilogue: Boolean
|
||||
protected open val needLeaveFrameInUnwindEpilogue: Boolean
|
||||
get() = irFunction?.annotations?.hasAnnotation(RuntimeNames.exportForCppRuntime) == true
|
||||
|| forwardingForeignExceptionsTerminatedWith != null
|
||||
|| irFunction?.origin == CBridgeOrigin.C_TO_KOTLIN_BRIDGE
|
||||
@@ -894,7 +894,7 @@ internal abstract class FunctionGenerationContext(
|
||||
fun extractValue(aggregate: LLVMValueRef, index: Int, name: String = ""): LLVMValueRef =
|
||||
LLVMBuildExtractValue(builder, aggregate, index, name)!!
|
||||
|
||||
fun gxxLandingpad(numClauses: Int, name: String = "", switchThreadState: Boolean = false, callFromCleanupBlock: Boolean = false): LLVMValueRef {
|
||||
fun gxxLandingpad(numClauses: Int, name: String = "", switchThreadState: Boolean = false): LLVMValueRef {
|
||||
val personalityFunction = context.llvm.gxxPersonalityFunction.llvmValue
|
||||
|
||||
// Type of `landingpad` instruction result (depends on personality function):
|
||||
@@ -907,8 +907,7 @@ internal abstract class FunctionGenerationContext(
|
||||
}
|
||||
call(context.llvm.setCurrentFrameFunction, listOf(slotsPhi!!))
|
||||
setCurrentFrameIsCalled = true
|
||||
if (!callFromCleanupBlock)
|
||||
handleEpilogueForExperimentalMM(context.llvm.Kotlin_mm_safePointExceptionUnwind)
|
||||
//handleEpilogueForExperimentalMM(context.llvm.Kotlin_mm_safePointExceptionUnwind)
|
||||
|
||||
return landingpad
|
||||
}
|
||||
@@ -1495,7 +1494,7 @@ internal abstract class FunctionGenerationContext(
|
||||
|
||||
if (shouldHaveCleanupLandingpad) {
|
||||
appendingTo(cleanupLandingpad) {
|
||||
val landingpad = gxxLandingpad(numClauses = 0, callFromCleanupBlock = true)
|
||||
val landingpad = gxxLandingpad(numClauses = 0)
|
||||
LLVMSetCleanup(landingpad, 1)
|
||||
|
||||
forwardingForeignExceptionsTerminatedWith?.let { terminator ->
|
||||
|
||||
+3
@@ -53,6 +53,9 @@ internal class ObjCExportFunctionGenerationContext(
|
||||
) : FunctionGenerationContext(builder) {
|
||||
private val objCExportCodegen = builder.objCExportCodegen
|
||||
|
||||
override val needLeaveFrameInUnwindEpilogue: Boolean
|
||||
get() = true
|
||||
|
||||
// Note: we could generate single "epilogue" and make all [ret]s just branch to it (like [DefaultFunctionGenerationContext]),
|
||||
// but this would be useless for most of the usages, which have only one [ret].
|
||||
// Remaining usages can be optimized ad hoc.
|
||||
|
||||
Reference in New Issue
Block a user