[PATCH] D30084: [ELF] - Move DependentSections vector from InputSection to InputSectionBase
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 17 10:31:31 PST 2017
LGTM. Feel free to commit in 1 or 2 patches.
George Rimar via Phabricator <reviews at reviews.llvm.org> writes:
> grimar created this revision.
>
> I splitted it from https://reviews.llvm.org/D29273.
> Since we plan to make relocatable sections as dependent for target ones for
> --emit-relocs implementation, this change is required to support .eh_frame case.
>
> EhInputSection inherets from InputSectionBase and not from InputSection.
> So for case when it has relocation section, it should be able to access DependentSections
> vector.
>
> This case is real for Linux kernel.
>
>
> https://reviews.llvm.org/D30084
>
> Files:
> ELF/InputFiles.cpp
> ELF/InputSection.h
> ELF/LinkerScript.cpp
>
>
> Index: ELF/LinkerScript.cpp
> ===================================================================
> --- ELF/LinkerScript.cpp
> +++ ELF/LinkerScript.cpp
> @@ -277,11 +277,7 @@
> for (InputSectionBase<ELFT> *S : V) {
> S->Live = false;
> reportDiscarded(S);
> -
> - InputSection<ELFT> *IS = dyn_cast<InputSection<ELFT>>(S);
> - if (!IS || IS->DependentSections.empty())
> - continue;
> - discard(IS->DependentSections);
> + discard(S->DependentSections);
> }
> }
>
> Index: ELF/InputSection.h
> ===================================================================
> --- ELF/InputSection.h
> +++ ELF/InputSection.h
> @@ -128,6 +128,9 @@
> // this but instead this->Repl.
> InputSectionBase<ELFT> *Repl;
>
> + // InputSections that are dependent on us (reverse dependency for GC)
> + llvm::TinyPtrVector<InputSectionBase<ELFT> *> DependentSections;
> +
> // Returns the size of this section (even if this is a common or BSS.)
> size_t getSize() const;
>
> @@ -281,9 +284,6 @@
> // to. The writer sets a value.
> uint64_t OutSecOff = 0;
>
> - // InputSections that are dependent on us (reverse dependency for GC)
> - llvm::TinyPtrVector<InputSectionBase<ELFT> *> DependentSections;
> -
> static bool classof(const InputSectionData *S);
>
> InputSectionBase<ELFT> *getRelocatedSection();
> Index: ELF/InputFiles.cpp
> ===================================================================
> --- ELF/InputFiles.cpp
> +++ ELF/InputFiles.cpp
> @@ -322,8 +322,7 @@
> if (Sec.sh_link >= Sections.size())
> fatal(toString(this) + ": invalid sh_link index: " +
> Twine(Sec.sh_link));
> - auto *IS = cast<InputSection<ELFT>>(Sections[Sec.sh_link]);
> - IS->DependentSections.push_back(Sections[I]);
> + Sections[Sec.sh_link]->DependentSections.push_back(Sections[I]);
> }
> }
> }
>
>
> Index: ELF/LinkerScript.cpp
> ===================================================================
> --- ELF/LinkerScript.cpp
> +++ ELF/LinkerScript.cpp
> @@ -277,11 +277,7 @@
> for (InputSectionBase<ELFT> *S : V) {
> S->Live = false;
> reportDiscarded(S);
> -
> - InputSection<ELFT> *IS = dyn_cast<InputSection<ELFT>>(S);
> - if (!IS || IS->DependentSections.empty())
> - continue;
> - discard(IS->DependentSections);
> + discard(S->DependentSections);
> }
> }
>
> Index: ELF/InputSection.h
> ===================================================================
> --- ELF/InputSection.h
> +++ ELF/InputSection.h
> @@ -128,6 +128,9 @@
> // this but instead this->Repl.
> InputSectionBase<ELFT> *Repl;
>
> + // InputSections that are dependent on us (reverse dependency for GC)
> + llvm::TinyPtrVector<InputSectionBase<ELFT> *> DependentSections;
> +
> // Returns the size of this section (even if this is a common or BSS.)
> size_t getSize() const;
>
> @@ -281,9 +284,6 @@
> // to. The writer sets a value.
> uint64_t OutSecOff = 0;
>
> - // InputSections that are dependent on us (reverse dependency for GC)
> - llvm::TinyPtrVector<InputSectionBase<ELFT> *> DependentSections;
> -
> static bool classof(const InputSectionData *S);
>
> InputSectionBase<ELFT> *getRelocatedSection();
> Index: ELF/InputFiles.cpp
> ===================================================================
> --- ELF/InputFiles.cpp
> +++ ELF/InputFiles.cpp
> @@ -322,8 +322,7 @@
> if (Sec.sh_link >= Sections.size())
> fatal(toString(this) + ": invalid sh_link index: " +
> Twine(Sec.sh_link));
> - auto *IS = cast<InputSection<ELFT>>(Sections[Sec.sh_link]);
> - IS->DependentSections.push_back(Sections[I]);
> + Sections[Sec.sh_link]->DependentSections.push_back(Sections[I]);
> }
> }
> }
More information about the llvm-commits
mailing list