diff --git a/codeOptimizers/src/prog8/optimizer/UnusedCodeRemover.kt b/codeOptimizers/src/prog8/optimizer/UnusedCodeRemover.kt index d51c24c0e..e5ecc9770 100644 --- a/codeOptimizers/src/prog8/optimizer/UnusedCodeRemover.kt +++ b/codeOptimizers/src/prog8/optimizer/UnusedCodeRemover.kt @@ -106,10 +106,10 @@ class UnusedCodeRemover(private val program: Program, if(decl.type==VarDeclType.VAR) { val block = decl.definingBlock val forceOutput = "force_output" in block.options() - if (!forceOutput && decl.origin==VarDeclOrigin.USERCODE && !decl.sharedWithAsm && !block.isInLibrary) { // TODO remove check on block.isInLibrary, but this now breaks some programs + if (!forceOutput && decl.origin==VarDeclOrigin.USERCODE && !decl.sharedWithAsm) { val usages = callgraph.usages(decl) if (usages.isEmpty()) { - if(!decl.definingModule.isLibrary) + // if(!decl.definingModule.isLibrary) errors.warn("removing unused variable '${decl.name}'", decl.position) return listOf(IAstModification.Remove(decl, parent as IStatementContainer)) } diff --git a/compiler/res/prog8lib/conv.p8 b/compiler/res/prog8lib/conv.p8 index 86a2752b6..c6887b8b8 100644 --- a/compiler/res/prog8lib/conv.p8 +++ b/compiler/res/prog8lib/conv.p8 @@ -7,7 +7,7 @@ conv { ; ----- number conversions to decimal strings ---- - str string_out = "????????????????" ; result buffer for the string conversion routines + str @shared string_out = "????????????????" ; result buffer for the string conversion routines asmsub str_ub0 (ubyte value @ A) clobbers(A,Y) { ; ---- convert the ubyte in A in decimal string form, with left padding 0s (3 positions total) diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index 2ff1162ba..2fc4174f3 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -369,7 +369,7 @@ _done set_both_strides(13) ; 160 increment = 1 line in 640 px 4c mode color &= 3 color <<= gfx2.plot.shift4c[lsb(x) & 3] - ubyte mask = gfx2.plot.mask4c[lsb(x) & 3] + ubyte @shared mask = gfx2.plot.mask4c[lsb(x) & 3] repeat height { %asm {{ lda cx16.VERA_DATA0 @@ -545,9 +545,9 @@ _done } sub plot(uword @zp x, uword y, ubyte color) { - ubyte[8] bits = [128, 64, 32, 16, 8, 4, 2, 1] - ubyte[4] mask4c = [%00111111, %11001111, %11110011, %11111100] - ubyte[4] shift4c = [6,4,2,0] + ubyte[8] @shared bits = [128, 64, 32, 16, 8, 4, 2, 1] + ubyte[4] @shared mask4c = [%00111111, %11001111, %11110011, %11111100] + ubyte[4] @shared shift4c = [6,4,2,0] when active_mode { 1 -> { diff --git a/compiler/res/prog8lib/diskio.p8 b/compiler/res/prog8lib/diskio.p8 index 6c557d6c7..aecee17db 100644 --- a/compiler/res/prog8lib/diskio.p8 +++ b/compiler/res/prog8lib/diskio.p8 @@ -407,7 +407,7 @@ io_error: sub save(ubyte drivenumber, uword filenameptr, uword address, uword size) -> ubyte { c64.SETNAM(string.length(filenameptr), filenameptr) c64.SETLFS(1, drivenumber, 0) - uword end_address = address + size + uword @shared end_address = address + size first_byte = 0 ; result var reuse %asm {{ diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 436e98557..74ea4ca59 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,7 +3,6 @@ TODO For next release ^^^^^^^^^^^^^^^^ -- (newvaralloc) UnusedCodeRemover after(decl: VarDecl): fix that vars defined in a library can also safely be removed if unused. Currently this breaks programs such as textelite (due to diskio.save().end_address ?) - make it so that subroutine parameters as variables can again be allocated in ZP, if there's still space