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 /llvm/lib/CodeGen/MachineModuleInfo.cpp | |
parent | 4abfe47e1fc8b4c7583d5bdcb20d102dd2a5efb1 (diff) | |
download | llvm-33b38339a0961c04ce32a6656aa54293d5ca4790.zip llvm-33b38339a0961c04ce32a6656aa54293d5ca4790.tar.gz llvm-33b38339a0961c04ce32a6656aa54293d5ca4790.tar.bz2 |
[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 'llvm/lib/CodeGen/MachineModuleInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineModuleInfo.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp index 50cbb14e..31d4fc7 100644 --- a/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -400,12 +400,14 @@ bool MachineModuleInfoWrapperPass::doInitialization(Module &M) { // FIXME: Do this for new pass manager. LLVMContext &Ctx = M.getContext(); MMI.getContext().setDiagnosticHandler( - [&Ctx](const SMDiagnostic &SMD, bool IsInlineAsm, const SourceMgr &SrcMgr, - std::vector<const MDNode *> &LocInfos) { + [&Ctx, &M](const SMDiagnostic &SMD, bool IsInlineAsm, + const SourceMgr &SrcMgr, + std::vector<const MDNode *> &LocInfos) { unsigned LocCookie = 0; if (IsInlineAsm) LocCookie = getLocCookie(SMD, SrcMgr, LocInfos); - Ctx.diagnose(DiagnosticInfoSrcMgr(SMD, IsInlineAsm, LocCookie)); + Ctx.diagnose( + DiagnosticInfoSrcMgr(SMD, M.getName(), IsInlineAsm, LocCookie)); }); MMI.DbgInfoAvailable = !M.debug_compile_units().empty(); return false; |