[llvm-branch-commits] [llvm] aa97472 - Re-land [MC] Fix quadratic behavior in addPendingLabel
Fangrui Song via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Apr 27 17:34:10 PDT 2020
Author: Alexandre Ganea
Date: 2020-04-27T17:30:36-07:00
New Revision: aa97472d211df67e91e8c1dd3188a0fb2ff942c8
URL: https://github.com/llvm/llvm-project/commit/aa97472d211df67e91e8c1dd3188a0fb2ff942c8
DIFF: https://github.com/llvm/llvm-project/commit/aa97472d211df67e91e8c1dd3188a0fb2ff942c8.diff
LOG: Re-land [MC] Fix quadratic behavior in addPendingLabel
This was discovered when compiling large unity/blob/jumbo files.
Differential Revision: https://reviews.llvm.org/D78775
(cherry picked from commit fd773e8a51b82775f411061117173a21b500642a)
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 9e3f87565e26..701cdf30b479 100644
--- a/llvm/include/llvm/MC/MCObjectStreamer.h
+++ b/llvm/include/llvm/MC/MCObjectStreamer.h
@@ -9,6 +9,7 @@
#ifndef LLVM_MC_MCOBJECTSTREAMER_H
#define LLVM_MC_MCOBJECTSTREAMER_H
+#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCSection.h"
@@ -38,7 +39,7 @@ class MCObjectStreamer : public MCStreamer {
bool EmitEHFrame;
bool EmitDebugFrame;
SmallVector<MCSymbol *, 2> PendingLabels;
- SmallVector<MCSection*, 2> PendingLabelSections;
+ SmallSetVector<MCSection *, 4> PendingLabelSections;
unsigned CurSubsectionIdx;
struct PendingMCFixup {
const MCSymbol *Sym;
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index 3d1358df475f..e05a0ec11f56 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);
}
More information about the llvm-branch-commits
mailing list