[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)
|
private val entryBb = basicBlockInFunction("entry", startLocation)
|
||||||
protected val cleanupLandingpad = basicBlockInFunction("cleanup_landingpad", endLocation)
|
protected val cleanupLandingpad = basicBlockInFunction("cleanup_landingpad", endLocation)
|
||||||
|
|
||||||
private val needLeaveFrameInUnwindEpilogue: Boolean
|
protected open val needLeaveFrameInUnwindEpilogue: Boolean
|
||||||
get() = irFunction?.annotations?.hasAnnotation(RuntimeNames.exportForCppRuntime) == true
|
get() = irFunction?.annotations?.hasAnnotation(RuntimeNames.exportForCppRuntime) == true
|
||||||
|| forwardingForeignExceptionsTerminatedWith != null
|
|| forwardingForeignExceptionsTerminatedWith != null
|
||||||
|| irFunction?.origin == CBridgeOrigin.C_TO_KOTLIN_BRIDGE
|
|| irFunction?.origin == CBridgeOrigin.C_TO_KOTLIN_BRIDGE
|
||||||
@@ -894,7 +894,7 @@ internal abstract class FunctionGenerationContext(
|
|||||||
fun extractValue(aggregate: LLVMValueRef, index: Int, name: String = ""): LLVMValueRef =
|
fun extractValue(aggregate: LLVMValueRef, index: Int, name: String = ""): LLVMValueRef =
|
||||||
LLVMBuildExtractValue(builder, aggregate, index, name)!!
|
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
|
val personalityFunction = context.llvm.gxxPersonalityFunction.llvmValue
|
||||||
|
|
||||||
// Type of `landingpad` instruction result (depends on personality function):
|
// Type of `landingpad` instruction result (depends on personality function):
|
||||||
@@ -907,8 +907,7 @@ internal abstract class FunctionGenerationContext(
|
|||||||
}
|
}
|
||||||
call(context.llvm.setCurrentFrameFunction, listOf(slotsPhi!!))
|
call(context.llvm.setCurrentFrameFunction, listOf(slotsPhi!!))
|
||||||
setCurrentFrameIsCalled = true
|
setCurrentFrameIsCalled = true
|
||||||
if (!callFromCleanupBlock)
|
//handleEpilogueForExperimentalMM(context.llvm.Kotlin_mm_safePointExceptionUnwind)
|
||||||
handleEpilogueForExperimentalMM(context.llvm.Kotlin_mm_safePointExceptionUnwind)
|
|
||||||
|
|
||||||
return landingpad
|
return landingpad
|
||||||
}
|
}
|
||||||
@@ -1495,7 +1494,7 @@ internal abstract class FunctionGenerationContext(
|
|||||||
|
|
||||||
if (shouldHaveCleanupLandingpad) {
|
if (shouldHaveCleanupLandingpad) {
|
||||||
appendingTo(cleanupLandingpad) {
|
appendingTo(cleanupLandingpad) {
|
||||||
val landingpad = gxxLandingpad(numClauses = 0, callFromCleanupBlock = true)
|
val landingpad = gxxLandingpad(numClauses = 0)
|
||||||
LLVMSetCleanup(landingpad, 1)
|
LLVMSetCleanup(landingpad, 1)
|
||||||
|
|
||||||
forwardingForeignExceptionsTerminatedWith?.let { terminator ->
|
forwardingForeignExceptionsTerminatedWith?.let { terminator ->
|
||||||
|
|||||||
+3
@@ -53,6 +53,9 @@ internal class ObjCExportFunctionGenerationContext(
|
|||||||
) : FunctionGenerationContext(builder) {
|
) : FunctionGenerationContext(builder) {
|
||||||
private val objCExportCodegen = builder.objCExportCodegen
|
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]),
|
// 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].
|
// but this would be useless for most of the usages, which have only one [ret].
|
||||||
// Remaining usages can be optimized ad hoc.
|
// Remaining usages can be optimized ad hoc.
|
||||||
|
|||||||
Reference in New Issue
Block a user