Skip to content

Commit

Permalink
[Object] make SourceMgr available to MCContext during inline asm symbols
Browse files Browse the repository at this point in the history
collection

Fixes PR51210.
  • Loading branch information
Yuanfang Chen committed Jul 26, 2021
1 parent 0d3e4d9 commit 1558bb8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions llvm/lib/Object/ModuleSymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,18 @@ initializeRecordStreamer(const Module &M,
if (!MCII)
return;

MCContext MCCtx(TT, MAI.get(), MRI.get(), STI.get());
std::unique_ptr<MemoryBuffer> Buffer(MemoryBuffer::getMemBuffer(InlineAsm));
SourceMgr SrcMgr;
SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());

MCContext MCCtx(TT, MAI.get(), MRI.get(), STI.get(), &SrcMgr);
std::unique_ptr<MCObjectFileInfo> MOFI(
T->createMCObjectFileInfo(MCCtx, /*PIC=*/false));
MOFI->setSDKVersion(M.getSDKVersion());
MCCtx.setObjectFileInfo(MOFI.get());
RecordStreamer Streamer(MCCtx, M);
T->createNullTargetStreamer(Streamer);

std::unique_ptr<MemoryBuffer> Buffer(MemoryBuffer::getMemBuffer(InlineAsm));
SourceMgr SrcMgr;
SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
std::unique_ptr<MCAsmParser> Parser(
createMCAsmParser(SrcMgr, MCCtx, Streamer, *MAI));

Expand Down

0 comments on commit 1558bb8

Please sign in to comment.