From: Peter Collingbourne Date: Mon, 27 Nov 2017 20:42:34 +0000 (+0000) Subject: COFF: Do not create SectionChunks for discarded comdat sections. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e70082a17201807d3e6066cbac1cc982a707750;p=llvm COFF: Do not create SectionChunks for discarded comdat sections. With this change, instead of creating a SectionChunk for each section in the object file, we only create them when we encounter a prevailing comdat section. Also change how symbol resolution occurs between comdat symbols. Now only the comdat leader participates in comdat resolution, and not any other external associated symbols. This is more in line with how COFF semantics are defined, and should allow for a more straightforward implementation of non-ANY comdat types. On my machine, this change reduces our runtime linking a release build of chrome_child.dll with /nopdb from 5.65s to 4.54s (median of 50 runs). Differential Revision: https://reviews.llvm.org/D40238 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319090 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index 3ad60b05b6f..2fb896eed97 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -275,6 +275,8 @@ struct coff_symbol_generic { support::ulittle32_t Value; }; +struct coff_aux_section_definition; + class COFFSymbolRef { public: COFFSymbolRef() = default; @@ -346,6 +348,18 @@ public: return (getType() & 0xF0) >> COFF::SCT_COMPLEX_TYPE_SHIFT; } + template const T *getAux() const { + return CS16 ? reinterpret_cast(CS16 + 1) + : reinterpret_cast(CS32 + 1); + } + + const coff_aux_section_definition *getSectionDefinition() const { + if (!getNumberOfAuxSymbols() || + getStorageClass() != COFF::IMAGE_SYM_CLASS_STATIC) + return nullptr; + return getAux(); + } + bool isAbsolute() const { return getSectionNumber() == -1; }