Set escape analysis to analyze all types including value types.

Since a value type might be boxed and this information is missing in IR
the analysis cannot distinguish value types and boxes, so let it analyze
all for now.
This commit is contained in:
Igor Chevdar
2017-08-08 13:45:46 +03:00
parent 56e08e40e8
commit e615b08ab7
3 changed files with 9 additions and 3 deletions
@@ -100,8 +100,9 @@ internal object EscapeAnalysis {
open fun add(entry: RoleInfoEntry) = entries.add(entry) open fun add(entry: RoleInfoEntry) = entries.add(entry)
} }
// TODO: Seems like overhead to analyze value types but they might be boxed, think how to optimize this.
private fun RuntimeAware.isInteresting(type: KotlinType?): Boolean = private fun RuntimeAware.isInteresting(type: KotlinType?): Boolean =
type != null && !type.isUnit() && !type.isNothing() && isObjectType(type) type != null && !type.isUnit() && !type.isNothing()/* && isObjectType(type)*/
private class Roles { private class Roles {
val data = HashMap<Role, RoleInfo>() val data = HashMap<Role, RoleInfo>()
@@ -253,8 +253,12 @@ internal class FunctionGenerationContext(val function: LLVMValueRef,
} }
is SlotType.PARAM_IF_ARENA -> is SlotType.PARAM_IF_ARENA ->
call(context.llvm.getParamSlotIfArenaFunction, if (LLVMTypeOf(vars.load(resultLifetime.slotType.parameter)) != codegen.runtime.objHeaderPtrType)
listOf(vars.load(resultLifetime.slotType.parameter), vars.createAnonymousSlot())) vars.createAnonymousSlot()
else {
call(context.llvm.getParamSlotIfArenaFunction,
listOf(vars.load(resultLifetime.slotType.parameter), vars.createAnonymousSlot()))
}
else -> throw Error("Incorrect slot type: ${resultLifetime.slotType}") else -> throw Error("Incorrect slot type: ${resultLifetime.slotType}")
} }
@@ -37,6 +37,7 @@ class Runtime(bitcodeFile: String) {
val globalHashType = getStructType("GlobalHash") val globalHashType = getStructType("GlobalHash")
val objHeaderType = getStructType("ObjHeader") val objHeaderType = getStructType("ObjHeader")
val objHeaderPtrType = pointerType(objHeaderType)
val arrayHeaderType = getStructType("ArrayHeader") val arrayHeaderType = getStructType("ArrayHeader")
val target = LLVMGetTarget(llvmModule)!!.toKString() val target = LLVMGetTarget(llvmModule)!!.toKString()