Lines Matching +full:defined +full:- +full:atoms

1 //===-- ReaderWriter/MachO/LayoutPass.cpp - Layout atoms ------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
39 // Less-than relationship of two atoms must be transitive, which is, if a < b
52 // Helper functions to check follow-on graph.
59 if (definedAtom->name().empty()) in atomToDebugString()
62 s << definedAtom->name(); in atomToDebugString()
64 if (definedAtom->customSectionName().empty()) in atomToDebugString()
67 s << definedAtom->customSectionName(); in atomToDebugString()
76 llvm::dbgs() << "There's a cycle in a follow-on chain!\n"; in showCycleDetectedError()
81 if (!registry.referenceKindToString(ref->kindNamespace(), ref->kindArch(), in showCycleDetectedError()
82 ref->kindValue(), kindValStr)) { in showCycleDetectedError()
86 << ": " << atomToDebugString(ref->target()) << "\n"; in showCycleDetectedError()
117 "> has no follow-on root!")) in checkReachabilityFromRoot()
121 const DefinedAtom *ap = i->second; in checkReachabilityFromRoot()
138 llvm::dbgs() << " file=" << atom->file().path() in printDefinedAtoms()
139 << ", name=" << atom->name() in printDefinedAtoms()
140 << ", size=" << atom->size() in printDefinedAtoms()
141 << ", type=" << atom->contentType() in printDefinedAtoms()
142 << ", ordinal=" << atom->ordinal() in printDefinedAtoms()
152 // Verify that there's no cycle in follow-on chain. in checkFollowonChain()
159 // Verify that all the atoms in followOnNexts have references to in checkFollowonChain()
168 /// The function compares atoms by sorting atoms in the following order
169 /// a) Sorts atoms by their ordinal overrides (layout-after/ingroup)
170 /// b) Sorts atoms by their permissions
171 /// c) Sorts atoms by their content
172 /// d) Sorts atoms by custom sorter
173 /// e) Sorts atoms on how they appear using File Ordinality
174 /// f) Sorts atoms on how they appear within the File
186 // Find the root of the chain if it is a part of a follow-on chain. in compareAtomsSub()
190 // Sort atoms by their ordinal overrides only if they fall in the same in compareAtomsSub()
198 DefinedAtom::ContentPermissions leftPerms = leftRoot->permissions(); in compareAtomsSub()
199 DefinedAtom::ContentPermissions rightPerms = rightRoot->permissions(); in compareAtomsSub()
208 DefinedAtom::ContentType leftType = leftRoot->contentType(); in compareAtomsSub()
209 DefinedAtom::ContentType rightType = rightRoot->contentType(); in compareAtomsSub()
225 const File *leftFile = &leftRoot->file(); in compareAtomsSub()
226 const File *rightFile = &rightRoot->file(); in compareAtomsSub()
229 LLVM_DEBUG(reason = formatReason(".o order", (int)leftFile->ordinal(), in compareAtomsSub()
230 (int)rightFile->ordinal())); in compareAtomsSub()
231 return leftFile->ordinal() < rightFile->ordinal(); in compareAtomsSub()
235 uint64_t leftOrdinal = leftRoot->ordinal(); in compareAtomsSub()
236 uint64_t rightOrdinal = rightRoot->ordinal(); in compareAtomsSub()
239 LLVM_DEBUG(reason = formatReason("ordinal", (int)leftRoot->ordinal(), in compareAtomsSub()
240 (int)rightRoot->ordinal())); in compareAtomsSub()
244 llvm::errs() << "Unordered: <" << left->name() << "> <" << right->name() in compareAtomsSub()
246 llvm_unreachable("Atoms with Same Ordinal!"); in compareAtomsSub()
256 llvm::dbgs() << "Layout: '" << lc._atom.get()->name() in compareAtoms()
258 << rc._atom.get()->name() << "' (" << reason << ")\n"; in compareAtoms()
278 atom = targetFollowOnAtomsIter->second; in findAtomFollowedBy()
284 // Check if all the atoms followed by the given target atom are of size zero.
286 // will be added to the head of the followon chain. All the atoms between the
287 // atom and the targetAtom (specified by layout-after) need to be of size zero
294 if (atom->size() != 0) in checkAllPrevAtomsZeroSize()
301 atom = targetFollowOnAtomsIter->second; in checkAllPrevAtomsZeroSize()
305 // Set the root of all atoms in targetAtom's chain to the given root.
315 targetAtom = targetFollowOnAtomsIter->second; in setChainRoot()
329 /// targetAtom is itself, Chain all the atoms that are contained in the tree
332 /// targetAtom until the targetAtom has all atoms of size 0, then chain the
337 // number of atoms that we have. in buildFollowOnTable()
342 if (r->kindNamespace() != lld::Reference::KindNamespace::all || in buildFollowOnTable()
343 r->kindValue() != lld::Reference::kindLayoutAfter) in buildFollowOnTable()
345 const DefinedAtom *targetAtom = dyn_cast<DefinedAtom>(r->target()); in buildFollowOnTable()
368 if (iter->second == targetAtom) { in buildFollowOnTable()
379 // the beginning of the chain. All the atoms followed by the target in buildFollowOnTable()
382 size_t currentAtomSize = ai->size(); in buildFollowOnTable()
399 /// assigning ordinals to each atom, if the atoms have their ordinals
401 /// main map thats used to sort the atoms while comparing two atoms together
413 for (const DefinedAtom *nextAtom = start->second; nextAtom; in buildOrdinalOverrideMap()
428 const auto *root = (ri == _followOnRoots.end()) ? atom.get() : ri->second; in decorate()
429 uint64_t override = (oi == _ordinalOverrideMap.end()) ? 0 : oi->second; in decorate()
444 LLVM_DEBUG(llvm::dbgs() << "******** Laying out atoms:\n"); in perform()
445 // sort the atoms in perform()
447 File::AtomRange<DefinedAtom> atomRange = mergedFile.defined(); in perform()
459 llvm::dbgs() << "unsorted atoms:\n"; in perform()
466 [&](const LayoutPass::SortKey &l, const LayoutPass::SortKey &r) -> bool { in perform()
473 llvm::dbgs() << "sorted atoms:\n"; in perform()
477 LLVM_DEBUG(llvm::dbgs() << "******** Finished laying out atoms\n"); in perform()
484 bool & leftBeforeRight) ->bool { in addLayoutPass()