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

Yevgeny Rouban via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 01:37:29 PST 2023


yrouban updated this revision to Diff 493238.
yrouban added a comment.

I have added the diff with its full context.


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.493238.patch
Type: text/x-patch
Size: 616 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230130/b480307d/attachment-0001.bin>


More information about the llvm-commits mailing list