[K/N] Don't land parameters on stack in release mode
This commit is contained in:
+9
-4
@@ -687,11 +687,16 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
if (function != null) {
|
if (function != null) {
|
||||||
parameters.forEach{
|
parameters.forEach {
|
||||||
val parameter = it.key
|
val parameter = it.key
|
||||||
val local = functionGenerationContext.vars.createParameter(
|
|
||||||
parameter, debugInfoIfNeeded(function, parameter))
|
if (context.shouldContainDebugInfo()) {
|
||||||
functionGenerationContext.mapParameterForDebug(local, it.value)
|
val local = functionGenerationContext.vars.createParameterOnStack(
|
||||||
|
parameter, debugInfoIfNeeded(function, parameter))
|
||||||
|
functionGenerationContext.mapParameterForDebug(local, it.value)
|
||||||
|
} else {
|
||||||
|
functionGenerationContext.vars.createParameter(parameter, it.value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -33,7 +33,7 @@ internal class VariableManager(val functionGenerationContext: FunctionGeneration
|
|||||||
}
|
}
|
||||||
|
|
||||||
inner class ParameterRecord(val address: LLVMValueRef, val refSlot: Boolean) : Record {
|
inner class ParameterRecord(val address: LLVMValueRef, val refSlot: Boolean) : Record {
|
||||||
override fun load() : LLVMValueRef = functionGenerationContext.loadSlot(address, false)
|
override fun load(): LLVMValueRef = functionGenerationContext.loadSlot(address, false)
|
||||||
override fun store(value: LLVMValueRef) = functionGenerationContext.store(value, address)
|
override fun store(value: LLVMValueRef) = functionGenerationContext.store(value, address)
|
||||||
override fun address() : LLVMValueRef = this.address
|
override fun address() : LLVMValueRef = this.address
|
||||||
override fun toString() = (if (refSlot) "refslot" else "slot") + " for ${address}"
|
override fun toString() = (if (refSlot) "refslot" else "slot") + " for ${address}"
|
||||||
@@ -85,7 +85,7 @@ internal class VariableManager(val functionGenerationContext: FunctionGeneration
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal var skipSlots = 0
|
internal var skipSlots = 0
|
||||||
internal fun createParameter(valueDeclaration: IrValueDeclaration, variableLocation: VariableDebugLocation?) : Int {
|
internal fun createParameterOnStack(valueDeclaration: IrValueDeclaration, variableLocation: VariableDebugLocation?): Int {
|
||||||
assert(!contextVariablesToIndex.contains(valueDeclaration))
|
assert(!contextVariablesToIndex.contains(valueDeclaration))
|
||||||
val index = variables.size
|
val index = variables.size
|
||||||
val type = functionGenerationContext.getLLVMType(valueDeclaration.type)
|
val type = functionGenerationContext.getLLVMType(valueDeclaration.type)
|
||||||
@@ -99,6 +99,9 @@ internal class VariableManager(val functionGenerationContext: FunctionGeneration
|
|||||||
return index
|
return index
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun createParameter(valueDeclaration: IrValueDeclaration, value: LLVMValueRef) =
|
||||||
|
createImmutable(valueDeclaration, value)
|
||||||
|
|
||||||
// Creates anonymous mutable variable.
|
// Creates anonymous mutable variable.
|
||||||
// Think of slot reuse.
|
// Think of slot reuse.
|
||||||
fun createAnonymousSlot(value: LLVMValueRef? = null) : LLVMValueRef {
|
fun createAnonymousSlot(value: LLVMValueRef? = null) : LLVMValueRef {
|
||||||
|
|||||||
Reference in New Issue
Block a user