diff options
author | Fangrui Song <i@maskray.me> | 2022-01-28 11:32:42 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-01-28 11:32:42 -0800 |
commit | 33b38339a0961c04ce32a6656aa54293d5ca4790 (patch) | |
tree | cd4b6dd4207541ae28b8a88cd5bb606c16eb50fb /lld/Common | |
parent | 4abfe47e1fc8b4c7583d5bdcb20d102dd2a5efb1 (diff) | |
download | llvm-33b38339a0961c04ce32a6656aa54293d5ca4790.tar.gz |
[lld] Add module name to LTO inline asm diagnostic
Close #52781: for LTO, the inline asm diagnostic uses `<inline asm>` as the file
name (lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp) and it is unclear which
module has the issue.
With this patch, we will see the module name (say `asm.o`) before `<inline asm>` with ThinLTO.
```
% clang -flto=thin -c asm.c && myld.lld asm.o -e f
ld.lld: error: asm.o <inline asm>:1:2: invalid instruction mnemonic 'invalid'
invalid
^~~~~~~
```
For regular LTO, unfortunately the original module name is lost and we only get
ld-temp.o.
Reviewed By: #lld-macho, ychen, Jez Ng
Differential Revision: https://reviews.llvm.org/D118434
Diffstat (limited to 'lld/Common')
-rw-r--r-- | lld/Common/ErrorHandler.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lld/Common/ErrorHandler.cpp b/lld/Common/ErrorHandler.cpp index 15b3bd058ee9..e557e533dedc 100644 --- a/lld/Common/ErrorHandler.cpp +++ b/lld/Common/ErrorHandler.cpp @@ -107,6 +107,13 @@ void lld::diagnosticHandler(const DiagnosticInfo &di) { SmallString<128> s; raw_svector_ostream os(s); DiagnosticPrinterRawOStream dp(os); + + // For an inline asm diagnostic, prepend the module name to get something like + // "$module <inline asm>:1:5: ". + if (auto *dism = dyn_cast<DiagnosticInfoSrcMgr>(&di)) + if (dism->isInlineAsmDiag()) + os << dism->getModuleName() << ' '; + di.print(dp); switch (di.getSeverity()) { case DS_Error: |