2019-10-21 16:29:38 +00:00
|
|
|
SixtyPical Callgraph
|
|
|
|
====================
|
|
|
|
|
|
|
|
This is a test suite, written in [Falderal][] format, for the ability of
|
|
|
|
a SixtyPical analyzer to construct a callgraph of which routines call which
|
|
|
|
other routines, and its ability to discover which routines will never be
|
|
|
|
called.
|
|
|
|
|
|
|
|
[Falderal]: http://catseye.tc/node/Falderal
|
|
|
|
|
|
|
|
-> Tests for functionality "Dump callgraph info for SixtyPical program"
|
|
|
|
|
2019-10-21 20:35:28 +00:00
|
|
|
The `main` routine is always called. The thing that it will
|
2019-10-22 08:07:16 +00:00
|
|
|
be called by is the system, but the callgraph analyzer simply
|
|
|
|
considers it to be "reachable".
|
2019-10-21 16:29:38 +00:00
|
|
|
|
|
|
|
| define main routine
|
|
|
|
| {
|
|
|
|
| }
|
2019-10-21 20:23:14 +00:00
|
|
|
= {
|
|
|
|
= "main": {
|
2019-10-22 08:07:16 +00:00
|
|
|
= "potentially-called-by": [],
|
|
|
|
= "potentially-calls": [],
|
|
|
|
= "reachable": true
|
2019-10-21 20:35:28 +00:00
|
|
|
= }
|
|
|
|
= }
|
|
|
|
|
|
|
|
If a routine is called by another routine, this fact will be noted.
|
2019-10-22 08:07:16 +00:00
|
|
|
If it is reachable (directly or indirectly) from `main`, this will
|
|
|
|
be noted as well.
|
2019-10-21 20:35:28 +00:00
|
|
|
|
|
|
|
| define main routine
|
|
|
|
| {
|
|
|
|
| call other
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| define other routine
|
|
|
|
| {
|
|
|
|
| }
|
|
|
|
= {
|
|
|
|
= "main": {
|
2019-10-22 08:07:16 +00:00
|
|
|
= "potentially-called-by": [],
|
2019-10-21 20:35:28 +00:00
|
|
|
= "potentially-calls": [
|
|
|
|
= "other"
|
2019-10-22 08:07:16 +00:00
|
|
|
= ],
|
|
|
|
= "reachable": true
|
2019-10-21 20:35:28 +00:00
|
|
|
= },
|
|
|
|
= "other": {
|
|
|
|
= "potentially-called-by": [
|
|
|
|
= "main"
|
|
|
|
= ],
|
2019-10-22 08:07:16 +00:00
|
|
|
= "potentially-calls": [],
|
|
|
|
= "reachable": true
|
2019-10-21 20:35:28 +00:00
|
|
|
= }
|
|
|
|
= }
|
|
|
|
|
2019-10-22 08:07:16 +00:00
|
|
|
If a routine is not potentially called by any other routine that is
|
|
|
|
ultimately potentially called by `main`, this absence will be noted
|
|
|
|
— the routine will not be considered reachable — and a compiler or
|
|
|
|
linker will be permitted to omit it from the final executable.
|
2019-10-21 20:35:28 +00:00
|
|
|
|
|
|
|
| define main routine
|
|
|
|
| {
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| define other routine
|
|
|
|
| {
|
|
|
|
| }
|
|
|
|
= {
|
|
|
|
= "main": {
|
2019-10-22 08:07:16 +00:00
|
|
|
= "potentially-called-by": [],
|
|
|
|
= "potentially-calls": [],
|
|
|
|
= "reachable": true
|
2019-10-21 20:35:28 +00:00
|
|
|
= },
|
|
|
|
= "other": {
|
2019-10-21 20:23:14 +00:00
|
|
|
= "potentially-called-by": [],
|
|
|
|
= "potentially-calls": []
|
|
|
|
= }
|
|
|
|
= }
|
2019-10-21 20:35:28 +00:00
|
|
|
|
2019-10-21 20:45:59 +00:00
|
|
|
If a routine is not called by another routine, but it is declared
|
2019-10-22 08:07:16 +00:00
|
|
|
explicitly as `preserved`, then it will still be considered
|
|
|
|
reachable, and a compiler or linker will not be permitted to omit it
|
|
|
|
from the final executable. This is useful for interrupt routines
|
|
|
|
and such that really are used by some part of the system, even if
|
|
|
|
not directly by another SixtyPical routine.
|
2019-10-21 20:45:59 +00:00
|
|
|
|
|
|
|
| define main routine
|
|
|
|
| {
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| define other preserved routine
|
|
|
|
| {
|
|
|
|
| }
|
|
|
|
= {
|
|
|
|
= "main": {
|
2019-10-22 08:07:16 +00:00
|
|
|
= "potentially-called-by": [],
|
|
|
|
= "potentially-calls": [],
|
|
|
|
= "reachable": true
|
2019-10-21 20:45:59 +00:00
|
|
|
= },
|
|
|
|
= "other": {
|
2019-10-22 08:07:16 +00:00
|
|
|
= "potentially-called-by": [],
|
|
|
|
= "potentially-calls": [],
|
|
|
|
= "reachable": true
|
|
|
|
= }
|
|
|
|
= }
|
|
|
|
|
|
|
|
If a routine is called from a preserved routine, that routine is
|
|
|
|
reachable.
|
|
|
|
|
|
|
|
| define main routine
|
|
|
|
| {
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| define other1 preserved routine
|
|
|
|
| {
|
|
|
|
| call other2
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| define other2 preserved routine
|
|
|
|
| {
|
|
|
|
| }
|
|
|
|
= {
|
|
|
|
= "main": {
|
|
|
|
= "potentially-called-by": [],
|
|
|
|
= "potentially-calls": [],
|
|
|
|
= "reachable": true
|
|
|
|
= },
|
|
|
|
= "other1": {
|
|
|
|
= "potentially-called-by": [],
|
|
|
|
= "potentially-calls": [
|
|
|
|
= "other2"
|
|
|
|
= ],
|
|
|
|
= "reachable": true
|
|
|
|
= },
|
|
|
|
= "other2": {
|
2019-10-21 20:45:59 +00:00
|
|
|
= "potentially-called-by": [
|
2019-10-22 08:07:16 +00:00
|
|
|
= "other1"
|
2019-10-21 20:45:59 +00:00
|
|
|
= ],
|
2019-10-22 08:07:16 +00:00
|
|
|
= "potentially-calls": [],
|
|
|
|
= "reachable": true
|
2019-10-21 20:45:59 +00:00
|
|
|
= }
|
|
|
|
= }
|
|
|
|
|
2019-10-22 08:07:16 +00:00
|
|
|
If a group of routines potentially call each other, but neither is
|
|
|
|
found to be reachable (directly or indirectly) from `main` or a
|
|
|
|
`preserved` routine, the routines in the group will not be considered
|
|
|
|
reachable.
|
2019-10-21 20:35:28 +00:00
|
|
|
|
|
|
|
| define main routine
|
|
|
|
| {
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| define other1 routine
|
|
|
|
| {
|
|
|
|
| call other2
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| define other2 routine
|
|
|
|
| {
|
|
|
|
| call other1
|
|
|
|
| }
|
|
|
|
= {
|
|
|
|
= "main": {
|
2019-10-22 08:07:16 +00:00
|
|
|
= "potentially-called-by": [],
|
|
|
|
= "potentially-calls": [],
|
|
|
|
= "reachable": true
|
2019-10-21 20:35:28 +00:00
|
|
|
= },
|
|
|
|
= "other1": {
|
|
|
|
= "potentially-called-by": [
|
|
|
|
= "other2"
|
|
|
|
= ],
|
|
|
|
= "potentially-calls": [
|
|
|
|
= "other2"
|
|
|
|
= ]
|
|
|
|
= },
|
|
|
|
= "other2": {
|
|
|
|
= "potentially-called-by": [
|
|
|
|
= "other1"
|
|
|
|
= ],
|
|
|
|
= "potentially-calls": [
|
|
|
|
= "other1"
|
|
|
|
= ]
|
|
|
|
= }
|
|
|
|
= }
|
2019-10-22 08:41:30 +00:00
|
|
|
|
|
|
|
-> Tests for functionality "Compile SixtyPical program with unreachable routine removal"
|
|
|
|
|
|
|
|
Basic test for actually removing unreachable routines from the resulting
|
|
|
|
executable when compiling SixtyPical programs.
|
|
|
|
|
|
|
|
| define main routine outputs a trashes z, n
|
|
|
|
| {
|
|
|
|
| ld a, 100
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| define other1 routine
|
|
|
|
| {
|
|
|
|
| call other2
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| define other2 routine
|
|
|
|
| {
|
|
|
|
| call other1
|
|
|
|
| }
|
|
|
|
= $080D LDA #$64
|
|
|
|
= $080F RTS
|
|
|
|
|
|
|
|
Test that marking routine as `preserved` preserves it in the output.
|
|
|
|
|
|
|
|
| define main routine outputs a trashes z, n
|
|
|
|
| {
|
|
|
|
| ld a, 100
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
| define other preserved routine outputs a trashes z, n
|
|
|
|
| {
|
|
|
|
| ld a, 5
|
|
|
|
| }
|
|
|
|
= $080D LDA #$64
|
|
|
|
= $080F RTS
|
|
|
|
= $0810 LDA #$05
|
|
|
|
= $0812 RTS
|