[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 {
|
||||
if (function != null) {
|
||||
parameters.forEach{
|
||||
parameters.forEach {
|
||||
val parameter = it.key
|
||||
val local = functionGenerationContext.vars.createParameter(
|
||||
parameter, debugInfoIfNeeded(function, parameter))
|
||||
functionGenerationContext.mapParameterForDebug(local, it.value)
|
||||
|
||||
if (context.shouldContainDebugInfo()) {
|
||||
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 {
|
||||
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 address() : LLVMValueRef = this.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 fun createParameter(valueDeclaration: IrValueDeclaration, variableLocation: VariableDebugLocation?) : Int {
|
||||
internal fun createParameterOnStack(valueDeclaration: IrValueDeclaration, variableLocation: VariableDebugLocation?): Int {
|
||||
assert(!contextVariablesToIndex.contains(valueDeclaration))
|
||||
val index = variables.size
|
||||
val type = functionGenerationContext.getLLVMType(valueDeclaration.type)
|
||||
@@ -99,6 +99,9 @@ internal class VariableManager(val functionGenerationContext: FunctionGeneration
|
||||
return index
|
||||
}
|
||||
|
||||
internal fun createParameter(valueDeclaration: IrValueDeclaration, value: LLVMValueRef) =
|
||||
createImmutable(valueDeclaration, value)
|
||||
|
||||
// Creates anonymous mutable variable.
|
||||
// Think of slot reuse.
|
||||
fun createAnonymousSlot(value: LLVMValueRef? = null) : LLVMValueRef {
|
||||
|
||||
Reference in New Issue
Block a user