Split LINK_STAGE phase into OBJECT_FILES and LINKER sub-phases,

to be able to measure lcc/lto time separately from ld time.
This commit is contained in:
Alexander Gorshenev
2017-03-22 12:53:35 +03:00
committed by alexander-gorshenev
parent e197573e3e
commit 2071414079
3 changed files with 19 additions and 11 deletions
@@ -87,7 +87,7 @@ public fun runTopLevelPhases(konanConfig: KonanConfig, environment: KotlinCoreEn
}
}
phaser.phase(KonanPhase.LINKER) {
phaser.phase(KonanPhase.LINK_STAGE) {
LinkStage(context).linkStage()
}
}
@@ -34,7 +34,9 @@ enum class KonanPhase(val description: String,
/* ... ... */ RTTI("RTTI Generation"),
/* ... ... */ CODEGEN("Code Generation"),
/* ... ... */ METADATOR("Metadata Generation"),
/* */ LINKER("Link Stage");
/* */ LINK_STAGE("Link stage"),
/* ... */ OBJECT_FILES("Bitcode to object file"),
/* ... */ LINKER("Linker");
val prerequisite = prerequisite.toSet()
}
@@ -61,7 +63,7 @@ object KonanPhases {
verbose?.forEach { phases[known(it)]!!.verbose = true }
if (get(NOLINK) ?: false ) {
KonanPhase.LINKER.enabled = false
KonanPhase.LINK_STAGE.enabled = false
}
}}
}
@@ -262,16 +262,22 @@ internal class LinkStage(val context: Context) {
fun linkStage() {
context.log("# Compiler root: ${distribution.konanHome}")
val bitcodeFiles = listOf<BitcodeFile>(emitted, distribution.start, distribution.runtime,
distribution.launcher) + libraries
val bitcodeFiles = listOf<BitcodeFile>(emitted, distribution.start,
distribution.runtime, distribution.launcher) + libraries
val objectFiles = if (optimize) {
listOf( llvmLto(bitcodeFiles ) )
} else {
bitcodeFiles.map{ it -> llvmLlc(it) }
var objectFiles: List<String> = listOf()
val phaser = PhaseManager(context)
phaser.phase(KonanPhase.OBJECT_FILES) {
objectFiles = if (optimize) {
listOf( llvmLto(bitcodeFiles ) )
} else {
bitcodeFiles.map{ it -> llvmLlc(it) }
}
}
phaser.phase(KonanPhase.LINKER) {
val executable = link(objectFiles)
}
val executable = link(objectFiles)
}
}