[llvm] [DWARF] Use ULEB128 and not just one byte for directory indices (PR #109067)
Daniel RodrÃguez Troitiño via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 10:54:20 PDT 2024
drodriguez wrote:
> Given that we know the number of indices, we could always emit the most efficient encoding. That said, we're emitting this only once per line table, so I'm not particularly worried about the additional byte and simplifies the implementation. LGTM.
I was striving for implementation simplicity. I started to think about a better implementation with different formats, but I did not see clearly how it would be better.
```
| Range | data1 | data2 | udata |
| 0-127 | 1 byte * | 2 bytes | 1 byte * |
| 128-255 | 1 byte * | 2 bytes | 2 bytes |
| 255-16383 | NA | 2 bytes * | 2 bytes * |
| 16384-65535 | NA | 2 bytes * | 3 bytes |
| 65536-2097151 | NA | NA | 3 bytes * |
```
One thing to notice is that one can use the range to choose a format, and that works for getting the best format for 0-16383, but for 16384-65536, one needs to calculate the distribution of indices to see if the udata encoding or the data2 encoding will be smaller.
https://github.com/llvm/llvm-project/pull/109067
More information about the llvm-commits
mailing list