From e98f73a629075ae3b9c4d5317bead5a122d69865 Mon Sep 17 00:00:00 2001 From: Alexandre Ganea Date: Fri, 24 Apr 2020 12:48:39 -0400 Subject: [PATCH] [MC] Fix quadratic behavior in addPendingLabel() Differential Revision: https://reviews.llvm.org/D78775 --- llvm/include/llvm/MC/MCObjectStreamer.h | 2 +- llvm/lib/MC/MCObjectStreamer.cpp | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/llvm/include/llvm/MC/MCObjectStreamer.h b/llvm/include/llvm/MC/MCObjectStreamer.h index 48d00fa..754b7e8 100644 --- a/llvm/include/llvm/MC/MCObjectStreamer.h +++ b/llvm/include/llvm/MC/MCObjectStreamer.h @@ -38,7 +38,7 @@ class MCObjectStreamer : public MCStreamer { bool EmitEHFrame; bool EmitDebugFrame; SmallVector PendingLabels; - SmallVector PendingLabelSections; + SmallPtrSet PendingLabelSections; unsigned CurSubsectionIdx; struct PendingMCFixup { const MCSymbol *Sym; diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 5bb8e76..fd4422f 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -59,12 +59,8 @@ void MCObjectStreamer::addPendingLabel(MCSymbol* S) { CurSection->addPendingLabel(S, CurSubsectionIdx); // Add this Section to the list of PendingLabelSections. - auto SecIt = std::find(PendingLabelSections.begin(), - PendingLabelSections.end(), CurSection); - if (SecIt == PendingLabelSections.end()) - PendingLabelSections.push_back(CurSection); - } - else + PendingLabelSections.insert(CurSection); + } else // There is no Section / Subsection for this label yet. PendingLabels.push_back(S); } -- 2.7.4