[ORC] Keep weak flag on VSO symbol tables during materialization, but treat

materializing weak symbols as strong.

This removes some elaborate flag tweaking and plays nicer with RuntimeDyld,
which relies of weak/common flags to determine whether it should emit a given
weak definition. (Switching to strong up-front makes it appear as if there is
already an overriding definition, which would require an extra back-channel to
override).

llvm-svn: 334966
This commit is contained in:
Lang Hames 2018-06-18 18:01:41 +00:00
parent deaab0b105
commit 4be38d1349

View File

@ -488,8 +488,6 @@ void VSO::resolve(const SymbolMap &Resolved) {
for (const auto &KV : Resolved) {
auto &Name = KV.first;
auto Sym = KV.second;
JITSymbolFlags ResolvedFlags = Sym.getFlags();
ResolvedFlags &= ~JITSymbolFlags::Weak;
assert(!Sym.getFlags().isLazy() && !Sym.getFlags().isMaterializing() &&
"Materializing flags should be managed internally");
@ -502,11 +500,14 @@ void VSO::resolve(const SymbolMap &Resolved) {
"Symbol should be materializing");
assert(I->second.getAddress() == 0 && "Symbol has already been resolved");
assert(ResolvedFlags ==
JITSymbolFlags::stripTransientFlags(I->second.getFlags()) &&
assert((Sym.getFlags() & ~JITSymbolFlags::Weak) ==
(JITSymbolFlags::stripTransientFlags(I->second.getFlags()) &
~JITSymbolFlags::Weak) &&
"Resolved flags should match the declared flags");
// Once resolved, symbols can never be weak.
JITSymbolFlags ResolvedFlags = Sym.getFlags();
ResolvedFlags &= ~JITSymbolFlags::Weak;
ResolvedFlags |= JITSymbolFlags::Materializing;
I->second = JITEvaluatedSymbol(Sym.getAddress(), ResolvedFlags);
@ -780,7 +781,6 @@ VSO::lookupImpl(std::shared_ptr<AsynchronousSymbolQuery> &Q,
for (auto &KV : MU->getSymbols()) {
auto SymK = Symbols.find(KV.first);
auto Flags = SymK->second.getFlags();
Flags &= ~JITSymbolFlags::Weak;
Flags &= ~JITSymbolFlags::Lazy;
Flags |= JITSymbolFlags::Materializing;
SymK->second.setFlags(Flags);
@ -871,7 +871,8 @@ Error VSO::defineImpl(MaterializationUnit &MU) {
if (!Added) {
if (KV.second.isStrong()) {
if (EntryItr->second.getFlags().isStrong())
if (EntryItr->second.getFlags().isStrong() ||
(EntryItr->second.getFlags() & JITSymbolFlags::Materializing))
Duplicates.insert(KV.first);
else
ExistingDefsOverridden.push_back(EntryItr);
@ -905,8 +906,6 @@ Error VSO::defineImpl(MaterializationUnit &MU) {
!ExistingDefItr->second.getFlags().isMaterializing() &&
"Overridden existing def should be in the Lazy state");
ExistingDefItr->second.getFlags() &= ~JITSymbolFlags::Weak;
auto UMII = UnmaterializedInfos.find(ExistingDefItr->first);
assert(UMII != UnmaterializedInfos.end() &&
"Overridden existing def should have an UnmaterializedInfo");