[llvm] fix wrong inline assembly line/col info in the error message with ThinLTO (PR #102211)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 8 19:24:30 PDT 2024


MaskRay wrote:

Thanks for the patch! The original filename is "<inline asm>", technically correct.
The new source filename for the debug info case is significantly more helpful.

```
% fclang -c x.cpp
x.cpp:3:17: error: unknown token in expression
    3 |                 "BAD SYNTAX$%");
      |                 ^
<inline asm>:1:14: note: instantiated into assembly here
    1 |         BAD SYNTAX$%
      |                     ^
% fclang -c x.cpp -flto=thin
% fld.lld -shared x.o
ld.lld: error: x.o <inline asm>:1:14: unknown token in expression
        BAD SYNTAX$%
                    ^

```

The first two test cases might be redundant

If the string is not on the same line as `asm`, the current filename:line is actually incorrect.
The column information is used to display `~~^`, but is not correct beside filename:line.

```cpp
void bad_multi_asm() {
  asm ( 
        "movl $10, %eax;"
        "BAD SYNTAX;"
        "subl %ebx, %eax;" );
}
```
```
ld.lld: error: x.o x.cpp:2:19: invalid instruction mnemonic 'bad'
        movl $10, %eax;BAD SYNTAX;subl %ebx, %eax;
                       ~~^
```


https://github.com/llvm/llvm-project/pull/102211


More information about the llvm-commits mailing list