fix callgraph issue when module gets removed by optimizations

This commit is contained in:
Irmen de Jong
2024-03-11 20:34:22 +01:00
parent 80f39e8097
commit c11a9b8709
2 changed files with 6 additions and 3 deletions

View File

@@ -56,9 +56,11 @@ class CallGraph(private val program: Program) : IAstVisitor {
override fun visit(directive: Directive) { override fun visit(directive: Directive) {
val thisModule = directive.definingModule val thisModule = directive.definingModule
if (directive.directive == "%import") { if (directive.directive == "%import") {
val importedModule: Module = program.modules.single { it.name == directive.args[0].name } val importedModule = program.modules.singleOrNull { it.name == directive.args[0].name } // the module may no longer exist at all due to optimizations
imports[thisModule] = imports.getValue(thisModule) + importedModule if(importedModule!=null) {
importedBy[importedModule] = importedBy.getValue(importedModule) + thisModule imports[thisModule] = imports.getValue(thisModule) + importedModule
importedBy[importedModule] = importedBy.getValue(importedModule) + thisModule
}
} }
super.visit(directive) super.visit(directive)

View File

@@ -3,6 +3,7 @@ TODO
Petaxian has gameplay problems on the C64 (with and without optimization) , cx16 target is fine. Petaxian has gameplay problems on the C64 (with and without optimization) , cx16 target is fine.
(seems unrelated to boolean type changes. 10.1 was still fine.) (seems unrelated to boolean type changes. 10.1 was still fine.)
caused by 358215e4ddf408e568ded0d36afce9f0162e21d1 Removed PostIncrDecr
... ...