diff --git a/bolt/include/bolt/Core/BinaryContext.h b/bolt/include/bolt/Core/BinaryContext.h index 085c0265de3ed..57d4515bf8325 100644 --- a/bolt/include/bolt/Core/BinaryContext.h +++ b/bolt/include/bolt/Core/BinaryContext.h @@ -354,9 +354,6 @@ class BinaryContext { /// Newly created segments. std::vector NewSegments; - /// Symbols that are expected to be undefined in MCContext during emission. - std::unordered_set UndefinedSymbols; - /// [name] -> [BinaryData*] map used for global symbol resolution. using SymbolMapType = StringMap; SymbolMapType GlobalSymbols; diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index ddaad6eef6140..2fd1ab13008b7 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -1896,16 +1896,6 @@ bool BinaryFunction::scanExternalRefs() { } } - // Inform BinaryContext that this function symbols will not be defined and - // relocations should not be created against them. - if (BC.HasRelocations) { - for (std::pair &LI : Labels) - BC.UndefinedSymbols.insert(LI.second); - for (MCSymbol *const EndLabel : FunctionEndLabels) - if (EndLabel) - BC.UndefinedSymbols.insert(EndLabel); - } - clearList(Relocations); clearList(ExternallyReferencedOffsets); @@ -3234,14 +3224,6 @@ void BinaryFunction::clearDisasmState() { clearList(Instructions); clearList(IgnoredBranches); clearList(TakenBranches); - - if (BC.HasRelocations) { - for (std::pair &LI : Labels) - BC.UndefinedSymbols.insert(LI.second); - for (MCSymbol *const EndLabel : FunctionEndLabels) - if (EndLabel) - BC.UndefinedSymbols.insert(EndLabel); - } } void BinaryFunction::setTrapOnEntry() { diff --git a/bolt/lib/Core/BinarySection.cpp b/bolt/lib/Core/BinarySection.cpp index 6f07017c26060..e803d17021f8b 100644 --- a/bolt/lib/Core/BinarySection.cpp +++ b/bolt/lib/Core/BinarySection.cpp @@ -112,8 +112,10 @@ void BinarySection::emitAsData(MCStreamer &Streamer, RI = ROE; // Skip undefined symbols. - auto HasUndefSym = [this](const auto &Relocation) { - return BC.UndefinedSymbols.count(Relocation.Symbol); + auto HasUndefSym = [](const auto &Relocation) { + return Relocation.Symbol && Relocation.Symbol->isTemporary() && + Relocation.Symbol->isUndefined() && + !Relocation.Symbol->isRegistered(); }; if (std::any_of(ROI, ROE, HasUndefSym))