17using namespace object;
20 for (
Symbol S : NewSymbols) {
21 S.UniqueId = NextSymbolUniqueId++;
22 Symbols.emplace_back(S);
27void Object::updateSymbols() {
30 SymbolMap[
Sym.UniqueId] = &
Sym;
34 return SymbolMap.lookup(UniqueId);
55 Sym.Referenced =
false;
56 for (
const Section &Sec : Sections) {
58 auto It = SymbolMap.find(R.Target);
59 if (It == SymbolMap.end())
61 "relocation target %zu not found", R.Target);
62 It->second->Referenced =
true;
70 S.UniqueId = NextSectionUniqueId++;
71 Sections.emplace_back(S);
76void Object::updateSections() {
80 SectionMap[S.UniqueId] = &S;
86 return SectionMap.lookup(UniqueId);
91 auto RemoveAssociated = [&AssociatedSections](
const Section &Sec) {
92 return AssociatedSections.
contains(Sec.UniqueId);
103 AssociatedSections.
clear();
105 Symbols, [&RemovedSections, &AssociatedSections](
const Symbol &
Sym) {
110 if (RemovedSections.
contains(
Sym.AssociativeComdatTargetSectionId))
111 AssociatedSections.
insert(
Sym.TargetSectionId);
112 return RemovedSections.
contains(
Sym.TargetSectionId);
115 }
while (!AssociatedSections.
empty());
121 for (
Section &Sec : Sections) {
122 if (ToTruncate(Sec)) {
125 Sec.Header.SizeOfRawData = 0;
ReachingDefAnalysis InstSet & ToRemove
This file defines the DenseSet and SmallDenseSet classes.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Implements a dense probed hash-table based set.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Error joinErrors(Error E1, Error E2)
Concatenate errors.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
void truncateSections(function_ref< bool(const Section &)> ToTruncate)
const Symbol * findSymbol(size_t UniqueId) const
const Section * findSection(ssize_t UniqueId) const
void addSections(ArrayRef< Section > NewSections)
void removeSections(function_ref< bool(const Section &)> ToRemove)
void addSymbols(ArrayRef< Symbol > NewSymbols)
Error removeSymbols(function_ref< Expected< bool >(const Symbol &)> ToRemove)