Resolved forward reference irq2 to __interrupt(rom_min_c64) void irq2()

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  *SCREEN = 'x'
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return

__interrupt(rom_min_c64) void irq1()
irq1: scope:[irq1]  from
  *HARDWARE_IRQ = &irq2
  to:irq1::@return
irq1::@return: scope:[irq1]  from irq1
  return 
  to:@return

__interrupt(rom_min_c64) void irq2()
irq2: scope:[irq2]  from
  *HARDWARE_IRQ = &irq1
  to:irq2::@return
irq2::@return: scope:[irq2]  from irq2
  return 
  to:@return

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

SYMBOL TABLE SSA
__constant void (** const HARDWARE_IRQ)() = (void (**)())$fffe
__constant char * const SCREEN = (char *)$400
void __start()
__interrupt(rom_min_c64) void irq1()
__interrupt(rom_min_c64) void irq2()
void main()

Simplifying constant pointer cast (char *) 1024
Simplifying constant pointer cast (void (**)()) 65534
Successful SSA optimization PassNCastSimplification
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
CALL GRAPH

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes

FINAL CONTROL FLOW GRAPH

__interrupt(rom_min_c64) void irq2()
irq2: scope:[irq2]  from
  [0] *HARDWARE_IRQ = &irq1
  to:irq2::@return
irq2::@return: scope:[irq2]  from irq2
  [1] return 
  to:@return

__interrupt(rom_min_c64) void irq1()
irq1: scope:[irq1]  from
  [2] *HARDWARE_IRQ = &irq2
  to:irq1::@return
irq1::@return: scope:[irq1]  from irq1
  [3] return 
  to:@return

void main()
main: scope:[main]  from
  [4] *SCREEN = 'x'
  to:main::@return
main::@return: scope:[main]  from main
  [5] return 
  to:@return


VARIABLE REGISTER WEIGHTS
__interrupt(rom_min_c64) void irq1()
__interrupt(rom_min_c64) void irq2()
void main()

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *HARDWARE_IRQ = &irq1 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [2] *HARDWARE_IRQ = &irq2 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [4] *SCREEN = 'x' [ ] (  [ ] { }  ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [irq1] 
Uplift Scope [irq2] 
Uplift Scope [] 

Uplifting [main] best 105 combination 
Uplifting [irq1] best 105 combination 
Uplifting [irq2] best 105 combination 
Uplifting [] best 105 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Unused interrupts pointing to each other but never used from main loop - should be optimized away
  // Upstart
  // Commodore 64 PRG executable file
.file [name="unused-irq.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(main)
  // Global Constants & labels
  .label SCREEN = $400
  .label HARDWARE_IRQ = $fffe
.segment Code
  // irq2
// Unused Interrupt Routine
irq2: {
    // interrupt(isr_rom_min_c64_entry) -- isr_rom_min_c64_entry 
    // [0] *HARDWARE_IRQ = &irq1 -- _deref_qprc1=pprc2 
    lda #<irq1
    sta HARDWARE_IRQ
    lda #>irq1
    sta HARDWARE_IRQ+1
    jmp __breturn
    // irq2::@return
  __breturn:
    // [1] return 
    // interrupt(isr_rom_min_c64_exit) -- isr_rom_min_c64_exit 
    jmp $ea81
}
  // irq1
// Unused Interrupt Routine
irq1: {
    // interrupt(isr_rom_min_c64_entry) -- isr_rom_min_c64_entry 
    // [2] *HARDWARE_IRQ = &irq2 -- _deref_qprc1=pprc2 
    lda #<irq2
    sta HARDWARE_IRQ
    lda #>irq2
    sta HARDWARE_IRQ+1
    jmp __breturn
    // irq1::@return
  __breturn:
    // [3] return 
    // interrupt(isr_rom_min_c64_exit) -- isr_rom_min_c64_exit 
    jmp $ea81
}
  // main
main: {
    // [4] *SCREEN = 'x' -- _deref_pbuc1=vbuc2 
    lda #'x'
    sta SCREEN
    jmp __breturn
    // main::@return
  __breturn:
    // [5] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant void (** const HARDWARE_IRQ)() = (void (**)()) 65534
__constant char * const SCREEN = (char *) 1024
__interrupt(rom_min_c64) void irq1()
__interrupt(rom_min_c64) void irq2()
void main()



FINAL ASSEMBLER
Score: 96

  // File Comments
// Unused interrupts pointing to each other but never used from main loop - should be optimized away
  // Upstart
  // Commodore 64 PRG executable file
.file [name="unused-irq.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(main)
  // Global Constants & labels
  .label SCREEN = $400
  .label HARDWARE_IRQ = $fffe
.segment Code
  // irq2
// Unused Interrupt Routine
irq2: {
    // interrupt(isr_rom_min_c64_entry) -- isr_rom_min_c64_entry 
    // *HARDWARE_IRQ = &irq1
    // [0] *HARDWARE_IRQ = &irq1 -- _deref_qprc1=pprc2 
    lda #<irq1
    sta HARDWARE_IRQ
    lda #>irq1
    sta HARDWARE_IRQ+1
    // irq2::@return
    // }
    // [1] return 
    // interrupt(isr_rom_min_c64_exit) -- isr_rom_min_c64_exit 
    jmp $ea81
}
  // irq1
// Unused Interrupt Routine
irq1: {
    // interrupt(isr_rom_min_c64_entry) -- isr_rom_min_c64_entry 
    // *HARDWARE_IRQ = &irq2
    // [2] *HARDWARE_IRQ = &irq2 -- _deref_qprc1=pprc2 
    lda #<irq2
    sta HARDWARE_IRQ
    lda #>irq2
    sta HARDWARE_IRQ+1
    // irq1::@return
    // }
    // [3] return 
    // interrupt(isr_rom_min_c64_exit) -- isr_rom_min_c64_exit 
    jmp $ea81
}
  // main
main: {
    // *SCREEN = 'x'
    // [4] *SCREEN = 'x' -- _deref_pbuc1=vbuc2 
    lda #'x'
    sta SCREEN
    // main::@return
    // }
    // [5] return 
    rts
}
  // File Data

