diff --git a/llvm/lib/AsmParser/Parser.cpp b/llvm/lib/AsmParser/Parser.cpp --- a/llvm/lib/AsmParser/Parser.cpp +++ b/llvm/lib/AsmParser/Parser.cpp @@ -28,9 +28,12 @@ std::unique_ptr Buf = MemoryBuffer::getMemBuffer(F); SM.AddNewSourceBuffer(std::move(Buf), SMLoc()); + if (M) + return LLParser(F.getBuffer(), SM, Err, M, Index, M->getContext(), Slots) + .Run(UpgradeDebugInfo, DataLayoutCallback); + LLVMContext Context; - return LLParser(F.getBuffer(), SM, Err, M, Index, - M ? M->getContext() : Context, Slots) + return LLParser(F.getBuffer(), SM, Err, M, Index, Context, Slots) .Run(UpgradeDebugInfo, DataLayoutCallback); }