COFF: Support isa<> for Symbol::Body, whose type is std::atomic<SymbolBody *>.

llvm-svn: 241477
This commit is contained in:
Rui Ueyama 2015-07-06 17:45:22 +00:00
parent e2d75239d1
commit 183f53fd22
4 changed files with 20 additions and 11 deletions

View File

@ -220,7 +220,7 @@ StringRef LinkerDriver::findDefaultEntry() {
};
for (auto E : Entries) {
Symbol *Sym = Symtab.find(E[0]);
if (Sym && !isa<Undefined>(Sym->Body.load()))
if (Sym && !isa<Undefined>(Sym->Body))
return E[1];
}
return "";
@ -591,7 +591,7 @@ bool LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) {
Symbol *Sym = Symtab.find(From);
if (!Sym)
continue;
if (auto *U = dyn_cast<Undefined>(Sym->Body.load()))
if (auto *U = dyn_cast<Undefined>(Sym->Body))
if (!U->WeakAlias)
U->WeakAlias = Symtab.addUndefined(To);
}

View File

@ -77,7 +77,7 @@ std::error_code SymbolTable::readArchives() {
// Add archive member files to ObjectQueue that should resolve
// existing undefined symbols.
for (Symbol *Sym : LazySyms)
if (auto EC = addMemberFile(cast<Lazy>(Sym->Body.load())))
if (auto EC = addMemberFile(cast<Lazy>(Sym->Body)))
return EC;
return std::error_code();
}
@ -126,7 +126,7 @@ bool SymbolTable::reportRemainingUndefines(bool Resolve) {
bool Ret = false;
for (auto &I : Symtab) {
Symbol *Sym = I.second;
auto *Undef = dyn_cast<Undefined>(Sym->Body.load());
auto *Undef = dyn_cast<Undefined>(Sym->Body);
if (!Undef)
continue;
StringRef Name = Undef->getName();
@ -140,10 +140,10 @@ bool SymbolTable::reportRemainingUndefines(bool Resolve) {
// This odd rule is for compatibility with MSVC linker.
if (Name.startswith("__imp_")) {
Symbol *Imp = find(Name.substr(strlen("__imp_")));
if (Imp && isa<Defined>(Imp->Body.load())) {
if (Imp && isa<Defined>(Imp->Body)) {
if (!Resolve)
continue;
auto *D = cast<Defined>(Imp->Body.load());
auto *D = cast<Defined>(Imp->Body);
auto *S = new (Alloc) DefinedLocalImport(Name, D);
LocalImportChunks.push_back(S->getChunk());
Sym->Body = S;
@ -332,11 +332,11 @@ std::error_code SymbolTable::addCombinedLTOObject() {
StringRef Name = Body->getName();
Symbol *Sym = insert(Body);
if (isa<DefinedBitcode>(Sym->Body.load())) {
if (isa<DefinedBitcode>(Sym->Body)) {
Sym->Body = Body;
continue;
}
if (auto *L = dyn_cast<Lazy>(Sym->Body.load())) {
if (auto *L = dyn_cast<Lazy>(Sym->Body)) {
// We may see new references to runtime library symbols such as __chkstk
// here. These symbols must be wholly defined in non-bitcode files.
if (auto EC = addMemberFile(L))

View File

@ -359,4 +359,13 @@ private:
} // namespace coff
} // namespace lld
// Support isa<>, cast<> and dyn_cast<> for Symbol::Body.
namespace llvm {
template <typename T>
struct simplify_type<std::atomic<T *>> {
typedef T *SimpleType;
static T *getSimplifiedValue(std::atomic<T *> &A) { return A.load(); }
};
}
#endif

View File

@ -244,7 +244,7 @@ void Writer::createImportTables() {
}
if (!DelayIdata.empty()) {
Symbol *Sym = Symtab->find("__delayLoadHelper2");
Defined *Helper = cast<Defined>(Sym->Body.load());
Defined *Helper = cast<Defined>(Sym->Body);
DelayIdata.create(Helper);
OutputSection *Sec = createSection(".didat");
for (Chunk *C : DelayIdata.getChunks())
@ -416,7 +416,7 @@ void Writer::writeHeader() {
Dir[EXCEPTION_TABLE].Size = Sec->getVirtualSize();
}
if (Symbol *Sym = Symtab->find("_tls_used")) {
if (Defined *B = dyn_cast<Defined>(Sym->Body.load())) {
if (Defined *B = dyn_cast<Defined>(Sym->Body)) {
Dir[TLS_TABLE].RelativeVirtualAddress = B->getRVA();
Dir[TLS_TABLE].Size = 40;
}
@ -542,7 +542,7 @@ OutputSection *Writer::createSection(StringRef Name) {
// Dest is .reloc section. Add contents to that section.
void Writer::addBaserels(OutputSection *Dest) {
std::vector<uint32_t> V;
Defined *ImageBase = cast<Defined>(Symtab->find("__ImageBase")->Body.load());
Defined *ImageBase = cast<Defined>(Symtab->find("__ImageBase")->Body);
for (OutputSection *Sec : OutputSections) {
if (Sec == Dest)
continue;