[PATCH] D78775: [MC] Fix quadratic behavior in addPendingLabel

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 24 10:16:29 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGe98f73a62907: [MC] Fix quadratic behavior in addPendingLabel() (authored by aganea).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78775/new/

https://reviews.llvm.org/D78775

Files:
  llvm/include/llvm/MC/MCObjectStreamer.h
  llvm/lib/MC/MCObjectStreamer.cpp


Index: llvm/lib/MC/MCObjectStreamer.cpp
===================================================================
--- llvm/lib/MC/MCObjectStreamer.cpp
+++ llvm/lib/MC/MCObjectStreamer.cpp
@@ -59,12 +59,8 @@
     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);
 }
Index: llvm/include/llvm/MC/MCObjectStreamer.h
===================================================================
--- llvm/include/llvm/MC/MCObjectStreamer.h
+++ llvm/include/llvm/MC/MCObjectStreamer.h
@@ -38,7 +38,7 @@
   bool EmitEHFrame;
   bool EmitDebugFrame;
   SmallVector<MCSymbol *, 2> PendingLabels;
-  SmallVector<MCSection*, 2> PendingLabelSections;
+  SmallPtrSet<MCSection *, 4> PendingLabelSections;
   unsigned CurSubsectionIdx;
   struct PendingMCFixup {
     const MCSymbol *Sym;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78775.259919.patch
Type: text/x-patch
Size: 1209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200424/ec2cce9c/attachment.bin>


More information about the llvm-commits mailing list