don't remove subroutines in a block marked with "force_output"

This commit is contained in:
Irmen de Jong 2021-02-21 23:25:26 +01:00
parent edf9a500d3
commit 0e62f5b759

View File

@ -28,7 +28,8 @@ internal class UnusedCodeRemover(private val program: Program,
val entrypoint = program.entrypoint()
program.modules.forEach {
callgraph.forAllSubroutines(it) { sub ->
if (sub !== entrypoint && !sub.isAsmSubroutine && (callgraph.calledBy[sub].isNullOrEmpty() || sub.containsNoCodeNorVars())) {
val forceOutput = "force_output" in sub.definingBlock().options()
if (sub !== entrypoint && !forceOutput && !sub.isAsmSubroutine && (callgraph.calledBy[sub].isNullOrEmpty() || sub.containsNoCodeNorVars())) {
removals.add(IAstModification.Remove(sub, sub.definingScope()))
}
}