[lld] [LLD] Implement --enable-non-contiguous-regions (PR #90007)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri May 10 13:09:56 PDT 2024


================
@@ -555,6 +583,32 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd,
   // Matched sections after the last SORT* are sorted by (--sort-alignment,
   // input order).
   sortByPositionThenCommandLine(sizeAfterPrevSort, ret.size());
+
+  // The flag --enable-non-contiguous-regions may cause sections to match an
+  // InputSectionDescription in more than one OutputSection. Matches after the
+  // first were collected in the spills set, so replace these with potential
+  // spill sections.
+  if (!spills.empty()) {
+    for (InputSectionBase *&sec : ret) {
+      if (!spills.contains(sec))
+        continue;
+
+      PotentialSpillSection *pss = make<PotentialSpillSection>(
+          sec, const_cast<InputSectionDescription *>(cmd));
+
----------------
MaskRay wrote:

The code style is pretty dense. Variables are not followed by a blank line.

`auto [it, inserted] = ..` is preferred for newer code

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


More information about the llvm-commits mailing list