diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -1681,7 +1681,7 @@ for (InputFile *file : lto->compile()) { auto *obj = cast>(file); - obj->parse(/*ignoreComdats=*/true); + obj->parse(); for (Symbol *sym : obj->getGlobalSymbols()) sym->parseSymbolVersion(); objectFiles.push_back(file); diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h --- a/lld/ELF/InputFiles.h +++ b/lld/ELF/InputFiles.h @@ -203,7 +203,7 @@ this->archiveName = std::string(archiveName); } - void parse(bool ignoreComdats = false); + void parse(); StringRef getShtGroupSignature(ArrayRef sections, const Elf_Shdr &sec); @@ -254,7 +254,7 @@ DWARFCache *getDwarf(); private: - void initializeSections(bool ignoreComdats); + void initializeSections(); void initializeSymbols(); void initializeJustSymbols(); diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -389,12 +389,12 @@ return makeArrayRef(this->symbols).slice(this->firstGlobal); } -template void ObjFile::parse(bool ignoreComdats) { +template void ObjFile::parse() { // Read a section table. justSymbols is usually false. if (this->justSymbols) initializeJustSymbols(); else - initializeSections(ignoreComdats); + initializeSections(); // Read a symbol table. initializeSymbols(); @@ -544,8 +544,7 @@ prev->nextInSectionGroup = head; } -template -void ObjFile::initializeSections(bool ignoreComdats) { +template void ObjFile::initializeSections() { const ELFFile &obj = this->getObj(); ArrayRef objSections = CHECK(obj.sections(), this); @@ -606,11 +605,8 @@ if (entries[0] != GRP_COMDAT) fatal(toString(this) + ": unsupported SHT_GROUP format"); - bool isNew = - ignoreComdats || - symtab->comdatGroups.try_emplace(CachedHashStringRef(signature), this) - .second; - if (isNew) { + if (symtab->comdatGroups.try_emplace(CachedHashStringRef(signature), this) + .second) { if (config->relocatable) this->sections[i] = createInputSection(sec); selectedGroups.push_back(entries); diff --git a/lld/test/ELF/lto/comdat.ll b/lld/test/ELF/lto/comdat.ll --- a/lld/test/ELF/lto/comdat.ll +++ b/lld/test/ELF/lto/comdat.ll @@ -5,11 +5,11 @@ ; CHECK: Name: foo ; CHECK-NEXT: Value: -; CHECK-NEXT: Size: 1 +; CHECK-NEXT: Size: 0 ; CHECK-NEXT: Binding: Global ; CHECK-NEXT: Type: Function ; CHECK-NEXT: Other: 0 -; CHECK-NEXT: Section: .text +; CHECK-NEXT: Section: Undefined target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" @@ -18,4 +18,3 @@ define void @foo() comdat { ret void } - diff --git a/lld/test/ELF/lto/comdat2.ll b/lld/test/ELF/lto/comdat2.ll --- a/lld/test/ELF/lto/comdat2.ll +++ b/lld/test/ELF/lto/comdat2.ll @@ -23,13 +23,13 @@ ; CHECK: Symbol { ; CHECK: Name: foo ; CHECK-NEXT: Value: -; CHECK-NEXT: Size: 1 +; CHECK-NEXT: Size: 0 ; CHECK-NEXT: Binding: Global ; CHECK-NEXT: Type: Function ; CHECK-NEXT: Other [ ; CHECK-NEXT: STV_PROTECTED ; CHECK-NEXT: ] -; CHECK-NEXT: Section: .text +; CHECK-NEXT: Section: Undefined ; CHECK-NEXT: } ; OTHER: Symbol { diff --git a/lld/wasm/InputFiles.h b/lld/wasm/InputFiles.h --- a/lld/wasm/InputFiles.h +++ b/lld/wasm/InputFiles.h @@ -95,7 +95,7 @@ } static bool classof(const InputFile *f) { return f->kind() == ObjectKind; } - void parse(bool ignoreComdats = false); + void parse(); // Returns the underlying wasm file. const WasmObjectFile *getWasmObj() const { return wasmObj.get(); } diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -248,7 +248,7 @@ } } -void ObjFile::parse(bool ignoreComdats) { +void ObjFile::parse() { // Parse a memory buffer as a wasm file. LLVM_DEBUG(dbgs() << "Parsing object: " << toString(this) << "\n"); std::unique_ptr bin = CHECK(createBinary(mb), toString(this)); @@ -313,8 +313,7 @@ ArrayRef comdats = wasmObj->linkingData().Comdats; for (StringRef comdat : comdats) { - bool isNew = ignoreComdats || symtab->addComdat(comdat); - keptComdats.push_back(isNew); + keptComdats.push_back(symtab->addComdat(comdat)); } // Populate `Segments`. diff --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp --- a/lld/wasm/SymbolTable.cpp +++ b/lld/wasm/SymbolTable.cpp @@ -53,7 +53,7 @@ // Regular object file auto *f = cast(file); - f->parse(false); + f->parse(); objectFiles.push_back(f); } @@ -78,7 +78,7 @@ for (StringRef filename : lto->compile()) { auto *obj = make(MemoryBufferRef(filename, "lto.tmp"), ""); - obj->parse(true); + obj->parse(); objectFiles.push_back(obj); } }