From: Duncan P. N. Exon Smith Date: Fri, 24 Apr 2015 21:03:05 +0000 (+0000) Subject: AsmWriter: Only collect attachment names once per module X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c8be244db70dfc071528c5b4e9387df91f2b0031;p=oota-llvm.git 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235774 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp index 7d0422d8c0a..54a370d08fb 100644 --- a/lib/IR/AsmWriter.cpp +++ b/lib/IR/AsmWriter.cpp @@ -1943,6 +1943,7 @@ class AssemblyWriter { SetVector Comdats; bool ShouldPreserveUseListOrder; UseListOrderStack UseListOrders; + SmallVector MDNames; public: /// Construct an AssemblyWriter with an external SlotTracker @@ -2967,8 +2968,9 @@ void AssemblyWriter::printMetadataAttachments( if (MDs.empty()) return; - SmallVector MDNames; - TheModule->getMDKindNames(MDNames); + if (MDNames.empty()) + TheModule->getMDKindNames(MDNames); + for (const auto &I : MDs) { unsigned Kind = I.first; if (Kind < MDNames.size()) {