diff options
author | paperchalice <liujunchang97@outlook.com> | 2024-04-13 18:45:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-13 18:45:37 +0800 |
commit | f6ca37bf1809b2fa8f6615d4a30eadf8f479c700 (patch) | |
tree | 8d57713d5ae4896e74ee46711b5e1bdc113f2d82 /llvm/lib/CodeGen/MachineModuleInfo.cpp | |
parent | 6775285e7695f2d45cf455f5d31b2c9fa9362d3d (diff) | |
download | llvm-f6ca37bf1809b2fa8f6615d4a30eadf8f479c700.zip llvm-f6ca37bf1809b2fa8f6615d4a30eadf8f479c700.tar.gz llvm-f6ca37bf1809b2fa8f6615d4a30eadf8f479c700.tar.bz2 |
[NewPM] Set diagnostic handler in `MachineModuleAnalysis` (#88229)
`setDiagnosticHandler` is idempotent.
Diffstat (limited to 'llvm/lib/CodeGen/MachineModuleInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineModuleInfo.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp index f24288b..1dba591 100644 --- a/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -213,7 +213,6 @@ static unsigned getLocCookie(const SMDiagnostic &SMD, const SourceMgr &SrcMgr, bool MachineModuleInfoWrapperPass::doInitialization(Module &M) { MMI.initialize(); MMI.TheModule = &M; - // FIXME: Do this for new pass manager. LLVMContext &Ctx = M.getContext(); MMI.getContext().setDiagnosticHandler( [&Ctx, &M](const SMDiagnostic &SMD, bool IsInlineAsm, @@ -240,6 +239,17 @@ AnalysisKey MachineModuleAnalysis::Key; MachineModuleAnalysis::Result MachineModuleAnalysis::run(Module &M, ModuleAnalysisManager &) { MMI.TheModule = &M; + LLVMContext &Ctx = M.getContext(); + MMI.getContext().setDiagnosticHandler( + [&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, M.getName(), IsInlineAsm, LocCookie)); + }); MMI.DbgInfoAvailable = !DisableDebugInfoPrinting && !M.debug_compile_units().empty(); return Result(MMI); |