diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/MC/MCSection.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/MC/MCSection.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/contrib/llvm-project/llvm/lib/MC/MCSection.cpp b/contrib/llvm-project/llvm/lib/MC/MCSection.cpp index 2c892ab81608..074534bd73db 100644 --- a/contrib/llvm-project/llvm/lib/MC/MCSection.cpp +++ b/contrib/llvm-project/llvm/lib/MC/MCSection.cpp @@ -22,8 +22,7 @@ using namespace llvm; MCSection::MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin) : Begin(Begin), BundleGroupBeforeFirstInst(false), HasInstructions(false), - HasData(false), IsRegistered(false), DummyFragment(this), Variant(V), - Kind(K) {} + IsRegistered(false), DummyFragment(this), Variant(V), Kind(K) {} MCSymbol *MCSection::getEndSymbol(MCContext &Ctx) { if (!End) @@ -86,6 +85,41 @@ MCSection::getSubsectionInsertionPoint(unsigned Subsection) { return IP; } +void MCSection::addPendingLabel(MCSymbol* label, unsigned Subsection) { + PendingLabels.push_back(PendingLabel(label, Subsection)); +} + +void MCSection::flushPendingLabels(MCFragment *F, uint64_t FOffset, + unsigned Subsection) { + if (PendingLabels.empty()) + return; + + // Set the fragment and fragment offset for all pending symbols in the + // specified Subsection, and remove those symbols from the pending list. + for (auto It = PendingLabels.begin(); It != PendingLabels.end(); ++It) { + PendingLabel& Label = *It; + if (Label.Subsection == Subsection) { + Label.Sym->setFragment(F); + Label.Sym->setOffset(FOffset); + PendingLabels.erase(It--); + } + } +} + +void MCSection::flushPendingLabels() { + // Make sure all remaining pending labels point to data fragments, by + // creating new empty data fragments for each Subsection with labels pending. + while (!PendingLabels.empty()) { + PendingLabel& Label = PendingLabels[0]; + iterator CurInsertionPoint = + this->getSubsectionInsertionPoint(Label.Subsection); + MCFragment *F = new MCDataFragment(); + getFragmentList().insert(CurInsertionPoint, F); + F->setParent(this); + flushPendingLabels(F, 0, Label.Subsection); + } +} + #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void MCSection::dump() const { raw_ostream &OS = errs(); |