[K/N] Move basic blocks with lazy init to middle of function
CoreSymbolication heuristics assume that last instruction in function corresponds to last function line. This is not always true anyway, but with this hack this will happen more often.
This commit is contained in:
+9
@@ -520,6 +520,15 @@ internal abstract class FunctionGenerationContext(
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function shouldn't be used normally.
|
||||||
|
* It is used to move block with strange debug info in the middle of function, to avoid last debug info being too strange,
|
||||||
|
* because it will break heuristics in CoreSymbolication
|
||||||
|
*/
|
||||||
|
fun moveBlockAfterEntry(block: LLVMBasicBlockRef) {
|
||||||
|
LLVMMoveBasicBlockAfter(block, this.entryBb)
|
||||||
|
}
|
||||||
|
|
||||||
fun alloca(type: LLVMTypeRef?, name: String = "", variableLocation: VariableDebugLocation? = null): LLVMValueRef {
|
fun alloca(type: LLVMTypeRef?, name: String = "", variableLocation: VariableDebugLocation? = null): LLVMValueRef {
|
||||||
if (isObjectType(type!!)) {
|
if (isObjectType(type!!)) {
|
||||||
appendingTo(localsInitBb) {
|
appendingTo(localsInitBb) {
|
||||||
|
|||||||
+7
@@ -2378,6 +2378,8 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
|
|
||||||
val bbInit = basicBlock("label_init", null)
|
val bbInit = basicBlock("label_init", null)
|
||||||
val bbExit = basicBlock("label_continue", null)
|
val bbExit = basicBlock("label_continue", null)
|
||||||
|
moveBlockAfterEntry(bbExit)
|
||||||
|
moveBlockAfterEntry(bbInit)
|
||||||
// TODO: Is it ok to use non-volatile read here since once value is FILE_INITIALIZED, it is no longer change?
|
// TODO: Is it ok to use non-volatile read here since once value is FILE_INITIALIZED, it is no longer change?
|
||||||
val state = load(statePtr)
|
val state = load(statePtr)
|
||||||
LLVMSetVolatile(state, 1)
|
LLVMSetVolatile(state, 1)
|
||||||
@@ -2399,6 +2401,9 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
val bbInit = basicBlock("label_init", null)
|
val bbInit = basicBlock("label_init", null)
|
||||||
val bbCheckLocalState = basicBlock("label_check_local", null)
|
val bbCheckLocalState = basicBlock("label_check_local", null)
|
||||||
val bbExit = basicBlock("label_continue", null)
|
val bbExit = basicBlock("label_continue", null)
|
||||||
|
moveBlockAfterEntry(bbExit)
|
||||||
|
moveBlockAfterEntry(bbCheckLocalState)
|
||||||
|
moveBlockAfterEntry(bbInit)
|
||||||
val globalState = load(globalStatePtr)
|
val globalState = load(globalStatePtr)
|
||||||
LLVMSetVolatile(globalState, 1)
|
LLVMSetVolatile(globalState, 1)
|
||||||
// Make sure we're not in the middle of global initializer invocation -
|
// Make sure we're not in the middle of global initializer invocation -
|
||||||
@@ -2421,6 +2426,8 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
|
|
||||||
val bbInit = basicBlock("label_init", null)
|
val bbInit = basicBlock("label_init", null)
|
||||||
val bbExit = basicBlock("label_continue", null)
|
val bbExit = basicBlock("label_continue", null)
|
||||||
|
moveBlockAfterEntry(bbExit)
|
||||||
|
moveBlockAfterEntry(bbInit)
|
||||||
condBr(icmpEq(load(statePtr), Int32(FILE_INITIALIZED).llvm), bbExit, bbInit)
|
condBr(icmpEq(load(statePtr), Int32(FILE_INITIALIZED).llvm), bbExit, bbInit)
|
||||||
positionAtEnd(bbInit)
|
positionAtEnd(bbInit)
|
||||||
call(context.llvm.callInitThreadLocal, listOf(kNullInt32Ptr, statePtr, initializerPtr),
|
call(context.llvm.callInitThreadLocal, listOf(kNullInt32Ptr, statePtr, initializerPtr),
|
||||||
|
|||||||
Reference in New Issue
Block a user