[lld] [lld-macho][NFC] Refactor insertions into inputSections (PR #85692)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 12:35:05 PDT 2024


================
@@ -38,6 +38,43 @@ static_assert(sizeof(void *) != 8 ||
 
 std::vector<ConcatInputSection *> macho::inputSections;
 
+void lld::macho::addInputSection(InputSection *inputSection) {
+  // Used across function calls to impose section ordering
+  static uint64_t inputOrder = 0;
+
+  if (auto *isec = dyn_cast<ConcatInputSection>(inputSection)) {
+    if (isec->isCoalescedWeak())
+      return;
+    if (config->emitInitOffsets &&
+        sectionType(isec->getFlags()) == S_MOD_INIT_FUNC_POINTERS) {
+      in.initOffsets->addInput(isec);
+      return;
----------------
alx32 wrote:

Yes, we only need to check via `assert` if we modify `inputSectionsOrder` - which doesn't happen before the return. 

https://github.com/llvm/llvm-project/pull/85692


More information about the llvm-commits mailing list