KhronosGroup / KhronosGroup/SPIRV-Tools
spirv-dis: Showing byte offsets can immensely bloat disassembly size due to alignment code
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 709
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 28
Description
Passing --offsets to the disassembler can cause the disassembly to contain thousands of whitespaces on each line before the actual byte offset. It looks like this might be caused by trying to align the offset comments between lines as the issue occurs for any instructions after a large OpSource block. Disabling this code at the end of InstructionDisassembler::EmitInstructionImpl() removes the bloating:
```
if (!comments.str().empty()) {
// Align the comments
const uint32_t line_length = GetLineLengthWithoutColor(line.str());
uint32_t align = std::max(
{line_length + 2, last_instruction_comment_alignment_, kCommentColumn});
// Round up the alignment to a multiple of 4 for more niceness.
align = (align + 3) & ~0x3u;
last_instruction_comment_alignment_ = std::min({align, 256u});
stream_ << std::string(align - line_length, ' ') << "; " << comments.str();
} else {
last_instruction_comment_alignment_ = 0;
}
```
Contributor guide
Assessment
This issue has not been assessed yet.