Index: lld/trunk/ELF/InputFiles.cpp =================================================================== --- lld/trunk/ELF/InputFiles.cpp +++ lld/trunk/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>(Sections[Sec.sh_link]); - IS->DependentSections.push_back(Sections[I]); + Sections[Sec.sh_link]->DependentSections.push_back(Sections[I]); } } } Index: lld/trunk/ELF/InputSection.h =================================================================== --- lld/trunk/ELF/InputSection.h +++ lld/trunk/ELF/InputSection.h @@ -128,6 +128,9 @@ // this but instead this->Repl. InputSectionBase *Repl; + // InputSections that are dependent on us (reverse dependency for GC) + llvm::TinyPtrVector *> 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 *> DependentSections; - static bool classof(const InputSectionData *S); InputSectionBase *getRelocatedSection(); Index: lld/trunk/ELF/LinkerScript.cpp =================================================================== --- lld/trunk/ELF/LinkerScript.cpp +++ lld/trunk/ELF/LinkerScript.cpp @@ -298,11 +298,7 @@ S->Live = false; if (S == In::ShStrTab) error("discarding .shstrtab section is not allowed"); - - InputSection *IS = dyn_cast>(S); - if (!IS || IS->DependentSections.empty()) - continue; - discard(IS->DependentSections); + discard(S->DependentSections); } }