COFF: Handle all COMDAT sections as non-GC root.

I don't remember why I thought that only functions are subject
of garbage collection, but the comment here said so, which is
not correct. Moreover, the code just below the comment does not
do what the comment says -- it handles non-COMDAT, non-function
sections as GC root. As a result, it just handles non-COMDAT
sections as GC root.

This patch cleans that up by removing SectionChunk::isRoot and
use isCOMDAT instead.

llvm-svn: 243700
This commit is contained in:
Rui Ueyama 2015-07-30 22:48:45 +00:00
parent 10ed6c361c
commit f69ecc1212
3 changed files with 1 additions and 10 deletions

View File

@ -39,10 +39,6 @@ SectionChunk::SectionChunk(ObjectFile *F, const coff_section *H)
unsigned Shift = (Header->Characteristics >> 20) & 0xF;
if (Shift > 0)
Align = uint32_t(1) << (Shift - 1);
// COMDAT sections are not GC root. Non-text sections are not
// subject of garbage collection (thus they are root).
Root = !isCOMDAT() && !(Header->Characteristics & IMAGE_SCN_CNT_CODE);
}
static void add16(uint8_t *P, int16_t V) { write16le(P, read16le(P) + V); }
@ -150,9 +146,6 @@ void SectionChunk::writeTo(uint8_t *Buf) {
void SectionChunk::addAssociative(SectionChunk *Child) {
AssocChildren.push_back(Child);
// Associative sections are live if their parent COMDATs are live,
// and vice versa, so they are not considered live by themselves.
Child->Root = false;
}
static uint8_t getBaserelType(const coff_relocation &Rel) {

View File

@ -153,7 +153,6 @@ public:
void setSymbol(DefinedRegular *S) { if (!Sym) Sym = S; }
// Used by the garbage collector.
bool isRoot() { return Root; }
bool isLive() { return Live; }
void markLive() {
assert(!Live && "Cannot mark an already live section!");
@ -194,7 +193,6 @@ private:
// Used by the garbage collector.
bool Live = false;
bool Root;
// Chunks are basically unnamed chunks of bytes.
// Symbols are associated for debugging and logging purposs only.

View File

@ -132,7 +132,7 @@ void Writer::markLive() {
}
for (Chunk *C : Symtab->getChunks()) {
auto *SC = dyn_cast<SectionChunk>(C);
if (!SC || !SC->isRoot() || SC->isLive())
if (!SC || SC->isCOMDAT() || SC->isLive())
continue;
SC->markLive();
Worklist.push_back(SC);