algorand / algorand/go-algorand

Make disassembler dead code aware

Abierto
#4,486 1 comentario 0 reacciones 0 asignados Ver en GitHub
Team Scytale
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

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.