[llvm] c1888a3 - [AsmParser] Avoid instantiating LLVMContext if not needed. NFC
Yevgeny Rouban via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 20 00:57:22 PDT 2023
Author: Yevgeny Rouban
Date: 2023-03-20T14:56:57+07:00
New Revision: c1888a370ada6e76d51cdb9c6eeefa2588a475eb
URL: https://github.com/llvm/llvm-project/commit/c1888a370ada6e76d51cdb9c6eeefa2588a475eb
DIFF: https://github.com/llvm/llvm-project/commit/c1888a370ada6e76d51cdb9c6eeefa2588a475eb.diff
LOG: [AsmParser] Avoid instantiating LLVMContext if not needed. NFC
Differential Revision: https://reviews.llvm.org/D142699
Added:
Modified:
llvm/lib/AsmParser/Parser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/AsmParser/Parser.cpp b/llvm/lib/AsmParser/Parser.cpp
index 035eea81378e5..eded892f358a8 100644
--- a/llvm/lib/AsmParser/Parser.cpp
+++ b/llvm/lib/AsmParser/Parser.cpp
@@ -28,9 +28,9 @@ static bool parseAssemblyInto(MemoryBufferRef F, Module *M,
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(F);
SM.AddNewSourceBuffer(std::move(Buf), SMLoc());
- LLVMContext Context;
+ std::optional<LLVMContext> OptContext;
return LLParser(F.getBuffer(), SM, Err, M, Index,
- M ? M->getContext() : Context, Slots)
+ M ? M->getContext() : OptContext.emplace(), Slots)
.Run(UpgradeDebugInfo, DataLayoutCallback);
}
More information about the llvm-commits
mailing list