aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/ModuleSymbolTable.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-12-25 13:49:57 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-12-25 13:49:57 +0000
commit99aabd70801bd4bc72c4942747f6d62c675112f5 (patch)
tree02bf056e9098f5ecddc7f18a99db9c79f4404b02 /llvm/lib/Object/ModuleSymbolTable.cpp
parent312c0ed19cc5276a17bacf2120097bec4515b0f1 (diff)
Diffstat (limited to 'llvm/lib/Object/ModuleSymbolTable.cpp')
-rw-r--r--llvm/lib/Object/ModuleSymbolTable.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp b/llvm/lib/Object/ModuleSymbolTable.cpp
index ab073e18cb46..07f76688fa43 100644
--- a/llvm/lib/Object/ModuleSymbolTable.cpp
+++ b/llvm/lib/Object/ModuleSymbolTable.cpp
@@ -16,6 +16,7 @@
#include "RecordStreamer.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalValue.h"
@@ -68,6 +69,11 @@ void ModuleSymbolTable::addModule(Module *M) {
static void
initializeRecordStreamer(const Module &M,
function_ref<void(RecordStreamer &)> Init) {
+ // This function may be called twice, once for ModuleSummaryIndexAnalysis and
+ // the other when writing the IR symbol table. If parsing inline assembly has
+ // caused errors in the first run, suppress the second run.
+ if (M.getContext().getDiagHandlerPtr()->HasErrors)
+ return;
StringRef InlineAsm = M.getModuleInlineAsm();
if (InlineAsm.empty())
return;
@@ -95,7 +101,8 @@ initializeRecordStreamer(const Module &M,
if (!MCII)
return;
- std::unique_ptr<MemoryBuffer> Buffer(MemoryBuffer::getMemBuffer(InlineAsm));
+ std::unique_ptr<MemoryBuffer> Buffer(
+ MemoryBuffer::getMemBuffer(InlineAsm, "<inline asm>"));
SourceMgr SrcMgr;
SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
@@ -115,6 +122,13 @@ initializeRecordStreamer(const Module &M,
if (!TAP)
return;
+ MCCtx.setDiagnosticHandler([&](const SMDiagnostic &SMD, bool IsInlineAsm,
+ const SourceMgr &SrcMgr,
+ std::vector<const MDNode *> &LocInfos) {
+ M.getContext().diagnose(
+ DiagnosticInfoSrcMgr(SMD, M.getName(), IsInlineAsm, /*LocCookie=*/0));
+ });
+
// Module-level inline asm is assumed to use At&t syntax (see
// AsmPrinter::doInitialization()).
Parser->setAssemblerDialect(InlineAsm::AD_ATT);