algorand / algorand/go-algorand

Make disassembler dead code aware

未关闭
#4,486 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Team Scytale
主要语言
Go
星标
1.4k
派生
537
平均合并
1 天 7 小时
30 天内合并 PR
18

描述

## 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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。