[llvm] r235774 - AsmWriter: Only collect attachment names once per module

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri Apr 24 14:03:05 PDT 2015


Author: dexonsmith
Date: Fri Apr 24 16:03:05 2015
New Revision: 235774

URL: http://llvm.org/viewvc/llvm-project?rev=235774&view=rev
Log:
AsmWriter: Only collect attachment names once per module

Collect metadata names once per `AssemblyWriter` instead of every time
we need to print some attachments.  Just a drive-by; this caught my eye
while I was refactoring the code in r235772.

Modified:
    llvm/trunk/lib/IR/AsmWriter.cpp

Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=235774&r1=235773&r2=235774&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Fri Apr 24 16:03:05 2015
@@ -1943,6 +1943,7 @@ class AssemblyWriter {
   SetVector<const Comdat *> Comdats;
   bool ShouldPreserveUseListOrder;
   UseListOrderStack UseListOrders;
+  SmallVector<StringRef, 8> MDNames;
 
 public:
   /// Construct an AssemblyWriter with an external SlotTracker
@@ -2967,8 +2968,9 @@ void AssemblyWriter::printMetadataAttach
   if (MDs.empty())
     return;
 
-  SmallVector<StringRef, 8> MDNames;
-  TheModule->getMDKindNames(MDNames);
+  if (MDNames.empty())
+    TheModule->getMDKindNames(MDNames);
+
   for (const auto &I : MDs) {
     unsigned Kind = I.first;
     if (Kind < MDNames.size()) {





More information about the llvm-commits mailing list