diff options
author | Rui Ueyama <ruiu@google.com> | 2015-07-06 20:45:22 +0300 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2015-07-06 20:45:22 +0300 |
commit | 183f53fd2213006589847fe40567720296e68717 (patch) | |
tree | 146af2817031633a9c6744f45c6d9126d16a313e /lld | |
parent | e2d75239d1311047475a75571e92509c63a5b91d (diff) |
COFF: Support isa<> for Symbol::Body, whose type is std::atomic<SymbolBody *>.
llvm-svn: 241477
Diffstat (limited to 'lld')
-rw-r--r-- | lld/COFF/Driver.cpp | 4 | ||||
-rw-r--r-- | lld/COFF/SymbolTable.cpp | 12 | ||||
-rw-r--r-- | lld/COFF/Symbols.h | 9 | ||||
-rw-r--r-- | lld/COFF/Writer.cpp | 6 |
4 files changed, 20 insertions, 11 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 9f352ac1c7cc..fa29d14678bf 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -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); } diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp index 780e47ebc470..5e27e5fda5fe 100644 --- a/lld/COFF/SymbolTable.cpp +++ b/lld/COFF/SymbolTable.cpp @@ -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)) diff --git a/lld/COFF/Symbols.h b/lld/COFF/Symbols.h index 8694b83247ef..88b0e69ae5de 100644 --- a/lld/COFF/Symbols.h +++ b/lld/COFF/Symbols.h @@ -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 diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp index 34cd4732f1ba..f9d1663e233d 100644 --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp @@ -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; |