[llvm] r302502 - Fix code section prefix for proper layout

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Mon May 8 18:43:25 PDT 2017


Author: tejohnson
Date: Mon May  8 20:43:24 2017
New Revision: 302502

URL: http://llvm.org/viewvc/llvm-project?rev=302502&view=rev
Log:
Fix code section prefix for proper layout

Summary:
r284533 added hot and cold section prefixes based on profile
information, to enable grouping of hot/cold functions at link time.
However, it used "cold" as the prefix for cold sections, but gold only
recognizes "unlikely" (which is used by gcc for cold sections).
Therefore, cold sections were not properly being grouped. Switch to
using "unlikely"

Reviewers: danielcdh, davidxl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D32983

Modified:
    llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
    llvm/trunk/test/Transforms/CodeGenPrepare/section.ll

Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=302502&r1=302501&r2=302502&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Mon May  8 20:43:24 2017
@@ -295,7 +295,7 @@ bool CodeGenPrepare::runOnFunction(Funct
     if (PSI->isFunctionHotInCallGraph(&F))
       F.setSectionPrefix(".hot");
     else if (PSI->isFunctionColdInCallGraph(&F))
-      F.setSectionPrefix(".cold");
+      F.setSectionPrefix(".unlikely");
   }
 
   /// This optimization identifies DIV instructions that can be

Modified: llvm/trunk/test/Transforms/CodeGenPrepare/section.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CodeGenPrepare/section.ll?rev=302502&r1=302501&r2=302502&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/CodeGenPrepare/section.ll (original)
+++ llvm/trunk/test/Transforms/CodeGenPrepare/section.ll Mon May  8 20:43:24 2017
@@ -35,7 +35,7 @@ define void @cold_func() !prof !16 {
 }
 
 ; CHECK: ![[HOT_ID]] = !{!"function_section_prefix", !".hot"}
-; CHECK: ![[COLD_ID]] = !{!"function_section_prefix", !".cold"}
+; CHECK: ![[COLD_ID]] = !{!"function_section_prefix", !".unlikely"}
 !llvm.module.flags = !{!1}
 !1 = !{i32 1, !"ProfileSummary", !2}
 !2 = !{!3, !4, !5, !6, !7, !8, !9, !10}




More information about the llvm-commits mailing list