Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  *screen = 'a'
  screen = ++ screen
  *screen = 'a'
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  screen = (char *)$400
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  call main
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  return 
  to:@return

SYMBOL TABLE SSA
void __start()
void main()
__loadstore char *screen

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

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

FINAL CONTROL FLOW GRAPH

void __start()
__start: scope:[__start]  from
  [0] phi()
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  [1] screen = (char *) 1024
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  [2] phi()
  [3] call main
  to:__start::@return
__start::@return: scope:[__start]  from __start::@1
  [4] return 
  to:@return

void main()
main: scope:[main]  from __start::@1
  [5] *screen = 'a'
  [6] screen = ++ screen
  [7] *screen = 'a'
  to:main::@return
main::@return: scope:[main]  from main
  [8] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void __start()
void main()
__loadstore char *screen // 11.5

Initial phi equivalence classes
Added variable screen to live range equivalence class [ screen ]
Complete equivalence classes
[ screen ]
Allocated zp[2]:2 [ screen ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] screen = (char *) 1024 [ screen ] (  [ screen ] { }  ) always clobbers reg byte a 
Statement [5] *screen = 'a' [ screen ] ( main:3 [ screen ] { }  ) always clobbers reg byte a reg byte y 
Statement [7] *screen = 'a' [ ] ( main:3 [ ] { }  ) always clobbers reg byte a reg byte y 
Potential registers zp[2]:2 [ screen ] : zp[2]:2 , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 11.5: zp[2]:2 [ screen ] 
Uplift Scope [main] 
Uplift Scope [__start] 

Uplifting [] best 99 combination zp[2]:2 [ screen ] 
Uplifting [main] best 99 combination 
Uplifting [__start] best 99 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests that global variables with initializer gets their comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="test-comments-global.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
  // The screen (should become a var-comment in ASM)
  .label screen = 2
.segment Code
  // __start
__start: {
    jmp __init1
    // __start::__init1
  __init1:
    // [1] screen = (char *) 1024 -- pbuz1=pbuc1 
    lda #<$400
    sta.z screen
    lda #>$400
    sta.z screen+1
    // [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
  __b1_from___init1:
    jmp __b1
    // __start::@1
  __b1:
    // [3] call main
    jsr main
    jmp __breturn
    // __start::@return
  __breturn:
    // [4] return 
    rts
}
  // main
// The program entry point
main: {
    // [5] *screen = 'a' -- _deref_pbuz1=vbuc1 
    // Put 'a' in screen
    lda #'a'
    ldy #0
    sta (screen),y
    // [6] screen = ++ screen -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // [7] *screen = 'a' -- _deref_pbuz1=vbuc1 
    // Put another 'a' in screen
    lda #'a'
    ldy #0
    sta (screen),y
    jmp __breturn
    // main::@return
  __breturn:
    // [8] return 
    rts
}
  // File Data

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

FINAL SYMBOL TABLE
void __start()
void main()
__loadstore char *screen // zp[2]:2 11.5

zp[2]:2 [ screen ]


FINAL ASSEMBLER
Score: 60

  // File Comments
// Tests that global variables with initializer gets their comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="test-comments-global.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
  // The screen (should become a var-comment in ASM)
  .label screen = 2
.segment Code
  // __start
__start: {
    // __start::__init1
    // __ma char * screen = (char*)0x0400
    // [1] screen = (char *) 1024 -- pbuz1=pbuc1 
    lda #<$400
    sta.z screen
    lda #>$400
    sta.z screen+1
    // [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
    // __start::@1
    // [3] call main
    jsr main
    // __start::@return
    // [4] return 
    rts
}
  // main
// The program entry point
main: {
    // *screen = 'a'
    // [5] *screen = 'a' -- _deref_pbuz1=vbuc1 
    // Put 'a' in screen
    lda #'a'
    ldy #0
    sta (screen),y
    // screen++;
    // [6] screen = ++ screen -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // *screen = 'a'
    // [7] *screen = 'a' -- _deref_pbuz1=vbuc1 
    // Put another 'a' in screen
    lda #'a'
    ldy #0
    sta (screen),y
    // main::@return
    // }
    // [8] return 
    rts
}
  // File Data

