[lld] [lld][MachO] Add N_COLD_FUNC support (PR #183909)

Zhaoxuan Jiang via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 9 19:30:11 PDT 2026


================
@@ -32,6 +32,9 @@ struct BPOrdererELF : lld::BPOrderer<BPOrdererELF> {
   static bool isCodeSection(const Section &sec) {
     return sec.flags & ELF::SHF_EXECINSTR;
   }
+  // ELF handles cold functions via separate output sections (.text.unlikely,
+  // .text.split), so no cold splitting is needed within BP.
+  static bool isColdSection(const Section &sec) { return false; }
----------------
nocchijiang wrote:

After looking into the implementation further, I believe we should completely revert the BP-related changes and focus this PR strictly on `N_COLD_FUNC` for Mach-O. Architecturally, BP should likely remain focused on customizable grouping for compression rather than having an inherent concept of "cold" sections. The existing generic BP code isn't quite ready for this type of grouping extension, and forcing it in now would result in an implementation we'd likely need to rewrite soon.

I propose we handle the grouping support in a dedicated PR first. Once that infrastructure is in place, we can adapt it specifically for each backend: using `N_COLD_FUNC` for Mach-O and section name suffixes for ELF. Does this approach make sense to you? I'll move forward with reverting the BP and ELF commits from this PR if so.

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


More information about the llvm-commits mailing list