[PATCH] D70720: [llvm-objdump] Display locations of variables alongside disassembly
Oliver Stannard (Linaro) via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 03:54:03 PST 2020
ostannard marked 6 inline comments as done.
ostannard added inline comments.
================
Comment at: llvm/lib/Support/FormattedStream.cpp:45
+
++Column;
+
----------------
MaskRay wrote:
> This is incorrect due to East Asian Width.... http://www.unicode.org/reports/tr11/tr11-36.html
>
> ```lang=cpp
> % cat a.cc
> int main() {
> int 喵🙂 = 0;
> int 喵喵🙂 = 15;
> int 喵🙂喵🙂 = 24;
> 喵🙂 = 28;
> 喵喵🙂 = 32;
> }
> % clang -c a.cc
> % llvm-objdump -S --no-show-raw-insn --debug-vars a.o
>
> a.o: file format elf64-x86-64
>
>
> Disassembly of section .text:
>
> 0000000000000000 main:
> ; int main() { ┠─ 喵🙂 = <unknown op DW_OP_fbreg (145)>
> ┃ ┠─ 喵喵🙂 = <unknown op DW_OP_fbreg (145)>
> ┃ ┃ ┠─ 喵🙂喵🙂 = <unknown op DW_OP_fbreg (145)>
> 0: pushq %rbp ┃ ┃ ┃
> 1: movq %rsp, %rbp ┃ ┃ ┃
> 4: xorl %eax, %eax ┃ ┃ ┃
> ; int 喵🙂 = 0; ┃ ┃ ┃
> 6: movl $0, -4(%rbp) ┃ ┃ ┃
> ; int 喵喵🙂 = 15; ┃ ┃ ┃
> d: movl $15, -8(%rbp) ┃ ┃ ┃
> ; int 喵🙂喵🙂 = 24; ┃ ┃ ┃
> 14: movl $24, -12(%rbp) ┃ ┃ ┃
> ; 喵🙂 = 28; ┃ ┃ ┃
> 1b: movl $28, -4(%rbp) ┃ ┃ ┃
> ; 喵喵🙂 = 32; ┃ ┃ ┃
> 22: movl $32, -8(%rbp) ┃ ┃ ┃
> ; } ┃ ┃ ┃
> 29: popq %rbp ┃ ┃ ┃
> 2a: retq ┻ ┻ ┻
> ```
>
There's some code in the Support library which does this, which also simplifies this function a bit. It handles east asian characters correctly (at least the ones in your example), but doesn't get the correct widths for emojis. Clang seems to handle emojis by printing a hex value which it knows the length of:
$ /work/llvm/build/bin/clang -fsyntax-only -c width.c
width.c:1:15: error: use of undeclared identifier 'a'
int 喵<U+1F642> = a;
^
1 error generated.
Fixing that is going to be a lot of work, and isn't related to this patch, so I'll just make it work for characters supported by the existing unicode support library for now.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70720/new/
https://reviews.llvm.org/D70720
More information about the llvm-commits
mailing list