algorand / algorand/go-algorand
Make disassembler dead code aware
- Lenguaje dominante
- Go
- Estrellas
- 1.4k
- Forks
- 537
- Merge medio
- 1 d 6 h
- PR fusionados (30 d)
- 17
Descripción
## Problem
The disassembler makes a best-effort attempt to annotate `intc` references with the associated literal value to improve human readability.
Since the disassembler is not dead code aware, it leads to annotated comments that are _obviously_ wrong. Consider the following snippet:
```
ops = testProg(t, `
target:
int 1
b skip
intcblock 10
retsub
callsub target
int 1
int 1
+
skip:
int 10
int 1
+
`, AssemblerMaxVersion)
text, err = Disassemble(ops.Program)
require.NoError(t, err)
fmt.Printf("%v\n", text)
```
As of https://github.com/algorand/go-algorand/pull/4442, the output _incorrectly_ shows `intc_0 // 10` instead of `intc_0 // 1`:
```
#pragma version 8
intcblock 1
label2:
intc_0 // 1
b label1
intcblock 10
retsub
callsub label2
intc_0 // 10
intc_0 // 10
+
label1:
pushint 10
intc_0 // 10
+
```
A direct response to the problem at-hand is to extend the disassembler to account for dead code, which fixes the example's comments.
Additionally, it may make sense to consider if there are more general rules / changes to consider for disassembly.
## Solution
## Dependencies
## Urgency
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.