forked from OSchip/llvm-project
COFF: Change Symbol::Body type from atomic pointer to regular pointer.
I made the field an atomic pointer in hope that we would be able to parallelize the symbol resolver soon, but that's not going to happen soon. This patch reverts that change for the sake of readability. llvm-svn: 248104
This commit is contained in:
parent
63bbe84b27
commit
1cce300843
|
@ -168,20 +168,16 @@ void SymbolTable::addLazy(Lazy *New, std::vector<Symbol *> *Accum) {
|
|||
Symbol *Sym = insert(New);
|
||||
if (Sym->Body == New)
|
||||
return;
|
||||
for (;;) {
|
||||
SymbolBody *Existing = Sym->Body;
|
||||
if (isa<Defined>(Existing))
|
||||
return;
|
||||
if (Lazy *L = dyn_cast<Lazy>(Existing))
|
||||
if (L->getFileIndex() < New->getFileIndex())
|
||||
return;
|
||||
if (!Sym->Body.compare_exchange_strong(Existing, New))
|
||||
continue;
|
||||
New->setBackref(Sym);
|
||||
if (isa<Undefined>(Existing))
|
||||
Accum->push_back(Sym);
|
||||
SymbolBody *Existing = Sym->Body;
|
||||
if (isa<Defined>(Existing))
|
||||
return;
|
||||
}
|
||||
if (Lazy *L = dyn_cast<Lazy>(Existing))
|
||||
if (L->getFileIndex() < New->getFileIndex())
|
||||
return;
|
||||
Sym->Body = New;
|
||||
New->setBackref(Sym);
|
||||
if (isa<Undefined>(Existing))
|
||||
Accum->push_back(Sym);
|
||||
}
|
||||
|
||||
void SymbolTable::addSymbol(SymbolBody *New) {
|
||||
|
@ -190,37 +186,32 @@ void SymbolTable::addSymbol(SymbolBody *New) {
|
|||
Symbol *Sym = insert(New);
|
||||
if (Sym->Body == New)
|
||||
return;
|
||||
SymbolBody *Existing = Sym->Body;
|
||||
|
||||
for (;;) {
|
||||
SymbolBody *Existing = Sym->Body;
|
||||
|
||||
// If we have an undefined symbol and a lazy symbol,
|
||||
// let the lazy symbol to read a member file.
|
||||
if (auto *L = dyn_cast<Lazy>(Existing)) {
|
||||
// Undefined symbols with weak aliases need not to be resolved,
|
||||
// since they would be replaced with weak aliases if they remain
|
||||
// undefined.
|
||||
if (auto *U = dyn_cast<Undefined>(New))
|
||||
if (!U->WeakAlias) {
|
||||
addMemberFile(L);
|
||||
return;
|
||||
}
|
||||
if (!Sym->Body.compare_exchange_strong(Existing, New))
|
||||
continue;
|
||||
return;
|
||||
// If we have an undefined symbol and a lazy symbol,
|
||||
// let the lazy symbol to read a member file.
|
||||
if (auto *L = dyn_cast<Lazy>(Existing)) {
|
||||
// Undefined symbols with weak aliases need not to be resolved,
|
||||
// since they would be replaced with weak aliases if they remain
|
||||
// undefined.
|
||||
if (auto *U = dyn_cast<Undefined>(New)) {
|
||||
if (!U->WeakAlias) {
|
||||
addMemberFile(L);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// compare() returns -1, 0, or 1 if the lhs symbol is less preferable,
|
||||
// equivalent (conflicting), or more preferable, respectively.
|
||||
int Comp = Existing->compare(New);
|
||||
if (Comp == 0)
|
||||
error(Twine("duplicate symbol: ") + Existing->getDebugName() + " and " +
|
||||
New->getDebugName());
|
||||
if (Comp < 0)
|
||||
if (!Sym->Body.compare_exchange_strong(Existing, New))
|
||||
continue;
|
||||
Sym->Body = New;
|
||||
return;
|
||||
}
|
||||
|
||||
// compare() returns -1, 0, or 1 if the lhs symbol is less preferable,
|
||||
// equivalent (conflicting), or more preferable, respectively.
|
||||
int Comp = Existing->compare(New);
|
||||
if (Comp == 0)
|
||||
error(Twine("duplicate symbol: ") + Existing->getDebugName() + " and " +
|
||||
New->getDebugName());
|
||||
if (Comp < 0)
|
||||
Sym->Body = New;
|
||||
}
|
||||
|
||||
Symbol *SymbolTable::insert(SymbolBody *New) {
|
||||
|
|
|
@ -39,7 +39,7 @@ class SymbolBody;
|
|||
// The resolver updates SymbolBody pointers as it resolves symbols.
|
||||
struct Symbol {
|
||||
explicit Symbol(SymbolBody *P) : Body(P) {}
|
||||
std::atomic<SymbolBody *> Body;
|
||||
SymbolBody *Body;
|
||||
};
|
||||
|
||||
// The base class for real symbol classes.
|
||||
|
@ -82,7 +82,7 @@ public:
|
|||
// has chosen the object among other objects having the same name,
|
||||
// you can access P->Backref->Body to get the resolver's result.
|
||||
void setBackref(Symbol *P) { Backref = P; }
|
||||
SymbolBody *repl() { return Backref ? Backref->Body.load() : this; }
|
||||
SymbolBody *repl() { return Backref ? Backref->Body : this; }
|
||||
|
||||
// Decides which symbol should "win" in the symbol table, this or
|
||||
// the Other. Returns 1 if this wins, -1 if the Other wins, or 0 if
|
||||
|
@ -416,13 +416,4 @@ inline uint64_t Defined::getRVA() {
|
|||
} // 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
|
||||
|
|
Loading…
Reference in New Issue