[PATCH] D85331: [HotColdSplit] Add options for splitting cold functions in separate section

Ruijie Fang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 10:54:01 PDT 2020


rjf created this revision.
rjf added reviewers: hiraditya, vsk, rcorcs.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
rjf requested review of this revision.

Add support for (if enabled) splitting cold functions into a separate section
in order to further boost locality of hot code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85331

Files:
  llvm/lib/Transforms/IPO/HotColdSplitting.cpp


Index: llvm/lib/Transforms/IPO/HotColdSplitting.cpp
===================================================================
--- llvm/lib/Transforms/IPO/HotColdSplitting.cpp
+++ llvm/lib/Transforms/IPO/HotColdSplitting.cpp
@@ -85,6 +85,16 @@
                        cl::desc("Base penalty for splitting cold code (as a "
                                 "multiple of TCC_Basic)"));
 
+static cl::opt<bool>
+    EnableColdSection("enable-cold-section", cl::init(false), cl::Hidden,
+                      cl::desc("Set to true for splitting cold functions into"
+                               " separate cold region."));
+
+static cl::opt<StringRef>
+    ColdSectionName("hotcoldsplit-cold-section-name", cl::init("__llvm_cold"),
+                    cl::Hidden,
+                    cl::desc("Cold section name for section splitting"));
+
 namespace {
 // Same as blockEndsInUnreachable in CodeGen/BranchFolding.cpp. Do not modify
 // this function unless you modify the MBB version as well.
@@ -339,8 +349,12 @@
     }
     CI->setIsNoInline();
 
-    if (OrigF->hasSection())
-      OutF->setSection(OrigF->getSection());
+    if (EnableColdSection)
+      OutF->setSection(ColdSectionName);
+    else {
+      if (OrigF->hasSection())
+        OutF->setSection(OrigF->getSection());
+    }
 
     markFunctionCold(*OutF, BFI != nullptr);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85331.283302.patch
Type: text/x-patch
Size: 1339 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200805/99d32eba/attachment.bin>


More information about the llvm-commits mailing list