Culled Empty Block (label) @1

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@2
main: scope:[main]  from @2
  asm { lda#'c' stasub.ll+1  }
  call sub 
  to:main::@1
main::@1: scope:[main]  from main
  to:main::@return
main::@return: scope:[main]  from main::@1
  return 
  to:@return
sub: scope:[sub]  from main
  asm { ll: lda#0 sta$400  }
  to:sub::@return
sub::@return: scope:[sub]  from sub
  return 
  to:@return
@2: scope:[]  from @begin
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@return
(void()) sub()
(label) sub::@return

Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
Adding NOP phi() at start of main::@1
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to sub:6 

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

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@1
@1: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @1
  [3] phi()
main: scope:[main]  from @1
  asm { lda#'c' stasub.ll+1  }
  [5] call sub 
  to:main::@return
main::@return: scope:[main]  from main
  [6] return 
  to:@return
sub: scope:[sub]  from main
  asm { ll: lda#0 sta$400  }
  to:sub::@return
sub::@return: scope:[sub]  from sub
  [8] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(void()) sub()

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
Target platform is c64basic
  // File Comments
// Tests that references to labels in other scopes is possible from inline ASM
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    // asm { lda#'c' stasub.ll+1  }
    lda #'c'
    sta sub.ll+1
    // [5] call sub 
    jsr sub
    jmp breturn
    // main::@return
  breturn:
    // [6] return 
    rts
}
  // sub
sub: {
    // asm { ll: lda#0 sta$400  }
  ll:
    lda #0
    sta $400
    jmp breturn
    // sub::@return
  breturn:
    // [8] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement asm { lda#'c' stasub.ll+1  } always clobbers reg byte a 
Statement asm { ll: lda#0 sta$400  } always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [sub] 
Uplift Scope [] 

Uplifting [main] best 48 combination 
Uplifting [sub] best 48 combination 
Uplifting [] best 48 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests that references to labels in other scopes is possible from inline ASM
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    // asm { lda#'c' stasub.ll+1  }
    lda #'c'
    sta sub.ll+1
    // [5] call sub 
    jsr sub
    jmp breturn
    // main::@return
  breturn:
    // [6] return 
    rts
}
  // sub
sub: {
    // asm { ll: lda#0 sta$400  }
  ll:
    lda #0
    sta $400
    jmp breturn
    // sub::@return
  breturn:
    // [8] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction breturn:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@return
(void()) sub()
(label) sub::@return



FINAL ASSEMBLER
Score: 30

  // File Comments
// Tests that references to labels in other scopes is possible from inline ASM
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    // asm
    // asm { lda#'c' stasub.ll+1  }
    lda #'c'
    sta sub.ll+1
    // sub()
    // [5] call sub 
    jsr sub
    // main::@return
    // }
    // [6] return 
    rts
}
  // sub
sub: {
    // asm
    // asm { ll: lda#0 sta$400  }
  ll:
    lda #0
    sta $400
    // sub::@return
    // }
    // [8] return 
    rts
}
  // File Data

