Inlined call call __init

CONTROL FLOW GRAPH SSA

void my_init()
my_init: scope:[my_init]  from __start::__init1
  my_value = '*'
  to:my_init::@return
my_init::@return: scope:[my_init]  from my_init
  return 
  to:@return

void main()
main: scope:[main]  from __start::@1
  call print
  to:main::@1
main::@1: scope:[main]  from main
  to:main::@return
main::@return: scope:[main]  from main::@1
  return 
  to:@return

void print()
print: scope:[print]  from main
  *SCREEN = my_value
  to:print::@return
print::@return: scope:[print]  from print
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  my_value = 0
  call my_init
  to:__start::@2
__start::@2: scope:[__start]  from __start::__init1
  to:__start::@1
__start::@1: scope:[__start]  from __start::@2
  call main
  to:__start::@3
__start::@3: scope:[__start]  from __start::@1
  to:__start::@return
__start::@return: scope:[__start]  from __start::@3
  return 
  to:@return

SYMBOL TABLE SSA
__constant char * const SCREEN = (char *)$400
void __start()
void main()
void my_init()
__loadstore volatile char my_value
void print()

Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@2
Adding NOP phi() at start of __start::@1
Adding NOP phi() at start of __start::@3
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
CALL GRAPH
Calls in [__start] to my_init:2 main:5 
Calls in [main] to print:11 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block label __start::@2
Culled Empty Block label __start::@3
Culled Empty Block label main::@1
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH

void __start()
__start: scope:[__start]  from
  [0] phi()
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  [1] my_value = 0
  [2] call my_init
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  [3] phi()
  [4] call main
  to:__start::@return
__start::@return: scope:[__start]  from __start::@1
  [5] return 
  to:@return

void my_init()
my_init: scope:[my_init]  from __start::__init1
  [6] my_value = '*'
  to:my_init::@return
my_init::@return: scope:[my_init]  from my_init
  [7] return 
  to:@return

void main()
main: scope:[main]  from __start::@1
  [8] phi()
  [9] call print
  to:main::@return
main::@return: scope:[main]  from main
  [10] return 
  to:@return

void print()
print: scope:[print]  from main
  [11] *SCREEN = my_value
  to:print::@return
print::@return: scope:[print]  from print
  [12] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void __start()
void main()
void my_init()
__loadstore volatile char my_value // 22.8
void print()

Initial phi equivalence classes
Added variable my_value to live range equivalence class [ my_value ]
Complete equivalence classes
[ my_value ]
Allocated zp[1]:2 [ my_value ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] my_value = 0 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [6] my_value = '*' [ my_value ] (  [ my_value ] { }  my_init:2 [ my_value ] { }  ) always clobbers reg byte a 
Statement [11] *SCREEN = my_value [ ] ( main:4::print:9 [ ] { }  ) always clobbers reg byte a 
Potential registers zp[1]:2 [ my_value ] : zp[1]:2 , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 22.8: zp[1]:2 [ my_value ] 
Uplift Scope [my_init] 
Uplift Scope [main] 
Uplift Scope [print] 
Uplift Scope [__start] 

Uplifting [] best 104 combination zp[1]:2 [ my_value ] 
Uplifting [my_init] best 104 combination 
Uplifting [main] best 104 combination 
Uplifting [print] best 104 combination 
Uplifting [__start] best 104 combination 
Attempting to uplift remaining variables inzp[1]:2 [ my_value ]
Uplifting [] best 104 combination zp[1]:2 [ my_value ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Demonstrates Library Constructor Functionality
// #pragma constructor_for() declares named constructors for other symbols
  // Upstart
  // Commodore 64 PRG executable file
.file [name="library-constructor-1.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(__start)
  // Global Constants & labels
  .label SCREEN = $400
  .label my_value = 2
.segment Code
  // __start
__start: {
    jmp __init1
    // __start::__init1
  __init1:
    // [1] my_value = 0 -- vbuz1=vbuc1 
    lda #0
    sta.z my_value
    // [2] call my_init
    jsr my_init
    // [3] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
  __b1_from___init1:
    jmp __b1
    // __start::@1
  __b1:
    // [4] call main
    // [8] phi from __start::@1 to main [phi:__start::@1->main]
  main_from___b1:
    jsr main
    jmp __breturn
    // __start::@return
  __breturn:
    // [5] return 
    rts
}
  // my_init
my_init: {
    // [6] my_value = '*' -- vbuz1=vbuc1 
    lda #'*'
    sta.z my_value
    jmp __breturn
    // my_init::@return
  __breturn:
    // [7] return 
    rts
}
  // main
main: {
    // [9] call print
    jsr print
    jmp __breturn
    // main::@return
  __breturn:
    // [10] return 
    rts
}
  // print
print: {
    // [11] *SCREEN = my_value -- _deref_pbuc1=vbuz1 
    lda.z my_value
    sta SCREEN
    jmp __breturn
    // print::@return
  __breturn:
    // [12] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __init1
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from___init1:
Removing instruction main_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __init1:
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char * const SCREEN = (char *) 1024
void __start()
void main()
void my_init()
__loadstore volatile char my_value // zp[1]:2 22.8
void print()

zp[1]:2 [ my_value ]


FINAL ASSEMBLER
Score: 59

  // File Comments
// Demonstrates Library Constructor Functionality
// #pragma constructor_for() declares named constructors for other symbols
  // Upstart
  // Commodore 64 PRG executable file
.file [name="library-constructor-1.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(__start)
  // Global Constants & labels
  .label SCREEN = $400
  .label my_value = 2
.segment Code
  // __start
__start: {
    // __start::__init1
    // volatile char my_value
    // [1] my_value = 0 -- vbuz1=vbuc1 
    lda #0
    sta.z my_value
    // #pragma constructor_for(my_init, print)
    // [2] call my_init
    jsr my_init
    // [3] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
    // __start::@1
    // [4] call main
    // [8] phi from __start::@1 to main [phi:__start::@1->main]
    jsr main
    // __start::@return
    // [5] return 
    rts
}
  // my_init
my_init: {
    // my_value = '*'
    // [6] my_value = '*' -- vbuz1=vbuc1 
    lda #'*'
    sta.z my_value
    // my_init::@return
    // }
    // [7] return 
    rts
}
  // main
main: {
    // print()
    // [9] call print
    jsr print
    // main::@return
    // }
    // [10] return 
    rts
}
  // print
print: {
    // *SCREEN = my_value
    // [11] *SCREEN = my_value -- _deref_pbuc1=vbuz1 
    lda.z my_value
    sta SCREEN
    // print::@return
    // }
    // [12] return 
    rts
}
  // File Data

