[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 02:35:38 PST 2023


yrouban created this revision.
yrouban added reviewers: efriedma, jsilvanus, tejohnson.
Herald added a subscriber: hiraditya.
Herald added a project: All.
yrouban requested review of this revision.
Herald added a project: LLVM.

Instantiating an LLVMContext might be uneasy task.


Repository:
  rG LLVM Github Monorepo

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,12 @@
   std::unique_ptr<MemoryBuffer> 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);
 }



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


More information about the llvm-commits mailing list