Page MenuHomePhabricator

D65548.diff
No OneTemporary

File Metadata

Created
Wed, Feb 26, 12:33 PM

D65548.diff

Index: llvm/lib/ExecutionEngine/Orc/Core.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -376,11 +376,13 @@
auto I = SymbolFlags.find(KV.first);
assert(I != SymbolFlags.end() &&
"Resolving symbol outside this responsibility set");
+ // Mask out Exported for compatibility with COFF
+ constexpr auto Mask = ~JITSymbolFlags::Exported;
if (I->second.isWeak())
- assert(I->second == (KV.second.getFlags() | JITSymbolFlags::Weak) &&
+ assert((I->second & Mask) == ((KV.second.getFlags() | JITSymbolFlags::Weak) & Mask) &&
"Resolving symbol with incorrect flags");
else
- assert(I->second == KV.second.getFlags() &&
+ assert((I->second & Mask) == (KV.second.getFlags() & Mask) &&
"Resolving symbol with incorrect flags");
}
#endif
@@ -871,12 +873,19 @@
"Symbol should be materializing");
assert(I->second.getAddress() == 0 && "Symbol has already been resolved");
- assert((Sym.getFlags() & ~JITSymbolFlags::Weak) ==
- (I->second.getFlags() & ~JITSymbolFlags::Weak) &&
+ // Mask out Exported flag for compatibility with COFF
+ constexpr auto Mask = ~(JITSymbolFlags::Weak | JITSymbolFlags::Exported);
+ assert((Sym.getFlags() & Mask) ==
+ (I->second.getFlags() & Mask) &&
"Resolved flags should match the declared flags");
// Once resolved, symbols can never be weak.
- JITSymbolFlags ResolvedFlags = Sym.getFlags();
+ // IMPORTANT: We use I->second.getFlags() because we want
+ // to reuse the flags from the original IR. Some
+ // object file formats like COFF don't have an
+ // exported flag, for example, so we want to preserve
+ // IR flags.
+ JITSymbolFlags ResolvedFlags = I->second.getFlags();
ResolvedFlags &= ~JITSymbolFlags::Weak;
I->second.setAddress(Sym.getAddress());
I->second.setFlags(ResolvedFlags);

Event Timeline