[llvm] 65fe71b - Revert "[MC] Fix quadratic behavior in addPendingLabel()"

Alexandre Ganea via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 24 13:43:41 PDT 2020


Author: Alexandre Ganea
Date: 2020-04-24T16:43:10-04:00
New Revision: 65fe71be48d6b4a98a711a867d42e09c5868f1d6

URL: https://github.com/llvm/llvm-project/commit/65fe71be48d6b4a98a711a867d42e09c5868f1d6
DIFF: https://github.com/llvm/llvm-project/commit/65fe71be48d6b4a98a711a867d42e09c5868f1d6.diff

LOG: Revert "[MC] Fix quadratic behavior in addPendingLabel()"

This reverts commit e98f73a629075ae3b9c4d5317bead5a122d69865.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCObjectStreamer.h b/llvm/include/llvm/MC/MCObjectStreamer.h
index 754b7e83135e..48d00fab2fa9 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<MCSymbol *, 2> PendingLabels;
-  SmallPtrSet<MCSection *, 4> PendingLabelSections;
+  SmallVector<MCSection*, 2> PendingLabelSections;
   unsigned CurSubsectionIdx;
   struct PendingMCFixup {
     const MCSymbol *Sym;

diff  --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index fd4422fc368c..5bb8e76713fb 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -59,8 +59,12 @@ void MCObjectStreamer::addPendingLabel(MCSymbol* S) {
     CurSection->addPendingLabel(S, CurSubsectionIdx);
 
     // Add this Section to the list of PendingLabelSections.
-    PendingLabelSections.insert(CurSection);
-  } else
+    auto SecIt = std::find(PendingLabelSections.begin(),
+                           PendingLabelSections.end(), CurSection);
+    if (SecIt == PendingLabelSections.end())
+      PendingLabelSections.push_back(CurSection);
+  }
+  else
     // There is no Section / Subsection for this label yet.
     PendingLabels.push_back(S);
 }


        


More information about the llvm-commits mailing list