[PATCH] D142699: [AsmParser] Avoid instantiating LLVMContext if not needed. NFC

Yevgeny Rouban via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 27 05:19:12 PST 2023


yrouban updated this revision to Diff 492712.
yrouban marked an inline comment as done.
yrouban added a comment.

accepted the suggested snippet.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142699/new/

https://reviews.llvm.org/D142699

Files:
  llvm/lib/AsmParser/Parser.cpp


Index: llvm/lib/AsmParser/Parser.cpp
===================================================================
--- llvm/lib/AsmParser/Parser.cpp
+++ llvm/lib/AsmParser/Parser.cpp
@@ -28,9 +28,9 @@
   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);
 }



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142699.492712.patch
Type: text/x-patch
Size: 614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230127/79d69bd1/attachment.bin>


More information about the llvm-commits mailing list